- /* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
- sizeof(*lit));
- lit->opc = (__u64)it->it_op;
-
- /* pack the intended request */
- mdc_open_pack(req, DLM_INTENT_REC_OFF, op_data,
- it->it_create_mode, 0, it->it_flags,
- lmm, lmmsize);
-
- /* for remote client, fetch remote perm for current user */
- repsize[repbufcnt++] = client_is_remote(exp) ?
- sizeof(struct mdt_remote_perm) :
- LUSTRE_POSIX_ACL_MAX_SIZE;
- repsize[repbufcnt++] = sizeof(struct lustre_capa);
- repsize[repbufcnt++] = sizeof(struct lustre_capa);
- } else if (it->it_op & IT_UNLINK) {
- size[DLM_INTENT_REC_OFF] = sizeof(struct mdt_rec_unlink);
- size[DLM_INTENT_REC_OFF + 1] = op_data->op_capa1 ?
- sizeof(struct lustre_capa) : 0;
- size[DLM_INTENT_REC_OFF + 2] = op_data->op_namelen + 1;
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
- req = ldlm_prep_enqueue_req(exp, 6, size, NULL, 0);
- if (!req)
- RETURN(-ENOMEM);
-
- /* pack the intent */
- lit = lustre_msg_buf(req->rq_reqmsg, DLM_INTENT_IT_OFF,
- sizeof(*lit));
- lit->opc = (__u64)it->it_op;
-
- /* pack the intended request */
- mdc_unlink_pack(req, DLM_INTENT_REC_OFF, op_data);
-
- repsize[repbufcnt++] = obddev->u.cli.cl_max_mds_cookiesize;
- } else if (it->it_op & (IT_GETATTR | IT_LOOKUP)) {
- obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE |
- OBD_MD_FLMODEASIZE | OBD_MD_FLDIREA |
- OBD_MD_FLMDSCAPA | OBD_MD_MEA;
- valid |= client_is_remote(exp) ? OBD_MD_FLRMTPERM :
- OBD_MD_FLACL;
- size[DLM_INTENT_REC_OFF] = sizeof(struct mdt_body);
- size[DLM_INTENT_REC_OFF + 1] = op_data->op_capa1 ?
- sizeof(struct lustre_capa) : 0;
- size[DLM_INTENT_REC_OFF + 2] = op_data->op_namelen + 1;
-
- if (it->it_op & IT_GETATTR)
- policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
+ spin_lock(&req->rq_lock);
+ req->rq_replay = 1;
+ spin_unlock(&req->rq_lock);
+
+ /* pack the intent */
+ lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
+ lit->opc = (__u64)it->it_op;
+
+ /* pack the intended request */
+ mdc_open_pack(req, op_data, it->it_create_mode, 0, it->it_flags, lmm,
+ lmmsize);
+
+ /* for remote client, fetch remote perm for current user */
+ if (client_is_remote(exp))
+ req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+ sizeof(struct mdt_remote_perm));
+ ptlrpc_request_set_replen(req);
+ return req;
+}
+
+static struct ptlrpc_request *mdc_intent_unlink_pack(struct obd_export *exp,
+ struct lookup_intent *it,
+ struct md_op_data *op_data)
+{
+ struct ptlrpc_request *req;
+ struct obd_device *obddev = class_exp2obd(exp);
+ struct ldlm_intent *lit;
+ int rc;
+ ENTRY;
+
+ req = ptlrpc_request_alloc(class_exp2cliimp(exp),
+ &RQF_LDLM_INTENT_UNLINK);
+ if (req == NULL)
+ RETURN(ERR_PTR(-ENOMEM));
+
+ mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
+ req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
+ op_data->op_namelen + 1);
+
+ rc = ldlm_prep_enqueue_req(exp, req, NULL, 0);
+ if (rc) {
+ ptlrpc_request_free(req);
+ RETURN(ERR_PTR(rc));
+ }
+
+ /* pack the intent */
+ lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT);
+ lit->opc = (__u64)it->it_op;
+
+ /* pack the intended request */
+ mdc_unlink_pack(req, op_data);
+
+ req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
+ obddev->u.cli.cl_max_mds_easize);
+ req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
+ obddev->u.cli.cl_max_mds_cookiesize);
+ ptlrpc_request_set_replen(req);
+ RETURN(req);
+}
+
+static struct ptlrpc_request *mdc_intent_getattr_pack(struct obd_export *exp,
+ struct lookup_intent *it,
+ struct md_op_data *op_data)
+{
+ struct ptlrpc_request *req;
+ struct obd_device *obddev = class_exp2obd(exp);
+ obd_valid valid = OBD_MD_FLGETATTR | OBD_MD_FLEASIZE |
+ OBD_MD_FLMODEASIZE | OBD_MD_FLDIREA |
+ OBD_MD_FLMDSCAPA | OBD_MD_MEA |
+ (client_is_remote(exp) ?
+ OBD_MD_FLRMTPERM : OBD_MD_FLACL);
+ struct ldlm_intent *lit;
+ int rc;
+ ENTRY;