Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+11 -3
+11 -3
fs/xfs/xfs_super.c
··· 1765 1765 xfs_remount_ro( 1766 1766 struct xfs_mount *mp) 1767 1767 { 1768 - int error; 1768 + struct xfs_icwalk icw = { 1769 + .icw_flags = XFS_ICWALK_FLAG_SYNC, 1770 + }; 1771 + int error; 1769 1772 1770 1773 /* 1771 1774 * Cancel background eofb scanning so it cannot race with the final ··· 1776 1773 */ 1777 1774 xfs_blockgc_stop(mp); 1778 1775 1779 - /* Get rid of any leftover CoW reservations... */ 1780 - error = xfs_blockgc_free_space(mp, NULL); 1776 + /* 1777 + * Clear out all remaining COW staging extents and speculative post-EOF 1778 + * preallocations so that we don't leave inodes requiring inactivation 1779 + * cleanups during reclaim on a read-only mount. We must process every 1780 + * cached inode, so this requires a synchronous cache scan. 1781 + */ 1782 + error = xfs_blockgc_free_space(mp, &icw); 1781 1783 if (error) { 1782 1784 xfs_force_shutdown(mp, SHUTDOWN_CORRUPT_INCORE); 1783 1785 return error;