diff --git a/drivers/staging/lustre/lustre/ldlm/interval_tree.c b/drivers/staging/lustre/lustre/ldlm/interval_tree.c index a3d7a7292417..eab2bd60241b 100644 --- a/drivers/staging/lustre/lustre/ldlm/interval_tree.c +++ b/drivers/staging/lustre/lustre/ldlm/interval_tree.c @@ -73,6 +73,7 @@ static inline int extent_compare(struct interval_node_extent *e1, struct interval_node_extent *e2) { int rc; + if (e1->start == e2->start) { if (e1->end < e2->end) rc = -1; @@ -321,6 +322,7 @@ static void interval_insert_color(struct interval_node *node, /* Parent is RED, so gparent must not be NULL */ if (node_is_left_child(parent)) { struct interval_node *uncle; + uncle = gparent->in_right; if (uncle && node_is_red(uncle)) { uncle->in_color = INTERVAL_BLACK; @@ -340,6 +342,7 @@ static void interval_insert_color(struct interval_node *node, __rotate_right(gparent, root); } else { struct interval_node *uncle; + uncle = gparent->in_left; if (uncle && node_is_red(uncle)) { uncle->in_color = INTERVAL_BLACK; @@ -427,6 +430,7 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_right)) { struct interval_node *o_left; + o_left = tmp->in_left; if (o_left) o_left->in_color = INTERVAL_BLACK; @@ -458,6 +462,7 @@ static void interval_erase_color(struct interval_node *node, } else { if (node_is_black_or_0(tmp->in_left)) { struct interval_node *o_right; + o_right = tmp->in_right; if (o_right) o_right->in_color = INTERVAL_BLACK; diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c index 0c09b611f4a6..a89eebaedabf 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c @@ -182,7 +182,9 @@ void ldlm_extent_add_lock(struct ldlm_resource *res, root = &res->lr_itree[idx].lit_root; found = interval_insert(&node->li_node, root); if (found) { /* The policy group found. */ - struct ldlm_interval *tmp = ldlm_interval_detach(lock); + struct ldlm_interval *tmp; + + tmp = ldlm_interval_detach(lock); LASSERT(tmp != NULL); ldlm_interval_free(tmp); ldlm_interval_attach(to_ldlm_interval(found), lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index e00478b9b50b..efb36354150f 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -291,6 +291,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, int first_enq, } } else { int reprocess_failed = 0; + lockmode_verify(mode); /* This loop determines if there are existing locks diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h index 06cf6d282e65..b3009cc1ad9c 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h @@ -214,6 +214,7 @@ static inline struct ldlm_extent * ldlm_interval_extent(struct ldlm_interval *node) { struct ldlm_lock *lock; + LASSERT(!list_empty(&node->li_group)); lock = list_entry(node->li_group.next, struct ldlm_lock, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c index 2c4af89eee7e..c0e54898a2e1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c @@ -226,6 +226,7 @@ EXPORT_SYMBOL(ldlm_lock_put); int ldlm_lock_remove_from_lru_nolock(struct ldlm_lock *lock) { int rc = 0; + if (!list_empty(&lock->l_lru)) { struct ldlm_namespace *ns = ldlm_lock_to_ns(lock); @@ -858,6 +859,7 @@ void ldlm_lock_decref_internal(struct ldlm_lock *lock, __u32 mode) void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode) { struct ldlm_lock *lock = __ldlm_handle2lock(lockh, 0); + LASSERTF(lock != NULL, "Non-existing lock: %#llx\n", lockh->cookie); ldlm_lock_decref_internal(lock, mode); LDLM_LOCK_PUT(lock); @@ -1286,6 +1288,7 @@ ldlm_mode_t ldlm_lock_match(struct ldlm_namespace *ns, __u64 flags, __u64 wait_flags = LDLM_FL_LVB_READY | LDLM_FL_DESTROYED | LDLM_FL_FAIL_NOTIFIED; struct l_wait_info lwi; + if (lock->l_completion_ast) { int err = lock->l_completion_ast(lock, LDLM_FL_WAIT_NOREPROC, @@ -2219,6 +2222,7 @@ void _ldlm_lock_debug(struct ldlm_lock *lock, nid = libcfs_nid2str(exp->exp_connection->c_peer.nid); } else if (exp && exp->exp_obd != NULL) { struct obd_import *imp = exp->exp_obd->u.cli.cl_import; + nid = libcfs_nid2str(imp->imp_connection->c_peer.nid); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c index 5fb9d842f7b9..870dac1de484 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c @@ -190,6 +190,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req, if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CANCEL_BL_CB_RACE)) { int to = cfs_time_seconds(1); + while (to > 0) { set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(to); @@ -884,6 +885,7 @@ void ldlm_put_ref(void) mutex_lock(&ldlm_ref_mutex); if (ldlm_refcount == 1) { int rc = ldlm_cleanup(); + if (rc) CERROR("ldlm_cleanup failed: %d\n", rc); else @@ -966,6 +968,7 @@ static cfs_hash_ops_t ldlm_export_lock_ops = { int ldlm_init_export(struct obd_export *exp) { int rc; + exp->exp_lock_hash = cfs_hash_create(obd_uuid2str(&exp->exp_client_uuid), HASH_EXP_LOCK_CUR_BITS, diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c index 0e1ab06d2543..b0f06d8228e1 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c @@ -943,6 +943,7 @@ EXPORT_SYMBOL(ldlm_pool_del); __u64 ldlm_pool_get_slv(struct ldlm_pool *pl) { __u64 slv; + spin_lock(&pl->pl_lock); slv = pl->pl_server_lock_volume; spin_unlock(&pl->pl_lock); @@ -971,6 +972,7 @@ EXPORT_SYMBOL(ldlm_pool_set_slv); __u64 ldlm_pool_get_clv(struct ldlm_pool *pl) { __u64 slv; + spin_lock(&pl->pl_lock); slv = pl->pl_client_lock_volume; spin_unlock(&pl->pl_lock); diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c index 95e71a0922f3..292ac7a2d02a 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c @@ -135,6 +135,7 @@ EXPORT_SYMBOL(ldlm_expired_completion_wait); int ldlm_get_enq_timeout(struct ldlm_lock *lock) { int timeout = at_get(ldlm_lock_to_ns_at(lock)); + if (AT_OFF) return obd_timeout / 2; /* Since these are non-updating timeouts, we should be conservative. @@ -601,6 +602,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, * again. */ if ((*flags) & LDLM_FL_LOCK_CHANGED) { int newmode = reply->lock_desc.l_req_mode; + LASSERT(!is_replay); if (newmode && newmode != lock->l_req_mode) { LDLM_DEBUG(lock, "server returned different mode %s", @@ -669,6 +671,7 @@ int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req, rc = ldlm_lock_enqueue(ns, &lock, NULL, flags); if (lock->l_completion_ast != NULL) { int err = lock->l_completion_ast(lock, *flags, NULL); + if (!rc) rc = err; if (rc) @@ -718,6 +721,7 @@ static inline int ldlm_capsule_handles_avail(struct req_capsule *pill, int off) { int size = req_capsule_msg_size(pill, loc); + return ldlm_req_handles_avail(size, off); } @@ -726,6 +730,7 @@ static inline int ldlm_format_handles_avail(struct obd_import *imp, enum req_location loc, int off) { int size = req_capsule_fmt_size(imp->imp_msg_magic, fmt, loc); + return ldlm_req_handles_avail(size, off); } @@ -1407,6 +1412,7 @@ static ldlm_policy_res_t ldlm_cancel_no_wait_policy(struct ldlm_namespace *ns, { ldlm_policy_res_t result = LDLM_POLICY_CANCEL_LOCK; ldlm_cancel_for_recovery cb = ns->ns_cancel_for_recovery; + lock_res_and_lock(lock); /* don't check added & count since we want to process all locks @@ -1721,6 +1727,7 @@ int ldlm_cancel_lru_local(struct ldlm_namespace *ns, struct list_head *cancels, int flags) { int added; + added = ldlm_prepare_lru_list(ns, cancels, count, max, flags); if (added <= 0) return added; @@ -2005,6 +2012,7 @@ struct iter_helper_data { static int ldlm_iter_helper(struct ldlm_lock *lock, void *closure) { struct iter_helper_data *helper = closure; + return helper->iter(lock, helper->closure); } diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c index 397adbe3ce0e..0fdbb9caa46e 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c @@ -804,6 +804,7 @@ static int __ldlm_namespace_free(struct ldlm_namespace *ns, int force) if (atomic_read(&ns->ns_bref) > 0) { struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL); int rc; + CDEBUG(D_DLMTRACE, "dlm namespace %s free waiting on refcount %d\n", ldlm_ns_name(ns), atomic_read(&ns->ns_bref)); @@ -1332,6 +1333,7 @@ void ldlm_dump_all_namespaces(ldlm_side_t client, int level) list_for_each(tmp, ldlm_namespace_list(client)) { struct ldlm_namespace *ns; + ns = list_entry(tmp, struct ldlm_namespace, ns_list_chain); ldlm_namespace_dump(level, ns); }