How to understand the codes about dentry ?

lx lxlenovostar at gmail.com
Wed Aug 28 10:30:31 EDT 2013


hi all

the codes about filesystem in the kernel is:

static inline struct list_head * d_hash(struct dentry *parent,
unsigned long hash){
      hash += (unsigned long)parent / L1_CACHE_BYTES;
      hash = hash^(hash>>D_HASHBITS)^(hash>>D_HASHBITS*2);
      return dentry_hashtable + (hash & D_HASHMASK);}

I know the function parameter of hash belongs to the qstr string is looking
up, and the local variableshash should add the *address of the dentry of
parent*.

Why count the hash value use "L1_CACHE_BYTES" , "D_HASHBITS" and
"D_HASHMASK"?

And How to understand the codes following ?

hash += (unsigned long)parent / L1_CACHE_BYTES;
hash = hash^(hash>>D_HASHBITS)^(hash>>D_HASHBITS*2);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130828/70c8735c/attachment.html 


More information about the Kernelnewbies mailing list