Re: [PATCH 01/12] generic/757: fix various bugs in this test

Christoph Hellwig
2024-11-21T10:13:29Z

On Thu, Nov 21, 2024 at 11:05:55AM +0100, Christoph Hellwig wrote:
> But the whole discard thing leaves me really confused, and the commit
> log in the patch references by the above link doesn't clear that up
> either.
>
> Why does dmlogwrites require discard for XFS (and apprently XFS only)?
> Note that discard is not required and often does not zero data. So
> if we need data to be zeroed we need to do that explicitly, and
> preferably in a way that is obvious.

Ok, I found the problem. src/log-writes/log-writes.c does try to
discard to zero, which is broken. This patch switches it to the
proper zeroout ioctl, which fixes my generic/757 issues, and should
also allow to revert commits to use dm-thin referenced in your link.

diff --git a/src/log-writes/log-writes.c b/src/log-writes/log-writes.c
index aa53473974d9..cb3ac962574c 100644
--- a/src/log-writes/log-writes.c
+++ b/src/log-writes/log-writes.c
@@ -31,7 +31,7 @@ static int discard_range(struct log *log, u64 start, u64 len)
{
u64 range[2] = { start, len };

- if (ioctl(log->replayfd, BLKDISCARD, &range) < 0) {
+ if (ioctl(log->replayfd, BLKZEROOUT, &range) < 0) {
if (log_writes_verbose)
printf("replay device doesn't support discard, "
"switching to writing zeros\n");