Whamcloud - gitweb
b=20563 Fix fid_flatten() after 1 trillion SEQ numbers
authorAndreas Dilger <andreas.dilger@oracle.com>
Tue, 30 Nov 2010 23:22:14 +0000 (16:22 -0700)
committerJohann Lombardi <johann.lombardi@oracle.com>
Mon, 24 Jan 2011 13:01:50 +0000 (14:01 +0100)
Fix the fid_flatten() function to properly handle FID mapping to
64-bit inode numbers, after the first 1 trillion SEQ numbers have
been granted out.  Even with CMD this would only happen after
1024 MDTs have each had 1B client mounts, so there is little risk
of introducing collisions as a result of this change, and at worst
this is a client-local phenomenon that is not persistent.

lustre/llite/namei.c

index 8e097d7..7535b00 100644 (file)
@@ -62,15 +62,15 @@ int ll_unlock(__u32 mode, struct lustre_handle *lockh)
 }
 
 /**
- * Flatten 128-bit FID values into a 64-bit value for
- * use as an inode number.  For non-IGIF FIDs this
- * starts just over 2^32, and continues without conflict
- * until 2^64, at which point we wrap the high 32 bits
- * of the SEQ into the range where there may not be many
- * OID values in use, to minimize the risk of conflict.
+ * Flatten 128-bit FID values into a 64-bit value for use as an inode number.
+ * For non-IGIF FIDs this starts just over 2^32, and continues without
+ * conflict until 2^64, at which point we wrap the high 32 bits of the SEQ
+ * into the range where there may not be many OID values in use, to minimize
+ * the risk of conflict.
  *
- * The time between re-used inode numbers is very long -
- * 2^32 SEQ numbers, or about 2^32 client mounts. */
+ * Suppose LUSTRE_SEQ_MAX_WIDTH is less than (2^24), which is currently true,
+ * the time between re-used inode numbers is very long - 2^40 SEQ numbers,
+ * or about 2^40 client mounts, if clients create less than 2^24 files/mount. */
 static inline __u64 fid_flatten(const struct lu_fid *fid)
 {
         __u64 ino;
@@ -83,7 +83,7 @@ static inline __u64 fid_flatten(const struct lu_fid *fid)
 
         seq = fid_seq(fid);
 
-        ino = (seq << 24) + ((seq >> (64-8)) & 0xffffff0000ULL) + fid_oid(fid);
+        ino = (seq << 24) + ((seq >> 24) & 0xffffff0000ULL) + fid_oid(fid);
 
         RETURN(ino ? ino : fid_oid(fid));
 }