mkfs: set rtstart from user-specified dblocks
PATCH 1/1 mkfs: set rtstart from user-specified dblocks
From: Darrick J. Wong <[email protected]>
generic/211 fails to format the disk on a system with an internal zoned device. Poking through the shell scripts, it's apparently doing this:
# mkfs.xfs -d size=629145600 -r size=629145600 -b size=4096 -m metadir=1,autofsck=1,uquota,gquota,pquota, -r zoned=1 -d rtinherit=1 /dev/sdd size 629145600 specified for data subvolume is too large, maximum is 131072 blocks
Strange -- we asked for 629M data and rt sections, the device is 20GB in size, but it claims insufficient space in the data subvolume.
Further analysis shows that open_devices is setting rtstart to 1% of the size of the data volume (or no less than 300M) and rounding that up to the nearest power of two (512M). Hence the 131072 number.
But wait, we said that we wanted a 629M data section. Let's set rtstart to the same value if the user didn't already provide one, instead of using the default value.
--- mkfs/xfs_mkfs.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
mkfs/xfs_mkfs.c +21 -10
@@ -3720,17 +3720,28 @@ open_devices( zt->rt.zone_capacity = zt->data.zone_capacity; zt->rt.nr_zones = zt->data.nr_zones - zt->data.nr_conv_zones; }else if (cfg->sb_feat.zoned && !cfg->rtstart && !xi->rt.dev) { -/* -* By default reserve at 1% of the total capacity (rounded up to -* the next power of two) for metadata, but match the minimum we -* enforce elsewhere. This matches what SMR HDDs provide. -*/ -uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , -BTOBB (300 *1024 *1024 )); +if (cfg->dblocks) { +/* +* If the user specified the size of the data device +* but not the start of the internal rt device, set +* the internal rt volume to start at the end of the +* data device. +*/ + cfg->rtstart = cfg->dblocks << (cfg->blocklog -BBSHIFT ); + }else { +/* +* By default reserve at 1% of the total capacity +* (rounded up to the next power of two) for metadata, +* but match the minimum we enforce elsewhere. This +* matches what SMR HDDs provide. +*/ +uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , +BTOBB (300 *1024 *1024 )); - cfg->rtstart =1 ; -while (cfg->rtstart < rt_target_size) - cfg->rtstart <<=1 ; + cfg->rtstart =1 ; +while (cfg->rtstart < rt_target_size) + cfg->rtstart <<=1 ; + } }if (cfg->rtstart) {
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
generic/211 fails to format the disk on a system with an internal zoned device. Poking through the shell scripts, it's apparently doing this:
On some anyway. We've had this on our CI machines as well, and it's been on my todo list why it doesn't happen everywhere, so thanks for digging into this and getting it off my todo list :)
Quoted 34 lines
# mkfs.xfs -d size=629145600 -r size=629145600 -b size=4096 -m metadir=1,autofsck=1,uquota,gquota,pquota, -r zoned=1 -d rtinherit=1 /dev/sdd size 629145600 specified for data subvolume is too large, maximum is 131072 blocksStrange -- we asked for 629M data and rt sections, the device is 20GB in size, but it claims insufficient space in the data subvolume.
Further analysis shows that
open_devicesis setting rtstart to 1% of the size of the data volume (or no less than 300M) and rounding that up to the nearest power of two (512M). Hence the 131072 number.But wait, we said that we wanted a 629M data section. Let's set rtstart to the same value if the user didn't already provide one, instead of using the default value.
Cc <[email protected]> # v6.15.0Fixes 2e5a737a61d34e ("xfs_mkfs: support creating file system with zoned RT devices")Signed-off-by "Darrick J. Wong" <[email protected]>--- mkfs/xfs_mkfs.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)mkfs/xfs_mkfs.c +0
-5@@ -3720,17 +3720,28 @@ open_devices( zt->rt.zone_capacity = zt->data.zone_capacity; zt->rt.nr_zones = zt->data.nr_zones - zt->data.nr_conv_zones; }else if (cfg->sb_feat.zoned && !cfg->rtstart && !xi->rt.dev) { -/* -* By default reserve at 1% of the total capacity (rounded up to -* the next power of two) for metadata, but match the minimum we -* enforce elsewhere. This matches what SMR HDDs provide. -*/
mkfs/xfs_mkfs.c open_devices( · line 3730
Quoted 10 lines
mkfs/xfs_mkfs.c +8
-2-uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , -BTOBB (300 *1024 *1024 )); +if (cfg->dblocks) { +/* +* If the user specified the size of the data device +* but not the start of the internal rt device, set +* the internal rt volume to start at the end of the +* data device. +*/ + cfg->rtstart = cfg->dblocks << (cfg->blocklog -BBSHIFT );
Overly long line here.
mkfs/xfs_mkfs.c open_devices( · line 3739
Quoted 9 lines
mkfs/xfs_mkfs.c +9
-0+ }else { +/* +* By default reserve at 1% of the total capacity +* (rounded up to the next power of two) for metadata, +* but match the minimum we enforce elsewhere. This +* matches what SMR HDDs provide. +*/ +uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , +BTOBB (300 *1024 *1024 ));
And here as well. Maybe split the sizse calculation into a helper to make these a bit more readable?
Otherwise this looks good.
Quoted 57 lines · Christoph Hellwig
Quoted 4 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
generic/211 fails to format the disk on a system with an internal zoned device. Poking through the shell scripts, it's apparently doing this:
On some anyway. We've had this on our CI machines as well, and it's been on my todo list why it doesn't happen everywhere, so thanks for digging into this and getting it off my todo list :)
Quoted 34 lines
# mkfs.xfs -d size=629145600 -r size=629145600 -b size=4096 -m metadir=1,autofsck=1,uquota,gquota,pquota, -r zoned=1 -d rtinherit=1 /dev/sdd size 629145600 specified for data subvolume is too large, maximum is 131072 blocksStrange -- we asked for 629M data and rt sections, the device is 20GB in size, but it claims insufficient space in the data subvolume.
Further analysis shows that
open_devicesis setting rtstart to 1% of the size of the data volume (or no less than 300M) and rounding that up to the nearest power of two (512M). Hence the 131072 number.But wait, we said that we wanted a 629M data section. Let's set rtstart to the same value if the user didn't already provide one, instead of using the default value.
Cc <[email protected]> # v6.15.0Fixes 2e5a737a61d34e ("xfs_mkfs: support creating file system with zoned RT devices")Signed-off-by "Darrick J. Wong" <[email protected]>--- mkfs/xfs_mkfs.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)mkfs/xfs_mkfs.c +0
-5@@ -3720,17 +3720,28 @@ open_devices( zt->rt.zone_capacity = zt->data.zone_capacity; zt->rt.nr_zones = zt->data.nr_zones - zt->data.nr_conv_zones; }else if (cfg->sb_feat.zoned && !cfg->rtstart && !xi->rt.dev) { -/* -* By default reserve at 1% of the total capacity (rounded up to -* the next power of two) for metadata, but match the minimum we -* enforce elsewhere. This matches what SMR HDDs provide. -*/ mkfs/xfs_mkfs.c open_devices( · line 3730
Quoted 10 lines
mkfs/xfs_mkfs.c +8
-2-uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , -BTOBB (300 *1024 *1024 )); +if (cfg->dblocks) { +/* +* If the user specified the size of the data device +* but not the start of the internal rt device, set +* the internal rt volume to start at the end of the +* data device. +*/ + cfg->rtstart = cfg->dblocks << (cfg->blocklog -BBSHIFT );Overly long line here.
Quoted 12 lines
mkfs/xfs_mkfs.c open_devices( · line 3739
Quoted 9 lines
mkfs/xfs_mkfs.c +9
-0+ }else { +/* +* By default reserve at 1% of the total capacity +* (rounded up to the next power of two) for metadata, +* but match the minimum we enforce elsewhere. This +* matches what SMR HDDs provide. +*/ +uint64_t rt_target_size =max ((xi->data.size +99 ) /100 , +BTOBB (300 *1024 *1024 ));And here as well. Maybe split the sizse calculation into a helper to make these a bit more readable?
Fixed:
static uint64_t
calc_rtstart(
const struct mkfs_params *cfg,
const struct libxfs_init *xi)
{
uint64_t rt_target_size;
uint64_t rtstart = 1;
if (cfg->dblocks) {
/*
* If the user specified the size of the data device but not
* the start of the internal rt device, set the internal rt
* volume to start at the end of the data device.
*/
return cfg->dblocks << (cfg->blocklog - BBSHIFT);
}
/*
* By default reserve at 1% of the total capacity (rounded up to the
* next power of two) for metadata, but match the minimum we enforce
* elsewhere. This matches what SMR HDDs provide.
*/
rt_target_size = max((xi->data.size + 99) / 100,
BTOBB(300 * 1024 * 1024));
while (rtstart < rt_target_size)
rtstart <<= 1;
return rtstart;
}and then the callsite turns into cfg->rtstart = calc_rtstart(...).
Quoted 1 line
Otherwise this looks good.
Thanks!
--D