linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@fusionio.com>
Subject: Re: [PATCH 1/2] Btrfs: restore restriper state on all mounts
Date: Tue, 26 Jun 2012 20:35:09 +0300	[thread overview]
Message-ID: <20120626173509.GA2484@zambezi.lan> (raw)
In-Reply-To: <20120626161739.GT28144@twin.jikos.cz>

First of all, thanks for reviewing!

On Tue, Jun 26, 2012 at 06:17:39PM +0200, David Sterba wrote:
> On Fri, Jun 22, 2012 at 09:24:12PM +0300, Ilya Dryomov wrote:
> > Fix a bug that triggered asserts in btrfs_balance() in both normal and
> > resume modes -- restriper state was not properly restored on read-only
> > mounts.  This factors out resuming code from btrfs_restore_balance(),
> > which is now also called earlier in the mount sequence to avoid the
> > problem of some early writes getting the old profile.
> > 
> > Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
> > ---
> > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> > index 77872da..dae7cd6 100644
> > --- a/fs/btrfs/disk-io.c
> > +++ b/fs/btrfs/disk-io.c
> > @@ -2492,9 +2497,6 @@ retry_root_backup:
> >  			err = btrfs_orphan_cleanup(fs_info->tree_root);
> >  		up_read(&fs_info->cleanup_work_sem);
> >  
> > -		if (!err)
> > -			err = btrfs_recover_balance(fs_info->tree_root);
> > -
> >  		if (err) {
> >  			close_ctree(tree_root);
> >  			return err;
> > @@ -2518,6 +2520,9 @@ fail_cleaner:
> >  fail_block_groups:
> >  	btrfs_free_block_groups(fs_info);
> >  
> > +fail_balance_ctl:
> > +	kfree(fs_info->balance_ctl);
> 
> I think you need to set fs_info->balance_ctl to NULL, otherwise this
> could lead to double free from free_fs_info. I was looking along the

Yes, I do.  I meant to call unset_balance_control(fs_info) there, but
changed it to kfree(), because of the BUG_ON() in the former.

unset_balance_control(), of course, sets ->balance_ctl to NULL ;)

> call paths and didn't see free_fs_info called on the mount failure path:
> 
> vfs->mount
>   btrfs_mount
>     btrfs_fill_super
>       open_ctree
>         (recover balance fails, frees ctl)
> 
> error is propagated back to vfs, no other fs callback is done (like
> kill_super which does call free_fs_info).
> 
> The only exit path that is not going through free_fs_info is after error
> from btrfs_fill_super, and this can fail from various reasons.
> 
> Either I'm missing something, or we leak a btrfs_fs_info every time a
> mount fails ...

No, we don't, you just missed it.  It's freed from btrfs_kill_super(),
which is called from deactivate_locked_super() after btrfs_fill_super()
errors out.

> 
> 
> Back to your patch, apart from the balance_ctl pointer reset, both are
> ok and given the number of bug reports [useless padding text here]
> 
>   this should go to 3.5-rc.

Thanks,

		Ilya

  reply	other threads:[~2012-06-26 17:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-22 18:24 [PATCH 0/2] Restriper restore bugfix Ilya Dryomov
2012-06-22 18:24 ` [PATCH 1/2] Btrfs: restore restriper state on all mounts Ilya Dryomov
2012-06-26 16:17   ` David Sterba
2012-06-26 17:35     ` Ilya Dryomov [this message]
2012-06-22 18:24 ` [PATCH 2/2] Btrfs: resume balance on rw (re)mounts properly Ilya Dryomov

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=20120626173509.GA2484@zambezi.lan \
    --to=idryomov@gmail.com \
    --cc=chris.mason@fusionio.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).