Skip to content

Commit a24cae8

Browse files
Darrick J. WongChandan Babu R
authored andcommitted
xfs: reset rootdir extent size hint after growfsrt
If growfsrt is run on a filesystem that doesn't have a rt volume, it's possible to change the rt extent size. If the root directory was previously set up with an inherited extent size hint and rtinherit, it's possible that the hint is no longer a multiple of the rt extent size. Although the verifiers don't complain about this, xfs_repair will, so if we detect this situation, log the root directory to clean it up. This is still racy, but it's better than nothing. Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 16e1fbd commit a24cae8

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

fs/xfs/xfs_rtalloc.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,39 @@ xfs_alloc_rsum_cache(
784784
xfs_warn(mp, "could not allocate realtime summary cache");
785785
}
786786

787+
/*
788+
* If we changed the rt extent size (meaning there was no rt volume previously)
789+
* and the root directory had EXTSZINHERIT and RTINHERIT set, it's possible
790+
* that the extent size hint on the root directory is no longer congruent with
791+
* the new rt extent size. Log the rootdir inode to fix this.
792+
*/
793+
static int
794+
xfs_growfs_rt_fixup_extsize(
795+
struct xfs_mount *mp)
796+
{
797+
struct xfs_inode *ip = mp->m_rootip;
798+
struct xfs_trans *tp;
799+
int error = 0;
800+
801+
xfs_ilock(ip, XFS_IOLOCK_EXCL);
802+
if (!(ip->i_diflags & XFS_DIFLAG_RTINHERIT) ||
803+
!(ip->i_diflags & XFS_DIFLAG_EXTSZINHERIT))
804+
goto out_iolock;
805+
806+
error = xfs_trans_alloc_inode(ip, &M_RES(mp)->tr_ichange, 0, 0, false,
807+
&tp);
808+
if (error)
809+
goto out_iolock;
810+
811+
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
812+
error = xfs_trans_commit(tp);
813+
xfs_iunlock(ip, XFS_ILOCK_EXCL);
814+
815+
out_iolock:
816+
xfs_iunlock(ip, XFS_IOLOCK_EXCL);
817+
return error;
818+
}
819+
787820
/*
788821
* Visible (exported) functions.
789822
*/
@@ -812,6 +845,7 @@ xfs_growfs_rt(
812845
xfs_extlen_t rsumblocks; /* current number of rt summary blks */
813846
xfs_sb_t *sbp; /* old superblock */
814847
uint8_t *rsum_cache; /* old summary cache */
848+
xfs_agblock_t old_rextsize = mp->m_sb.sb_rextsize;
815849

816850
sbp = &mp->m_sb;
817851

@@ -1046,6 +1080,12 @@ xfs_growfs_rt(
10461080
if (error)
10471081
goto out_free;
10481082

1083+
if (old_rextsize != in->extsize) {
1084+
error = xfs_growfs_rt_fixup_extsize(mp);
1085+
if (error)
1086+
goto out_free;
1087+
}
1088+
10491089
/* Update secondary superblocks now the physical grow has completed */
10501090
error = xfs_update_secondary_sbs(mp);
10511091

0 commit comments

Comments
 (0)