From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Layton 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 Message-ID: <1163773304.13410.48.camel@dantu.rdu.redhat.com> References: <1163770980.13410.39.camel@dantu.rdu.redhat.com> <20061117135037.GB18567@parisc-linux.org> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit Cc: linux-fsdevel@vger.kernel.org Return-path: Received: from mx1.redhat.com ([66.187.233.31]:51921 "EHLO mx1.redhat.com") by vger.kernel.org with ESMTP id S932909AbWKQOVq (ORCPT ); Fri, 17 Nov 2006 09:21:46 -0500 To: Matthew Wilcox In-Reply-To: <20061117135037.GB18567@parisc-linux.org> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.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