LASSERT(exp != NULL && !IS_ERR(exp));
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_SEQ_QUERY,
LUSTRE_MDS_VERSION, SEQ_QUERY);
- if (!req)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
/* Init operation code */
op = req_capsule_client_get(&req->rq_pill, &RMF_SEQ_OPC);
case FLD_QUERY:
req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_QUERY,
LUSTRE_MDS_VERSION, FLD_QUERY);
- if (!req)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
/*
* XXX: only needed when talking to old server(< 2.6), it should
case FLD_READ:
req = ptlrpc_request_alloc_pack(imp, &RQF_FLD_READ,
LUSTRE_MDS_VERSION, FLD_READ);
- if (!req)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
req_capsule_set_size(&req->rq_pill, &RMF_GENERIC_DATA,
RCL_SERVER, PAGE_SIZE);
__u64 reply_buf_size;
char __user *reply_buf;
/* out */
- __u64 status;
+ __s64 status;
__u64 reply_length;
};
req = ptlrpc_request_alloc_pack(lock->l_export->exp_imp_reverse,
&RQF_LDLM_BL_CALLBACK,
LUSTRE_DLM_VERSION, LDLM_BL_CALLBACK);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
ca = ptlrpc_req_async_args(ca, req);
ca->ca_set_arg = arg;
req_fmt, LUSTRE_DLM_VERSION,
LDLM_GL_CALLBACK);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
if (arg->gl_desc != NULL) {
/* copy the GL descriptor */
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_LDLM_CONVERT, LUSTRE_DLM_VERSION,
LDLM_CONVERT);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
body = req_capsule_client_get(&req->rq_pill, &RMF_DLM_REQ);
body->lock_handle[0] = lock->l_remote_handle;
req = ptlrpc_request_alloc_pack(imp, &RQF_LDLM_ENQUEUE,
LUSTRE_DLM_VERSION, LDLM_ENQUEUE);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
/* We're part of recovery, so don't wait for it. */
req->rq_send_state = LUSTRE_IMP_REPLAY_LOCKS;
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_STATFS,
LUSTRE_MDS_VERSION, MDS_STATFS);
- if (req == NULL)
- return -ENOMEM;
+ if (IS_ERR(req))
+ return PTR_ERR(req);
ptlrpc_request_set_replen(req);
req->rq_interpret_reply = mdc_statfs_interpret;
fmt = &RQF_MDS_STATFS_NEW;
req = ptlrpc_request_alloc_pack(imp, fmt, LUSTRE_MDS_VERSION,
MDS_STATFS);
- if (req == NULL)
- GOTO(output, rc = -ENOMEM);
+ if (IS_ERR(req))
+ GOTO(output, rc = PTR_ERR(req));
req->rq_allow_intr = 1;
if ((flags & OBD_STATFS_SUM) &&
req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_PROGRESS,
LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS);
- if (req == NULL)
- GOTO(out, rc = -ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_UNREGISTER,
LUSTRE_MDS_VERSION,
MDS_HSM_CT_UNREGISTER);
- if (req == NULL)
- GOTO(out, rc = -ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
mdc_pack_body(&req->rq_pill, NULL, 0, 0, -1, 0);
ptlrpc_request_set_replen(req);
rc = mdc_queue_wait(req);
- GOTO(out, rc);
-out:
+
ptlrpc_req_put(req);
- return rc;
+
+ RETURN(rc);
}
static int mdc_ioc_hsm_state_get(struct obd_export *exp,
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_LDLM_ENQUEUE, LUSTRE_DLM_VERSION,
LDLM_ENQUEUE);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, 0);
ptlrpc_request_set_replen(req);
req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
&RQF_OST_QUOTACTL, LUSTRE_OST_VERSION,
OST_QUOTACTL);
- if (req == NULL)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
if (oqctl->qc_cmd == LUSTRE_Q_ITEROQUOTA)
req_capsule_set_size(&req->rq_pill, &RMF_OBD_QUOTA_ITER,
EXPORT_SYMBOL(ptlrpc_request_free);
/**
- * Allocate new request for operatione \a opcode and immediatelly pack it for
+ * Allocate new request for operation \a opcode and immediatelly pack it for
* network transfer.
* Only used for simple requests like OBD_PING where the only important
* part of the request is operation itself.
- * Returns allocated request or NULL on error.
+ *
+ * Returns allocated request on success, and -errno on failure.
*/
struct ptlrpc_request *ptlrpc_request_alloc_pack(struct obd_import *imp,
const struct req_format *format,
__u32 version, int opcode)
{
- struct ptlrpc_request *req = ptlrpc_request_alloc(imp, format);
+ struct ptlrpc_request *req;
int rc;
- if (req) {
- rc = ptlrpc_request_pack(req, version, opcode);
- if (rc) {
- ptlrpc_request_free(req);
- req = NULL;
- }
+ req = ptlrpc_request_alloc(imp, format);
+ if (!req)
+ return ERR_PTR(-ENOMEM);
+
+ rc = ptlrpc_request_pack(req, version, opcode);
+ if (rc) {
+ ptlrpc_request_free(req);
+ return ERR_PTR(rc);
}
+
return req;
}
EXPORT_SYMBOL(ptlrpc_request_alloc_pack);
req = ptlrpc_request_alloc_pack(imp, &RQF_SEC_CTX, LUSTRE_OBD_VERSION,
SEC_CTX_INIT);
- if (!req || !req->rq_cli_ctx || !req->rq_cli_ctx->cc_sec) {
+ if (IS_ERR(req)) {
+ param.status = PTR_ERR(req);
+ req = NULL;
+ goto out_copy;
+ } else if (!req->rq_cli_ctx || !req->rq_cli_ctx->cc_sec) {
param.status = -ENOMEM;
goto out_copy;
}
if (rc != -EACCES)
param.status = -ETIMEDOUT;
CDEBUG(D_SEC,
- "%s: ctx init req got %d, returning to userspace status %llu\n",
+ "%s: ctx init req got %d, returning to userspace status %lld\n",
obd->obd_name, rc, param.status);
goto out_copy;
}
req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING, LUSTRE_OBD_VERSION,
OBD_PING);
- if (req == NULL) {
+ if (IS_ERR(req)) {
atomic_dec(&imp->imp_replay_inflight);
- RETURN(-ENOMEM);
+ RETURN(PTR_ERR(req));
}
ptlrpc_request_set_replen(req);
req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT,
LUSTRE_OBD_VERSION, rq_opc);
- if (req == NULL)
- RETURN(ERR_PTR(-ENOMEM));
+ if (IS_ERR(req))
+ RETURN(ERR_CAST(req));
/* We are disconnecting, do not retry a failed DISCONNECT rpc if
* it fails. We can get through the above with a down server
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_NEXT_BLOCK,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_NEXT_BLOCK);
- if (!req)
- GOTO(err_exit, rc = -ENOMEM);
+ if (IS_ERR(req))
+ GOTO(err_exit, rc = PTR_ERR(req));
body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
body->lgd_logid = loghandle->lgh_id;
req = ptlrpc_request_alloc_pack(imp, &RQF_LLOG_ORIGIN_HANDLE_PREV_BLOCK,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_PREV_BLOCK);
- if (!req)
- GOTO(err_exit, rc = -ENOMEM);
+ if (IS_ERR(req))
+ GOTO(err_exit, rc = PTR_ERR(req));
body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
body->lgd_logid = loghandle->lgh_id;
&RQF_LLOG_ORIGIN_HANDLE_READ_HEADER,
LUSTRE_LOG_VERSION,
LLOG_ORIGIN_HANDLE_READ_HEADER);
- if (!req)
- GOTO(err_exit, rc = -ENOMEM);
+ if (IS_ERR(req))
+ GOTO(err_exit, rc = PTR_ERR(req));
body = req_capsule_client_get(&req->rq_pill, &RMF_LLOGD_BODY);
body->lgd_logid = handle->lgh_id;
if (rc)
RETURN(rc);
- if (!req)
- RETURN(-ENOMEM);
+ if (IS_ERR(req))
+ RETURN(PTR_ERR(req));
req->rq_send_state = LUSTRE_IMP_FULL;
req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING,
LUSTRE_OBD_VERSION, OBD_PING);
- if (req) {
- ptlrpc_request_set_replen(req);
- req->rq_no_resend = req->rq_no_delay = 1;
- }
+ if (IS_ERR(req))
+ return ERR_CAST(req);
+
+ ptlrpc_request_set_replen(req);
+ req->rq_no_resend = req->rq_no_delay = 1;
+
return req;
}
with_imp_locked(obd, imp, rc) {
req = ptlrpc_prep_ping(imp);
- if (!req) {
- rc = -ENOMEM;
+ if (IS_ERR(req)) {
+ rc = PTR_ERR(req);
continue;
}
req->rq_send_state = LUSTRE_IMP_FULL;
RETURN(0);
req = ptlrpc_prep_ping(imp);
- if (!req) {
- CERROR("OOM trying to ping %s->%s\n",
- imp->imp_obd->obd_uuid.uuid,
- obd2cli_tgt(imp->imp_obd));
- RETURN(-ENOMEM);
+ if (IS_ERR(req)) {
+ CERROR("%s: ping failed: rc = %ld\n",
+ imp->imp_obd->obd_name, PTR_ERR(req));
+ RETURN(PTR_ERR(req));
}
DEBUG_REQ(D_INFO, req, "pinging %s->%s",