diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/osc/osc_request.c')
-rw-r--r-- | drivers/staging/lustre/lustre/osc/osc_request.c | 326 |
1 files changed, 140 insertions, 186 deletions
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c index 53d6a35c80b9..ee6707a5ea9d 100644 --- a/drivers/staging/lustre/lustre/osc/osc_request.c +++ b/drivers/staging/lustre/lustre/osc/osc_request.c @@ -69,30 +69,29 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, struct lov_stripe_md *lsm) { int lmm_size; - ENTRY; lmm_size = sizeof(**lmmp); if (lmmp == NULL) - RETURN(lmm_size); + return lmm_size; if (*lmmp != NULL && lsm == NULL) { OBD_FREE(*lmmp, lmm_size); *lmmp = NULL; - RETURN(0); + return 0; } else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (*lmmp == NULL) { OBD_ALLOC(*lmmp, lmm_size); if (*lmmp == NULL) - RETURN(-ENOMEM); + return -ENOMEM; } if (lsm) ostid_cpu_to_le(&lsm->lsm_oi, &(*lmmp)->lmm_oi); - RETURN(lmm_size); + return lmm_size; } /* Unpack OSC object metadata from disk storage (LE byte order). */ @@ -101,47 +100,46 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, { int lsm_size; struct obd_import *imp = class_exp2cliimp(exp); - ENTRY; if (lmm != NULL) { if (lmm_bytes < sizeof(*lmm)) { CERROR("%s: lov_mds_md too small: %d, need %d\n", exp->exp_obd->obd_name, lmm_bytes, (int)sizeof(*lmm)); - RETURN(-EINVAL); + return -EINVAL; } /* XXX LOV_MAGIC etc check? */ if (unlikely(ostid_id(&lmm->lmm_oi) == 0)) { CERROR("%s: zero lmm_object_id: rc = %d\n", exp->exp_obd->obd_name, -EINVAL); - RETURN(-EINVAL); + return -EINVAL; } } lsm_size = lov_stripe_md_size(1); if (lsmp == NULL) - RETURN(lsm_size); + return lsm_size; if (*lsmp != NULL && lmm == NULL) { OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); OBD_FREE(*lsmp, lsm_size); *lsmp = NULL; - RETURN(0); + return 0; } if (*lsmp == NULL) { OBD_ALLOC(*lsmp, lsm_size); if (unlikely(*lsmp == NULL)) - RETURN(-ENOMEM); + return -ENOMEM; OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo)); if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) { OBD_FREE(*lsmp, lsm_size); - RETURN(-ENOMEM); + return -ENOMEM; } loi_init((*lsmp)->lsm_oinfo[0]); } else if (unlikely(ostid_id(&(*lsmp)->lsm_oi) == 0)) { - RETURN(-EBADF); + return -EBADF; } if (lmm != NULL) @@ -154,7 +152,7 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, else (*lsmp)->lsm_maxbytes = LUSTRE_STRIPE_MAXBYTES; - RETURN(lsm_size); + return lsm_size; } static inline void osc_pack_capa(struct ptlrpc_request *req, @@ -202,7 +200,6 @@ static int osc_getattr_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -223,7 +220,7 @@ static int osc_getattr_interpret(const struct lu_env *env, } out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -232,17 +229,16 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -255,7 +251,7 @@ static int osc_getattr_async(struct obd_export *exp, struct obd_info *oinfo, aa->aa_oi = oinfo; ptlrpc_set_add_req(set, req); - RETURN(0); + return 0; } static int osc_getattr(const struct lu_env *env, struct obd_export *exp, @@ -264,17 +260,16 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -296,7 +291,6 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp, oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd); oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -308,19 +302,18 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct ost_body *body; int rc; - ENTRY; LASSERT(oinfo->oi_oa->o_valid & OBD_MD_FLGROUP); req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } osc_pack_req_body(req, oinfo); @@ -338,10 +331,9 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp, lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa, &body->oa); - EXIT; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_setattr_interpret(const struct lu_env *env, @@ -349,7 +341,6 @@ static int osc_setattr_interpret(const struct lu_env *env, struct osc_setattr_args *sa, int rc) { struct ost_body *body; - ENTRY; if (rc != 0) GOTO(out, rc); @@ -362,7 +353,7 @@ static int osc_setattr_interpret(const struct lu_env *env, &body->oa); out: rc = sa->sa_upcall(sa->sa_cookie, rc); - RETURN(rc); + return rc; } int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, @@ -373,17 +364,16 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, struct ptlrpc_request *req; struct osc_setattr_args *sa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SETATTR); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SETATTR); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } if (oti && oinfo->oi_oa->o_valid & OBD_MD_FLCOOKIE) @@ -413,7 +403,7 @@ int osc_setattr_async_base(struct obd_export *exp, struct obd_info *oinfo, ptlrpc_set_add_req(rqset, req); } - RETURN(0); + return 0; } static int osc_setattr_async(struct obd_export *exp, struct obd_info *oinfo, @@ -431,7 +421,6 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, struct ost_body *body; struct lov_stripe_md *lsm; int rc; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -440,7 +429,7 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa, if (!lsm) { rc = obd_alloc_memmd(exp, &lsm); if (rc < 0) - RETURN(rc); + return rc; } req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_CREATE); @@ -506,7 +495,7 @@ out_req: out: if (rc && !*ea) obd_free_memmd(exp, &lsm); - RETURN(rc); + return rc; } int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, @@ -517,17 +506,16 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, struct osc_setattr_args *sa; struct ost_body *body; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_PUNCH); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -551,7 +539,7 @@ int osc_punch_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_punch(const struct lu_env *env, struct obd_export *exp, @@ -571,7 +559,6 @@ static int osc_sync_interpret(const struct lu_env *env, { struct osc_fsync_args *fa = arg; struct ost_body *body; - ENTRY; if (rc) GOTO(out, rc); @@ -585,7 +572,7 @@ static int osc_sync_interpret(const struct lu_env *env, *fa->fa_oi->oi_oa = body->oa; out: rc = fa->fa_upcall(fa->fa_cookie, rc); - RETURN(rc); + return rc; } int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, @@ -596,17 +583,16 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, struct ost_body *body; struct osc_fsync_args *fa; int rc; - ENTRY; req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_SYNC); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; osc_set_capa_size(req, &RMF_CAPA1, oinfo->oi_capa); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SYNC); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } /* overload the size and blocks fields in the oa with start/end */ @@ -630,25 +616,23 @@ int osc_sync_base(struct obd_export *exp, struct obd_info *oinfo, else ptlrpc_set_add_req(rqset, req); - RETURN (0); + return 0; } static int osc_sync(const struct lu_env *env, struct obd_export *exp, struct obd_info *oinfo, obd_size start, obd_size end, struct ptlrpc_request_set *set) { - ENTRY; - if (!oinfo->oi_oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } oinfo->oi_oa->o_size = start; oinfo->oi_oa->o_blocks = end; oinfo->oi_oa->o_valid |= (OBD_MD_FLSIZE | OBD_MD_FLBLOCKS); - RETURN(osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set)); + return osc_sync_base(exp, oinfo, oinfo->oi_cb_up, oinfo, set); } /* Find and cancel locally locks matched by @mode in the resource found by @@ -662,7 +646,6 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, struct ldlm_res_id res_id; struct ldlm_resource *res; int count; - ENTRY; /* Return, i.e. cancel nothing, only if ELC is supported (flag in * export) but disabled through procfs (flag in NS). @@ -671,19 +654,19 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa, * when we still want to cancel locks in advance and just cancel them * locally, without sending any RPC. */ if (exp_connect_cancelset(exp) && !ns_connect_cancelset(ns)) - RETURN(0); + return 0; ostid_build_res_name(&oa->o_oi, &res_id); res = ldlm_resource_get(ns, NULL, &res_id, 0, 0); if (res == NULL) - RETURN(0); + return 0; LDLM_RESOURCE_ADDREF(res); count = ldlm_cancel_resource_local(res, cancels, NULL, mode, lock_flags, 0, NULL); LDLM_RESOURCE_DELREF(res); ldlm_resource_putref(res); - RETURN(count); + return count; } static int osc_destroy_interpret(const struct lu_env *env, @@ -720,7 +703,6 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, struct obd_trans_info *oti) { int rc = 0; - ENTRY; LASSERT(oa); LASSERT(ea); @@ -728,16 +710,16 @@ int osc_create(const struct lu_env *env, struct obd_export *exp, if ((oa->o_valid & OBD_MD_FLFLAGS) && oa->o_flags == OBD_FL_RECREATE_OBJS) { - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); } if (!fid_seq_is_mdt(ostid_seq(&oa->o_oi))) - RETURN(osc_real_create(exp, oa, ea, oti)); + return osc_real_create(exp, oa, ea, oti); /* we should not get here anymore */ LBUG(); - RETURN(rc); + return rc; } /* Destroy requests can be async always on the client, and we don't even really @@ -760,11 +742,10 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, struct ost_body *body; LIST_HEAD(cancels); int rc, count; - ENTRY; if (!oa) { CDEBUG(D_INFO, "oa NULL\n"); - RETURN(-EINVAL); + return -EINVAL; } count = osc_resource_get_unused(exp, oa, &cancels, LCK_PW, @@ -773,7 +754,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_DESTROY); if (req == NULL) { ldlm_lock_list_put(&cancels, l_bl_ast, count); - RETURN(-ENOMEM); + return -ENOMEM; } osc_set_capa_size(req, &RMF_CAPA1, (struct obd_capa *)capa); @@ -781,7 +762,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, 0, &cancels, count); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ @@ -817,7 +798,7 @@ static int osc_destroy(const struct lu_env *env, struct obd_export *exp, /* Do not wait for response */ ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } static void osc_announce_cached(struct client_obd *cli, struct obdo *oa, @@ -948,7 +929,6 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) { int rc = 0; struct ost_body *body; - ENTRY; client_obd_list_lock(&cli->cl_loi_list_lock); /* Don't shrink if we are already above or below the desired limit @@ -959,13 +939,13 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (target_bytes >= cli->cl_avail_grant) { client_obd_list_unlock(&cli->cl_loi_list_lock); - RETURN(0); + return 0; } client_obd_list_unlock(&cli->cl_loi_list_lock); OBD_ALLOC_PTR(body); if (!body) - RETURN(-ENOMEM); + return -ENOMEM; osc_announce_cached(cli, &body->oa, 0); @@ -986,7 +966,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes) if (rc != 0) __osc_update_grant(cli, body->oa.o_grant); OBD_FREE_PTR(body); - RETURN(rc); + return rc; } static int osc_should_shrink_grant(struct client_obd *client) @@ -1256,11 +1236,10 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, struct req_capsule *pill; struct brw_page *pg_prev; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ)) - RETURN(-ENOMEM); /* Recoverable */ + return -ENOMEM; /* Recoverable */ if (OBD_FAIL_CHECK(OBD_FAIL_OSC_BRW_PREP_REQ2)) - RETURN(-EINVAL); /* Fatal */ + return -EINVAL; /* Fatal */ if ((cmd & OBD_BRW_WRITE) != 0) { opc = OST_WRITE; @@ -1272,7 +1251,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_BRW_READ); } if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; for (niocount = i = 1; i < page_count; i++) { if (!can_merge_pages(pga[i - 1], pga[i])) @@ -1289,7 +1268,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, opc); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req->rq_request_portal = OST_IO_PORTAL; /* bug 7198 */ ptlrpc_at_set_req_timeout(req); @@ -1435,11 +1414,11 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,struct obdo *oa, aa->aa_ocapa = capa_get(ocapa); *reqp = req; - RETURN(0); + return 0; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int check_write_checksum(struct obdo *oa, const lnet_process_id_t *peer, @@ -1496,18 +1475,17 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) struct client_obd *cli = aa->aa_cli; struct ost_body *body; __u32 client_cksum = 0; - ENTRY; if (rc < 0 && rc != -EDQUOT) { DEBUG_REQ(D_INFO, req, "Failed request with rc = %d\n", rc); - RETURN(rc); + return rc; } LASSERTF(req->rq_repmsg != NULL, "rc = %d\n", rc); body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY); if (body == NULL) { DEBUG_REQ(D_INFO, req, "Can't unpack body\n"); - RETURN(-EPROTO); + return -EPROTO; } /* set/clear over quota flag for a uid/gid */ @@ -1524,7 +1502,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) osc_update_grant(cli, body); if (rc < 0) - RETURN(rc); + return rc; if (aa->aa_oa->o_valid & OBD_MD_FLCKSUM) client_cksum = aa->aa_oa->o_cksum; /* save for later */ @@ -1532,19 +1510,19 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (lustre_msg_get_opc(req->rq_reqmsg) == OST_WRITE) { if (rc > 0) { CERROR("Unexpected +ve rc %d\n", rc); - RETURN(-EPROTO); + return -EPROTO; } LASSERT(req->rq_bulk->bd_nob == aa->aa_requested_nob); if (sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk)) - RETURN(-EAGAIN); + return -EAGAIN; if ((aa->aa_oa->o_valid & OBD_MD_FLCKSUM) && client_cksum && check_write_checksum(&body->oa, peer, client_cksum, body->oa.o_cksum, aa->aa_requested_nob, aa->aa_page_count, aa->aa_ppga, cksum_type_unpack(aa->aa_oa->o_flags))) - RETURN(-EAGAIN); + return -EAGAIN; rc = check_write_rcs(req, aa->aa_requested_nob,aa->aa_nio_count, aa->aa_page_count, aa->aa_ppga); @@ -1561,7 +1539,7 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc) if (rc > aa->aa_requested_nob) { CERROR("Unexpected rc %d (%d requested)\n", rc, aa->aa_requested_nob); - RETURN(-EPROTO); + return -EPROTO; } if (rc != req->rq_bulk->bd_nob_transferred) { @@ -1641,7 +1619,7 @@ out: lustre_get_wire_obdo(&req->rq_import->imp_connect_data, aa->aa_oa, &body->oa); - RETURN(rc); + return rc; } static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, @@ -1655,8 +1633,6 @@ static int osc_brw_internal(int cmd, struct obd_export *exp, struct obdo *oa, int generation, resends = 0; struct l_wait_info lwi; - ENTRY; - init_waitqueue_head(&waitq); generation = exp->exp_obd->u.cli.cl_import->imp_generation; @@ -1711,7 +1687,7 @@ restart_bulk: out: if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; - RETURN (rc); + return rc; } static int osc_brw_redo_request(struct ptlrpc_request *request, @@ -1720,7 +1696,6 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, struct ptlrpc_request *new_req; struct osc_brw_async_args *new_aa; struct osc_async_page *oap; - ENTRY; DEBUG_REQ(rc == -EINPROGRESS ? D_RPCTRACE : D_ERROR, request, "redo for recoverable error %d", rc); @@ -1732,7 +1707,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, aa->aa_page_count, aa->aa_ppga, &new_req, aa->aa_ocapa, 0, 1); if (rc) - RETURN(rc); + return rc; list_for_each_entry(oap, &aa->aa_oaps, oap_rpc_item) { if (oap->oap_request != NULL) { @@ -1741,7 +1716,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, request, oap->oap_request); if (oap->oap_interrupted) { ptlrpc_req_finished(new_req); - RETURN(-EINTR); + return -EINTR; } } } @@ -1784,7 +1759,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request, ptlrpcd_add_req(new_req, PDL_POLICY_SAME, -1); DEBUG_REQ(D_INFO, new_req, "new request"); - RETURN(0); + return 0; } /* @@ -1873,7 +1848,6 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct obd_import *imp = class_exp2cliimp(exp); struct client_obd *cli; int rc, page_count_orig; - ENTRY; LASSERT((imp != NULL) && (imp->imp_obd != NULL)); cli = &imp->imp_obd->u.cli; @@ -1883,8 +1857,8 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, * I/O can succeed */ if (imp->imp_invalid) - RETURN(-EIO); - RETURN(0); + return -EIO; + return 0; } /* test_brw with a failed create can trip this, maybe others. */ @@ -1894,7 +1868,7 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, orig = ppga = osc_build_ppga(pga, page_count); if (ppga == NULL) - RETURN(-ENOMEM); + return -ENOMEM; page_count_orig = page_count; sort_brw_pages(ppga, page_count); @@ -1935,7 +1909,7 @@ out: if (saved_oa != NULL) OBDO_FREE(saved_oa); - RETURN(rc); + return rc; } static int brw_interpret(const struct lu_env *env, @@ -1946,7 +1920,6 @@ static int brw_interpret(const struct lu_env *env, struct osc_extent *tmp; struct cl_object *obj = NULL; struct client_obd *cli = aa->aa_cli; - ENTRY; rc = osc_brw_fini_request(req, rc); CDEBUG(D_INODE, "request %p aa %p rc %d\n", req, aa, rc); @@ -1970,7 +1943,7 @@ static int brw_interpret(const struct lu_env *env, } if (rc == 0) - RETURN(0); + return 0; else if (rc == -EAGAIN || rc == -EINPROGRESS) rc = -EIO; } @@ -2040,7 +2013,7 @@ static int brw_interpret(const struct lu_env *env, client_obd_list_unlock(&cli->cl_loi_list_lock); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(rc); + return rc; } /** @@ -2072,7 +2045,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, int rc; LIST_HEAD(rpc_list); - ENTRY; LASSERT(!list_empty(ext_list)); /* add pages into rpc_list to build BRW rpc */ @@ -2228,7 +2200,6 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli, */ ptlrpcd_add_req(req, pol, -1); rc = 0; - EXIT; out: if (mem_tight != 0) @@ -2257,7 +2228,7 @@ out: if (clerq && !IS_ERR(clerq)) cl_req_completion(env, clerq, rc); } - RETURN(rc); + return rc; } static int osc_set_lock_data_with_check(struct ldlm_lock *lock, @@ -2337,7 +2308,6 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, __u64 *flags, int agl, int rc) { int intent = *flags & LDLM_FL_HAS_INTENT; - ENTRY; if (intent) { /* The request was created before ldlm_cli_enqueue call. */ @@ -2347,6 +2317,8 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, &RMF_DLM_REP); LASSERT(rep != NULL); + rep->lock_policy_res1 = + ptlrpc_status_ntoh(rep->lock_policy_res1); if (rep->lock_policy_res1) rc = rep->lock_policy_res1; } @@ -2361,7 +2333,7 @@ static int osc_enqueue_fini(struct ptlrpc_request *req, struct ost_lvb *lvb, /* Call the update callback. */ rc = (*upcall)(cookie, rc); - RETURN(rc); + return rc; } static int osc_enqueue_interpret(const struct lu_env *env, @@ -2494,7 +2466,6 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, int match_lvb = (agl != 0 ? 0 : LDLM_FL_LVB_READY); ldlm_mode_t mode; int rc; - ENTRY; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother. */ @@ -2536,7 +2507,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, * Return -ECANCELED to tell the caller. */ ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); - RETURN(-ECANCELED); + return -ECANCELED; } else if (osc_set_lock_data_with_check(matched, einfo)) { *flags |= LDLM_FL_LVB_READY; /* addref the lock only if not async requests and PW @@ -2561,7 +2532,7 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, /* For async requests, decref the lock. */ ldlm_lock_decref(lockh, einfo->ei_mode); LDLM_LOCK_PUT(matched); - RETURN(ELDLM_OK); + return ELDLM_OK; } else { ldlm_lock_decref(lockh, mode); LDLM_LOCK_PUT(matched); @@ -2574,12 +2545,12 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_LDLM_ENQUEUE_LVB); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ldlm_prep_enqueue_req(exp, req, &cancels, 0); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } req_capsule_set_size(&req->rq_pill, &RMF_DLM_LVB, RCL_SERVER, @@ -2615,14 +2586,14 @@ int osc_enqueue_base(struct obd_export *exp, struct ldlm_res_id *res_id, } else if (intent) { ptlrpc_req_finished(req); } - RETURN(rc); + return rc; } rc = osc_enqueue_fini(req, lvb, upcall, cookie, flags, agl, rc); if (intent) ptlrpc_req_finished(req); - RETURN(rc); + return rc; } static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, @@ -2631,7 +2602,6 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, { struct ldlm_res_id res_id; int rc; - ENTRY; ostid_build_res_name(&oinfo->oi_md->lsm_oi, &res_id); rc = osc_enqueue_base(exp, &res_id, &oinfo->oi_flags, &oinfo->oi_policy, @@ -2639,7 +2609,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo, oinfo->oi_md->lsm_oinfo[0]->loi_kms_valid, oinfo->oi_cb_up, oinfo, einfo, oinfo->oi_lockh, rqset, rqset != NULL, 0); - RETURN(rc); + return rc; } int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, @@ -2650,10 +2620,9 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, struct obd_device *obd = exp->exp_obd; int lflags = *flags; ldlm_mode_t rc; - ENTRY; if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH)) - RETURN(-EIO); + return -EIO; /* Filesystem lock extents are extended to page boundaries so that * dealing with the page cache is a little smoother */ @@ -2674,35 +2643,32 @@ int osc_match_base(struct obd_export *exp, struct ldlm_res_id *res_id, if (!osc_set_data_with_check(lockh, data)) { if (!(lflags & LDLM_FL_TEST_LOCK)) ldlm_lock_decref(lockh, rc); - RETURN(0); + return 0; } } if (!(lflags & LDLM_FL_TEST_LOCK) && mode != rc) { ldlm_lock_addref(lockh, LCK_PR); ldlm_lock_decref(lockh, LCK_PW); } - RETURN(rc); + return rc; } - RETURN(rc); + return rc; } int osc_cancel_base(struct lustre_handle *lockh, __u32 mode) { - ENTRY; - if (unlikely(mode == LCK_GROUP)) ldlm_lock_decref_and_cancel(lockh, mode); else ldlm_lock_decref(lockh, mode); - RETURN(0); + return 0; } static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md, __u32 mode, struct lustre_handle *lockh) { - ENTRY; - RETURN(osc_cancel_base(lockh, mode)); + return osc_cancel_base(lockh, mode); } static int osc_cancel_unused(struct obd_export *exp, @@ -2726,7 +2692,6 @@ static int osc_statfs_interpret(const struct lu_env *env, struct osc_async_args *aa, int rc) { struct obd_statfs *msfs; - ENTRY; if (rc == -EBADR) /* The request has in fact never been sent @@ -2734,7 +2699,7 @@ static int osc_statfs_interpret(const struct lu_env *env, * Exit immediately since the caller is * aware of the problem and takes care * of the clean up */ - RETURN(rc); + return rc; if ((rc == -ENOTCONN || rc == -EAGAIN) && (aa->aa_oi->oi_flags & OBD_STATFS_NODELAY)) @@ -2751,7 +2716,7 @@ static int osc_statfs_interpret(const struct lu_env *env, *aa->aa_oi->oi_osfs = *msfs; out: rc = aa->aa_oi->oi_cb_up(aa->aa_oi, rc); - RETURN(rc); + return rc; } static int osc_statfs_async(struct obd_export *exp, @@ -2762,7 +2727,6 @@ static int osc_statfs_async(struct obd_export *exp, struct ptlrpc_request *req; struct osc_async_args *aa; int rc; - ENTRY; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2772,12 +2736,12 @@ static int osc_statfs_async(struct obd_export *exp, * timestamps are not ideal because they need time synchronization. */ req = ptlrpc_request_alloc(obd->u.cli.cl_import, &RQF_OST_STATFS); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2795,7 +2759,7 @@ static int osc_statfs_async(struct obd_export *exp, aa->aa_oi = oinfo; ptlrpc_set_add_req(rqset, req); - RETURN(0); + return 0; } static int osc_statfs(const struct lu_env *env, struct obd_export *exp, @@ -2806,7 +2770,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, struct ptlrpc_request *req; struct obd_import *imp = NULL; int rc; - ENTRY; /*Since the request might also come from lprocfs, so we need *sync this with client_disconnect_export Bug15684*/ @@ -2815,7 +2778,7 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, imp = class_import_get(obd->u.cli.cl_import); up_read(&obd->u.cli.cl_sem); if (!imp) - RETURN(-ENODEV); + return -ENODEV; /* We could possibly pass max_age in the request (as an absolute * timestamp or a "seconds.usec ago") so the target can avoid doing @@ -2828,12 +2791,12 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, class_import_put(imp); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_STATFS); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } ptlrpc_request_set_replen(req); req->rq_request_portal = OST_CREATE_PORTAL; @@ -2856,7 +2819,6 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp, *osfs = *msfs; - EXIT; out: ptlrpc_req_finished(req); return rc; @@ -2874,20 +2836,19 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) struct lov_user_md_v3 lum, *lumk; struct lov_user_ost_data_v1 *lmm_objects; int rc = 0, lum_size; - ENTRY; if (!lsm) - RETURN(-ENODATA); + return -ENODATA; /* we only need the header part from user space to get lmm_magic and * lmm_stripe_count, (the header part is common to v1 and v3) */ lum_size = sizeof(struct lov_user_md_v1); if (copy_from_user(&lum, lump, lum_size)) - RETURN(-EFAULT); + return -EFAULT; if ((lum.lmm_magic != LOV_USER_MAGIC_V1) && (lum.lmm_magic != LOV_USER_MAGIC_V3)) - RETURN(-EINVAL); + return -EINVAL; /* lov_user_md_vX and lov_mds_md_vX must have the same size */ LASSERT(sizeof(struct lov_user_md_v1) == sizeof(struct lov_mds_md_v1)); @@ -2900,7 +2861,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic); OBD_ALLOC(lumk, lum_size); if (!lumk) - RETURN(-ENOMEM); + return -ENOMEM; if (lum.lmm_magic == LOV_USER_MAGIC_V1) lmm_objects = @@ -2922,7 +2883,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump) if (lumk != &lum) OBD_FREE(lumk, lum_size); - RETURN(rc); + return rc; } @@ -2932,7 +2893,6 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, struct obd_device *obd = exp->exp_obd; struct obd_ioctl_data *data = karg; int err = 0; - ENTRY; if (!try_module_get(THIS_MODULE)) { CERROR("Can't get module. Is it alive?"); @@ -3016,15 +2976,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, obd_count keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm) { - ENTRY; if (!vallen || !val) - RETURN(-EFAULT); + return -EFAULT; if (KEY_IS(KEY_LOCK_TO_STRIPE)) { __u32 *stripe = val; *vallen = sizeof(*stripe); *stripe = 0; - RETURN(0); + return 0; } else if (KEY_IS(KEY_LAST_ID)) { struct ptlrpc_request *req; obd_id *reply; @@ -3034,14 +2993,14 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_OST_GET_INFO_LAST_ID); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_GET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3060,7 +3019,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp, *((obd_id *)val) = *reply; out: ptlrpc_req_finished(req); - RETURN(rc); + return rc; } else if (KEY_IS(KEY_FIEMAP)) { struct ll_fiemap_info_key *fm_key = (struct ll_fiemap_info_key *)key; @@ -3142,10 +3101,10 @@ fini_req: drop_lock: if (mode) ldlm_lock_decref(&lockh, LCK_PR); - RETURN(rc); + return rc; } - RETURN(-EINVAL); + return -EINVAL; } static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, @@ -3157,25 +3116,24 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, struct obd_import *imp = class_exp2cliimp(exp); char *tmp; int rc; - ENTRY; OBD_FAIL_TIMEOUT(OBD_FAIL_OSC_SHUTDOWN, 10); if (KEY_IS(KEY_CHECKSUM)) { if (vallen != sizeof(int)) - RETURN(-EINVAL); + return -EINVAL; exp->exp_obd->u.cli.cl_checksum = (*(int *)val) ? 1 : 0; - RETURN(0); + return 0; } if (KEY_IS(KEY_SPTLRPC_CONF)) { sptlrpc_conf_client_adapt(obd); - RETURN(0); + return 0; } if (KEY_IS(KEY_FLUSH_CTX)) { sptlrpc_import_flush_my_ctx(imp); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_SET)) { @@ -3192,7 +3150,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, list_add(&cli->cl_lru_osc, &cli->cl_cache->ccc_lru); spin_unlock(&cli->cl_cache->ccc_lru_lock); - RETURN(0); + return 0; } if (KEY_IS(KEY_CACHE_LRU_SHRINK)) { @@ -3202,11 +3160,11 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, nr = osc_lru_shrink(cli, min(nr, target)); *(int *)val -= nr; - RETURN(0); + return 0; } if (!set && !KEY_IS(KEY_GRANT_SHRINK)) - RETURN(-EINVAL); + return -EINVAL; /* We pass all other commands directly to OST. Since nobody calls osc methods directly and everybody is supposed to go through LOV, we @@ -3219,7 +3177,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, &RQF_OST_SET_GRANT_INFO : &RQF_OBD_SET_INFO); if (req == NULL) - RETURN(-ENOMEM); + return -ENOMEM; req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY, RCL_CLIENT, keylen); @@ -3229,7 +3187,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO); if (rc) { ptlrpc_request_free(req); - RETURN(rc); + return rc; } tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY); @@ -3248,7 +3206,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, OBDO_ALLOC(oa); if (!oa) { ptlrpc_req_finished(req); - RETURN(-ENOMEM); + return -ENOMEM; } *oa = ((struct ost_body *)val)->oa; aa->aa_oa = oa; @@ -3263,7 +3221,7 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp, } else ptlrpcd_add_req(req, PDL_POLICY_ROUND, -1); - RETURN(0); + return 0; } @@ -3280,8 +3238,6 @@ static int osc_llog_finish(struct obd_device *obd, int count) { struct llog_ctxt *ctxt; - ENTRY; - ctxt = llog_get_context(obd, LLOG_MDS_OST_ORIG_CTXT); if (ctxt) { llog_cat_close(NULL, ctxt->loc_handle); @@ -3291,7 +3247,7 @@ static int osc_llog_finish(struct obd_device *obd, int count) ctxt = llog_get_context(obd, LLOG_SIZE_REPL_CTXT); if (ctxt) llog_cleanup(NULL, ctxt); - RETURN(0); + return 0; } static int osc_reconnect(const struct lu_env *env, @@ -3317,7 +3273,7 @@ static int osc_reconnect(const struct lu_env *env, data->ocd_version, data->ocd_grant, lost_grant); } - RETURN(0); + return 0; } static int osc_disconnect(struct obd_export *exp) @@ -3369,7 +3325,6 @@ static int osc_import_event(struct obd_device *obd, struct client_obd *cli; int rc = 0; - ENTRY; LASSERT(imp->imp_obd == obd); switch (event) { @@ -3433,7 +3388,7 @@ static int osc_import_event(struct obd_device *obd, CERROR("Unknown import event %d\n", event); LBUG(); } - RETURN(rc); + return rc; } /** @@ -3457,9 +3412,9 @@ static int osc_cancel_for_recovery(struct ldlm_lock *lock) (lock->l_granted_mode == LCK_PR || lock->l_granted_mode == LCK_CR) && (osc_dlm_lock_pageref(lock) == 0)) - RETURN(1); + return 1; - RETURN(0); + return 0; } static int brw_queue_work(const struct lu_env *env, void *data) @@ -3469,7 +3424,7 @@ static int brw_queue_work(const struct lu_env *env, void *data) CDEBUG(D_CACHE, "Run writeback work for client obd %p.\n", cli); osc_io_unplug(env, cli, NULL, PDL_POLICY_SAME); - RETURN(0); + return 0; } int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3478,11 +3433,10 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) struct client_obd *cli = &obd->u.cli; void *handler; int rc; - ENTRY; rc = ptlrpcd_addref(); if (rc) - RETURN(rc); + return rc; rc = client_obd_setup(obd, lcfg); if (rc) @@ -3517,7 +3471,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) INIT_LIST_HEAD(&cli->cl_grant_shrink_list); ns_register_cancel(obd->obd_namespace, osc_cancel_for_recovery); - RETURN(rc); + return rc; out_ptlrpcd_work: ptlrpcd_destroy_work(handler); @@ -3525,13 +3479,12 @@ out_client_setup: client_obd_cleanup(obd); out_ptlrpcd: ptlrpcd_decref(); - RETURN(rc); + return rc; } static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - ENTRY; switch (stage) { case OBD_CLEANUP_EARLY: { @@ -3570,7 +3523,7 @@ static int osc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) break; } } - RETURN(rc); + return rc; } int osc_cleanup(struct obd_device *obd) @@ -3578,8 +3531,6 @@ int osc_cleanup(struct obd_device *obd) struct client_obd *cli = &obd->u.cli; int rc; - ENTRY; - /* lru cleanup */ if (cli->cl_cache != NULL) { LASSERT(atomic_read(&cli->cl_cache->ccc_users) > 0); @@ -3597,7 +3548,7 @@ int osc_cleanup(struct obd_device *obd) rc = client_obd_cleanup(obd); ptlrpcd_decref(); - RETURN(rc); + return rc; } int osc_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg) @@ -3671,7 +3622,6 @@ int __init osc_init(void) { struct lprocfs_static_vars lvars = { 0 }; int rc; - ENTRY; /* print an address of _any_ initialized kernel symbol from this * module, to allow debugging with gdb that doesn't support data @@ -3679,6 +3629,8 @@ int __init osc_init(void) CDEBUG(D_INFO, "Lustre OSC module (%p).\n", &osc_caches); rc = lu_kmem_init(osc_caches); + if (rc) + return rc; lprocfs_osc_init_vars(&lvars); @@ -3686,13 +3638,13 @@ int __init osc_init(void) LUSTRE_OSC_NAME, &osc_device_type); if (rc) { lu_kmem_fini(osc_caches); - RETURN(rc); + return rc; } spin_lock_init(&osc_ast_guard); lockdep_set_class(&osc_ast_guard, &osc_ast_guard_class); - RETURN(rc); + return rc; } static void /*__exit*/ osc_exit(void) @@ -3704,5 +3656,7 @@ static void /*__exit*/ osc_exit(void) MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>"); MODULE_DESCRIPTION("Lustre Object Storage Client (OSC)"); MODULE_LICENSE("GPL"); +MODULE_VERSION(LUSTRE_VERSION_STRING); -cfs_module(osc, LUSTRE_VERSION_STRING, osc_init, osc_exit); +module_init(osc_init); +module_exit(osc_exit); |