linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Alex Lyakas <alex.btrfs@zadarastorage.com>
Cc: Josef Bacik <jbacik@fusionio.com>,
	linux-btrfs@vger.kernel.org, Miao Xie <miaox@cn.fujitsu.com>
Subject: Re: [PATCH v3] btrfs: clean snapshots one by one
Date: Thu, 4 Jul 2013 19:03:37 +0200	[thread overview]
Message-ID: <20130704170337.GU18204@suse.cz> (raw)
In-Reply-To: <CAOcd+r0RM0YD+Ycky9S_h-LtLAkkztL1z-Ppp8W_85DuQP0t7w@mail.gmail.com>

On Thu, Jul 04, 2013 at 06:29:23PM +0300, Alex Lyakas wrote:
> > @@ -7363,6 +7365,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
> >         wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
> >
> >         while (1) {
> > +               if (!for_reloc && btrfs_fs_closing(root->fs_info)) {
> > +                       pr_debug("btrfs: drop snapshot early exit\n");
> > +                       err = -EAGAIN;
> > +                       goto out_end_trans;
> > +               }
> Here you exit the loop, but the "drop_progress" in the root item is
> incorrect. When the system is remounted, and snapshot deletion
> resumes, it seems that it tries to resume from the EXTENT_ITEM that
> does not exist anymore, and [1] shows that btrfs_lookup_extent_info()
> simply does not find the needed extent.
> So then I hit panic in walk_down_tree():
> BUG: wc->refs[level - 1] == 0
> 
> I fixed it like follows:
> There is a place where btrfs_drop_snapshot() checks if it needs to
> detach from transaction and re-attach. So I moved the exit point there
> and the code is like this:
> 
> 		if (btrfs_should_end_transaction(trans, tree_root) ||
> 			(!for_reloc && btrfs_need_cleaner_sleep(root))) {
> 			ret = btrfs_update_root(trans, tree_root,
> 						&root->root_key,
> 						root_item);
> 			if (ret) {
> 				btrfs_abort_transaction(trans, tree_root, ret);
> 				err = ret;
> 				goto out_end_trans;
> 			}
> 
> 			btrfs_end_transaction_throttle(trans, tree_root);
> 			if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
> 				err = -EAGAIN;
> 				goto out_free;
> 			}
> 			trans = btrfs_start_transaction(tree_root, 0);
> ...
> 
> With this fix, I do not hit the panic, and snapshot deletion proceeds
> and completes alright after mount.
> 
> Do you agree to my analysis or I am missing something? It seems that
> Josef's btrfs-next still has this issue (as does Chris's for-linus).

Sound analysis and I agree with the fix. The clean-by-one patch has been
merged into 3.10 so we need a stable fix for that.

thanks,
david

  reply	other threads:[~2013-07-04 17:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 15:13 [PATCH v3] btrfs: clean snapshots one by one David Sterba
2013-03-16 19:34 ` Alex Lyakas
2013-05-07  0:41 ` Chris Mason
2013-05-07 11:54   ` David Sterba
2013-05-10 13:04     ` Chris Mason
2013-05-14  6:32     ` Miao Xie
2013-07-04 15:29 ` Alex Lyakas
2013-07-04 17:03   ` David Sterba [this message]
2013-07-04 19:52     ` Alex Lyakas
2013-07-05  2:21       ` Josef Bacik
2013-07-14 16:20       ` Alex Lyakas
2013-07-15 16:41         ` Josef Bacik

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=20130704170337.GU18204@suse.cz \
    --to=dsterba@suse.cz \
    --cc=alex.btrfs@zadarastorage.com \
    --cc=jbacik@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=miaox@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).