Avoid partial read in luks1 reencryption loop.

Starting with kernel 5.17-rc there are some changes
in block layer aiming to block partial I/O in
O_DIRECT mode.
This commit is contained in:
Ondrej Kozina
2022-02-04 11:23:12 +01:00
parent f2dbab7043
commit e38a184907

View File

@@ -737,6 +737,8 @@ static int copy_data_forward(struct reenc_ctx *rc, int fd_old, int fd_new,
return -EIO;
while (!quit && rc->device_offset < rc->device_size) {
if ((rc->device_size - rc->device_offset) < (uint64_t)block_size)
block_size = rc->device_size - rc->device_offset;
s1 = read_buf(fd_old, buf, block_size);
if (s1 < 0 || ((size_t)s1 != block_size &&
(rc->device_offset + s1) != rc->device_size)) {