__diff_normalize(fid_ver(f0), fid_ver(f1));
}
-static inline void ostid_cpu_to_le(struct ost_id *src_oi,
+static inline void ostid_cpu_to_le(const struct ost_id *src_oi,
struct ost_id *dst_oi)
{
if (fid_seq_is_mdt0(ostid_seq(src_oi))) {
}
}
-static inline void ostid_le_to_cpu(struct ost_id *src_oi,
+static inline void ostid_le_to_cpu(const struct ost_id *src_oi,
struct ost_id *dst_oi)
{
if (fid_seq_is_mdt0(ostid_seq(src_oi))) {
* 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);
}
}
OBD_FAIL_TIMEOUT(OBD_FAIL_LDLM_CREATE_RESOURCE, 2);
rc = ns->ns_lvbo->lvbo_init(res);
if (rc < 0) {
- CERROR("lvbo_init failed for resource "
- LPU64": rc %d\n", name->name[0], rc);
+ CERROR("%s: lvbo_init failed for resource "LPX64":"
+ LPX64": rc = %d\n", ns->ns_obd->obd_name,
+ name->name[0], name->name[1], rc);
if (res->lr_lvb_data) {
OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
res->lr_lvb_data = NULL;
LASSERT(count <= LOV_MAX_STRIPE_COUNT);
for (i = 0, lod = lmm->lmm_objects; i < count; i++, lod++) {
struct ost_id oi;
- ostid_le_to_cpu((struct ost_id *)&lod->l_ost_oi, &oi);
+ ostid_le_to_cpu(&lod->l_ost_oi, &oi);
CDEBUG(level, "stripe %u idx %u subobj "DOSTID"\n",
i, le32_to_cpu(lod->l_ost_idx), POSTID(&oi));
}
/* XXX get fid by resource id. why don't include fid in ldlm_resource */
fid = &info->mti_tmp_fid2;
- fid_build_from_res_name(fid, &lock->l_resource->lr_name);
+ fid_extract_from_res_name(fid, &lock->l_resource->lr_name);
obj = mdt_object_find(&env, info->mti_mdt, fid);
if (IS_ERR(obj))
* (lh->mlh_pdo_hash) in parallel directory lock.
*/
static int mdt_pdir_hash_lock(struct mdt_thread_info *info,
- struct mdt_lock_handle *lh,
- struct mdt_object *obj, __u64 ibits)
+ struct mdt_lock_handle *lh,
+ struct mdt_object *obj, __u64 ibits)
{
- struct ldlm_res_id *res_id = &info->mti_res_id;
- struct ldlm_namespace *ns = info->mti_mdt->mdt_namespace;
- ldlm_policy_data_t *policy = &info->mti_policy;
- int rc;
+ struct ldlm_res_id *res = &info->mti_res_id;
+ struct ldlm_namespace *ns = info->mti_mdt->mdt_namespace;
+ ldlm_policy_data_t *policy = &info->mti_policy;
+ int rc;
- /*
- * Finish res_id initializing by name hash marking part of
- * directory which is taking modification.
- */
- LASSERT(lh->mlh_pdo_hash != 0);
- fid_build_pdo_res_name(mdt_object_fid(obj), lh->mlh_pdo_hash, res_id);
- memset(policy, 0, sizeof(*policy));
- policy->l_inodebits.bits = ibits;
- /*
- * Use LDLM_FL_LOCAL_ONLY for this lock. We do not know yet if it is
- * going to be sent to client. If it is - mdt_intent_policy() path will
- * fix it up and turn FL_LOCAL flag off.
- */
- rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
- res_id, LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB,
- &info->mti_exp->exp_handle.h_cookie);
- return rc;
+ /*
+ * Finish res_id initializing by name hash marking part of
+ * directory which is taking modification.
+ */
+ LASSERT(lh->mlh_pdo_hash != 0);
+ fid_build_pdo_res_name(mdt_object_fid(obj), lh->mlh_pdo_hash, res);
+ memset(policy, 0, sizeof(*policy));
+ policy->l_inodebits.bits = ibits;
+ /*
+ * Use LDLM_FL_LOCAL_ONLY for this lock. We do not know yet if it is
+ * going to be sent to client. If it is - mdt_intent_policy() path will
+ * fix it up and turn FL_LOCAL flag off.
+ */
+ rc = mdt_fid_lock(ns, &lh->mlh_reg_lh, lh->mlh_reg_mode, policy,
+ res, LDLM_FL_LOCAL_ONLY | LDLM_FL_ATOMIC_CB,
+ &info->mti_exp->exp_handle.h_cookie);
+ return rc;
}
static int mdt_rename_lock(struct mdt_thread_info *info,
/* Called with res->lr_lvb_sem held */
static int ofd_lvbo_init(struct ldlm_resource *res)
{
- struct ost_lvb *lvb = NULL;
+ struct ost_lvb *lvb;
struct ofd_device *ofd;
struct ofd_object *fo;
struct ofd_thread_info *info;
OBD_ALLOC_PTR(lvb);
if (lvb == NULL)
- GOTO(out, rc = -ENOMEM);
+ GOTO(out_env, rc = -ENOMEM);
res->lr_lvb_data = lvb;
res->lr_lvb_len = sizeof(*lvb);
ost_fid_from_resid(&info->fti_fid, &res->lr_name);
fo = ofd_object_find(&env, ofd, &info->fti_fid);
if (IS_ERR(fo))
- GOTO(out, rc = PTR_ERR(fo));
+ GOTO(out_lvb, rc = PTR_ERR(fo));
rc = ofd_attr_get(&env, fo, &info->fti_attr);
if (rc)
- GOTO(out_put, rc);
+ GOTO(out_obj, rc);
lvb->lvb_size = info->fti_attr.la_size;
lvb->lvb_blocks = info->fti_attr.la_blocks;
lvb->lvb_atime = info->fti_attr.la_atime;
lvb->lvb_ctime = info->fti_attr.la_ctime;
- CDEBUG(D_DLMTRACE, "res: "LPX64" initial lvb size: "LPX64", "
+ CDEBUG(D_DLMTRACE, "res: "DFID" initial lvb size: "LPU64", "
"mtime: "LPX64", blocks: "LPX64"\n",
- res->lr_name.name[0], lvb->lvb_size,
+ PFID(&info->fti_fid), lvb->lvb_size,
lvb->lvb_mtime, lvb->lvb_blocks);
EXIT;
-out_put:
+out_obj:
ofd_object_put(&env, fo);
-out:
- lu_env_fini(&env);
- if (rc && lvb != NULL)
+out_lvb:
+ if (rc != 0)
OST_LVB_SET_ERR(lvb->lvb_blocks, rc);
+out_env:
+ lu_env_fini(&env);
/* Don't free lvb data on lookup error */
return rc;
}
ofd = ldlm_res_to_ns(res)->ns_lvbp;
LASSERT(ofd != NULL);
- lvb = res->lr_lvb_data;
- if (lvb == NULL) {
- CERROR("%s: no lvb when running lvbo_update, res: "LPU64"!\n",
- ofd_obd(ofd)->obd_name, res->lr_name.name[0]);
- RETURN(0);
- }
-
rc = lu_env_init(&env, LCT_DT_THREAD);
if (rc)
- GOTO(out_unlock, rc);
+ RETURN(rc);
info = ofd_info_init(&env, NULL);
+ fid_extract_from_res_name(&info->fti_fid, &res->lr_name);
+
+ lvb = res->lr_lvb_data;
+ if (lvb == NULL) {
+ CERROR("%s: no LVB data for "DFID"\n",
+ ofd_obd(ofd)->obd_name, PFID(&info->fti_fid));
+ GOTO(out_env, rc = 0);
+ }
+
/* Update the LVB from the network message */
if (req != NULL) {
struct ost_lvb *rpc_lvb;
lock_res(res);
if (rpc_lvb->lvb_size > lvb->lvb_size || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb size: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb size: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_size, rpc_lvb->lvb_size);
lvb->lvb_size = rpc_lvb->lvb_size;
}
if (rpc_lvb->lvb_mtime > lvb->lvb_mtime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb mtime: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb mtime: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_mtime, rpc_lvb->lvb_mtime);
lvb->lvb_mtime = rpc_lvb->lvb_mtime;
}
if (rpc_lvb->lvb_atime > lvb->lvb_atime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb atime: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb atime: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_atime, rpc_lvb->lvb_atime);
lvb->lvb_atime = rpc_lvb->lvb_atime;
}
if (rpc_lvb->lvb_ctime > lvb->lvb_ctime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb ctime: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb ctime: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_ctime, rpc_lvb->lvb_ctime);
lvb->lvb_ctime = rpc_lvb->lvb_ctime;
}
if (rpc_lvb->lvb_blocks > lvb->lvb_blocks || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb blocks: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb blocks: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_blocks, rpc_lvb->lvb_blocks);
lvb->lvb_blocks = rpc_lvb->lvb_blocks;
}
lock_res(res);
if (info->fti_attr.la_size > lvb->lvb_size || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb size from disk: "
- LPU64" -> %llu\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb size from disk: "
+ LPU64" -> %llu\n", PFID(&info->fti_fid),
lvb->lvb_size, info->fti_attr.la_size);
lvb->lvb_size = info->fti_attr.la_size;
}
if (info->fti_attr.la_mtime >lvb->lvb_mtime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb mtime from disk: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb mtime from disk: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_mtime, info->fti_attr.la_mtime);
lvb->lvb_mtime = info->fti_attr.la_mtime;
}
if (info->fti_attr.la_atime >lvb->lvb_atime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb atime from disk: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb atime from disk: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_atime, info->fti_attr.la_atime);
lvb->lvb_atime = info->fti_attr.la_atime;
}
if (info->fti_attr.la_ctime >lvb->lvb_ctime || !increase_only) {
- CDEBUG(D_DLMTRACE, "res: "LPU64" updating lvb ctime from disk: "
- LPU64" -> "LPU64"\n", res->lr_name.name[0],
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb ctime from disk: "
+ LPU64" -> "LPU64"\n", PFID(&info->fti_fid),
lvb->lvb_ctime, info->fti_attr.la_ctime);
lvb->lvb_ctime = info->fti_attr.la_ctime;
}
if (info->fti_attr.la_blocks > lvb->lvb_blocks || !increase_only) {
- CDEBUG(D_DLMTRACE,"res: "LPU64" updating lvb blocks from disk: "
- LPU64" -> %llu\n", res->lr_name.name[0],
- lvb->lvb_blocks,
+ CDEBUG(D_DLMTRACE, "res: "DFID" updating lvb blocks from disk: "
+ LPU64" -> %llu\n", PFID(&info->fti_fid), lvb->lvb_blocks,
(unsigned long long)info->fti_attr.la_blocks);
lvb->lvb_blocks = info->fti_attr.la_blocks;
}
ofd_object_put(&env, fo);
out_env:
lu_env_fini(&env);
-out_unlock:
return rc;
}
}
struct ldlm_valblock_ops ofd_lvbo = {
- lvbo_init: ofd_lvbo_init,
- lvbo_update: ofd_lvbo_update,
- lvbo_free: ofd_lvbo_free,
- lvbo_size: ofd_lvbo_size,
- lvbo_fill: ofd_lvbo_fill
+ .lvbo_init = ofd_lvbo_init,
+ .lvbo_update = ofd_lvbo_update,
+ .lvbo_free = ofd_lvbo_free,
+ .lvbo_size = ofd_lvbo_size,
+ .lvbo_fill = ofd_lvbo_fill
};
/* initialize environment */
rc = lu_env_init(env, LCT_MD_THREAD);
- if (rc) {
- OBD_FREE_PTR(env);
- RETURN(rc);
- }
+ if (rc != 0)
+ GOTO(out_free, rc);
qti = qmt_info(env);
/* extract global index FID and quota identifier */
- fid_extract_quota_resid(&res->lr_name, &qti->qti_fid, &qti->qti_id);
+ fid_extract_from_quota_res(&qti->qti_fid, &qti->qti_id, &res->lr_name);
/* sanity check the global index FID */
rc = lquota_extract_fid(&qti->qti_fid, &pool_id, &pool_type, &qtype);
CDEBUG(D_QUOTA, DFID" initialized lvb\n", PFID(&qti->qti_fid));
}
- res->lr_lvb_len = sizeof(struct lquota_lvb);
+ res->lr_lvb_len = sizeof(struct lquota_lvb);
EXIT;
out:
lu_env_fini(env);
+out_free:
OBD_FREE_PTR(env);
return rc;
}
lquota_generate_fid(&qti->qti_fid, pool->qpi_key & 0x0000ffff,
pool->qpi_key >> 16, lqe->lqe_site->lqs_qtype);
- fid_build_quota_resid(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
+ fid_build_quota_res_name(&qti->qti_fid, &lqe->lqe_id, &qti->qti_resid);
res = ldlm_resource_get(qmt->qmt_ns, NULL, &qti->qti_resid, LDLM_PLAIN,
0);
if (res == NULL) {
break;
case IT_QUOTA_DQACQ:
/* build resource name associated for per-ID quota lock */
- fid_build_quota_resid(&qbody->qb_fid, &qbody->qb_id,
- &qti->qti_resid);
+ fid_build_quota_res_name(&qbody->qb_fid, &qbody->qb_id,
+ &qti->qti_resid);
/* copy einfo template and fill ei_cbdata with lqe pointer */
memcpy(&qti->qti_einfo, &qsd_id_einfo, sizeof(qti->qti_einfo));