From c60fd462a33131dabb52d5b01b18284bacde78c2 Mon Sep 17 00:00:00 2001
From: shadow <shadow>
Date: Fri, 16 May 2008 06:50:00 +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 569729e322..58558797de 100644
--- a/lustre/ChangeLog
+++ b/lustre/ChangeLog
@@ -24,6 +24,13 @@ tbd Sun Microsystems, Inc.
 	  	'tunefs.lustre --param="mdt.quota_type=ug1" $MDTDEV'.
 	  For more information, please refer to bugzilla 13904.
 
+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   : normal
 Bugzilla   : 12888
 Description: mds_mfd_close() ASSERTION(rc == 0) 
diff --git a/lustre/llite/file.c b/lustre/llite/file.c
index d49116fc25..bb95f2740c 100644
--- a/lustre/llite/file.c
+++ b/lustre/llite/file.c
@@ -713,17 +713,18 @@ int ll_page_removal_cb(void *data, int discard)
         ll_teardown_mmaps(mapping,
                           (__u64)page->index << PAGE_CACHE_SHIFT,
                           ((__u64)page->index<<PAGE_CACHE_SHIFT)|
-                                                              ~PAGE_CACHE_MASK);        
+                                                              ~PAGE_CACHE_MASK);
         LL_CDEBUG_PAGE(D_PAGE, page, "removing page\n");
+        if (!discard && PageWriteback(page))
+                wait_on_page_writeback(page);
 
         if (!discard && clear_page_dirty_for_io(page)) {
-                LASSERT(page->mapping);
                 rc = ll_call_writepage(page->mapping->host, page);
                 /* either waiting for io to complete or reacquiring
                  * 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", mapping->host->i_ino,
                                mapping->host, page, rc);
-- 
GitLab