diff --git a/lustre/ChangeLog b/lustre/ChangeLog index bee80a75a866b3075857542a937129aa86a95b8e..46d86910bb0300d7c4e18c1daffdf7c6e4f3c434 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -1507,6 +1507,12 @@ Details : Use spin_lock_nested() in (the only) situation where more than dead-lock in ldlm_lock_change_resource() by enforcing particular lock ordering. +Severity : normal +Bugzilla : 16450 +Description: Use struct ldlm_callback_suite in ldlm_lock_create(). +Details : Instead of specifying each ldlm_lock call-back through separate + parameter, wrap them into struct ldlm_callback_suite. + -------------------------------------------------------------------------------- 2007-08-10 Cluster File Systems, Inc. <info@clusterfs.com> diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index fc3b59313c7dbc9d0a6c782cd309d12a8907ff1c..93daaf6e89d4b2994373448b8ad2ad9067e75c00 100644 --- a/lustre/ldlm/ldlm_flock.c +++ b/lustre/ldlm/ldlm_flock.c @@ -168,6 +168,7 @@ ldlm_process_flock_lock(struct ldlm_lock *req, int *flags, int first_enq, int added = (mode == LCK_NL); int overlaps = 0; int splitted = 0; + const struct ldlm_callback_suite null_cbs = { NULL }; ENTRY; CDEBUG(D_DLMTRACE, "flags %#x pid %u mode %u start "LPU64" end "LPU64 @@ -373,7 +374,7 @@ reprocess: if (!new2) { unlock_res_and_lock(req); new2 = ldlm_lock_create(ns, &res->lr_name, LDLM_FLOCK, - lock->l_granted_mode, NULL, NULL, NULL, + lock->l_granted_mode, &null_cbs, NULL, 0); lock_res_and_lock(req); if (!new2) { diff --git a/lustre/ldlm/ldlm_internal.h b/lustre/ldlm/ldlm_internal.h index 24cfca34deb0fb4cb2239b158cc179a71f57d1e2..a6eb21cf03d5b42f5aa8244427e37dc719cbe07f 100644 --- a/lustre/ldlm/ldlm_internal.h +++ b/lustre/ldlm/ldlm_internal.h @@ -112,9 +112,9 @@ typedef enum { void ldlm_grant_lock(struct ldlm_lock *lock, struct list_head *work_list); struct ldlm_lock * ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *, - ldlm_type_t type, ldlm_mode_t, ldlm_blocking_callback, - ldlm_completion_callback, ldlm_glimpse_callback, void *data, - __u32 lvb_len); + ldlm_type_t type, ldlm_mode_t, + const struct ldlm_callback_suite *cbs, + void *data, __u32 lvb_len); ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *, struct ldlm_lock **, void *cookie, int *flags); void ldlm_lock_addref_internal(struct ldlm_lock *, __u32 mode); diff --git a/lustre/ldlm/ldlm_lock.c b/lustre/ldlm/ldlm_lock.c index 191cf10c1c16ec0ea5347ebf30f60e99689c82fe..63d331cb0b009fc3f2b98b89ea95f8e6c2147bbc 100644 --- a/lustre/ldlm/ldlm_lock.c +++ b/lustre/ldlm/ldlm_lock.c @@ -1171,9 +1171,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, const struct ldlm_res_id *res_id, ldlm_type_t type, ldlm_mode_t mode, - ldlm_blocking_callback blocking, - ldlm_completion_callback completion, - ldlm_glimpse_callback glimpse, + const struct ldlm_callback_suite *cbs, void *data, __u32 lvb_len) { struct ldlm_lock *lock; @@ -1192,10 +1190,13 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns, lock->l_req_mode = mode; lock->l_ast_data = data; - lock->l_blocking_ast = blocking; - lock->l_completion_ast = completion; - lock->l_glimpse_ast = glimpse; lock->l_pid = cfs_curproc_pid(); + if (cbs) { + lock->l_blocking_ast = cbs->lcs_blocking; + lock->l_completion_ast = cbs->lcs_completion; + lock->l_glimpse_ast = cbs->lcs_glimpse; + lock->l_weigh_ast = cbs->lcs_weigh; + } lock->l_tree_node = NULL; /* if this is the extent lock, allocate the interval tree node */ diff --git a/lustre/ldlm/ldlm_lockd.c b/lustre/ldlm/ldlm_lockd.c index 948abea9ed84b5d1aaf5c864e3b088764c39d95d..348fd7b955779672d0123c24de8e6d4904668baa 100644 --- a/lustre/ldlm/ldlm_lockd.c +++ b/lustre/ldlm/ldlm_lockd.c @@ -984,8 +984,7 @@ int ldlm_handle_enqueue0(struct ldlm_namespace *ns, lock = ldlm_lock_create(ns, &dlm_req->lock_desc.l_resource.lr_name, dlm_req->lock_desc.l_resource.lr_type, dlm_req->lock_desc.l_req_mode, - cbs->lcs_blocking, cbs->lcs_completion, - cbs->lcs_glimpse, NULL, 0); + cbs, NULL, 0); if (!lock) GOTO(out, rc = -ENOMEM); diff --git a/lustre/ldlm/ldlm_request.c b/lustre/ldlm/ldlm_request.c index 99f211ee6514601580d497748f846898cc96e672..9c50907efaf33b48035bdc3ea3d453caa1b9aa30 100644 --- a/lustre/ldlm/ldlm_request.c +++ b/lustre/ldlm/ldlm_request.c @@ -303,6 +303,10 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, { struct ldlm_lock *lock; int err; + const struct ldlm_callback_suite cbs = { .lcs_completion = completion, + .lcs_blocking = blocking, + .lcs_glimpse = glimpse, + }; ENTRY; LASSERT(!(*flags & LDLM_FL_REPLAY)); @@ -311,8 +315,7 @@ int ldlm_cli_enqueue_local(struct ldlm_namespace *ns, LBUG(); } - lock = ldlm_lock_create(ns, res_id, type, mode, blocking, - completion, glimpse, data, lvb_len); + lock = ldlm_lock_create(ns, res_id, type, mode, &cbs, data, lvb_len); if (unlikely(!lock)) GOTO(out_nolock, err = -ENOMEM); LDLM_DEBUG(lock, "client-side local enqueue handler, new lock created"); @@ -669,15 +672,20 @@ int ldlm_cli_enqueue(struct obd_export *exp, struct ptlrpc_request **reqp, /* If we're replaying this lock, just check some invariants. * If we're creating a new lock, get everything all setup nice. */ if (is_replay) { - lock = ldlm_handle2lock(lockh); + lock = ldlm_handle2lock_long(lockh, 0); LASSERT(lock != NULL); LDLM_DEBUG(lock, "client-side enqueue START"); LASSERT(exp == lock->l_conn_export); } else { + const struct ldlm_callback_suite cbs = { + .lcs_completion = einfo->ei_cb_cp, + .lcs_blocking = einfo->ei_cb_bl, + .lcs_glimpse = einfo->ei_cb_gl, + .lcs_weigh = einfo->ei_cb_wg + }; lock = ldlm_lock_create(ns, res_id, einfo->ei_type, - einfo->ei_mode, einfo->ei_cb_bl, - einfo->ei_cb_cp, einfo->ei_cb_gl, - einfo->ei_cbdata, lvb_len); + einfo->ei_mode, &cbs, einfo->ei_cbdata, + lvb_len); if (lock == NULL) RETURN(-ENOMEM); /* for the local lock, add the reference */