diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/ldlm/ldlm_request.c')
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_request.c | 112 |
1 files changed, 62 insertions, 50 deletions
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 8867dc175325..9ce437b18793 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -423,8 +423,10 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, lock = ldlm_lock_create(ns, res_id, type, mode, &cbs, data, lvb_len, lvb_type); - if (unlikely(!lock)) - GOTO(out_nolock, err = -ENOMEM); + if (unlikely(!lock)) { + err = -ENOMEM; + goto out_nolock; + } ldlm_lock2handle(lock, lockh); @@ -444,7 +446,7 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, err = ldlm_lock_enqueue(ns, &lock, policy, flags); if (unlikely(err != ELDLM_OK)) - GOTO(out, err); + goto out; if (policy != NULL) *policy = lock->l_policy_data; @@ -510,7 +512,7 @@ static void failed_lock_cleanup(struct ldlm_namespace *ns, int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode, __u64 *flags, void *lvb, __u32 lvb_len, - struct lustre_handle *lockh,int rc) + struct lustre_handle *lockh, int rc) { struct ldlm_namespace *ns = exp->exp_obd->obd_namespace; int is_replay = *flags & LDLM_FL_REPLAY; @@ -535,13 +537,15 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc == ELDLM_LOCK_ABORTED ? "ABORTED" : "FAILED"); if (rc != ELDLM_LOCK_ABORTED) - GOTO(cleanup, rc); + goto cleanup; } /* Before we return, swab the reply */ reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - if (reply == NULL) - GOTO(cleanup, rc = -EPROTO); + if (reply == NULL) { + rc = -EPROTO; + goto cleanup; + } if (lvb_len != 0) { LASSERT(lvb != NULL); @@ -550,12 +554,14 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, RCL_SERVER); if (size < 0) { LDLM_ERROR(lock, "Fail to get lvb_len, rc = %d", size); - GOTO(cleanup, rc = size); + rc = size; + goto cleanup; } else if (unlikely(size > lvb_len)) { LDLM_ERROR(lock, "Replied LVB is larger than " "expectation, expected = %d, replied = %d", lvb_len, size); - GOTO(cleanup, rc = -EINVAL); + rc = -EINVAL; + goto cleanup; } } @@ -563,7 +569,9 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, if (lvb_len != 0) rc = ldlm_fill_lvb(lock, &req->rq_pill, RCL_SERVER, lvb, size); - GOTO(cleanup, rc = (rc != 0 ? rc : ELDLM_LOCK_ABORTED)); + if (rc == 0) + rc = ELDLM_LOCK_ABORTED; + goto cleanup; } /* lock enqueued on the server */ @@ -616,8 +624,10 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc = ldlm_lock_change_resource(ns, lock, &reply->lock_desc.l_resource.lr_name); - if (rc || lock->l_resource == NULL) - GOTO(cleanup, rc = -ENOMEM); + if (rc || lock->l_resource == NULL) { + rc = -ENOMEM; + goto cleanup; + } LDLM_DEBUG(lock, "client-side enqueue, new resource"); } if (with_policy) @@ -629,7 +639,8 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, &reply->lock_desc.l_policy_data, &lock->l_policy_data); if (type != LDLM_PLAIN) - LDLM_DEBUG(lock,"client-side enqueue, new policy data"); + LDLM_DEBUG(lock, + "client-side enqueue, new policy data"); } if ((*flags) & LDLM_FL_AST_SENT || @@ -657,7 +668,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, unlock_res_and_lock(lock); if (rc < 0) { cleanup_phase = 1; - GOTO(cleanup, rc); + goto cleanup; } } @@ -876,21 +887,8 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, /* for the local lock, add the reference */ ldlm_lock_addref_internal(lock, einfo->ei_mode); ldlm_lock2handle(lock, lockh); - if (policy != NULL) { - /* INODEBITS_INTEROP: If the server does not support - * inodebits, we will request a plain lock in the - * descriptor (ldlm_lock2desc() below) but use an - * inodebits lock internally with both bits set. - */ - if (einfo->ei_type == LDLM_IBITS && - !(exp_connect_flags(exp) & - OBD_CONNECT_IBITS)) - lock->l_policy_data.l_inodebits.bits = - MDS_INODELOCK_LOOKUP | - MDS_INODELOCK_UPDATE; - else + if (policy != NULL) lock->l_policy_data = *policy; - } if (einfo->ei_type == LDLM_EXTENT) lock->l_req_extent = policy->l_extent; @@ -1049,14 +1047,18 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc != ELDLM_OK) - GOTO(out, rc); + goto out; reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - if (reply == NULL) - GOTO(out, rc = -EPROTO); + if (reply == NULL) { + rc = -EPROTO; + goto out; + } - if (req->rq_status) - GOTO(out, rc = req->rq_status); + if (req->rq_status) { + rc = req->rq_status; + goto out; + } res = ldlm_lock_convert(lock, new_mode, &reply->lock_flags); if (res != NULL) { @@ -1067,7 +1069,7 @@ int ldlm_cli_convert(struct lustre_handle *lockh, int new_mode, __u32 *flags) rc = lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC, NULL); if (rc) - GOTO(out, rc); + goto out; } } else { rc = LUSTRE_EDEADLK; @@ -1191,8 +1193,10 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, } req = ptlrpc_request_alloc(imp, &RQF_LDLM_CANCEL); - if (req == NULL) - GOTO(out, rc = -ENOMEM); + if (req == NULL) { + rc = -ENOMEM; + goto out; + } req_capsule_filled_sizes(&req->rq_pill, RCL_CLIENT); req_capsule_set_size(&req->rq_pill, &RMF_DLM_REQ, RCL_CLIENT, @@ -1201,7 +1205,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, rc = ptlrpc_request_pack(req, LUSTRE_DLM_VERSION, LDLM_CANCEL); if (rc) { ptlrpc_request_free(req); - GOTO(out, rc); + goto out; } req->rq_request_portal = LDLM_CANCEL_REQUEST_PORTAL; @@ -1214,7 +1218,7 @@ int ldlm_cli_cancel_req(struct obd_export *exp, struct list_head *cancels, if (flags & LCF_ASYNC) { ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1); sent = count; - GOTO(out, 0); + goto out; } else { rc = ptlrpc_queue_wait(req); } @@ -1261,8 +1265,7 @@ int ldlm_cli_update_pool(struct ptlrpc_request *req) __u32 new_limit; if (unlikely(!req->rq_import || !req->rq_import->imp_obd || - !imp_connect_lru_resize(req->rq_import))) - { + !imp_connect_lru_resize(req->rq_import))) { /* * Do nothing for corner cases. */ @@ -1974,22 +1977,28 @@ int ldlm_resource_foreach(struct ldlm_resource *res, ldlm_iterator_t iter, list_for_each_safe(tmp, next, &res->lr_granted) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); - if (iter(lock, closure) == LDLM_ITER_STOP) - GOTO(out, rc = LDLM_ITER_STOP); + if (iter(lock, closure) == LDLM_ITER_STOP) { + rc = LDLM_ITER_STOP; + goto out; + } } list_for_each_safe(tmp, next, &res->lr_converting) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); - if (iter(lock, closure) == LDLM_ITER_STOP) - GOTO(out, rc = LDLM_ITER_STOP); + if (iter(lock, closure) == LDLM_ITER_STOP) { + rc = LDLM_ITER_STOP; + goto out; + } } list_for_each_safe(tmp, next, &res->lr_waiting) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); - if (iter(lock, closure) == LDLM_ITER_STOP) - GOTO(out, rc = LDLM_ITER_STOP); + if (iter(lock, closure) == LDLM_ITER_STOP) { + rc = LDLM_ITER_STOP; + goto out; + } } out: unlock_res(res); @@ -2094,12 +2103,14 @@ static int replay_lock_interpret(const struct lu_env *env, atomic_dec(&req->rq_import->imp_replay_inflight); if (rc != ELDLM_OK) - GOTO(out, rc); + goto out; reply = req_capsule_server_get(&req->rq_pill, &RMF_DLM_REP); - if (reply == NULL) - GOTO(out, rc = -EPROTO); + if (reply == NULL) { + rc = -EPROTO; + goto out; + } lock = ldlm_handle2lock(&aa->lock_handle); if (!lock) { @@ -2108,7 +2119,8 @@ static int replay_lock_interpret(const struct lu_env *env, aa->lock_handle.cookie, reply->lock_handle.cookie, req->rq_export->exp_client_uuid.uuid, libcfs_id2str(req->rq_peer)); - GOTO(out, rc = -ESTALE); + rc = -ESTALE; + goto out; } /* Key change rehash lock in per-export hash with new key */ |