[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 7/8] ensure uniform post-trailer-zeros length
From: |
David Disseldorp |
Subject: |
[PATCH v2 7/8] ensure uniform post-trailer-zeros length |
Date: |
Wed, 14 Apr 2021 01:19:12 +0200 |
After the trailer entry, copy-out currently writes out zeros up to the
next block boundary. When reflink is enabled, writes may be unbuffered.
To ensure that the post-trailer-zeros length matches with and without
reflink_flag, calculate the zeros length based on where the I/O buffer
offset would be instead of where it currently is.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
src/copyout.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/copyout.c b/src/copyout.c
index 1f0a917..a6efd68 100644
--- a/src/copyout.c
+++ b/src/copyout.c
@@ -63,13 +63,17 @@ read_for_checksum (int in_file_des, int file_size, char
*file_name)
}
/* Write out NULs to fill out the rest of the current block on
- OUT_FILE_DES. */
+ OUT_FILE_DES. With reflink_flag, I/O may not have been buffered. To ensure
+ that the post-trailer-zeros length matches with and without reflink_flag,
+ calculate the length based on where the I/O buffer offset would be. */
static void
tape_clear_rest_of_block (int out_file_des)
{
- write_nuls_to_file (io_block_size - output_size, out_file_des,
- tape_buffered_write);
+ off_t boff = (output_bytes + output_size) % io_block_size;
+ if (boff)
+ write_nuls_to_file (io_block_size - boff, out_file_des,
+ tape_buffered_write);
}
/* Write NULs on OUT_FILE_DES to move from OFFSET (the current location)
--
2.26.2
- [PATCH v2 0/8] cpio copy-out reflink and chain support, David Disseldorp, 2021/04/13
- [PATCH v2 1/8] open device with O_NONBLOCK option, David Disseldorp, 2021/04/13
- [PATCH v2 2/8] add --chain option, David Disseldorp, 2021/04/13
- [PATCH v2 6/8] attempt copy_file_range if explicitly requested, David Disseldorp, 2021/04/13
- [PATCH v2 5/8] add --reflink option, David Disseldorp, 2021/04/13
- [PATCH v2 4/8] add copy_file_range syscall support, David Disseldorp, 2021/04/13
- [PATCH v2 3/8] add --chain test coverage, David Disseldorp, 2021/04/13
- [PATCH v2 7/8] ensure uniform post-trailer-zeros length,
David Disseldorp <=
- [PATCH v2 8/8] add --reflink test coverage, David Disseldorp, 2021/04/13