public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Boris Burkov <boris@bur.io>
To: dsterba@suse.cz, Graham Cobb <g.btrfs@cobb.uk.net>,
	Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>,
	Omar Sandoval <osandov@osandov.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH] btrfs: detect nocow for swap after snapshot delete
Date: Wed, 19 Aug 2020 10:46:09 -0700	[thread overview]
Message-ID: <20200819174609.GA1218106@devvm842.ftw2.facebook.com> (raw)
In-Reply-To: <20200819142548.GN2026@twin.jikos.cz>

On Wed, Aug 19, 2020 at 04:25:48PM +0200, David Sterba wrote:
> On Wed, Aug 19, 2020 at 12:59:28PM +0100, Graham Cobb wrote:
> > On 19/08/2020 12:29, David Sterba wrote:
> > > 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'.

My reproduction has been:
create subvol
create swapfile in subvol
btrfs subvol snapshot subvol snapshot
btrfs subvol delete snapshot
sync/btrfs fi sync/waiting
swapon subvol/swapfile

Note that I haven't been touching the swapfile in any way after
initially creating it. Nor have I been turning swap on/off in any
coordinated way before/after the snapshot except to test after the
snapshot is deleted.

I tried both suggestions with and without the patch and saw that with
the patch, swapon reliably succeeds after 'btrfs subvol sync' and does
not reliably succeed even after 'btrfs subvol delete -c' or sync calls,
so it seems that we need the subvolume to be completely cleaned. Without
the patch, after both 'btrfs subvol delete -c' and after 'btrfs subvol
sync', the swapon fails. Thanks for the review, and testing suggestions!

  reply	other threads:[~2020-08-19 17:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-18 18:00 [PATCH] btrfs: detect nocow for swap after snapshot delete Boris Burkov
2020-08-19 11:29 ` David Sterba
2020-08-19 11:59   ` Graham Cobb
2020-08-19 14:25     ` David Sterba
2020-08-19 17:46       ` Boris Burkov [this message]
2020-08-20 16:13         ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200819174609.GA1218106@devvm842.ftw2.facebook.com \
    --to=boris@bur.io \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=dsterba@suse.cz \
    --cc=g.btrfs@cobb.uk.net \
    --cc=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=osandov@osandov.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox