linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Alex Lyakas <alex.btrfs@zadarastorage.com>
Cc: Josef Bacik <jbacik@fusionio.com>, <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: stop all workers before cleaning up roots
Date: Mon, 5 Aug 2013 11:09:06 -0400	[thread overview]
Message-ID: <20130805150906.GG2372@localhost.localdomain> (raw)
In-Reply-To: <CAOcd+r1mkZhaFNNBsu6G89zBKmtLTL5U72mBczFpukMNXckKXw@mail.gmail.com>

On Thu, Aug 01, 2013 at 05:05:35PM +0300, Alex Lyakas wrote:
> Hi Josef,
> 
> On Thu, May 30, 2013 at 11:58 PM, Josef Bacik <jbacik@fusionio.com> wrote:
> > Dave reported a panic because the extent_root->commit_root was NULL in the
> > caching kthread.  That is because we just unset it in free_root_pointers, which
> > is not the correct thing to do, we have to either wait for the caching kthread
> > to complete or hold the extent_commit_sem lock so we know the thread has exited.
> > This patch makes the kthreads all stop first and then we do our cleanup.  This
> > should fix the race.  Thanks,
> >
> > Reported-by: David Sterba <dsterba@suse.cz>
> > Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> > ---
> >  fs/btrfs/disk-io.c |    6 +++---
> >  1 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> > index 2b53afd..77cb566 100644
> > --- a/fs/btrfs/disk-io.c
> > +++ b/fs/btrfs/disk-io.c
> > @@ -3547,13 +3547,13 @@ int close_ctree(struct btrfs_root *root)
> >
> >         btrfs_free_block_groups(fs_info);
> 
> do you think it would be safer to stop all workers first and make sure
> they are stopped, then do btrfs_free_block_groups()? I see, for
> example, that btrfs_free_block_groups() checks:
> if (block_group->cached == BTRFS_CACHE_STARTED)
> which could be perhaps racy with other people spawning caching_threads.
> 
> So maybe better to stop all threads (including cleaner and committer)
> and then free everything?
> 

Well nobody should be writing anymore, so we shouldn't be starting any new
caching_kthreads, we should just be cleaning up threads that are already
running.  Btrfs_free_block_groups() will wait on any kthreads it spawned, so we
are good there.  Hth,

Josef

      reply	other threads:[~2013-08-05 15:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-30 20:58 [PATCH] Btrfs: stop all workers before cleaning up roots Josef Bacik
2013-08-01 14:05 ` Alex Lyakas
2013-08-05 15:09   ` Josef Bacik [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=20130805150906.GG2372@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=alex.btrfs@zadarastorage.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;
as well as URLs for NNTP newsgroup(s).