From 51c95f899b894aceba0b3914e82d13c78c012ba7 Mon Sep 17 00:00:00 2001 From: nikita Date: Sat, 18 Oct 2008 15:42:22 +0000 Subject: [PATCH] Instead of specifying each ldlm_lock call-back through separate parameter, wrap them into struct ldlm_callback_suite. b=16450 --- lustre/ChangeLog | 6 ++++++ lustre/ldlm/ldlm_flock.c | 3 ++- lustre/ldlm/ldlm_internal.h | 6 +++--- lustre/ldlm/ldlm_lock.c | 13 +++++++------ lustre/ldlm/ldlm_lockd.c | 3 +-- lustre/ldlm/ldlm_request.c | 20 ++++++++++++++------ 6 files changed, 33 insertions(+), 18 deletions(-) diff --git a/lustre/ChangeLog b/lustre/ChangeLog index bee80a7..46d8691 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. diff --git a/lustre/ldlm/ldlm_flock.c b/lustre/ldlm/ldlm_flock.c index fc3b593..93daaf6 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 24cfca3..a6eb21c 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 191cf10..63d331c 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 948abea..348fd7b 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 99f211e..9c50907 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 */ -- 1.8.3.1