linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@redhat.com>
To: Matthew Wilcox <matthew@wil.cx>
Cc: linux-fsdevel@vger.kernel.org
Subject: Re: [RFC][PATCH] ensure i_ino uniqueness in filesystems without permanent inode numbers (via pointer conversion)
Date: Fri, 17 Nov 2006 09:21:44 -0500	[thread overview]
Message-ID: <1163773304.13410.48.camel@dantu.rdu.redhat.com> (raw)
In-Reply-To: <20061117135037.GB18567@parisc-linux.org>

On Fri, 2006-11-17 at 06:50 -0700, Matthew Wilcox wrote:
> On Fri, Nov 17, 2006 at 08:43:00AM -0500, Jeff Layton wrote:
> > +/* convert an inode address into an unsigned int and xor it with a random value
> > + * determined at boot time */
> > +static inline unsigned int inode_to_uint (struct inode *inode)
> > +{
> > +	return ((((unsigned long) (inode - (struct inode *) 0))
> > +		 ^ inode_xor_mask) & 0xffffffff);
> > +}
> 
> Seems a little obfuscated.  Why not simply:
> 
> 	return ((unsigned long)inode ^ inode_xor_mask) & 0xffffffff;

Because the lower 8-9 bits of the inode pointer aren't significant
(presuming an inode struct size of ~400-800 bytes). If we take those out
of the picture then we extend the range of addresses that we can
uniquely squish into a 32 bit value.

Of course, all of this depends on the idea that the slab allocator grabs
pages that are somewhat close together in the kernel's address space.
I'm trying to figure out whether that is the case or not...

I've also been told that the address subtraction above is bogus and
undefined, though it does seem to work. I'll probably need to respin
that part into actual bit shifts by hand...

-- Jeff



  parent reply	other threads:[~2006-11-17 14:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-17 13:43 [RFC][PATCH] ensure i_ino uniqueness in filesystems without permanent inode numbers (via pointer conversion) Jeff Layton
2006-11-17 13:50 ` Matthew Wilcox
2006-11-17 14:14   ` Jörn Engel
2006-11-17 14:24     ` Jeff Layton
2006-11-17 14:21   ` Jeff Layton [this message]
2006-11-17 16:31     ` Jeff Layton
2006-11-17 14:24 ` Matthew Wilcox
2006-11-17 14:48   ` Jeff Layton
2006-11-17 15:01     ` Dave Kleikamp
2006-11-17 15:06       ` Jeff Layton
2006-11-17 15:26         ` Dave Kleikamp

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=1163773304.13410.48.camel@dantu.rdu.redhat.com \
    --to=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=matthew@wil.cx \
    /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).