Skip to content

Commit f4c32e8

Browse files
committed
xfs: fix realtime bitmap/summary file truncation when growing rt volume
The realtime bitmap and summary files are regular files that are hidden away from the directory tree. Since they're regular files, inode inactivation will try to purge what it thinks are speculative preallocations beyond the incore size of the file. Unfortunately, xfs_growfs_rt forgets to update the incore size when it resizes the inodes, with the result that inactivating the rt inodes at unmount time will cause their contents to be truncated. Fix this by updating the incore size when we change the ondisk size as part of updating the superblock. Note that we don't do this when we're allocating blocks to the rt inodes because we actually want those blocks to get purged if the growfs fails. This fixes corruption complaints from the online rtsummary checker when running xfs/233. Since that test requires rmap, one can also trigger this by growing an rt volume, cycling the mount, and creating rt files. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
1 parent e5b2374 commit f4c32e8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

fs/xfs/xfs_rtalloc.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,20 +1027,26 @@ xfs_growfs_rt(
10271027
xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
10281028
xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
10291029
/*
1030-
* Update the bitmap inode's size.
1030+
* Update the bitmap inode's size ondisk and incore. We need
1031+
* to update the incore size so that inode inactivation won't
1032+
* punch what it thinks are "posteof" blocks.
10311033
*/
10321034
mp->m_rbmip->i_d.di_size =
10331035
nsbp->sb_rbmblocks * nsbp->sb_blocksize;
1036+
i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size);
10341037
xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
10351038
/*
10361039
* Get the summary inode into the transaction.
10371040
*/
10381041
xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL);
10391042
xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL);
10401043
/*
1041-
* Update the summary inode's size.
1044+
* Update the summary inode's size. We need to update the
1045+
* incore size so that inode inactivation won't punch what it
1046+
* thinks are "posteof" blocks.
10421047
*/
10431048
mp->m_rsumip->i_d.di_size = nmp->m_rsumsize;
1049+
i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size);
10441050
xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE);
10451051
/*
10461052
* Copy summary data from old to new sizes.

0 commit comments

Comments
 (0)