]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: validate rt extent size hint when rtinherit is set
authorDarrick J. Wong <djwong@kernel.org>
Wed, 28 Jul 2021 23:03:16 +0000 (19:03 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 28 Jul 2021 23:03:16 +0000 (19:03 -0400)
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 <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
mkfs/xfs_mkfs.c

index f84a42f9830c3a354439a797a8f56021d113cc04..9c14c04eae280b0a0988930f0081439ea93dfd88 100644 (file)
@@ -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;