From: David Sterba <dave@jikos.cz>
To: Chris Mason <chris.mason@oracle.com>
Cc: David Sterba <dave@jikos.cz>, Josef Bacik <josef@redhat.com>,
linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: protect the pending_snapshots list with trans_lock
Date: Tue, 21 Jun 2011 00:32:20 +0200 [thread overview]
Message-ID: <20110620223220.GI12709@twin.jikos.cz> (raw)
In-Reply-To: <1308137405-sup-6493@shiny>
On Wed, Jun 15, 2011 at 07:41:37AM -0400, Chris Mason wrote:
> There is definitely a window where two procs can be inside
> create_snapshot() at the same time in the same transaction.
I trust you on that. I was trying to follow the callgraph from
btrfs_strat_transaction called from create_snapshot to see whether and
how two calls may access the list and came to conclusion that there must
be a fresh transaction after the call. There are lots of
join_transaction, commit_transaction calls and I could have lost track.
I'm leaving this to me as a homework, it was very educative anyway.
> Going down to your list:
>
> >
> > 2) you need to protect every access to the pending_snapshot:
> > - add in create_snapshot
>
> create_snapshot is racey.
agreed, the patch fixes it
>
> > - splice in btrfs_destroy_pending_snapshots
>
> This can only happen during unmount while there are no writers.
>
> > - list foreach in create_pending_snapshots
>
> This can only happen during commit while there are no writers
this counts as protection, for both
> > - list_empty in btrfs_commit_transaction
>
> This is there to make sure that any delayed allocation from the source
> subvol is actually done in the snapshot. You're right that we should
> have a better check here. The worst possible case in getting this wrong
> is that the snapshot misses some recent file writes in the original, but
> it will be completely consistent.
I think this is ok and acceptable.
Thanks,
david
prev parent reply other threads:[~2011-06-20 22:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-14 19:17 [PATCH] Btrfs: protect the pending_snapshots list with trans_lock Josef Bacik
2011-06-15 9:53 ` David Sterba
2011-06-15 11:41 ` Chris Mason
2011-06-20 22:32 ` David Sterba [this message]
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=20110620223220.GI12709@twin.jikos.cz \
--to=dave@jikos.cz \
--cc=chris.mason@oracle.com \
--cc=josef@redhat.com \
--cc=linux-btrfs@vger.kernel.org \
/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