Hello, Please find version-5 of this series. v5 mainly addresses the review comments from Matthew to have a better iop->state bitmap handling functions. Please do let me know if any comments/feedback. Testing ========= Continuing to run more tests, but so far I haven't observed any surprises on my 1k and 4k blocksize with default options & -g "auto" runs. <Pasting RFCv3 => RFCv4 relevant changelog for v5 and dopping everything else> ======================================================================== This addresses a problem reported by Brian for a short write case with delalloc release. This is addressed in patch-5 in function iomap_write_delalloc_scan(). I suppose this is a major change from the previous rfcv3. I did test a unit test which Brian provided with xfs_io -f option. Before those changes, the kernel caused a bug_on during unmount with the unit test. This gets fixed with the changes added in v4. i.e. After v4 ================= root@ubuntu# ./xfs_io -fc "truncate 4k" -c "mmap 0 4k" -c "mread 0 4k" -c "pwrite 0 1" -c "pwrite -f 2k 1" -c fsync /mnt1/tmnt/testfile wrote 1/1 bytes at offset 0 1.000000 bytes, 1 ops; 0.0001 sec (7.077 KiB/sec and 7246.3768 ops/sec) pwrite: Bad address root@ubuntu# ./xfs_io -c "fiemap -v" /mnt1/tmnt/testfile /mnt1/tmnt/testfile: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..1]: 22..23 2 0x1 1: [2..7]: hole 6 root@ubuntu# filefrag -v /mnt1/tmnt/testfile Filesystem type is: 58465342 File size of /mnt1/tmnt/testfile is 4096 (4 blocks of 1024 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 11.. 11: 1: last /mnt1/tmnt/testfile: 1 extent found root@ubuntu# umount /mnt1/tmnt root@ubuntu# Before v4 =========== root@ubuntu# mount /dev/loop8 /mnt1/test root@ubuntu# ./xfs_io -fc "truncate 4k" -c "mmap 0 4k" -c "mread 0 4k" -c "pwrite 0 1" -c "pwrite -f 2k 1" -c fsync /mnt1/test/testfile wrote 1/1 bytes at offset 0 1.000000 bytes, 1 ops; 0.0000 sec (10.280 KiB/sec and 10526.3158 ops/sec) pwrite: Bad address root@ubuntu# ./xfs_io -c "fiemap -v" /mnt1/test/testfile /mnt1/test/testfile: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..1]: 22..23 2 0x0 1: [2..3]: hole 2 2: [4..5]: 0..1 2 0x7 3: [6..7]: hole 2 root@ubuntu# filefrag -v /mnt1/test/testfile Filesystem type is: 58465342 File size of /mnt1/test/testfile is 4096 (4 blocks of 1024 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 11.. 11: 1: 1: 2.. 2: 0.. 0: 0: last,unknown_loc,delalloc /mnt1/test/testfile: 2 extents found root@ubuntu# umount /mnt1/test <dmesg snip> [ 156.581188] XFS (loop8): Unmounting Filesystem 7889507d-fc7f-4a1c-94d5-06797f2cc790 [ 156.584455] XFS (loop8): ino 43 data fork has delalloc extent at [0x2:0x1] [ 156.587847] XFS: Assertion failed: 0, file: fs/xfs/xfs_icache.c, line: 1816 [ 156.591675] ------------[ cut here ]------------ [ 156.594133] kernel BUG at fs/xfs/xfs_message.c:102! [ 156.596669] invalid opcode: 0000 [#1] PREEMPT SMP PTI [ 156.599277] CPU: 7 PID: 435 Comm: kworker/7:5 Not tainted 6.3.0-rc6-xfstests-00003-g99a844f4e411-dirty #105 [ 156.603721] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.15.0-0-g2dd4b9b3f840-prebuilt.qemu.org 04/01/2014 [ 156.608701] Workqueue: xfs-inodegc/loop8 xfs_inodegc_worker [ 156.611426] RIP: 0010:assfail+0x38/0x40 [ 156.646981] Call Trace: [ 156.647951] <TASK> [ 156.648904] xfs_inodegc_set_reclaimable+0x15b/0x160 [ 156.651270] xfs_inodegc_worker+0x95/0x1d0 [ 156.653202] process_one_work+0x274/0x550 [ 156.655305] worker_thread+0x4f/0x300 [ 156.657081] ? __pfx_worker_thread+0x10/0x10 [ 156.658977] kthread+0xf6/0x120 [ 156.660657] ? __pfx_kthread+0x10/0x10 [ 156.662565] ret_from_fork+0x2c/0x50 [ 156.664421] </TASK> Previous changelogs & TODOs at [1] [1]: https://lore.kernel.org/linux-xfs/cover.1683208091.git.ritesh.list@xxxxxxxxx/ Ritesh Harjani (IBM) (5): iomap: Rename iomap_page_create/release() to iop_alloc/free() iomap: Refactor iop_set_range_uptodate() function iomap: Add iop's uptodate state handling functions iomap: Allocate iop in ->write_begin() early iomap: Add per-block dirty state tracking to improve performance fs/gfs2/aops.c | 2 +- fs/iomap/buffered-io.c | 264 ++++++++++++++++++++++++++++++++--------- fs/xfs/xfs_aops.c | 2 +- fs/zonefs/file.c | 2 +- include/linux/iomap.h | 1 + 5 files changed, 210 insertions(+), 61 deletions(-) -- 2.39.2