Whamcloud - gitweb
LU-1442 llite: cleanup if a page failed to add into cache
authorJinshan Xiong <jinshan.xiong@whamcloud.com>
Mon, 23 Jul 2012 14:09:51 +0000 (22:09 +0800)
committerOleg Drokin <green@whamcloud.com>
Fri, 27 Jul 2012 23:13:49 +0000 (19:13 -0400)
In lustre, we assume that a dirty page must be queued in osc cache
for writing. However, in vvp_io_commit_write(), if a page failed to
add into cache, page dirty flag isn't cleared this will cause the
page will never be added into cache again.

Signed-off-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
Change-Id: I1c132c6f1d4f5845682e51850eb895b292fc5f0d
Reviewed-on: http://review.whamcloud.com/3447
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Reviewed-by: Johann Lombardi <johann@whamcloud.com>
lustre/llite/vvp_io.c

index 016b144..50a19c9 100644 (file)
@@ -1000,13 +1000,12 @@ static int vvp_io_commit_write(const struct lu_env *env,
          */
         if (!PageDirty(vmpage)) {
                 tallyop = LPROC_LL_DIRTY_MISSES;
-                vvp_write_pending(cl2ccc(obj), cp);
-                set_page_dirty(vmpage);
-                /* ll_set_page_dirty() does the same for now, but
-                 * it will not soon. */
-                vvp_write_pending(cl2ccc(obj), cp);
                 result = cl_page_cache_add(env, io, pg, CRT_WRITE);
-                if (result == -EDQUOT) {
+                if (result == 0) {
+                        /* page was added into cache successfully. */
+                        set_page_dirty(vmpage);
+                        vvp_write_pending(cl2ccc(obj), cp);
+                } else if (result == -EDQUOT) {
                         pgoff_t last_index = i_size_read(inode) >> CFS_PAGE_SHIFT;
                         bool need_clip = true;
 
@@ -1034,7 +1033,6 @@ static int vvp_io_commit_write(const struct lu_env *env,
                         }
                         if (need_clip)
                                 cl_page_clip(env, pg, 0, to);
-                       clear_page_dirty_for_io(vmpage);
                         result = vvp_page_sync_io(env, io, pg, cp, CRT_WRITE);
                         if (result)
                                 CERROR("Write page %lu of inode %p failed %d\n",