]> www.infradead.org Git - linux.git/commitdiff
xfs: expose block size in stat
authorPankaj Raghav <p.raghav@samsung.com>
Thu, 22 Aug 2024 13:50:16 +0000 (15:50 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 2 Sep 2024 14:19:44 +0000 (16:19 +0200)
For block size larger than page size, the unit of efficient IO is
the block size, not the page size. Leaving stat() to report
PAGE_SIZE as the block size causes test programs like fsx to issue
illegal ranges for operations that require block size alignment
(e.g. fallocate() insert range). Hence update the preferred IO size
to reflect the block size in this case.

This change is based on a patch originally from Dave Chinner.[1]

[1] https://lwn.net/ml/linux-fsdevel/20181107063127.3902-16-david@fromorbit.com/

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20240822135018.1931258-9-kernel@pankajraghav.com
Acked-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Daniel Gomez <da.gomez@samsung.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/xfs/xfs_iops.c

index 1cdc8034f54d93f4a40ab3e3e4f91c6c9dfed7ec..6483b4c4cf355eb622c5c31521076e5f3287eb9c 100644 (file)
@@ -567,7 +567,7 @@ xfs_stat_blksize(
                        return 1U << mp->m_allocsize_log;
        }
 
-       return PAGE_SIZE;
+       return max_t(uint32_t, PAGE_SIZE, mp->m_sb.sb_blocksize);
 }
 
 STATIC int