]> git.itanic.dy.fi Git - linux-stable/commit
xfs: don't commit sunit/swidth updates to disk if that would cause repair failures
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 11 Dec 2019 21:19:06 +0000 (13:19 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Thu, 19 Dec 2019 15:53:48 +0000 (07:53 -0800)
commit13eaec4b2adf2657b8167b67e27c97cc7314d923
tree7aedf30538f9049553ed2e5d6bf1a82f9666f506
parent4f5b1b3a8fa07dc8ecedfaf539b3deed8931a73e
xfs: don't commit sunit/swidth updates to disk if that would cause repair failures

Alex Lyakas reported[1] that mounting an xfs filesystem with new sunit
and swidth values could cause xfs_repair to fail loudly.  The problem
here is that repair calculates the where mkfs should have allocated the
root inode, based on the superblock geometry.  The allocation decisions
depend on sunit, which means that we really can't go updating sunit if
it would lead to a subsequent repair failure on an otherwise correct
filesystem.

Port from xfs_repair some code that computes the location of the root
inode and teach mount to skip the ondisk update if it would cause
problems for repair.  Along the way we'll update the documentation,
provide a function for computing the minimum AGFL size instead of
open-coding it, and cut down some indenting in the mount code.

Note that we allow the mount to proceed (and new allocations will
reflect this new geometry) because we've never screened this kind of
thing before.  We'll have to wait for a new future incompat feature to
enforce correct behavior, alas.

Note that the geometry reporting always uses the superblock values, not
the incore ones, so that is what xfs_info and xfs_growfs will report.

[1] https://lore.kernel.org/linux-xfs/20191125130744.GA44777@bfoster/T/#m00f9594b511e076e2fcdd489d78bc30216d72a7d

Reported-by: Alex Lyakas <alex@zadara.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc.h
fs/xfs/xfs_mount.c
fs/xfs/xfs_trace.h