ENTRY;
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_GETSTATUS_PACK))
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
body = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
rc = next->md_ops->mdo_root_get(info->mti_env, next, &body->fid1);
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_STATFS_PACK)) {
- rc = -ENOMEM;
+ rc = err_serious(-ENOMEM);
} else {
osfs = req_capsule_server_get(&info->mti_pill,&RMF_OBD_STATFS);
/* XXX max_age optimisation is needed here. See mds_statfs */
&info->mti_u.ksfs);
statfs_pack(osfs, &info->mti_u.ksfs);
}
-
RETURN(rc);
}
ENTRY;
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK))
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
repbody = req_capsule_server_get(pill, &RMF_MDT_BODY);
repbody->eadatasize = 0;
LASSERT(info->mti_object != NULL);
name = req_capsule_client_get(&info->mti_pill, &RMF_NAME);
if (name == NULL)
- RETURN(-EFAULT);
+ RETURN(err_serious(-EFAULT));
CDEBUG(D_INODE, "getattr with lock for "DFID"/%s, ldlm_rep = %p\n",
PFID(mdt_object_fid(parent)), name, ldlm_rep);
reqbody = req_capsule_client_get(&info->mti_pill, &RMF_MDT_BODY);
if (reqbody == NULL)
- GOTO(out, rc = -EFAULT);
+ GOTO(out, rc = err_serious(-EFAULT));
rc = mdt_init_ucred(info, reqbody);
if (rc)
LASSERT(req->rq_export != NULL);
info->mti_mdt = mdt_dev(req->rq_export->exp_obd->obd_lu_dev);
rc = mdt_init_idmap(info);
- }
+ } else
+ rc = err_serious(rc);
return rc;
}
static int mdt_disconnect(struct mdt_thread_info *info)
{
- return target_handle_disconnect(mdt_info_req(info));
+ int rc;
+
+ rc = target_handle_disconnect(mdt_info_req(info));
+ if (rc)
+ rc = err_serious(rc);
+ return rc;
}
static int mdt_sendpage(struct mdt_thread_info *info,
reqbody = req_capsule_client_get(&info->mti_pill, &RMF_MDT_BODY);
if (reqbody == NULL)
- RETURN(-EFAULT);
+ RETURN(err_serious(-EFAULT));
desc = ptlrpc_prep_bulk_exp (req, 1, BULK_GET_SINK, MDS_BULK_PORTAL);
if (!desc)
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
/* allocate the page for the desc */
page = alloc_pages(GFP_KERNEL, 0);
ENTRY;
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_READPAGE_PACK))
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
reqbody = req_capsule_client_get(&info->mti_pill, &RMF_MDT_BODY);
repbody = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
if (reqbody == NULL || repbody == NULL)
- RETURN(-EFAULT);
+ RETURN(err_serious(-EFAULT));
rc = mdt_init_ucred(info, reqbody);
if (rc)
rc = req_capsule_pack(pill);
if (rc != 0) {
CERROR("Can't pack response, rc %d\n", rc);
- RETURN(rc);
+ RETURN(err_serious(rc));
}
/*
* and will get oops.
*/
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_REINT_UNPACK))
- RETURN(-EFAULT);
+ RETURN(err_serious(-EFAULT));
rc = mdt_reint_unpack(info, op);
if (rc != 0) {
CERROR("Can't unpack reint, rc %d\n", rc);
- RETURN(rc);
+ RETURN(err_serious(rc));
}
rc = mdt_init_ucred_reint(info);
__u32 *ptr;
long opc;
- opc = -EFAULT;
+ opc = err_serious(-EFAULT);
ptr = req_capsule_client_get(&info->mti_pill, &RMF_REINT_OPC);
if (ptr != NULL) {
opc = *ptr;
DEBUG_REQ(D_INODE, mdt_info_req(info), "reint opt = %ld", opc);
if (opc < REINT_MAX && fmt[opc] != NULL)
req_capsule_extend(&info->mti_pill, fmt[opc]);
- else
+ else {
CERROR("Unsupported opc: %ld\n", opc);
+ opc = err_serious(opc);
+ }
}
return opc;
}
body = req_capsule_client_get(pill, &RMF_MDT_BODY);
if (body == NULL)
- RETURN(-EINVAL);
+ RETURN(err_serious(-EINVAL));
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_SYNC_PACK))
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
if (fid_seq(&body->fid1) == 0) {
/* sync the whole device */
rc = req_capsule_pack(pill);
if (rc == 0)
rc = mdt_device_sync(info);
+ else
+ rc = err_serious(rc);
} else {
/* sync an object */
rc = mdt_unpack_req_pack_rep(info, HABEO_CORPUS|HABEO_REFERO);
mdt_body_reverse_idmap(info, body);
}
}
- }
+ } else
+ rc = err_serious(rc);
}
RETURN(rc);
}
static int mdt_quotacheck_handle(struct mdt_thread_info *info)
{
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
static int mdt_quotactl_handle(struct mdt_thread_info *info)
{
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
/*
int rc;
ENTRY;
rc = target_handle_ping(mdt_info_req(info));
+ if (rc < 0)
+ rc = err_serious(rc);
RETURN(rc);
}
static int mdt_obd_log_cancel(struct mdt_thread_info *info)
{
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
static int mdt_obd_qc_callback(struct mdt_thread_info *info)
{
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
rc = ldlm_handle_enqueue0(info->mti_mdt->mdt_namespace,
req, info->mti_dlm_req, &cbs);
info->mti_fail_id = OBD_FAIL_LDLM_REPLY;
- return rc ? : req->rq_status;
+ return rc ? err_serious(rc) : req->rq_status;
}
static int mdt_convert(struct mdt_thread_info *info)
LASSERT(info->mti_dlm_req);
req = mdt_info_req(info);
rc = ldlm_handle_convert0(req, info->mti_dlm_req);
- return rc ? : req->rq_status;
+ return rc ? err_serious(rc) : req->rq_status;
}
static int mdt_bl_callback(struct mdt_thread_info *info)
{
CERROR("bl callbacks should not happen on MDS\n");
LBUG();
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
static int mdt_cp_callback(struct mdt_thread_info *info)
{
CERROR("cp callbacks should not happen on MDS\n");
LBUG();
- return -EOPNOTSUPP;
+ return err_serious(-EOPNOTSUPP);
}
/*
static int mdt_req_handle(struct mdt_thread_info *info,
struct mdt_handler *h, struct ptlrpc_request *req)
{
- int rc;
+ int rc, serious = 0;
__u32 flags;
ENTRY;
if (rc == 0 && flags & MUTABOR &&
req->rq_export->exp_connect_flags & OBD_CONNECT_RDONLY)
+ /* should it be rq_status? */
rc = -EROFS;
if (rc == 0 && flags & HABEO_CLAVIS) {
}
}
- if (rc == 0)
+ if (rc == 0) {
/*
- * Process request.
+ * Process request, there can be two types of rc:
+ * 1) errors with msg unpack/pack, other failures outside the
+ * operation itself. This is counted as serious errors;
+ * 2) errors during fs operation, should be placed in rq_status
+ * only
*/
rc = h->mh_act(info);
+ serious = is_serious(rc);
+ rc = clear_serious(rc);
+ } else
+ serious = 1;
req->rq_status = rc;
/*
- * It is not correct to zero @rc out here unconditionally. First of all,
- * for error cases, we do not need target_committed_to_req(req). Second
- * reason is that, @rc is passed to target_send_reply() and used for
- * figuring out what should be done about reply in capricular case. We
- * only zero it out for ELDLM_* codes which > 0 because they do not
- * support invariant of marking req as difficult only in case of error.
+ * ELDLM_* codes which > 0 should be in rq_status only as well as
+ * all non-serious errors.
*/
- if (rc > 0)
+ if (rc > 0 || !serious)
rc = 0;
LASSERT(current->journal_info == NULL);
}
/* If we're DISCONNECTing, the mdt_export_data is already freed */
- if (h->mh_opc != MDS_DISCONNECT)
+ if (rc == 0 && h->mh_opc != MDS_DISCONNECT)
target_committed_to_req(req);
RETURN(rc);
struct mdt_thread_info *info)
{
ENTRY;
+
+#if 0
+ if (req->rq_reply_state == NULL && rc == 0) {
+ req->rq_status = rc;
+ lustre_pack_reply(req, 1, NULL, NULL);
+ }
+#endif
target_send_reply(req, rc, info->mti_fail_id);
RETURN(0);
}
supported);
if (h != NULL) {
rc = mdt_req_handle(info, h, req);
+ rc = mdt_reply(req, rc, info);
} else {
req->rq_status = -ENOTSUPP;
rc = ptlrpc_error(req);
RETURN(rc);
}
- rc = mdt_reply(req, rc, info);
}
} else
CERROR(LUSTRE_MDT_NAME" drops mal-formed request\n");
reqbody = req_capsule_client_get(&info->mti_pill, &RMF_MDT_BODY);
if (reqbody == NULL)
- GOTO(out, rc = -EFAULT);
+ GOTO(out, rc = err_serious(-EFAULT));
rc = mdt_init_ucred(info, reqbody);
if (rc)
if (mdt_it_flavor[opcode].it_reint != opc) {
CERROR("Reint code %ld doesn't match intent: %d\n",
opc, opcode);
- RETURN(-EPROTO);
+ RETURN(err_serious(-EPROTO));
}
/* Get lock from request for possible resent case. */
rep = req_capsule_server_get(&info->mti_pill, &RMF_DLM_REP);
if (rep == NULL)
- RETURN(-EFAULT);
+ RETURN(err_serious(-EFAULT));
/* MDC expects this in any case */
if (rc != 0)
mdt_set_disposition(info, rep, DISP_LOOKUP_EXECD);
- rep->lock_policy_res2 = rc;
-
/* cross-ref case, the lock should be returned to the client */
if (rc == -EREMOTE) {
LASSERT(lustre_handle_is_used(&lhc->mlh_lh));
rep->lock_policy_res2 = 0;
RETURN(mdt_intent_lock_replace(info, lockp, NULL, lhc, flags));
}
- rep->lock_policy_res2 = rc;
+ rep->lock_policy_res2 = clear_serious(rc);
RETURN(ELDLM_LOCK_ABORTED);
}
if (rc == 0)
rc = ELDLM_OK;
} else
- rc = -EFAULT;
+ rc = err_serious(-EFAULT);
} else {
/* No intent was provided */
LASSERT(pill->rc_fmt == &RQF_LDLM_ENQUEUE);
rc = req_capsule_pack(pill);
+ if (rc)
+ rc = err_serious(rc);
}
RETURN(rc);
}
int mdt_pin(struct mdt_thread_info* info)
{
ENTRY;
- RETURN(-EOPNOTSUPP);
+ RETURN(err_serious(-EOPNOTSUPP));
}
/* Cross-ref request. Currently it can only be a pure open (w/o create) */
/* TODO: JOIN file */
if (create_flags & MDS_OPEN_JOIN_FILE) {
CERROR("JOIN file will be supported soon\n");
- GOTO(out, result = -EOPNOTSUPP);
+ GOTO(out, result = err_serious(-EOPNOTSUPP));
}
CDEBUG(D_INODE, "I am going to open "DFID"/("DFID":%s) "
}
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_OPEN_PACK))
- GOTO(out, result = -ENOMEM);
+ GOTO(out, result = err_serious(-ENOMEM));
mdt_set_disposition(info, ldlm_rep,
(DISP_IT_EXECD | DISP_LOOKUP_EXECD));
/* Close may come with the Size-on-MDS update. Unpack it. */
rc = mdt_close_unpack(info);
if (rc)
- RETURN(rc);
+ RETURN(err_serious(rc));
LASSERT(info->mti_epoch);
ma->ma_need = MA_INODE | MA_LOV | MA_COOKIE;
repbody->eadatasize = 0;
repbody->aclsize = 0;
- }
+ } else
+ rc = err_serious(rc);
med = &mdt_info_req(info)->rq_export->exp_mdt_data;
CDEBUG(D_INODE, "no handle for file close: fid = "DFID
": cookie = "LPX64"\n", PFID(info->mti_rr.rr_fid1),
info->mti_epoch->handle.cookie);
- rc = -ESTALE;
+ rc = err_serious(-ESTALE);
} else {
class_handle_unhash(&mfd->mfd_handle);
list_del_init(&mfd->mfd_list);
mdt_shrink_reply(info, REPLY_REC_OFF + 1, 0, 0);
if (MDT_FAIL_CHECK(OBD_FAIL_MDS_CLOSE_PACK))
- RETURN(-ENOMEM);
+ RETURN(err_serious(-ENOMEM));
RETURN(rc ? rc : ret);
}
rc = req_capsule_pack(&info->mti_pill);
if (rc)
- RETURN(rc);
+ RETURN(err_serious(rc));
repbody = req_capsule_server_get(&info->mti_pill,
&RMF_MDT_BODY);
/* Done Writing may come with the Size-on-MDS update. Unpack it. */
rc = mdt_close_unpack(info);
if (rc)
- RETURN(rc);
+ RETURN(err_serious(rc));
med = &mdt_info_req(info)->rq_export->exp_mdt_data;
spin_lock(&med->med_open_lock);