Skip to contentSkip to conversation

xfs: fix IOMAP_F_DIRTY flag overwrite in zoned DIO

PATCH In review Andrey Albershteyn 2 participants 2 messages Aug 10 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix IOMAP_F_DIRTY flag overwrite in zoned DIO

Missing IOMAP_F_DIRTY prevents completion handlers from updating i_size on the direct IO path, the flag is set but was overwritten by IOMAP_F_ANON_WRITE latter. The writeback path for buffered IO doesn't seem to require IOMAP_F_DIRTY and looks like an error.

Fixes 2e2383405824 ("xfs: implement direct writes to zoned RT devices")
---
 fs/xfs/xfs_aops.c  | 1 -
 fs/xfs/xfs_iomap.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)
fs/xfs/xfs_aops.c +0 -1
index 51293b6f331f..01a981bf126e 100644
@@ -632,7 +632,6 @@ xfs_zoned_map_blocks(
 	xfs_iunlock(ip, XFS_ILOCK_EXCL);
 
 	wpc->iomap.type = IOMAP_MAPPED;
-	wpc->iomap.flags = IOMAP_F_DIRTY;
 	wpc->iomap.bdev = mp->m_rtdev_targp->bt_bdev;
 	wpc->iomap.offset = offset;
 	wpc->iomap.length = XFS_FSB_TO_B(mp, count_fsb);
fs/xfs/xfs_iomap.c +1 -2
index 225c3de88d03..45eef1b815b3 100644
@@ -1081,11 +1081,10 @@ xfs_zoned_direct_write_iomap_begin(
 	}
 
 	iomap->type = IOMAP_MAPPED;
-	iomap->flags = IOMAP_F_DIRTY;
 	iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev;
 	iomap->offset = offset;
 	iomap->length = length;
-	iomap->flags = IOMAP_F_ANON_WRITE;
+	iomap->flags = IOMAP_F_DIRTY | IOMAP_F_ANON_WRITE;
 	return 0;
 }
 
Signature · 1 line
2.54.0
#1 lore raw
Quoted 7 lines · Andrey Albershteyn

Missing IOMAP_F_DIRTY prevents completion handlers from updating i_size on the direct IO path, the flag is set but was overwritten by IOMAP_F_ANON_WRITE latter. The writeback path for buffered IO doesn't seem to require IOMAP_F_DIRTY and looks like an error.

Fixes 2e2383405824 ("xfs: implement direct writes to zoned RT devices")

I actually have exactly the same fix in a series I'm about to send out, and a cleanup to move this into common code.

I guess we both saw the same Sashiko comment :)