From: nikita Date: Thu, 23 Nov 2006 18:06:59 +0000 (+0000) Subject: fid: factor common function out. X-Git-Tag: v1_8_0_110~486^2~84 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ad19d2923b394fe9d8792c46d2d344074055a0d4;p=fs%2Flustre-release.git fid: factor common function out. --- diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index 6ce7c4d..62abbe2 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -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" diff --git a/lustre/liblustre/llite_fid.c b/lustre/liblustre/llite_fid.c index 20df52f..af1d887 100644 --- a/lustre/liblustre/llite_fid.c +++ b/lustre/liblustre/llite_fid.c @@ -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); } diff --git a/lustre/llite/llite_fid.c b/lustre/llite/llite_fid.c index 4c2a6167..85ad4f3 100644 --- a/lustre/llite/llite_fid.c +++ b/lustre/llite/llite_fid.c @@ -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); } diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index ff1a1e0..84db235 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -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, diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 8bf95aa..0c9774f 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -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); } /*