Whamcloud - gitweb
LU-3285 lvbo: pass lock as parameter to lvbo_update() 16/28016/19
authorMikhal Pershin <mike.pershin@intel.com>
Thu, 22 Dec 2016 11:15:11 +0000 (14:15 +0300)
committerMike Pershin <mike.pershin@intel.com>
Tue, 17 Oct 2017 19:08:50 +0000 (19:08 +0000)
LVBO lvbo_update call was using ldlm_resource as parameter,
the ldlm_lock parameter is added to recognize DoM resource
in MDT LVBO functions and perform DoM specific actions.

Signed-off-by: Mikhal Pershin <mike.pershin@intel.com>
Change-Id: Id1cfee12bfc13893206c771f45acf7dd44da56ba
Reviewed-on: https://review.whamcloud.com/28016
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/mdt/mdt_lvb.c
lustre/ofd/ofd_lvb.c

index 17b51ae..2d0952e 100644 (file)
@@ -289,11 +289,10 @@ typedef int (*ldlm_cancel_cbt)(struct ldlm_lock *lock);
  * of ldlm_[res_]lvbo_[init,update,fill]() functions.
  */
 struct ldlm_valblock_ops {
-        int (*lvbo_init)(struct ldlm_resource *res);
-        int (*lvbo_update)(struct ldlm_resource *res,
-                           struct ptlrpc_request *r,
-                           int increase);
-        int (*lvbo_free)(struct ldlm_resource *res);
+       int (*lvbo_init)(struct ldlm_resource *res);
+       int (*lvbo_update)(struct ldlm_resource *res, struct ldlm_lock *lock,
+                          struct ptlrpc_request *r,  int increase);
+       int (*lvbo_free)(struct ldlm_resource *res);
        /* Return size of lvb data appropriate RPC size can be reserved */
        int (*lvbo_size)(struct ldlm_lock *lock);
        /* Called to fill in lvb data to RPC buffer @buf */
@@ -1360,9 +1359,11 @@ ldlm_handle2lock_long(const struct lustre_handle *h, __u64 flags)
  * Update Lock Value Block Operations (LVBO) on a resource taking into account
  * data from request \a r
  */
-static inline int ldlm_res_lvbo_update(struct ldlm_resource *res,
-                                      struct ptlrpc_request *req, int increase)
+static inline int ldlm_lvbo_update(struct ldlm_resource *res,
+                                  struct ldlm_lock *lock,
+                                  struct ptlrpc_request *req, int increase)
 {
+       struct ldlm_namespace *ns = ldlm_res_to_ns(res);
        int rc;
 
        /* delayed lvb init may be required */
@@ -1372,14 +1373,18 @@ static inline int ldlm_res_lvbo_update(struct ldlm_resource *res,
                return rc;
        }
 
-       if (ldlm_res_to_ns(res)->ns_lvbo &&
-           ldlm_res_to_ns(res)->ns_lvbo->lvbo_update) {
-               return ldlm_res_to_ns(res)->ns_lvbo->lvbo_update(res, req,
-                                                                increase);
-       }
+       if (ns->ns_lvbo && ns->ns_lvbo->lvbo_update)
+               return ns->ns_lvbo->lvbo_update(res, lock, req, increase);
+
        return 0;
 }
 
+static inline int ldlm_res_lvbo_update(struct ldlm_resource *res,
+                                      struct ptlrpc_request *req, int increase)
+{
+       return ldlm_lvbo_update(res, NULL, req, increase);
+}
+
 int ldlm_error2errno(enum ldlm_error error);
 enum ldlm_error ldlm_errno2error(int err_no); /* don't call it `errno': this
                                               * confuses user-space. */
index 8d427ec..141de60 100644 (file)
@@ -2441,7 +2441,7 @@ static void ldlm_cancel_lock_for_export(struct obd_export *exp,
 
        res = ldlm_resource_getref(lock->l_resource);
 
-       ldlm_res_lvbo_update(res, NULL, 1);
+       ldlm_lvbo_update(res, lock, NULL, 1);
        ldlm_lock_cancel(lock);
        if (!exp->exp_obd->obd_stopping)
                ldlm_reprocess_all(res);
index 3e80cb2..04e3c8e 100644 (file)
@@ -713,7 +713,7 @@ static int ldlm_handle_ast_error(struct ldlm_lock *lock,
                        /* update lvbo to return proper attributes.
                         * see bug 23174 */
                        ldlm_resource_getref(res);
-                       ldlm_res_lvbo_update(res, NULL, 1);
+                       ldlm_lvbo_update(res, lock, NULL, 1);
                        ldlm_resource_putref(res);
                }
                ldlm_lock_cancel(lock);
@@ -748,11 +748,11 @@ static int ldlm_cb_interpret(const struct lu_env *env,
                } else if (rc == -ELDLM_NO_LOCK_DATA) {
                        LDLM_DEBUG(lock, "lost race - client has a lock but no "
                                   "inode");
-                       ldlm_res_lvbo_update(lock->l_resource, NULL, 1);
+                       ldlm_lvbo_update(lock->l_resource, lock, NULL, 1);
                } else if (rc != 0) {
                        rc = ldlm_handle_ast_error(lock, req, rc, "glimpse");
                } else {
-                       rc = ldlm_res_lvbo_update(lock->l_resource, req, 1);
+                       rc = ldlm_lvbo_update(lock->l_resource, lock, req, 1);
                }
                break;
        case LDLM_BL_CALLBACK:
@@ -1690,7 +1690,9 @@ int ldlm_request_cancel(struct ptlrpc_request *req,
                         if (res != NULL) {
                                 ldlm_resource_getref(res);
                                 LDLM_RESOURCE_ADDREF(res);
-                                ldlm_res_lvbo_update(res, NULL, 1);
+
+                               if (!ldlm_is_discard_data(lock))
+                                       ldlm_lvbo_update(res, lock, NULL, 1);
                         }
                         pres = res;
                 }
index d4c5097..31c2438 100644 (file)
@@ -51,6 +51,7 @@ static int mdt_lvbo_init(struct ldlm_resource *res)
 }
 
 static int mdt_lvbo_update(struct ldlm_resource *res,
+                          struct ldlm_lock *lock,
                           struct ptlrpc_request *req,
                           int increase_only)
 {
index b1d50eb..c4e43b4 100644 (file)
@@ -77,7 +77,7 @@ static int ofd_lvbo_free(struct ldlm_resource *res)
  *
  * Called with res->lr_lvb_sem held.
  *
- * \param[in] res      LDLM resource
+ * \param[in] lock     LDLM lock on resource
  *
  * \retval             0 on successful setup
  * \retval             negative value on error
@@ -172,14 +172,14 @@ out_env:
  *  \a req != NULL : called by the DLM itself after a glimpse callback
  *  \a req == NULL : called by the OFD after a disk write
  *
- * \param[in] res              LDLM resource
+ * \param[in] lock             LDLM lock
  * \param[in] req              PTLRPC request
  * \param[in] increase_only    don't allow LVB values to decrease
  *
  * \retval             0 on successful setup
  * \retval             negative value on error
  */
-static int ofd_lvbo_update(struct ldlm_resource *res,
+static int ofd_lvbo_update(struct ldlm_resource *res, struct ldlm_lock *lock,
                           struct ptlrpc_request *req, int increase_only)
 {
        struct ofd_device       *ofd;