Skip to contentSkip to conversation

CA-411820: add STATX_DIOALIGN support to GFS2

PATCH New Mark Syms 1 participant 1 message Jun 2, 2025 GFS2 file system

lore
Share & tools
lore

Mark Syms

author
#0 lore raw

PATCH 1/1 CA-411820: add STATX_DIOALIGN support to GFS2

Inspiration taken from 8434ef1d8aa but in simplified form. 8434ef1d8aa makes the response conditional on the result from ext4_dio_alignment. It is not clear if similar discrimination needs to be performed for GFS2 or if the iomap defaults will be generally suitable. In tests performed with XenServer this does appear to be the case.

---
 fs/gfs2/inode.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
fs/gfs2/inode.c +13 -0
index 187d789a8f1e..9310ecfe1f15 100644
@@ -2172,6 +2172,19 @@ static int gfs2_getattr(struct mnt_idmap *idmap,
 
 	generic_fillattr(&nop_mnt_idmap, request_mask, inode, stat);
 
+	/*
+	 * Return the DIO alignment restrictions if requested.  We only return
+	 * this information when requested.
+	 */
+	if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
+		struct block_device *bdev = inode->i_sb->s_bdev;
+
+		stat->result_mask |= STATX_DIOALIGN;
+		/* iomap defaults */
+		stat->dio_mem_align = bdev_dma_alignment(bdev) + 1;
+		stat->dio_offset_align = bdev_logical_block_size(bdev);
+	}
+
 	if (gfs2_holder_initialized(&gh))
 		gfs2_glock_dq_uninit(&gh);
 
Signature · 1 line
2.49.0