Whamcloud - gitweb
Instead of specifying each ldlm_lock call-back through separate parameter,
authornikita <nikita>
Sat, 18 Oct 2008 15:42:22 +0000 (15:42 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 15:42:22 +0000 (15:42 +0000)
wrap them into struct ldlm_callback_suite.
b=16450

lustre/ChangeLog
lustre/ldlm/ldlm_flock.c
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c

index bee80a7..46d8691 100644 (file)
@@ -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>
index fc3b593..93daaf6 100644 (file)
@@ -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) {
index 24cfca3..a6eb21c 100644 (file)
@@ -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);
index 191cf10..63d331c 100644 (file)
@@ -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 */
index 948abea..348fd7b 100644 (file)
@@ -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);
index 99f211e..9c50907 100644 (file)
@@ -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 */