From: David Sterba <dsterba@suse.cz>
To: Boris Burkov <boris@bur.io>
Cc: 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 13:29:41 +0200 [thread overview]
Message-ID: <20200819112941.GK2026@twin.jikos.cz> (raw)
In-Reply-To: <20200818180005.933061-1-boris@bur.io>
On Tue, Aug 18, 2020 at 11:00:05AM -0700, Boris Burkov wrote:
> can_nocow_extent and btrfs_cross_ref_exist both rely on a heuristic for
> detecting a must cow condition which is not exactly accurate, but saves
> unnecessary tree traversal. The incorrect assumption is that if the
> extent was created in a generation smaller than the last snapshot
> generation, it must be referenced by that snapshot. That is true, except
> the snapshot could have since been deleted, without affecting the last
> snapshot generation.
>
> The original patch claimed a performance win from this check, but it
> also leads to a bug where you are unable to use a swapfile if you ever
> snapshotted the subvolume it's in.
Do you mean snapshotted and deleted? As I understand it:
- create fs
- create swapfile in a subvolume
- activate, use, deactivate it
- create snapshot, maybe changing the swapfile
- delete the snapshot, wait until it's gone
- swapfile activation fails, although there are no shared extents and
the state is effectively the same as if it were created from scratch
> Make the check slower and more strict
> for the swapon case, without modifying the general cow checks as a
> compromise. Turning swap on does not seem to be a particularly
> performance sensitive operation, so incurring a possibly unnecessary
> btrfs_search_slot seems worthwhile for the added usability.
Yeah slowdown should be acceptable here, it's a one time action going
over some metadata.
> Note: Until the snapshot delete transaction is committed,
> check_committed_refs will still cause the logic to think that cow is
> necessary, so the user must sync before swapon.
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.
next prev parent reply other threads:[~2020-08-19 11:30 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 [this message]
2020-08-19 11:59 ` Graham Cobb
2020-08-19 14:25 ` David Sterba
2020-08-19 17:46 ` Boris Burkov
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=20200819112941.GK2026@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=boris@bur.io \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--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