From: John L. Hammond Date: Tue, 8 Oct 2013 22:23:09 +0000 (-0500) Subject: LU-4078 mdc: fix bad ERR_PTR usage in mdc_locks.c X-Git-Tag: 2.5.51~47 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=54e6f66590057ee1229fecfa532decfc62bd222e LU-4078 mdc: fix bad ERR_PTR usage in mdc_locks.c In mdc_intent_open_pack() return an ERR_PTR() rather than NULL when ldlm_prep_enqueue_req() fails. In mdc_intent_getattr_async() check the return value of mdc_intent_getattr_pack() using IS_ERR(). Clean up the includes in mdc_locks.c. Signed-off-by: John L. Hammond Change-Id: I89348389ccd102d1226caf16b315ac9b2a96b307 Reviewed-on: http://review.whamcloud.com/7886 Reviewed-by: Andreas Dilger Tested-by: Hudson Tested-by: Maloo Reviewed-by: Nathaniel Clark --- diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 1a71afb..5d43c47 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -38,19 +38,18 @@ #ifdef __KERNEL__ # include -# include -# include -# include +# include #else # include #endif -#include +#include #include #include -/* fid_res_name_eq() */ -#include -#include +#include /* fid_res_name_eq() */ +#include +#include +#include #include "mdc_internal.h" struct mdc_getattr_args { @@ -347,11 +346,11 @@ static struct ptlrpc_request *mdc_intent_open_pack(struct obd_export *exp, req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT, max(lmmsize, obddev->u.cli.cl_default_mds_easize)); - rc = ldlm_prep_enqueue_req(exp, req, &cancels, count); - if (rc) { - ptlrpc_request_free(req); - return NULL; - } + rc = ldlm_prep_enqueue_req(exp, req, &cancels, count); + if (rc < 0) { + ptlrpc_request_free(req); + RETURN(ERR_PTR(rc)); + } spin_lock(&req->rq_lock); req->rq_replay = req->rq_import->imp_replayable; @@ -1300,10 +1299,10 @@ int mdc_intent_getattr_async(struct obd_export *exp, op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1), ldlm_it2str(it->it_op), it->it_flags); - fid_build_reg_res_name(&op_data->op_fid1, &res_id); - req = mdc_intent_getattr_pack(exp, it, op_data); - if (!req) - RETURN(-ENOMEM); + fid_build_reg_res_name(&op_data->op_fid1, &res_id); + req = mdc_intent_getattr_pack(exp, it, op_data); + if (IS_ERR(req)) + RETURN(PTR_ERR(req)); rc = mdc_enter_request(&obddev->u.cli); if (rc != 0) {