RETURN(0);
}
-int mdc_lock_match(struct obd_export *exp, int flags,
- const struct lu_fid *fid, ldlm_type_t type,
- ldlm_policy_data_t *policy, ldlm_mode_t mode,
- struct lustre_handle *lockh)
+ldlm_mode_t mdc_lock_match(struct obd_export *exp, int flags,
+ const struct lu_fid *fid, ldlm_type_t type,
+ ldlm_policy_data_t *policy, ldlm_mode_t mode,
+ struct lustre_handle *lockh)
{
struct ldlm_res_id res_id =
{ .name = {fid_seq(fid),
fid_oid(fid),
fid_ver(fid)} };
- struct obd_device *obd = class_exp2obd(exp);
- int rc;
+ ldlm_mode_t rc;
ENTRY;
- rc = ldlm_lock_match(obd->obd_namespace, flags,
+ rc = ldlm_lock_match(class_exp2obd(exp)->obd_namespace, flags,
&res_id, type, policy, mode, lockh);
-
RETURN(rc);
}
lockreq->lock_flags |= LDLM_FL_INTENT_ONLY;
}
- /* This can go when we're sure that this can never happen */
- LASSERT(rc != -ENOENT);
if (rc == ELDLM_LOCK_ABORTED) {
einfo->ei_mode = 0;
memset(lockh, 0, sizeof(*lockh));
lockrep = lustre_msg_buf(req->rq_repmsg, DLM_LOCKREPLY_OFF,
sizeof(*lockrep));
LASSERT(lockrep != NULL); /* checked by ldlm_cli_enqueue() */
- LASSERT_REPSWABBED(req, DLM_LOCKREPLY_OFF); /* swabbed by ldlm_cli_enqueue() */
+ /* swabbed by ldlm_cli_enqueue() */
+ LASSERT(lustre_rep_swabbed(req, DLM_LOCKREPLY_OFF));
it->d.lustre.it_disposition = (int)lockrep->lock_policy_res1;
it->d.lustre.it_status = (int)lockrep->lock_policy_res2;
/* We could just return 1 immediately, but since we should only
* be called in revalidate_it if we already have a lock, let's
* verify that. */
- struct ldlm_res_id res_id = { .name = { fid_seq(&op_data->op_fid2),
- fid_oid(&op_data->op_fid2),
- fid_ver(&op_data->op_fid2) } };
ldlm_policy_data_t policy;
- ldlm_mode_t mode = LCK_CR;
+ ldlm_mode_t mode;
/* As not all attributes are kept under update lock, e.g.
owner/group/acls are under lookup lock, we need both
policy.l_inodebits.bits = (it->it_op == IT_GETATTR) ?
MDS_INODELOCK_UPDATE : MDS_INODELOCK_LOOKUP;
- rc = ldlm_lock_match(exp->exp_obd->obd_namespace,
- LDLM_FL_BLOCK_GRANTED, &res_id,
- LDLM_IBITS, &policy, mode, &lockh);
- if (!rc) {
- mode = LCK_CW;
- rc = ldlm_lock_match(exp->exp_obd->obd_namespace,
- LDLM_FL_BLOCK_GRANTED, &res_id,
- LDLM_IBITS, &policy, mode, &lockh);
- }
- if (!rc) {
- mode = LCK_PR;
- rc = ldlm_lock_match(exp->exp_obd->obd_namespace,
- LDLM_FL_BLOCK_GRANTED, &res_id,
- LDLM_IBITS, &policy, mode, &lockh);
- }
-
- if (!rc) {
- mode = LCK_PW;
- rc = ldlm_lock_match(exp->exp_obd->obd_namespace,
- LDLM_FL_BLOCK_GRANTED, &res_id,
- LDLM_IBITS, &policy, mode, &lockh);
- }
-
- if (rc) {
+ mode = mdc_lock_match(exp, LDLM_FL_BLOCK_GRANTED,
+ &op_data->op_fid2, LDLM_IBITS, &policy,
+ LCK_CR|LCK_CW|LCK_PR|LCK_PW, &lockh);
+ if (mode) {
memcpy(&it->d.lustre.it_lock_handle, &lockh,
sizeof(lockh));
it->d.lustre.it_lock_mode = mode;
/* Only return failure if it was not GETATTR by cfid
(from inode_revalidate) */
- if (rc || op_data->op_namelen != 0)
- RETURN(rc);
+ if (mode || op_data->op_namelen != 0)
+ RETURN(!!mode);
}
/* lookup_it may be called only after revalidate_it has run, because
mdt_body = lustre_msg_buf(request->rq_repmsg, DLM_REPLY_REC_OFF,
sizeof(*mdt_body));
- LASSERT(mdt_body != NULL); /* mdc_enqueue checked */
- LASSERT_REPSWABBED(request, 1); /* mdc_enqueue swabbed */
+ /* mdc_enqueue checked */
+ LASSERT(mdt_body != NULL);
+ /* mdc_enqueue swabbed */
+ LASSERT(lustre_rep_swabbed(request, 1));
/* If we were revalidating a fid/name pair, mark the intent in
* case we fail and get called again from lookup */