Skip to content

Commit

Permalink
xfs: update lazy sb counters immediately for resizefs
Browse files Browse the repository at this point in the history
sb_fdblocks will be updated lazily if lazysbcount is enabled,
therefore when shrinking the filesystem sb_fdblocks could be
larger than sb_dblocks and xfs_validate_sb_write() would fail.

Even for growfs case, it'd be better to update lazy sb counters
immediately to reflect the real sb counters.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
  • Loading branch information
Gao Xiang authored and Darrick J. Wong committed Mar 25, 2021
1 parent f9dd7ba commit 014695c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/xfs/xfs_fsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,15 @@ xfs_growfs_data_private(
nb - mp->m_sb.sb_dblocks);
if (id.nfree)
xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, id.nfree);

/*
* Sync sb counters now to reflect the updated values. This is
* particularly important for shrink because the write verifier
* will fail if sb_fdblocks is ever larger than sb_dblocks.
*/
if (xfs_sb_version_haslazysbcount(&mp->m_sb))
xfs_log_sb(tp);

xfs_trans_set_sync(tp);
error = xfs_trans_commit(tp);
if (error)
Expand Down

0 comments on commit 014695c

Please sign in to comment.