if (create) {
OBD_ALLOC(imp_conn, sizeof(*imp_conn));
- if (!imp_conn)
- GOTO(out_put, rc = -ENOMEM);
+ if (!imp_conn) {
+ rc = -ENOMEM;
+ goto out_put;
+ }
}
spin_lock(&imp->imp_lock);
imp, imp->imp_obd->obd_name, uuid->uuid,
(priority ? ", moved to head" : ""));
spin_unlock(&imp->imp_lock);
- GOTO(out_free, rc = 0);
+ rc = 0;
+ goto out_free;
}
}
/* No existing import connection found for \a uuid. */
(priority ? "head" : "tail"));
} else {
spin_unlock(&imp->imp_lock);
- GOTO(out_free, rc = -ENOENT);
+ rc = -ENOENT;
+ goto out_free;
}
spin_unlock(&imp->imp_lock);
spin_lock(&imp->imp_lock);
if (list_empty(&imp->imp_conn_list)) {
LASSERT(!imp->imp_connection);
- GOTO(out, rc);
+ goto out;
}
list_for_each_entry(imp_conn, &imp->imp_conn_list, oic_item) {
if (imp->imp_state != LUSTRE_IMP_CLOSED &&
imp->imp_state != LUSTRE_IMP_DISCON) {
CERROR("can't remove current connection\n");
- GOTO(out, rc = -EBUSY);
+ rc = -EBUSY;
+ goto out;
}
ptlrpc_connection_put(imp->imp_connection);
rc = ldlm_get_ref();
if (rc) {
CERROR("ldlm_get_ref failed: %d\n", rc);
- GOTO(err, rc);
+ goto err;
}
ptlrpc_init_client(rq_portal, rp_portal, name,
&obddev->obd_ldlm_client);
imp = class_new_import(obddev);
- if (imp == NULL)
- GOTO(err_ldlm, rc = -ENOENT);
+ if (imp == NULL) {
+ rc = -ENOENT;
+ goto err_ldlm;
+ }
imp->imp_client = &obddev->obd_ldlm_client;
imp->imp_connect_op = connect_op;
memcpy(cli->cl_target_uuid.uuid, lustre_cfg_buf(lcfg, 1),
rc = client_import_add_conn(imp, &server_uuid, 1);
if (rc) {
CERROR("can't add initial connection\n");
- GOTO(err_import, rc);
+ goto err_import;
}
cli->cl_import = imp;
if (obddev->obd_namespace == NULL) {
CERROR("Unable to create client namespace - %s\n",
obddev->obd_name);
- GOTO(err_import, rc = -ENOMEM);
+ rc = -ENOMEM;
+ goto err_import;
}
cli->cl_qchk_stat = CL_NOT_QUOTACHECKED;
*exp = NULL;
down_write(&cli->cl_sem);
- if (cli->cl_conn_count > 0 )
- GOTO(out_sem, rc = -EALREADY);
+ if (cli->cl_conn_count > 0) {
+ rc = -EALREADY;
+ goto out_sem;
+ }
rc = class_connect(&conn, obd, cluuid);
if (rc)
- GOTO(out_sem, rc);
+ goto out_sem;
cli->cl_conn_count++;
*exp = class_conn2export(&conn);
imp->imp_dlm_handle = conn;
rc = ptlrpc_init_import(imp);
if (rc != 0)
- GOTO(out_ldlm, rc);
+ goto out_ldlm;
ocd = &imp->imp_connect_data;
if (data) {
rc = ptlrpc_connect_import(imp);
if (rc != 0) {
LASSERT(imp->imp_state == LUSTRE_IMP_DISCON);
- GOTO(out_ldlm, rc);
+ goto out_ldlm;
}
LASSERT(*exp != NULL && (*exp)->exp_connection);
if (!cli->cl_conn_count) {
CERROR("disconnecting disconnected device (%s)\n",
obd->obd_name);
- GOTO(out_disconnect, rc = -EINVAL);
+ rc = -EINVAL;
+ goto out_disconnect;
}
cli->cl_conn_count--;
- if (cli->cl_conn_count)
- GOTO(out_disconnect, rc = 0);
+ if (cli->cl_conn_count) {
+ rc = 0;
+ goto out_disconnect;
+ }
/* Mark import deactivated now, so we don't try to reconnect if any
* of the cleanup RPCs fails (e.g. LDLM cancel, etc). We don't
lock = search_queue(&res->lr_granted, &mode, policy, old_lock,
flags, unref);
- if (lock != NULL)
- GOTO(out, rc = 1);
- if (flags & LDLM_FL_BLOCK_GRANTED)
- GOTO(out, rc = 0);
+ if (lock != NULL) {
+ rc = 1;
+ goto out;
+ }
+ if (flags & LDLM_FL_BLOCK_GRANTED) {
+ rc = 0;
+ goto out;
+ }
lock = search_queue(&res->lr_converting, &mode, policy, old_lock,
flags, unref);
- if (lock != NULL)
- GOTO(out, rc = 1);
+ if (lock != NULL) {
+ rc = 1;
+ goto out;
+ }
lock = search_queue(&res->lr_waiting, &mode, policy, old_lock,
flags, unref);
- if (lock != NULL)
- GOTO(out, rc = 1);
+ if (lock != NULL) {
+ rc = 1;
+ goto out;
+ }
out:
unlock_res(res);
if (lock != NULL) {
lock_res_and_lock(lock);
if (lock->l_flags & LDLM_FL_GONE_MASK)
- GOTO(out, mode);
+ goto out;
if (lock->l_flags & LDLM_FL_CBPENDING &&
lock->l_readers == 0 && lock->l_writers == 0)
- GOTO(out, mode);
+ goto out;
if (bits)
*bits = lock->l_policy_data.l_inodebits.bits;
/* if this is the extent lock, allocate the interval tree node */
if (type == LDLM_EXTENT) {
if (ldlm_interval_alloc(lock) == NULL)
- GOTO(out, 0);
+ goto out;
}
if (lvb_len) {
lock->l_lvb_len = lvb_len;
OBD_ALLOC(lock->l_lvb_data, lvb_len);
if (lock->l_lvb_data == NULL)
- GOTO(out, 0);
+ goto out;
}
lock->l_lvb_type = lvb_type;
if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_NEW_LOCK))
- GOTO(out, 0);
+ goto out;
return lock;
* need to do anything else. */
*flags &= ~(LDLM_FL_BLOCK_GRANTED |
LDLM_FL_BLOCK_CONV | LDLM_FL_BLOCK_WAIT);
- GOTO(out, ELDLM_OK);
+ goto out;
}
ldlm_resource_unlink_lock(lock);
if (res->lr_type == LDLM_EXTENT && lock->l_tree_node == NULL) {
if (node == NULL) {
ldlm_lock_destroy_nolock(lock);
- GOTO(out, rc = -ENOMEM);
+ rc = -ENOMEM;
+ goto out;
}
INIT_LIST_HEAD(&node->li_group);
ldlm_resource_add_lock(res, &res->lr_waiting, lock);
else
ldlm_grant_lock(lock, NULL);
- GOTO(out, ELDLM_OK);
+ goto out;
} else {
CERROR("This is client-side-only module, cannot handle "
"LDLM_NAMESPACE_SERVER resource type lock.\n");
* to keep the number of requests in flight to ns_max_parallel_ast */
arg->set = ptlrpc_prep_fcset(ns->ns_max_parallel_ast ? : UINT_MAX,
work_ast_lock, arg);
- if (arg->set == NULL)
- GOTO(out, rc = -ENOMEM);
+ if (arg->set == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
ptlrpc_set_wait(arg->set);
ptlrpc_set_destroy(arg->set);
rc = atomic_read(&arg->restart) ? -ERESTART : 0;
- GOTO(out, rc);
+ goto out;
out:
OBD_FREE_PTR(arg);
return rc;
lvb_len = req_capsule_get_size(&req->rq_pill, &RMF_DLM_LVB, RCL_CLIENT);
if (lvb_len < 0) {
LDLM_ERROR(lock, "Fail to get lvb_len, rc = %d", lvb_len);
- GOTO(out, rc = lvb_len);
+ rc = lvb_len;
+ goto out;
} else if (lvb_len > 0) {
if (lock->l_lvb_len > 0) {
/* for extent lock, lvb contains ost_lvb{}. */
"expectation, expected = %d, "
"replied = %d",
lock->l_lvb_len, lvb_len);
- GOTO(out, rc = -EINVAL);
+ rc = -EINVAL;
+ goto out;
}
} else if (ldlm_has_layout(lock)) { /* for layout lock, lvb has
* variable length */
OBD_ALLOC(lvb_data, lvb_len);
if (lvb_data == NULL) {
LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
- GOTO(out, rc = -ENOMEM);
+ rc = -ENOMEM;
+ goto out;
}
lock_res_and_lock(lock);
/* bug 11300: the lock has already been granted */
unlock_res_and_lock(lock);
LDLM_DEBUG(lock, "Double grant race happened");
- GOTO(out, rc = 0);
+ rc = 0;
+ goto out;
}
/* If we receive the completion AST before the actual enqueue returned,
&dlm_req->lock_desc.l_resource.lr_name);
if (rc < 0) {
LDLM_ERROR(lock, "Failed to allocate resource");
- GOTO(out, rc);
+ goto out;
}
LDLM_DEBUG(lock, "completion AST, new resource");
CERROR("change resource!\n");
lock->l_lvb_data, lvb_len);
if (rc < 0) {
unlock_res_and_lock(lock);
- GOTO(out, rc);
+ goto out;
}
}
LDLM_DEBUG_NOLOCK("client completion callback handler END (lock %p)",
lock);
- GOTO(out, rc);
+ goto out;
out:
if (rc < 0) {
rc = ldlm_init_flock_export(exp);
if (rc)
- GOTO(err, rc);
+ goto err;
return 0;
err:
rc = ldlm_proc_setup();
if (rc != 0)
- GOTO(out, rc);
+ goto out;
memset(&conf, 0, sizeof(conf));
conf = (typeof(conf)) {
CERROR("failed to start service\n");
rc = PTR_ERR(ldlm_state->ldlm_cb_service);
ldlm_state->ldlm_cb_service = NULL;
- GOTO(out, rc);
+ goto out;
}
OBD_ALLOC(blp, sizeof(*blp));
- if (blp == NULL)
- GOTO(out, rc = -ENOMEM);
+ if (blp == NULL) {
+ rc = -ENOMEM;
+ goto out;
+ }
ldlm_state->ldlm_bl_pool = blp;
spin_lock_init(&blp->blp_lock);
for (i = 0; i < blp->blp_min_threads; i++) {
rc = ldlm_bl_thread_start(blp);
if (rc < 0)
- GOTO(out, rc);
+ goto out;
}
rc = ldlm_pools_init();
if (rc) {
CERROR("Failed to initialize LDLM pools: %d\n", rc);
- GOTO(out, rc);
+ goto out;
}
return 0;
if (parent_ns_proc == NULL) {
CERROR("%s: proc entry is not initialized\n",
ldlm_ns_name(ns));
- GOTO(out_free_name, rc = -EINVAL);
+ rc = -EINVAL;
+ goto out_free_name;
}
pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
NULL, NULL);
CERROR("LProcFS failed in ldlm-pool-init\n");
rc = PTR_ERR(pl->pl_proc_dir);
pl->pl_proc_dir = NULL;
- GOTO(out_free_name, rc);
+ goto out_free_name;
}
var_name[MAX_STRING_SIZE] = '\0';
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
- if (!pl->pl_stats)
- GOTO(out_free_name, rc = -ENOMEM);
+ if (!pl->pl_stats) {
+ rc = -ENOMEM;
+ goto out_free_name;
+ }
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_GRANTED_STAT,
LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
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);
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;
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);
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;
}
}
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));
+ rc = (rc != 0 ? rc : ELDLM_LOCK_ABORTED);
+ goto cleanup;
}
/* lock enqueued on the server */
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)
unlock_res_and_lock(lock);
if (rc < 0) {
cleanup_phase = 1;
- GOTO(cleanup, rc);
+ goto cleanup;
}
}
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) {
rc = lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC,
NULL);
if (rc)
- GOTO(out, rc);
+ goto out;
}
} else {
rc = LUSTRE_EDEADLK;
}
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,
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;
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);
}
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);
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) {
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 */
if (IS_ERR(ldlm_type_proc_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
rc = PTR_ERR(ldlm_type_proc_dir);
- GOTO(err, rc);
+ goto err;
}
ldlm_ns_proc_dir = lprocfs_register("namespaces",
if (IS_ERR(ldlm_ns_proc_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
rc = PTR_ERR(ldlm_ns_proc_dir);
- GOTO(err_type, rc);
+ goto err_type;
}
ldlm_svc_proc_dir = lprocfs_register("services",
if (IS_ERR(ldlm_svc_proc_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
rc = PTR_ERR(ldlm_svc_proc_dir);
- GOTO(err_ns, rc);
+ goto err_ns;
}
rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);
nsd = &ldlm_ns_hash_defs[idx];
if (nsd->nsd_type == LDLM_NS_TYPE_UNKNOWN) {
CERROR("Unknown type %d for ns %s\n", ns_type, name);
- GOTO(out_ref, NULL);
+ goto out_ref;
}
if (nsd->nsd_type == ns_type)
OBD_ALLOC_PTR(ns);
if (!ns)
- GOTO(out_ref, NULL);
+ goto out_ref;
ns->ns_rs_hash = cfs_hash_create(name,
nsd->nsd_all_bits, nsd->nsd_all_bits,
CFS_HASH_SPIN_BKTLOCK |
CFS_HASH_NO_ITEMREF);
if (ns->ns_rs_hash == NULL)
- GOTO(out_ns, NULL);
+ goto out_ns;
cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, idx) {
nsb = cfs_hash_bd_extra_get(ns->ns_rs_hash, &bd);
rc = ldlm_namespace_proc_register(ns);
if (rc != 0) {
CERROR("Can't initialize ns proc, rc %d\n", rc);
- GOTO(out_hash, rc);
+ goto out_hash;
}
idx = ldlm_namespace_nr_read(client);
rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client);
if (rc) {
CERROR("Can't initialize lock pool, rc %d\n", rc);
- GOTO(out_proc, rc);
+ goto out_proc;
}
ldlm_namespace_register(ns, client);
"namespace with %d resources in use, "
"(rc=%d)\n", ldlm_ns_name(ns),
atomic_read(&ns->ns_bref), rc);
- GOTO(force_wait, rc);
+ goto force_wait;
}
if (atomic_read(&ns->ns_bref)) {