Whamcloud - gitweb
LU-1650 obdclass: find the lock by index of subpage
authorJinshan Xiong <jinshan.xiong@intel.com>
Mon, 26 Nov 2012 20:04:31 +0000 (12:04 -0800)
committerOleg Drokin <green@whamcloud.com>
Wed, 5 Dec 2012 02:34:42 +0000 (21:34 -0500)
In check_and_discard_cb(), subpage's index should be used to find if
there exists another lock to cover the same page.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Id8e1da89ef81fad4c7917360d591fc7bd1309a00
Reviewed-on: http://review.whamcloud.com/4698
Tested-by: Hudson
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
lustre/include/cl_object.h
lustre/obdclass/cl_lock.c

index 1b68697..66b1658 100644 (file)
@@ -2784,9 +2784,18 @@ struct cl_lock *cl_lock_peek(const struct lu_env *env, const struct cl_io *io,
 struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io,
                                 const struct cl_lock_descr *need,
                                 const char *scope, const void *source);
-struct cl_lock *cl_lock_at_page(const struct lu_env *env, struct cl_object *obj,
-                                struct cl_page *page, struct cl_lock *except,
-                                int pending, int canceld);
+struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, struct cl_object *obj,
+                                 pgoff_t index, struct cl_lock *except,
+                                 int pending, int canceld);
+static inline struct cl_lock *cl_lock_at_page(const struct lu_env *env,
+                                              struct cl_object *obj,
+                                              struct cl_page *page,
+                                              struct cl_lock *except,
+                                              int pending, int canceld)
+{
+        return cl_lock_at_pgoff(env, obj, page->cp_index, except,
+                                pending, canceld);
+}
 
 const struct cl_lock_slice *cl_lock_at(const struct cl_lock *lock,
                                        const struct lu_device_type *dtype);
index d61fd6f..5fd0aeb 100644 (file)
@@ -1840,9 +1840,9 @@ EXPORT_SYMBOL(cl_lock_cancel);
  * Finds an existing lock covering given page and optionally different from a
  * given \a except lock.
  */
-struct cl_lock *cl_lock_at_page(const struct lu_env *env, struct cl_object *obj,
-                                struct cl_page *page, struct cl_lock *except,
-                                int pending, int canceld)
+struct cl_lock *cl_lock_at_pgoff(const struct lu_env *env, struct cl_object *obj,
+                                 pgoff_t index, struct cl_lock *except,
+                                 int pending, int canceld)
 {
         struct cl_object_header *head;
         struct cl_lock          *scan;
@@ -1857,7 +1857,7 @@ struct cl_lock *cl_lock_at_page(const struct lu_env *env, struct cl_object *obj,
 
         need->cld_mode = CLM_READ; /* CLM_READ matches both READ & WRITE, but
                                     * not PHANTOM */
-        need->cld_start = need->cld_end = page->cp_index;
+        need->cld_start = need->cld_end = index;
         need->cld_enq_flags = 0;
 
         cfs_spin_lock(&head->coh_lock_guard);
@@ -1886,7 +1886,7 @@ struct cl_lock *cl_lock_at_page(const struct lu_env *env, struct cl_object *obj,
         cfs_spin_unlock(&head->coh_lock_guard);
         RETURN(lock);
 }
-EXPORT_SYMBOL(cl_lock_at_page);
+EXPORT_SYMBOL(cl_lock_at_pgoff);
 
 /**
  * Calculate the page offset at the layer of @lock.
@@ -1917,8 +1917,8 @@ static int check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
                 struct cl_lock *tmp;
 
                 /* refresh non-overlapped index */
-                tmp = cl_lock_at_page(env, lock->cll_descr.cld_obj, page, lock,
-                                      1, 0);
+                tmp = cl_lock_at_pgoff(env, lock->cll_descr.cld_obj, index, lock,
+                                       1, 0);
                 if (tmp != NULL) {
                         /* Cache the first-non-overlapped index so as to skip
                          * all pages within [index, clt_fn_index). This