public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mkfs: use stx_blksize for dev block size by default
@ 2025-02-06 19:00 da.gomez
  2025-02-06 22:27 ` Darrick J. Wong
  2025-02-07  4:30 ` Christoph Hellwig
  0 siblings, 2 replies; 17+ messages in thread
From: da.gomez @ 2025-02-06 19:00 UTC (permalink / raw)
  To: linux-xfs; +Cc: Luis Chamberlain, Daniel Gomez, Pankaj Raghav, gost.dev

From: Daniel Gomez <da.gomez@samsung.com>

In patch [1] ("bdev: use bdev_io_min() for statx block size"), block
devices will now report their preferred minimum I/O size for optimal
performance in the stx_blksize field of the statx data structure. This
change updates the current default 4 KiB block size for all devices
reporting a minimum I/O larger than 4 KiB, opting instead to query for
its advertised minimum I/O value in the statx data struct.

[1]:
https://lore.kernel.org/all/20250204231209.429356-9-mcgrof@kernel.org/

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Set MIN-IO from statx as the default filesystem fundamental block size.
This ensures that, for devices reporting values within the supported
XFS block size range, we do not incur in RMW. If the MIN-IO reported
value is lower than the current default of 4 KiB, then 4 KiB will be
used instead.
---
 mkfs/xfs_mkfs.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index bbd0dbb6c80ab63ebf9edbe0a9a304149770f89d..e17389622682bc23f9b20c207db7e22181e2fe6f 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2178,6 +2178,26 @@ _("block size %d cannot be smaller than sector size %d\n"),
 	}
 }
 
+void
+get_dev_blocksize(
+	struct cli_params	*cli,
+	struct mkfs_default_params *dft)
+{
+	struct statx stx;
+	int ret;
+
+	if (!cli->xi->data.name)
+		return;
+
+	ret = statx(AT_FDCWD, cli->xi->data.name,
+		    AT_STATX_DONT_SYNC | AT_NO_AUTOMOUNT,
+		    STATX_DIOALIGN | STATX_TYPE | STATX_MODE | STATX_INO, &stx);
+	if (!ret)
+		dft->blocksize =
+			min(max(1 << XFS_DFL_BLOCKSIZE_LOG, stx.stx_blksize),
+			    XFS_MAX_BLOCKSIZE);
+}
+
 static void
 validate_blocksize(
 	struct mkfs_params	*cfg,
@@ -2189,6 +2209,7 @@ validate_blocksize(
 	 * For RAID4/5/6 we want to align sector size and block size,
 	 * so we need to start with the device geometry extraction too.
 	 */
+	get_dev_blocksize(cli, dft);
 	if (!cli->blocksize)
 		cfg->blocksize = dft->blocksize;
 	else

---
base-commit: 90d6da68ee54e6d4ef99eca4a82cac6036a34b00
change-id: 20250206-min-io-default-blocksize-13334f54899e

Best regards,
-- 
Daniel Gomez <da.gomez@samsung.com>


^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2025-05-13  5:33 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-06 19:00 [PATCH] mkfs: use stx_blksize for dev block size by default da.gomez
2025-02-06 22:27 ` Darrick J. Wong
2025-02-06 22:50   ` Luis Chamberlain
2025-02-06 23:07     ` Darrick J. Wong
2025-02-07  9:12     ` Daniel Gomez
2025-02-07 19:16       ` Luis Chamberlain
2025-02-07  9:39   ` Daniel Gomez
2025-02-07 19:26   ` Luis Chamberlain
2025-02-07 19:31     ` Darrick J. Wong
2025-02-07 19:44       ` Luis Chamberlain
2025-02-07  4:30 ` Christoph Hellwig
2025-02-07 10:04   ` Daniel Gomez
2025-02-13  4:10     ` Christoph Hellwig
2025-02-13 13:26       ` Daniel Gomez
2025-02-18  8:30         ` Christoph Hellwig
2025-05-09 14:27           ` Luis Chamberlain
2025-05-13  5:33             ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox