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 - To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html