Whamcloud - gitweb
b=20563 Increase LUSTRE_SEQ_MAX_WIDTH
authorpravin <Pravin.Shelar@sun.com>
Thu, 10 Jun 2010 03:55:37 +0000 (09:25 +0530)
committerRobert Read <robert.read@oracle.com>
Thu, 10 Jun 2010 04:30:28 +0000 (21:30 -0700)
Increase value of LUSTRE_SEQ_MAX_WIDTH, fix fid_flatten() so that it would not
depend on LUSTRE_SEQ_MAX_WIDTH.

i=rahul
i=andreas

lustre/include/lclient.h
lustre/include/linux/lustre_compat25.h
lustre/include/lustre_fid.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/dir.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/llite/llite_nfs.c

index 306ae11..2162c56 100644 (file)
@@ -354,7 +354,8 @@ void cl_inode_fini(struct inode *inode);
 int cl_local_size(struct inode *inode);
 
 __u16 ll_dirent_type_get(struct lu_dirent *ent);
-ino_t cl_fid_build_ino(const struct lu_fid *fid);
+__u64 cl_fid_build_ino(const struct lu_fid *fid);
+__u32 cl_fid_build_ino32(const struct lu_fid *fid);
 __u32 cl_fid_build_gen(const struct lu_fid *fid);
 
 #ifdef INVARIANT_CHECK
index 4d70eb7..f526f45 100644 (file)
@@ -196,7 +196,6 @@ do {cfs_mutex_lock_nested(&(inode)->i_mutex, I_MUTEX_PARENT); } while(0)
 #define to_kdev_t(dev)                  (dev)
 #define kdev_t_to_nr(dev)               (dev)
 #define val_to_kdev(dev)                (dev)
-#define ILOOKUP(sb, ino, test, data)    ilookup5(sb, ino, test, (void *)(data));
 
 #ifdef HAVE_BLKDEV_PUT_2ARGS
 #define ll_blkdev_put(a, b) blkdev_put(a, b)
index d00b9af..51a5ae5 100644 (file)
@@ -67,17 +67,14 @@ extern const struct lu_fid LU_DOT_LUSTRE_FID;
 
 enum {
         /*
-         * This is how may FIDs may be allocated in one sequence. 16384 for
-         * now.
+         * This is how may FIDs may be allocated in one sequence(128k)
          */
-        LUSTRE_SEQ_MAX_WIDTH = 0x0000000000000400ULL,
+        LUSTRE_SEQ_MAX_WIDTH = 0x0000000000020000ULL,
 
         /*
-         * How many sequences may be allocate for meta-sequence (this is 128
-         * sequences).
+         * How many sequences to allocate to a client at once.
          */
-        /* changed to 16 to avoid overflow in test11 */
-        LUSTRE_SEQ_META_WIDTH = 0x0000000000000010ULL,
+        LUSTRE_SEQ_META_WIDTH = 0x0000000000000001ULL,
 
          /*
           * seq allocation pool size.
@@ -330,9 +327,51 @@ fid_build_pdo_res_name(const struct lu_fid *f,
         return name;
 }
 
+
+/**
+ * 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. */
 static inline __u64 fid_flatten(const struct lu_fid *fid)
 {
-        return (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+        __u64 ino;
+        __u64 seq;
+
+        if (fid_is_igif(fid)) {
+                ino = lu_igif_ino(fid);
+                RETURN(ino);
+        }
+
+        seq = fid_seq(fid);
+
+        ino = (seq << 24) + ((seq >> (64-8)) & 0xffffff0000ULL) + fid_oid(fid);
+
+        RETURN(ino ? ino : fid_oid(fid));
+}
+
+/**
+ * map fid to 32 bit value for ino on 32bit systems. */
+static inline __u32 fid_flatten32(const struct lu_fid *fid)
+{
+        __u32 ino;
+        __u64 seq;
+
+        if (fid_is_igif(fid)) {
+                ino = lu_igif_ino(fid);
+                RETURN(ino);
+        }
+
+        seq = fid_seq(fid) - FID_SEQ_START;
+
+        ino = ((seq & 0xfffffULL) << 12) + ((seq >> 8) & 0xfffff000) +
+                (seq >> (64 - (40-8)) & 0xffffff00) + fid_oid(fid);
+        RETURN(ino ? ino : fid_oid(fid));
 }
 
 #define LUSTRE_SEQ_SRV_NAME "seq_srv"
index 580226f..60fc4c7 100644 (file)
@@ -1285,26 +1285,22 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent)
 }
 
 /**
- * build inode number from passed @fid */
-ino_t cl_fid_build_ino(const struct lu_fid *fid)
+ * for 32 bit inode numbers directly map seq+oid to 32bit number.
+ */
+__u32 cl_fid_build_ino32(const struct lu_fid *fid)
 {
-        ino_t ino;
-        ENTRY;
-
-        if (fid_is_igif(fid)) {
-                ino = lu_igif_ino(fid);
-                RETURN(ino);
-        }
-
-        /* Very stupid and having many downsides inode allocation algorithm
-         * based on fid. */
-        ino = fid_flatten(fid) & 0xFFFFFFFF;
+        RETURN(fid_flatten32(fid));
+}
 
