Re: [PATCH] btrfs: detect nocow for swap after snapshot delete
From: David Sterba <hidden>
Date: 2020-08-19 14:26:56
On Wed, Aug 19, 2020 at 12:59:28PM +0100, Graham Cobb wrote:
On 19/08/2020 12:29, David Sterba wrote:quoted
How often could the snapshot deletion and swapfile activation happen at the same time? Snapshotting subvolume with the swapfile requires deactivation, snapshot/send/whatever and then activation. This sounds like a realistic usecase.It is very likely when the swapfile is one that is only used occasionally (for example, when running a particular program which needs a massive amount of virtual memory, or having to stop using a different swapfile because a disk looks like it is starting to fail). If the swapfile is not normally used, it is not unlikely it got snapshotted (as part of a larger operation, presumably) while deactivated. When the user tries to use it, they realise it isn't working because it is snapshotted, so they delete the snapshot and then immediately try to activate it again -- causing confusion when it still fails.
That makes sense from user POV. I still don't uderstand if it's sufficient to commit the transaction deleting the snapshot or if it's necessary to wait until the subvolume is completely cleaned. The former would require 'btrfs subvol delte -c /snapshot' while the latter needs the id of the subvolume and then 'btrfs subvol sync /path id'.