From 4f91d5161d005eed6ff7a9fe6abea99690f4bcb7 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Thu, 8 Mar 2012 15:29:09 +0800 Subject: [PATCH] LU-1198 idl: move FID VER to DLM resource name[1] Until Lustre 1.8.7/2.1.1 the FID version was packed into name[2]. However, this leaves very little room in the LDLM resource name for other uses. The upcoming quota code needs to store another FID into the LDLM resource to allow directory tree quotas, and managed by the DLM. The 32-bit VER, which is currently always 0, is moved into the high bits of name[1] along with the 32-bit OID, to avoid consuming the name[2] field. Since future use of the FID version (including snapshots, pools, etc) will need changes on the client side anyway, there will never be non-zero VER on an existing client. Signed-off-by: Andreas Dilger Change-Id: If1e500cfb277dfc25bc056bb0c5763e48e7dccdf Reviewed-on: http://review.whamcloud.com/2271 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Johann Lombardi Reviewed-by: Oleg Drokin --- lustre/include/lustre/lustre_idl.h | 10 ++++++++++ lustre/include/lustre_fid.h | 22 ++++++++-------------- lustre/ldlm/ldlm_resource.c | 4 ++-- lustre/ptlrpc/wiretest.c | 3 +++ lustre/utils/wirecheck.c | 5 +++++ lustre/utils/wiretest.c | 3 +++ 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/lustre/include/lustre/lustre_idl.h b/lustre/include/lustre/lustre_idl.h index d0580ce..99bbc2f 100644 --- a/lustre/include/lustre/lustre_idl.h +++ b/lustre/include/lustre/lustre_idl.h @@ -1578,6 +1578,16 @@ extern void lustre_swab_generic_32s (__u32 *val); extern void lustre_swab_ll_fid (struct ll_fid *fid); +/* NOTE: until Lustre 1.8.7/2.1.1 the fid_ver() was packed into name[2], + * but was moved into name[1] along with the OID to avoid consuming the + * name[2,3] fields that need to be used for the quota id (also a FID). */ +enum { + LUSTRE_RES_ID_SEQ_OFF = 0, + LUSTRE_RES_ID_VER_OID_OFF = 1, + LUSTRE_RES_ID_WAS_VER_OFF = 2, /* see note above */ + LUSTRE_RES_ID_HSH_OFF = 3 +}; + #define MDS_STATUS_CONN 1 #define MDS_STATUS_LOV 2 diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index db88f41..32d680c 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -298,15 +298,12 @@ int fid_is_local(const struct lu_env *env, struct ldlm_namespace; -enum { - LUSTRE_RES_ID_SEQ_OFF = 0, - LUSTRE_RES_ID_OID_OFF = 1, - LUSTRE_RES_ID_VER_OFF = 2, - LUSTRE_RES_ID_HSH_OFF = 3 -}; - /* - * Build (DLM) resource name from fid. + * Build (DLM) resource name from FID. + * + * NOTE: until Lustre 1.8.7/2.1.1 the fid_ver() was packed into name[2], + * but was moved into name[1] along with the OID to avoid consuming the + * renaming name[2,3] fields that need to be used for the quota identifier. */ static inline struct ldlm_res_id * fid_build_reg_res_name(const struct lu_fid *f, @@ -314,8 +311,7 @@ fid_build_reg_res_name(const struct lu_fid *f, { memset(name, 0, sizeof *name); name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f); - name->name[LUSTRE_RES_ID_OID_OFF] = fid_oid(f); - name->name[LUSTRE_RES_ID_VER_OFF] = fid_ver(f); + name->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(f); return name; } @@ -325,10 +321,8 @@ fid_build_reg_res_name(const struct lu_fid *f, static inline int fid_res_name_eq(const struct lu_fid *f, const struct ldlm_res_id *name) { - return - name->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(f) && - name->name[LUSTRE_RES_ID_OID_OFF] == fid_oid(f) && - name->name[LUSTRE_RES_ID_VER_OFF] == fid_ver(f); + return name->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(f) && + name->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(f); } diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index cbb0ac9..cd7936b 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -406,8 +406,8 @@ static unsigned ldlm_res_hop_fid_hash(cfs_hash_t *hs, __u32 val; fid.f_seq = id->name[LUSTRE_RES_ID_SEQ_OFF]; - fid.f_oid = (__u32)id->name[LUSTRE_RES_ID_OID_OFF]; - fid.f_ver = (__u32)id->name[LUSTRE_RES_ID_VER_OFF]; + fid.f_oid = (__u32)id->name[LUSTRE_RES_ID_VER_OID_OFF]; + fid.f_ver = (__u32)(id->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32); hash = fid_flatten32(&fid); hash += (hash >> 4) + (hash << 12); /* mixing oid and seq */ diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index 4530724..9aca930 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -338,6 +338,9 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_FLOCK == 12); CLASSERT(LDLM_IBITS == 13); CLASSERT(LDLM_MAX_TYPE == 14); + CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); + CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); + CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index de023f6..d888439 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -1969,6 +1969,11 @@ main(int argc, char **argv) CHECK_CVALUE(LDLM_IBITS); CHECK_CVALUE(LDLM_MAX_TYPE); + CHECK_CVALUE(LUSTRE_RES_ID_SEQ_OFF); + CHECK_CVALUE(LUSTRE_RES_ID_VER_OID_OFF); + /* CHECK_CVALUE(LUSTRE_RES_ID_WAS_VER_OFF); packed with OID */ + CHECK_CVALUE(LUSTRE_RES_ID_HSH_OFF); + CHECK_VALUE(OBD_PING); CHECK_VALUE(OBD_LOG_CANCEL); CHECK_VALUE(OBD_QC_CALLBACK); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 4d9a874..76dcca4 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -343,6 +343,9 @@ void lustre_assert_wire_constants(void) CLASSERT(LDLM_FLOCK == 12); CLASSERT(LDLM_IBITS == 13); CLASSERT(LDLM_MAX_TYPE == 14); + CLASSERT(LUSTRE_RES_ID_SEQ_OFF == 0); + CLASSERT(LUSTRE_RES_ID_VER_OID_OFF == 1); + CLASSERT(LUSTRE_RES_ID_HSH_OFF == 3); LASSERTF(OBD_PING == 400, "found %lld\n", (long long)OBD_PING); LASSERTF(OBD_LOG_CANCEL == 401, "found %lld\n", -- 1.8.3.1