-        if (unlikely(ino == 0))
-                /* the first result ino is 0xFFC001, so this is rarely used */
-                ino = 0xffbcde;
-        ino = ino | 0x80000000;
-        RETURN(ino);
+/**
+ * build inode number from passed @fid */
+__u64 cl_fid_build_ino(const struct lu_fid *fid)
+{
+#if BITS_PER_LONG == 32
+        RETURN(fid_flatten32(fid));
+#else
+        RETURN(fid_flatten(fid));
+#endif
 }
 
 /**
index 5e929a5..8499db8 100644 (file)
@@ -238,7 +238,7 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
                                 char          *name;
                                 int            namelen;
                                 struct lu_fid  fid;
-                                ino_t          ino;
+                                __u64          ino;
 
                                 hash    = le64_to_cpu(ent->lde_hash);
                                 namelen = le16_to_cpu(ent->lde_namelen);
index aedf472..8e8ed3a 100644 (file)
@@ -442,7 +442,7 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                                 char          *name;
                                 int            namelen;
                                 struct lu_fid  fid;
-                                ino_t          ino;
+                                __u64          ino;
 
                                 /*
                                  * XXX: implement correct swabbing here.
@@ -467,7 +467,10 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                                 fid  = ent->lde_fid;
                                 name = ent->lde_name;
                                 fid_le_to_cpu(&fid, &fid);
-                                ino  = cl_fid_build_ino(&fid);
+                                if (cfs_curproc_is_32bit())
+                                        ino = cl_fid_build_ino32(&fid);
+                                else
+                                        ino = cl_fid_build_ino(&fid);
                                 type = ll_dirent_type_get(ent);
                                 done = filldir(cookie, name, namelen,
                                                (loff_t)hash, ino, type);
index 6992c7e..103420b 100644 (file)
@@ -2212,6 +2212,7 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
                   struct lookup_intent *it, struct kstat *stat)
 {
         struct inode *inode = de->d_inode;
+        struct ll_inode_info *lli = ll_i2info(inode);
         int res = 0;
 
         res = ll_inode_revalidate_it(de, it);
@@ -2221,7 +2222,11 @@ int ll_getattr_it(struct vfsmount *mnt, struct dentry *de,
                 return res;
 
         stat->dev = inode->i_sb->s_dev;
-        stat->ino = inode->i_ino;
+        if (cfs_curproc_is_32bit())
+                stat->ino = cl_fid_build_ino32(&lli->lli_fid);
+        else
+                stat->ino = inode->i_ino;
+
         stat->mode = inode->i_mode;
         stat->nlink = inode->i_nlink;
         stat->uid = inode->i_uid;
index c597df9..66e9741 100644 (file)
@@ -73,14 +73,14 @@ static struct inode *search_inode_for_lustre(struct super_block *sb,
         struct ptlrpc_request *req = NULL;
         struct inode          *inode = NULL;
         int                   eadatalen = 0;
-        ino_t                 ino = cl_fid_build_ino(fid);
+        unsigned long         hash = (unsigned long) cl_fid_build_ino(fid);
         struct  md_op_data    *op_data;
         int                   rc;
         ENTRY;
 
-        CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", ino, PFID(fid));
+        CDEBUG(D_INFO, "searching inode for:(%lu,"DFID")\n", hash, PFID(fid));
 
-        inode = ILOOKUP(sb, ino, ll_nfs_test_inode, fid);
+        inode = ilookup5(sb, hash, ll_nfs_test_inode, (void *)fid);
         if (inode)
                 RETURN(inode);