Re: [RFC PATCH v2 0/5] Add buffered write-through support to iomap & xfs

From: IBM

Date: Thu Apr 23 2026 - 20:21:08 EST


Ojaswin Mujoo <ojaswin@xxxxxxxxxxxxx> writes:

> On Thu, Apr 23, 2026 at 02:25:43PM +0200, Pankaj Raghav (Samsung) wrote:
>> >
>> >
>> > * Testing Notes (UPDATED) *
>> >
>> > - I've added support for RWF_WRITETHROUGH to fsx and fsstress in
>> > xfstests and these patches survive fsx with integrity verification as
>> > well as fsstress parallel stressing.
>> > - -g quick with blocks size == page size and blocksize < pagesize shows
>> > no new regressions.
>>
>> I am hitting a very strange error in generic/127. I deconstructed it in
>> to two commands that can reproduce the issue:
>>
>> ```
>> $ dd if=/dev/zero of=/media/test/fsx_lite_nommap bs=262144 count=1
>>
>> $ /root/home/xfstests/ltp/fsx -l 262144 -o 65536 -S 191110531 -N 100000 -L -R -W /media/test/fsx_lite_nommap
>> mapped writes DISABLED
>> Seed set to 191110531
>> main: filesystem does not support exchange range, disabling!
>> main: atomic writes need O_DIRECT (-Z), disabling!
>> short read: 0x0 bytes instead of 0x6c7f
>> LOG DUMP (1 total operations):
>> 1( 1 mod 256): READ 0x39381 thru 0x3ffff (0x6c7f bytes)
>> Log of operations saved to "/media/test/fsx_lite_nommap.fsxops"; replay with --replay-ops
>> fsx: save_buffer: .fsxgood file too short... will save 0x0 bytes instead of 0x40000
>> : Operation not supported
>> Correct content saved for comparison
>> (maybe hexdump "/media/test/fsx_lite_nommap" vs "/media/test/fsx_lite_nommap.fsxgood")
>> ```
>>
>> This is on a bs == ps (4k block size) xfs filesystem.
>> ```
>> $ xfs_info /media/test/
>> meta-data=/dev/nvme1n1 isize=512 agcount=4, agsize=2097152 blks
>> = sectsz=4096 attr=2, projid32bit=1
>> = crc=1 finobt=1, sparse=1, rmapbt=0
>> = reflink=1 bigtime=1 inobtcount=1 nrext64=0
>> data = bsize=4096 blocks=8388608, imaxpct=25
>> = sunit=0 swidth=0 blks
>> naming =version 2 bsize=4096 ascii-ci=0, ftype=1
>> log =internal log bsize=4096 blocks=16384, version=2
>> = sectsz=4096 sunit=1 blks, lazy-count=1
>> realtime =none extsz=4096 blocks=0, rtextents=0
>> ```
>>
>> The same test passes if I pass `-G` to fsx parameters(disabling writethrough).
>>
>> The error is coming when we do a read operation which feels very
>> strange. Could you run this in your setup and see if you can reproduce
>> them? I still do not know where the issue is coming from or it is
>> because of my test setup.
>
> Hey Pankaj, I think the xfstests branch I shared might have been missing
> one small fix that can cause this issue. I've update the branch with the
> fix, can you give it a try:
>
> https://github.com/OjaswinM/xfstests/tree/iomap-buf-writethrough2
>

Ohk, just noticed your reply, after sending a response...

Thinking it again, I agree we should just always ftruncate it back to
the original file_size. Because we might have changed to file size while
testing the writethrough support.

Thanks for fixing it! This fix looks right to me.

~# git diff
diff --git a/ltp/fsx.c b/ltp/fsx.c
index c9901f65..720bca83 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -2095,7 +2095,7 @@ test_writethrough_io(void)
return 0;
}

- if (ftruncate(fd, 0) != 0) {
+ if (ftruncate(fd, file_size) != 0) {
perror("test_writethrough_io: failed to ftruncate to 0\n");
exit(132);
}

-ritesh


> Regards,
> Ojaswin
>
>>
>> --
>> Pankaj