Skip to content

Commit e034d9c

Browse files
committed
Merge tag 'xfs-5.16-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
Pull xfs fix from Darrick Wong: "This fixes a race between a readonly remount process and other processes that hold a file IOLOCK on files that previously experienced copy on write, that could result in severe filesystem corruption if the filesystem is then remounted rw. I think this is fairly rare (since the only reliable reproducer I have that fits the second criteria is the experimental xfs_scrub program), but the race is clear, so we still need to fix this. Summary: - Fix a data corruption vector that can result from the ro remount process failing to clear all speculative preallocations from files and the rw remount process not noticing the incomplete cleanup" * tag 'xfs-5.16-fixes-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux: xfs: remove all COW fork extents when remounting readonly
2 parents 8f97a35 + 089558b commit e034d9c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

fs/xfs/xfs_super.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,16 +1765,24 @@ static int
17651765
xfs_remount_ro(
17661766
struct xfs_mount *mp)
17671767
{
1768-
int error;
1768+
struct xfs_icwalk icw = {
1769+
.icw_flags = XFS_ICWALK_FLAG_SYNC,
1770+
};
1771+
int error;
17691772

17701773
/*
17711774
* Cancel background eofb scanning so it cannot race with the final
17721775
* log force+buftarg wait and deadlock the remount.
17731776
*/
17741777
xfs_blockgc_stop(mp);
17751778

1776-
/* Get rid of any leftover CoW reservations... */
1777-
error = xfs_blockgc_free_space(mp, NULL);
1779+
/*
1780+
* Clear out all remaining COW staging extents and speculative post-EOF
1781+
* preallocations so that we don't leave inodes requiring inactivation
1782+
* cleanups during reclaim on a read-only mount. We must process every
1783+
* cached inode, so this requires a synchronous cache scan.
1784+
*/
1785+
error = xfs_blockgc_free_space(mp, &icw);
17781786
if (error) {
17791787
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
17801788
return error;

0 commit comments

Comments
 (0)