All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Liu Bo <bo.li.liu@oracle.com>
Cc: Josef Bacik <JBacik@fusionio.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: only exclude supers in the range of our block group V2
Date: Thu, 25 Apr 2013 09:04:13 -0400	[thread overview]
Message-ID: <20130425130413.GJ2631@localhost.localdomain> (raw)
In-Reply-To: <20130425034826.GA24053@liubo>

On Wed, Apr 24, 2013 at 09:48:27PM -0600, Liu Bo wrote:
> On Wed, Apr 24, 2013 at 10:48:09AM -0400, Josef Bacik wrote:
> > On Wed, Apr 24, 2013 at 08:43:21AM -0600, Liu Bo wrote:
> > > On Wed, Apr 24, 2013 at 09:00:16AM -0400, Josef Bacik wrote:
> > > > On Wed, Apr 24, 2013 at 02:57:40AM -0600, Liu Bo wrote:
> > > > > On Tue, Apr 23, 2013 at 02:48:54PM -0400, Josef Bacik wrote:
> > > > > > If we fail to load block groups halfway through we can leave extent_state's on
> > > > > > the excluded tree.  This is because we just lookup the supers and add them to
> > > > > > the excluded tree regardless of which block group we are looking at currently.
> > > > > > This is a problem because we remove the excluded extents for the range of the
> > > > > > block group only, so if we don't ever load a block group for one of the excluded
> > > > > > extents we won't ever free it.  This fixes the problem by only adding excluded
> > > > > > extents if it falls in the block group range we care about.  With this patch
> > > > > > we're no longer leaking space when we fail to read all of the block groups.
> > > > > > Thanks,
> > > > > > 
> > > > > > Signed-off-by: Josef Bacik <jbacik@fusionio.com>
> > > > > > ---
> > > > > > V1->V2: fixed a slight problem where i should have been comparing to the end of
> > > > > > hte block group not the begining.
> > > > > > 
> > > > > >  fs/btrfs/extent-tree.c |   24 +++++++++++++++++++++---
> > > > > >  1 files changed, 21 insertions(+), 3 deletions(-)
> > > > > > 
> > > > > > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> > > > > > index b441be3..a81f689 100644
> > > > > > --- a/fs/btrfs/extent-tree.c
> > > > > > +++ b/fs/btrfs/extent-tree.c
> > > > > > @@ -270,9 +270,27 @@ static int exclude_super_stripes(struct btrfs_root *root,
> > > > > >  			return ret;
> > > > > >  
> > > > > >  		while (nr--) {
> > > > > > -			cache->bytes_super += stripe_len;
> > > > > > -			ret = add_excluded_extent(root, logical[nr],
> > > > > > -						  stripe_len);
> > > > > > +			u64 start, len;
> > > > > > +
> > > > > > +			if (logical[nr] > cache->key.objectid +
> > > > > > +			    cache->key.offset)
> > > > > > +				continue;
> > > > > > +
> > > > > > +			if (logical[nr] + stripe_len <= cache->key.objectid)
> > > > > > +				continue;
> > > > > 
> > > > > hmm...I just doubt that these two cases can happen.
> > > > > 
> > > > > btrfs_rmap_block() ensures that logical[nr] will be larger than
> > > > > cache->key.objectid.
> > > > > 
> > > > > Am I missing something?
> > > > 
> > > > Yeah, we can still get ranges that are past the end of the cache, just put a
> > > > printk in there and you'll see it happen.  Now it's not likely that a logical
> > > > will be less than the start but better safe than sorry.  Thanks,
> > > > 
> > > 
> > > But if it's really past the end of the cache, there might be something wrong in
> > > btrfs_rmap_block() IMO.
> > > 
> > > Ok, I'll dig it somehow.
> > > 
> > 
> > It's doing it right, we just loop through all of the supers, which we have no
> > idea where they show up logically.  It's not a problem with rmap, it's doing the
> > right thing, we just need to add this extra check because rmap is not bounded in
> > its logical search.  Thanks,
> 
> Sorry, I still didn't get how this happens...
> 
> I'll try to create new btrfs with raid0, raid1, raid10, raid5, raid6...
> 
> Could you please show me the testcase or something so that I can persuade
> myself?
> 

Ok I see what happened, I was using an old btrfs-image which makes one big chunk
to cover the entire file system, so that is how I was getting logical values
higher than the cache.  So not a normal case for sure, but since it is possible
for it to happen in a bad file system situation we should still leave it.
Thanks,

Josef

  reply	other threads:[~2013-04-25 13:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-23 18:48 [PATCH] Btrfs: only exclude supers in the range of our block group V2 Josef Bacik
2013-04-24  8:57 ` Liu Bo
2013-04-24 13:00   ` Josef Bacik
2013-04-24 14:43     ` Liu Bo
2013-04-24 14:48       ` Josef Bacik
2013-04-25  3:48         ` Liu Bo
2013-04-25 13:04           ` Josef Bacik [this message]
2013-04-25 13:27             ` 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=20130425130413.GJ2631@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=bo.li.liu@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.