* [PATCH] mkfs: use a default sector size that is also suitable for the rtdev
@ 2025-01-27 13:54 Christoph Hellwig
2025-01-27 21:37 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2025-01-27 13:54 UTC (permalink / raw)
To: aalbersh; +Cc: linux-xfs
When creating a filesytem where the data device has a sector size
smalle than that of the RT device without further options, mkfs
currently fails with:
mkfs.xfs: error - cannot set blocksize 512 on block device $RTDEV: Invalid argument
This is because XFS sets the sector size based on logical block size
of the data device, but not that of the RT device. Change the code
so that is uses the larger of the two values.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
mkfs/xfs_mkfs.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 6cc7e6439ca1..0627af81da37 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -2368,7 +2368,9 @@ validate_sectorsize(
* advertised sector size of the device. We use the physical
* sector size unless the requested block size is smaller
* than that, then we can use logical, but warn about the
- * inefficiency.
+ * inefficiency. If the file system has a RT device, the
+ * sectorsize needs to be the maximum of the data and RT
+ * device.
*
* Some architectures have a page size > XFS_MAX_SECTORSIZE.
* In that case, a ramdisk or persistent memory device may
@@ -2378,8 +2380,18 @@ validate_sectorsize(
ft->data.physical_sector_size =
ft->data.logical_sector_size;
}
-
cfg->sectorsize = ft->data.physical_sector_size;
+
+ if (cli->xi->rt.name) {
+ if (ft->rt.physical_sector_size > XFS_MAX_SECTORSIZE) {
+ ft->rt.physical_sector_size =
+ ft->rt.logical_sector_size;
+ }
+
+ if (cfg->sectorsize < ft->rt.physical_sector_size)
+ cfg->sectorsize = ft->rt.physical_sector_size;
+ }
+
if (cfg->blocksize < cfg->sectorsize &&
cfg->blocksize >= ft->data.logical_sector_size) {
fprintf(stderr,
--
2.45.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mkfs: use a default sector size that is also suitable for the rtdev
2025-01-27 13:54 [PATCH] mkfs: use a default sector size that is also suitable for the rtdev Christoph Hellwig
@ 2025-01-27 21:37 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2025-01-27 21:37 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: aalbersh, linux-xfs
On Mon, Jan 27, 2025 at 02:54:03PM +0100, Christoph Hellwig wrote:
> When creating a filesytem where the data device has a sector size
> smalle than that of the RT device without further options, mkfs
> currently fails with:
>
> mkfs.xfs: error - cannot set blocksize 512 on block device $RTDEV: Invalid argument
>
> This is because XFS sets the sector size based on logical block size
> of the data device, but not that of the RT device. Change the code
> so that is uses the larger of the two values.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
That makes sense to me.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> mkfs/xfs_mkfs.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 6cc7e6439ca1..0627af81da37 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2368,7 +2368,9 @@ validate_sectorsize(
> * advertised sector size of the device. We use the physical
> * sector size unless the requested block size is smaller
> * than that, then we can use logical, but warn about the
> - * inefficiency.
> + * inefficiency. If the file system has a RT device, the
> + * sectorsize needs to be the maximum of the data and RT
> + * device.
> *
> * Some architectures have a page size > XFS_MAX_SECTORSIZE.
> * In that case, a ramdisk or persistent memory device may
> @@ -2378,8 +2380,18 @@ validate_sectorsize(
> ft->data.physical_sector_size =
> ft->data.logical_sector_size;
> }
> -
> cfg->sectorsize = ft->data.physical_sector_size;
> +
> + if (cli->xi->rt.name) {
> + if (ft->rt.physical_sector_size > XFS_MAX_SECTORSIZE) {
> + ft->rt.physical_sector_size =
> + ft->rt.logical_sector_size;
> + }
> +
> + if (cfg->sectorsize < ft->rt.physical_sector_size)
> + cfg->sectorsize = ft->rt.physical_sector_size;
> + }
> +
> if (cfg->blocksize < cfg->sectorsize &&
> cfg->blocksize >= ft->data.logical_sector_size) {
> fprintf(stderr,
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-27 21:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-27 13:54 [PATCH] mkfs: use a default sector size that is also suitable for the rtdev Christoph Hellwig
2025-01-27 21:37 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox