From c627a7903a475c34e6b4809477bc510c76fb09ea Mon Sep 17 00:00:00 2001 From: yury Date: Thu, 6 Apr 2006 07:40:46 +0000 Subject: [PATCH] - changes about fids: - f_seq is 64bit field to allow to create not less than 2 ^ 64 objects; - f_num is compound 64bit field containing oid (object id) and object version; - for issuing dlm locks we use f_num. --- lustre/include/linux/lustre_idl.h | 53 ++++++++++++++++++++++++++++----------- lustre/llite/namei.c | 8 +++--- lustre/mdt/mdt_handler.c | 2 ++ lustre/obdclass/lu_object.c | 9 +++---- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index ef41490..5fcec00 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -623,32 +623,57 @@ typedef enum { #define MDS_INODELOCK_FULL ((1<<(MDS_INODELOCK_MAXSHIFT+1))-1) struct lu_fid { - __u32 f_seq; /* holds fid sequence, each client should be able to - perform 2 ^ 32 connections. */ - __u16 f_wid; /* holds width of sequence. */ - __u16 f_num; /* holds fid number. */ + __u64 f_seq; /* holds fid sequence. Lustre should support 2 ^ 64 + * objects, thus even if one sequence has one object we + * reach this value. */ + __u64 f_num; /* firt 32 bits holds fid number and another 32 bits holds + * version of object. */ }; -static inline __u32 fid_seq(const struct lu_fid *fid) +/* get object sequence */ +static inline __u64 fid_seq(const struct lu_fid *fid) { return fid->f_seq; } -static inline __u16 fid_wid(const struct lu_fid *fid) +/* get complex object number (id + version) */ +static inline __u64 fid_num(const struct lu_fid *fid) { - return fid->f_wid; + return fid->f_num; +} + +/* maximal objects in sequence */ +#define LUSTRE_FID_SEQ_WIDTH 10000 + +/* object id is stored in rightmost 32 bits and version in leftmost 32 bits. So + * that if object has no version component ->f_num shows object id and no need + * to mask anything out. */ +#define LUSTRE_FID_OID_MASK 0x00000000ffffffffull +#define LUSTRE_FID_VER_MASK (~LUSTRE_FID_OID_MASK) + +/* shifts of both components */ +#define LUSTRE_FID_OID_SHIFT 0 +#define LUSTRE_FID_VER_SHIFT (sizeof(((struct lu_fid *)0)->f_num) / 2 * 8) + +/* get object id */ +static inline __u32 fid_oid(const struct lu_fid *fid) +{ + return (__u32)((fid->f_num & LUSTRE_FID_OID_MASK) >> LUSTRE_FID_OID_SHIFT); } -static inline __u16 fid_num(const struct lu_fid *fid) +/* get object version */ +static inline __u32 fid_ver(const struct lu_fid *fid) { - return fid->f_num; + return (__u32)((fid->f_num & LUSTRE_FID_VER_MASK) >> LUSTRE_FID_VER_SHIFT); } -#define DFID2 "%lu/%u" +/* show sequence, object id and version */ +#define DFID3 LPU64"/%lu:%lu" -#define PFID2(fid) \ - (unsigned long)fid_seq(fid), \ - (unsigned int)fid_num(fid) +#define PFID3(fid) \ + fid_seq(fid), \ + fid_num(fid), \ + fid_num(fid) /* temporary stuff for compatibility */ struct ll_fid { @@ -667,7 +692,7 @@ static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) { /* check that there is no alignment padding */ CLASSERT(sizeof *f0 == - sizeof f0->f_seq + sizeof f0->f_wid + sizeof f0->f_num); + sizeof f0->f_seq + sizeof f0->f_num); return memcmp(f0, f1, sizeof *f0) == 0; } diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 724ef88..1d2b58a 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -181,11 +181,13 @@ int ll_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, struct ll_inode_info *lli; lli = ll_i2info(inode); - + + /* DLM locks are taken using version component as well, + * so we use fid_num() instead of fid_oid(). */ if (lock->l_resource->lr_name.name[0] != fid_seq(&lli->lli_fid) || lock->l_resource->lr_name.name[1] != fid_num(&lli->lli_fid)) { - LDLM_ERROR(lock, "data mismatch with object "DLID2" (%p)", - PLID2(&lli->lli_fid), inode); + LDLM_ERROR(lock, "data mismatch with object "DLID3" (%p)", + PLID3(&lli->lli_fid), inode); } } #else diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 58a534d..349737f 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -201,6 +201,8 @@ int fid_lock(struct ldlm_namespace *ns, const struct lu_fid *f, LASSERT(lh != NULL); LASSERT(f != NULL); + /* we use fid_num() whoch includes also object version instread of raw + * fid_oid(). */ res_id.name[0] = fid_seq(f); res_id.name[1] = fid_num(f); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 5f76f3f..9997844 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -188,14 +188,11 @@ static struct lu_object *htable_lookup(struct lu_site *s, return NULL; } -/* maximal objects in sequence */ -#define FID_SEQ_WIDTH 10000 - static __u32 fid_hash(const struct lu_fid *f) { - /* FIXME: this is proto anyway, so we do not care of getting rid - of hardcoded things in it like sequence width, etc. */ - return fid_seq(f) * FID_SEQ_WIDTH + fid_num(f); + /* all objects with same id and different versions will belong to same + * collisions list. */ + return fid_seq(f) * LUSTRE_FID_SEQ_WIDTH + fid_oid(f); } struct lu_object *lu_object_find(struct lu_site *s, const struct lu_fid *f) -- 1.8.3.1