linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Fasheh <mfasheh@suse.de>
To: Jan Schmidt <list.btrfs@jan-o-sch.net>
Cc: linux-btrfs@vger.kernel.org, Chris Mason <chris.mason@oracle.com>
Subject: Re: [PATCH 1/3] btrfs: extended inode refs
Date: Mon, 9 Jul 2012 13:33:14 -0700	[thread overview]
Message-ID: <20120709203314.GD8323@wotan.suse.de> (raw)
In-Reply-To: <4FF6FCA8.2060100@jan-o-sch.net>


> > diff --git a/fs/btrfs/inode-item.c b/fs/btrfs/inode-item.c
> > index baa74f3..496fb1c 100644
> > --- a/fs/btrfs/inode-item.c
> > +++ b/fs/btrfs/inode-item.c
> > @@ -18,6 +18,7 @@
> >  
> >  #include "ctree.h"
> >  #include "disk-io.h"
> > +#include "hash.h"
> >  #include "transaction.h"
> >  
> >  static int find_name_in_backref(struct btrfs_path *path, const char *name,
> > @@ -49,18 +50,56 @@ static int find_name_in_backref(struct btrfs_path *path, const char *name,
> >  	return 0;
> >  }
> >  
> > -struct btrfs_inode_ref *
> > +int find_name_in_ext_backref(struct btrfs_path *path, const char *name,
> > +			     int name_len,
> > +			     struct btrfs_inode_extref **extref_ret)
> 
> Exported functions should be prefixed "btrfs_". What about btrfs_find_extref_name?
> 
> > +{
> > +	struct extent_buffer *leaf;
> > +	struct btrfs_inode_extref *extref;
> > +	unsigned long ptr;
> > +	unsigned long name_ptr;
> > +	u32 item_size;
> > +	u32 cur_offset = 0;
> > +	int ref_name_len;
> > +
> > +	leaf = path->nodes[0];
> > +	item_size = btrfs_item_size_nr(leaf, path->slots[0]);
> > +	ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
> > +
> > +	/*
> > +	 * Search all extended backrefs in this item. We're only
> > +	 * looking through any collisions so most of the time this is
> > +	 * just going to compare against one buffer. If all is well,
> > +	 * we'll return success and the inode ref object.
> > +	 */
> > +	while (cur_offset < item_size) {
> > +		extref = (struct btrfs_inode_extref *) (ptr + cur_offset);
> > +		name_ptr = (unsigned long)(&extref->name);
> > +		ref_name_len = btrfs_inode_extref_name_len(leaf, extref);
> > +
> > +		if (ref_name_len == name_len
> > +		    && (memcmp_extent_buffer(leaf, name, name_ptr, name_len) == 0)) {
> > +			if (extref_ret)
> > +				*extref_ret = extref;
> > +			return 1;
> > +		}
> > +
> > +		cur_offset += ref_name_len + sizeof(*extref);
> > +	}
> > +	return 0;
> 
> For consistency, I'd like to switch return 0 and 1.

Ok so btrfs_find_name_in_ext_backref() is designed to mirror
btrfs_find_name_in_backref() for obvious reasons - it does the same thing
except for extended backrefs. So it'd actually be inconsistent if I change
this (unless I change both but I don't think we want to do that).

The name is kept without the btrfs_ prefix for the same reasons, however I
don't think prefixing it is a big deal so I'll go ahead and make _that_
change unless you feel otherwise.

Thanks,
	--Mark


--
Mark Fasheh

  parent reply	other threads:[~2012-07-09 20:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21 21:46 [PATCH 0/3] btrfs: extended inode refs Mark Fasheh
2012-05-21 21:46 ` [PATCH 1/3] " Mark Fasheh
2012-07-06 14:56   ` Jan Schmidt
2012-07-06 15:14     ` Stefan Behrens
2012-07-09 19:05     ` Mark Fasheh
2012-07-09 20:33     ` Mark Fasheh [this message]
2012-05-21 21:46 ` [PATCH 2/3] " Mark Fasheh
2012-07-06 14:57   ` Jan Schmidt
2012-08-06 23:31     ` Mark Fasheh
2012-05-21 21:46 ` [PATCH 3/3] " Mark Fasheh
2012-07-06 14:57   ` Jan Schmidt
2012-07-09 20:24     ` Mark Fasheh
  -- strict thread matches above, loose matches on Subject: below --
2012-08-08 18:55 [PATCH 0/3] " Mark Fasheh
2012-08-08 18:55 ` [PATCH 1/3] " Mark Fasheh
2012-08-14  9:32   ` Jan Schmidt
2012-08-14 16:51     ` Mark Fasheh
2012-04-05 20:09 [PATCH 0/3] " Mark Fasheh
2012-04-05 20:09 ` [PATCH 1/3] " Mark Fasheh
2012-04-12 13:08   ` Jan Schmidt
2012-04-24 22:23     ` Mark Fasheh
2012-04-25 10:19       ` Jan Schmidt

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=20120709203314.GD8323@wotan.suse.de \
    --to=mfasheh@suse.de \
    --cc=chris.mason@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=list.btrfs@jan-o-sch.net \
    /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).