Commit e034d9cb authored by Linus Torvalds's avatar Linus Torvalds

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
parents 8f97a35a 089558bc
......@@ -1765,6 +1765,9 @@ static int
xfs_remount_ro(
struct xfs_mount *mp)
{
struct xfs_icwalk icw = {
.icw_flags = XFS_ICWALK_FLAG_SYNC,
};
int error;
/*
......@@ -1773,8 +1776,13 @@ xfs_remount_ro(
*/
xfs_blockgc_stop(mp);
/* Get rid of any leftover CoW reservations... */
error = xfs_blockgc_free_space(mp, NULL);
/*
* Clear out all remaining COW staging extents and speculative post-EOF
* preallocations so that we don't leave inodes requiring inactivation
* cleanups during reclaim on a read-only mount. We must process every
* cached inode, so this requires a synchronous cache scan.
*/
error = xfs_blockgc_free_space(mp, &icw);
if (error) {
xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE);
return error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment