From: Jinshan Xiong Date: Mon, 26 Nov 2012 20:04:31 +0000 (-0800) Subject: LU-1650 obdclass: find the lock by index of subpage X-Git-Tag: 2.1.4-RC1~19 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=454d7f9c3358b4f86d04c63dcb6d445c2e4f40ad;p=fs%2Flustre-release.git LU-1650 obdclass: find the lock by index of subpage 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 Change-Id: Id8e1da89ef81fad4c7917360d591fc7bd1309a00 Reviewed-on: http://review.whamcloud.com/4698 Tested-by: Hudson Reviewed-by: Bobi Jam Tested-by: Maloo Reviewed-by: Johann Lombardi --- diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index 1b68697..66b1658 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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); diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index d61fd6f..5fd0aeb 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -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