diff --git a/man/cryptsetup-reencrypt.8 b/man/cryptsetup-reencrypt.8 index b3c374c1..e0de6561 100644 --- a/man/cryptsetup-reencrypt.8 +++ b/man/cryptsetup-reencrypt.8 @@ -158,13 +158,15 @@ WARNING: This is destructive operation and cannot be reverted. .TP .B "\-\-use-directio" -Use direct-io (O_DIRECT) for all read/write data operations. +Use direct-io (O_DIRECT) for all read/write data operations related +to block device undergoing reencryption. Useful if direct-io operations perform better than normal buffered operations (e.g. in virtual environments). .TP .B "\-\-use-fsync" -Use fsync call after every written block. +Use fsync call after every written block. This applies for reencryption +log files as well. .TP .B "\-\-write-log" Update log file after every block write. This can slow down reencryption diff --git a/src/cryptsetup_reencrypt.c b/src/cryptsetup_reencrypt.c index 997c3887..a1cc51d5 100644 --- a/src/cryptsetup_reencrypt.c +++ b/src/cryptsetup_reencrypt.c @@ -76,7 +76,7 @@ struct reenc_ctx { char crypt_path_org[PATH_MAX]; char crypt_path_new[PATH_MAX]; int log_fd; - char *log_buf; + char log_buf[SECTOR_SIZE]; struct { char *password; @@ -351,13 +351,11 @@ static void close_log(struct reenc_ctx *rc) log_dbg("Closing LUKS reencryption log file %s.", rc->log_file); if (rc->log_fd != -1) close(rc->log_fd); - free(rc->log_buf); - rc->log_buf = NULL; } static int open_log(struct reenc_ctx *rc) { - int flags = opt_directio ? O_DIRECT : 0; + int flags = opt_fsync ? O_SYNC : 0; rc->log_fd = open(rc->log_file, O_RDWR|O_EXCL|O_CREAT|flags, S_IRUSR|S_IWUSR); if (rc->log_fd != -1) { @@ -371,12 +369,6 @@ static int open_log(struct reenc_ctx *rc) if (rc->log_fd == -1) return -EINVAL; - if (posix_memalign((void *)&rc->log_buf, alignment(rc->log_fd), SECTOR_SIZE)) { - log_err(_("Allocation of aligned memory failed.\n")); - close_log(rc); - return -ENOMEM; - } - if (!rc->in_progress && write_log(rc) < 0) { close_log(rc); return -EIO;