Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Zach Brown <zab@redhat.com>
Cc: Josef Bacik <JBacik@fusionio.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: add a incompatible format change for smaller metadata extent refs
Date: Thu, 7 Mar 2013 16:29:18 -0500	[thread overview]
Message-ID: <20130307212918.GB1905@localhost.localdomain> (raw)
In-Reply-To: <20130307195042.GI3565@lenny.home.zabbo.net>

On Thu, Mar 07, 2013 at 12:50:42PM -0700, Zach Brown wrote:
> 
> > +static inline int btrfs_fs_incompat(struct btrfs_fs_info *fs_info, u64 flag)
> > +{
> > +	struct btrfs_super_block *disk_super;
> > +	disk_super = fs_info->super_copy;
> > +	return (btrfs_super_incompat_flags(disk_super) & flag);
> > +}
> 
> That'll fail if there are ever flag bits that don't fit in an int.  The
> sneakest fix is wrapping the conditional in the obscure !!().  Making it
> a bool and really returning true and false would probably be easier on
> the brain.
> 

We can't do bool but i'll do the !!() thing.

> 
> >  	ret = btrfs_search_slot(trans, root, &key, path, extra_size, 1);
> >  	if (ret < 0) {
> >  		err = ret;
> >  		goto out;
> >  	}
> > +
> > +	/*
> > +	 * We may be a newly converted file system which still has the old fat
> > +	 * extent entries for metadata, so try and see if we have one of those.
> > +	 */
> > +	if (ret > 0 && skinny_metadata) {
> > +		skinny_metadata = false;
> > +		if (path->slots[0]) {
> > +			path->slots[0]--;
> > +			btrfs_item_key_to_cpu(path->nodes[0], &key,
> > +					      path->slots[0]);
> > +			if (key.objectid == bytenr &&
> > +			    key.type == BTRFS_EXTENT_ITEM_KEY &&
> > +			    key.offset == num_bytes)
> > +				ret = 0;
> > +		}
> > +		if (ret) {
> > +			key.type = BTRFS_EXTENT_ITEM_KEY;
> > +			key.offset = num_bytes;
> > +			btrfs_release_path(path);
> > +			goto again;
> > +		}
> > +	}
> > +
> 
> >  			ret = btrfs_search_slot(trans, extent_root,
> >  						&key, path, -1, 1);
> > +			if (ret > 0 && skinny_metadata && path->slots[0]) {
> > +				/*
> > +				 * Couldn't find our skinny metadata item,
> > +				 * see if we have ye olde extent item.
> > +				 */
> > +				path->slots[0]--;
> > +				btrfs_item_key_to_cpu(path->nodes[0], &key,
> > +						      path->slots[0]);
> > +				if (key.objectid == bytenr &&
> > +				    key.type == BTRFS_EXTENT_ITEM_KEY &&
> > +				    key.offset == num_bytes)
> > +					ret = 0;
> > +			}
> > +
> > +			if (ret > 0 && skinny_metadata) {
> > +				skinny_metadata = false;
> > +				key.type = BTRFS_EXTENT_ITEM_KEY;
> > +				key.offset = num_bytes;
> > +				btrfs_release_path(path);
> > +				ret = btrfs_search_slot(trans, extent_root,
> > +							&key, path, -1, 1);
> > +			}
> > +
> 
> These blobs of similar code sure look like they should be in a function.
> 

The searches do different things in different places so we have to have samey
blobs like this until we get everybody on skinny metadata and can delete the old
code.  Thanks,

Josef

  reply	other threads:[~2013-03-07 21:29 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-07 19:27 [PATCH] Btrfs: add a incompatible format change for smaller metadata extent refs Josef Bacik
2013-03-07 19:50 ` Zach Brown
2013-03-07 21:29   ` Josef Bacik [this message]
2013-03-08  3:19     ` Dave Chinner
2013-03-07 23:11 ` David Sterba
2013-03-08  3:16 ` Liu Bo

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=20130307212918.GB1905@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=zab@redhat.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