* 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,
- struct ldlm_res_id *name)
+fid_build_reg_res_name(const struct lu_fid *fid, struct ldlm_res_id *res)
{
- memset(name, 0, sizeof *name);
- name->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(f);
- name->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(f);
- return name;
+ memset(res, 0, sizeof(*res));
+ res->name[LUSTRE_RES_ID_SEQ_OFF] = fid_seq(fid);
+ res->name[LUSTRE_RES_ID_VER_OID_OFF] = fid_ver_oid(fid);
+
+ return res;
+}
+
+/*
+ * Return true if resource is for object identified by FID.
+ */
+static inline int fid_res_name_eq(const struct lu_fid *fid,
+ const struct ldlm_res_id *res)
+{
+ return res->name[LUSTRE_RES_ID_SEQ_OFF] == fid_seq(fid) &&
+ res->name[LUSTRE_RES_ID_VER_OID_OFF] == fid_ver_oid(fid);
+}
+
+/*
+ * Extract FID from LDLM resource. Reverse of fid_build_reg_res_name().
+ */
+static inline struct lu_fid *
+fid_extract_from_res_name(struct lu_fid *fid, const struct ldlm_res_id *res)
+{
+ fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF];
+ fid->f_oid = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF]);
+ fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32);
+ LASSERT(fid_res_name_eq(fid, res));
+
+ return fid;
}
/*
* Build (DLM) resource identifier from global quota FID and quota ID.
*/
static inline struct ldlm_res_id *
-fid_build_quota_resid(const struct lu_fid *glb_fid, union lquota_id *qid,
+fid_build_quota_res_name(const struct lu_fid *glb_fid, union lquota_id *qid,
struct ldlm_res_id *res)
{
fid_build_reg_res_name(glb_fid, res);
res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF] = fid_seq(&qid->qid_fid);
res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] = fid_ver_oid(&qid->qid_fid);
+
return res;
}
/*
* Extract global FID and quota ID from resource name
*/
-static inline void fid_extract_quota_resid(struct ldlm_res_id *res,
- struct lu_fid *glb_fid,
- union lquota_id *qid)
+static inline void fid_extract_from_quota_res(struct lu_fid *glb_fid,
+ union lquota_id *qid,
+ const struct ldlm_res_id *res)
{
- glb_fid->f_seq = res->name[LUSTRE_RES_ID_SEQ_OFF];
- glb_fid->f_oid = (__u32)res->name[LUSTRE_RES_ID_VER_OID_OFF];
- glb_fid->f_ver = (__u32)(res->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32);
-
+ fid_extract_from_res_name(glb_fid, res);
qid->qid_fid.f_seq = res->name[LUSTRE_RES_ID_QUOTA_SEQ_OFF];
qid->qid_fid.f_oid = (__u32)res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF];
qid->qid_fid.f_ver =
(__u32)(res->name[LUSTRE_RES_ID_QUOTA_VER_OID_OFF] >> 32);
}
-/*
- * Return true if resource is for object identified by fid.
- */
-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_VER_OID_OFF] == fid_ver_oid(f);
-}
-
-/* reverse function of fid_build_reg_res_name() */
-static inline void fid_build_from_res_name(struct lu_fid *f,
- const struct ldlm_res_id *name)
-{
- fid_zero(f);
- f->f_seq = name->name[LUSTRE_RES_ID_SEQ_OFF];
- f->f_oid = name->name[LUSTRE_RES_ID_VER_OID_OFF] & 0xffffffff;
- f->f_ver = name->name[LUSTRE_RES_ID_VER_OID_OFF] >> 32;
- LASSERT(fid_res_name_eq(f, name));
-}
-
static inline struct ldlm_res_id *
-fid_build_pdo_res_name(const struct lu_fid *f,
- unsigned int hash,
- struct ldlm_res_id *name)
+fid_build_pdo_res_name(const struct lu_fid *fid, unsigned int hash,
+ struct ldlm_res_id *res)
{
- fid_build_reg_res_name(f, name);
- name->name[LUSTRE_RES_ID_HSH_OFF] = hash;
- return name;
+ fid_build_reg_res_name(fid, res);
+ res->name[LUSTRE_RES_ID_HSH_OFF] = hash;
+
+ return res;
}
/**
name->name[LUSTRE_RES_ID_SEQ_OFF] = ostid_id(oi);
name->name[LUSTRE_RES_ID_VER_OID_OFF] = ostid_seq(oi);
} else {
- fid_build_reg_res_name((struct lu_fid *)oi, name);
+ fid_build_reg_res_name(&oi->oi_fid, name);
}
}
ostid_set_id(oi, name->name[LUSTRE_RES_ID_SEQ_OFF]);
} else {
/* new resid */
- fid_build_from_res_name((struct lu_fid *)oi, name);
+ fid_extract_from_res_name(&oi->oi_fid, name);
}
}
ostid_to_fid(fid, &oi, 0);
} else {
/* new resid */
- fid_build_from_res_name(fid, name);
+ fid_extract_from_res_name(fid, name);
}
}