Whamcloud - gitweb
b=23289 disable RS_DEBUG by default
[fs/lustre-release.git] / lustre / include / lustre_fid.h
index 51a5ae5..f31c4b5 100644 (file)
@@ -26,7 +26,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  */
 /*
 /*
  * struct lu_fid
  */
+#include <libcfs/libcfs.h>
 #include <lustre/lustre_idl.h>
 #include <lustre_req_layout.h>
 #include <lustre_mdt.h>
 
-#include <libcfs/libcfs.h>
 
 struct lu_site;
 struct lu_context;
@@ -369,8 +369,16 @@ static inline __u32 fid_flatten32(const struct lu_fid *fid)
 
         seq = fid_seq(fid) - FID_SEQ_START;
 
-        ino = ((seq & 0xfffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
-                (seq >> (64 - (40-8)) & 0xffffff00) + fid_oid(fid);
+       /*
+          map the high bits of the OID into higher bits of the inode number so that
+          inodes generated at about the same time have a reduced chance of collisions.
+          This will give a period of 1024 clients and 128 k = 128M inodes without collisions.
+       */
+
+        ino = ((seq & 0x000fffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
+               (seq >> (64 - (40-8)) & 0xffffff00) +
+               (fid_oid(fid) & 0xff000fff) + ((fid_oid(fid) & 0x00fff000) << 16);
+
         RETURN(ino ? ino : fid_oid(fid));
 }