From 1725069067fa1113812973be73df9960004506c8 Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Fri, 16 May 2008 06:36:27 +0000
Subject: [PATCH] VM protocol want old IO finished before start new, in this
 case need wait until PG_writeback is cleared until check dirty flag and call
 writepages in lock cancel callback. b=15443 i=nikita i=zam

---
 lustre/ChangeLog    | 7 +++++++
 lustre/llite/file.c | 7 ++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/lustre/ChangeLog b/lustre/ChangeLog
index 36265d42cc..fb897c0437 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -12,6 +12,13 @@ tbd  Sun Microsystems, Inc.
        * RHEL 4 and RHEL 5/SLES 10 clients behaves differently on 'cd' to a
         removed cwd "./" (refer to Bugzilla 14399).
 
+Severity   : normal
+Bugzilla   : 15443
+Description: wait until IO finished before start new when do lock cancel.
+Details    : VM protocol want old IO finished before start new, in this case
+             need wait until PG_writeback is cleared until check dirty flag and
+             call writepages in lock cancel callback.
+
 Severity   : enhancement
 Bugzilla   : 14929
 Description: using special macro for print time and cleanup in includes.
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index 80ac03b901..32360dc1e6 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -840,12 +840,13 @@ void ll_pgcache_remove_extent(struct inode *inode, struct lov_stripe_md *lsm,
 
                 cond_resched();
 
-                page = find_get_page(mapping, i);
+                page = find_lock_page(mapping, i);
                 if (page == NULL)
                         continue;
                 LL_CDEBUG_PAGE(D_PAGE, page, "lock page idx %lu ext "LPU64"\n",
                                i, tmpex.l_extent.start);
-                lock_page(page);
+                if (!discard && PageWriteback(page))
+                        wait_on_page_writeback(page);
 
                 /* page->mapping to check with racing against teardown */
                 if (!discard && clear_page_dirty_for_io(page)) {
@@ -854,7 +855,7 @@ void ll_pgcache_remove_extent(struct inode *inode, struct lov_stripe_md *lsm,
                          * the lock that the failed writepage released */
                         lock_page(page);
                         wait_on_page_writeback(page);
-                        if (rc != 0) {
+                        if (rc < 0) {
                                 CERROR("writepage inode %lu(%p) of page %p "
                                        "failed: %d\n", inode->i_ino, inode,
                                        page, rc);
-- 
GitLab