From 1e8afffb6260104a8a3773f6fdb91af8ca1a6ff4 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 28 Jul 2021 19:03:16 -0400 Subject: [PATCH] mkfs: validate rt extent size hint when rtinherit is set Extent size hints exist to nudge the behavior of the file data block allocator towards trying to make aligned allocations. Therefore, it doesn't make sense to allow a hint that isn't a multiple of the fundamental allocation unit for a given file. This means that if the sysadmin is formatting with rtinherit set on the root dir, validate_extsize_hint needs to check the hint value on a simulated realtime file to make sure that it's correct. Unfortunately, the gate check here was for a nonzero rt extent size, which is wrong since we never format with rtextsize==0. This leads to absurd failures such as: # mkfs.xfs -f /dev/sdf -r extsize=7b -d rtinherit=0,extszinherit=13 illegal extent size hint 13, must be less than 649088 and a multiple of 7. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Carlos Maiolino Signed-off-by: Eric Sandeen --- mkfs/xfs_mkfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index f84a42f98..9c14c04ea 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -2384,10 +2384,11 @@ _("illegal extent size hint %lld, must be less than %u.\n"), } /* - * Now we do it again with a realtime file so that we know the hint and - * flag that get passed on to realtime files will be correct. + * If the value is to be passed on to realtime files, revalidate with + * a realtime file so that we know the hint and flag that get passed on + * to realtime files will be correct. */ - if (mp->m_sb.sb_rextsize == 0) + if (!(cli->fsx.fsx_xflags & FS_XFLAG_RTINHERIT)) return; flags = XFS_DIFLAG_REALTIME; -- 2.47.2