Whamcloud - gitweb
fid: factor common function out.
authornikita <nikita>
Thu, 23 Nov 2006 18:06:59 +0000 (18:06 +0000)
committernikita <nikita>
Thu, 23 Nov 2006 18:06:59 +0000 (18:06 +0000)
lustre/include/lustre_fid.h
lustre/liblustre/llite_fid.c
lustre/llite/llite_fid.c
lustre/mdd/mdd_lov.c
lustre/obdclass/lu_object.c

index 6ce7c4d..62abbe2 100644 (file)
@@ -244,6 +244,11 @@ fid_build_pdo_res_name(const struct lu_fid *f,
         return name;
 }
 
+static inline __u64 fid_flatten(const struct lu_fid *fid)
+{
+        return (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+}
+
 #define LUSTRE_SEQ_SRV_NAME "seq_srv"
 #define LUSTRE_SEQ_CTL_NAME "seq_ctl"
 
index 20df52f..af1d887 100644 (file)
@@ -57,6 +57,6 @@ unsigned long llu_fid_build_ino(struct llu_sb_info *sbi,
 {
         unsigned long ino;
         ENTRY;
-        ino = (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+        ino = fid_flatten(fid);
         RETURN(ino & 0x7fffffff);
 }
index 4c2a616..85ad4f3 100644 (file)
@@ -47,6 +47,6 @@ ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
          * Very stupid and having many downsides inode allocation algorithm
          * based on fid.
          */
-        ino = (fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid);
+        ino = fid_flatten(fid);
         RETURN(ino & 0x7fffffff);
 }
index ff1a1e0..84db235 100644 (file)
@@ -95,10 +95,10 @@ int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,
 
         snprintf(name, strlen(MDD_OBD_NAME) + 5, "%s-%d",
                  MDD_OBD_NAME, mds_id);
-        
+
         snprintf(uuid, strlen(MDD_OBD_UUID) + 5, "%s-%d",
                  MDD_OBD_UUID, mds_id);
-        
+
         lustre_cfg_bufs_reset(bufs, name);
         lustre_cfg_bufs_set_string(bufs, 1, MDD_OBD_TYPE);
         lustre_cfg_bufs_set_string(bufs, 2, uuid);
@@ -133,7 +133,7 @@ int mdd_init_obd(const struct lu_env *env, struct mdd_device *mdd,
         obd->obd_upcall.onu_upcall = mdd_lov_update;
         obd->obd_upcall.onu_owner = mdd;
         mdd->mdd_obd_dev = obd;
-        
+
         EXIT;
 class_detach:
         if (rc)
@@ -160,7 +160,7 @@ int mdd_fini_obd(const struct lu_env *env, struct mdd_device *mdd)
         OBD_ALLOC_PTR(bufs);
         if (!bufs)
                 RETURN(-ENOMEM);
-        
+
         lustre_cfg_bufs_reset(bufs, MDD_OBD_NAME);
         lcfg = lustre_cfg_new(LCFG_ATTACH, bufs);
         OBD_FREE_PTR(bufs);
@@ -334,7 +334,7 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
  */
 static obd_id mdd_lov_create_id(const struct lu_fid *fid)
 {
-        return ((fid_seq(fid) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(fid));
+        return fid_flatten(fid);
 }
 
 static int mdd_lov_objid_alloc(const struct lu_env *env,
index 8bf95aa..0c9774f 100644 (file)
@@ -431,19 +431,7 @@ static __u32 fid_hash(const struct lu_fid *f, int bits)
 {
         /* all objects with same id and different versions will belong to same
          * collisions list. */
-#if 1
-        return hash_long((fid_seq(f) - 1) * LUSTRE_SEQ_MAX_WIDTH + fid_oid(f),
-                         bits);
-#else
-        unsigned long hash;
-        __u64 seq;
-
-        seq  = fid_seq(f);
-        hash = seq ^ fid_oid(f);
-        if (sizeof hash != sizeof seq)
-                hash ^= seq >> 32;
-        return hash_long(hash, 32);
-#endif
+        return hash_long(fid_flatten(f), bits);
 }
 
 /*