On Wed, Dec 11, 2024 at 10:24:56AM -0800, Darrick J. Wong wrote: > On Wed, Dec 11, 2024 at 02:49:08PM +0000, Filipe Manana wrote: > > Hello, > > > > While looking at a btrfs bug where we fail to active a swap file that > > used to have shared extents, I noticed xfs has the same bug, however > > the test fails intermittently, suggesting some sort of race. > > I bet swapon is racing with inodegc unmapping the extents from the > previously rm'd files. Almost certainly the case. All sync does is stabilise the unlinked lists so recovery will see the unlinked inodes; it has no effect on expediting background inodegc, nor should it. > The fix for this is (probably?) to call > xfs_inodegc_flush from xfs_iomap_swapfile_activate... though that might > be involved, since iirc at that point we hold the swapfile's IOLOCK. For this sort of artificial test, freeze and unfreeze to ensure that the background inodegc is drained before the swapon command is run. It's not clear to me that there is a real world use case where this is actually a problem, so for testing purposes a freeze before swapon seems like the right way to go here... -Dave. -- Dave Chinner david@xxxxxxxxxxxxx