Whamcloud - gitweb
LU-4977 llite: Fix the deadlock in balance_dirty_pages() 49/10149/3
authorJinshan Xiong <jinshan.xiong@intel.com>
Tue, 29 Apr 2014 04:52:54 +0000 (21:52 -0700)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 14 May 2014 15:15:39 +0000 (15:15 +0000)
If the page is already dirtied in ll_write_end() and kernel tries
to call balance_dirty_pages() to write back dirty pages in the same
thread, this is deadlock case if the page is already held by clio.

This can also fix the issue of LU-4873.

Signed-off-by: Jinshan Xiong <jinshan.xiong@intel.com>
Change-Id: Iae7f6bd8956e5fc134568d776c9aa3a6b68b1ec5
Reviewed-on: http://review.whamcloud.com/10149
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/llite/rw26.c

index 24414c9..c3fe272 100644 (file)
@@ -554,9 +554,8 @@ static int ll_write_begin(struct file *file, struct address_space *mapping,
        env = lcc->lcc_env;
        io  = lcc->lcc_io;
 
-       if (likely(to == PAGE_SIZE)) /* LU-4873 */
-               /* To avoid deadlock, try to lock page first. */
-               vmpage = grab_cache_page_nowait(mapping, index);
+       /* To avoid deadlock, try to lock page first. */
+       vmpage = grab_cache_page_nowait(mapping, index);
        if (unlikely(vmpage == NULL ||
                     PageDirty(vmpage) || PageWriteback(vmpage))) {
                struct ccc_io *cio = ccc_env_io(env);
@@ -665,6 +664,11 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
                        LASSERT(from == 0);
                cio->u.write.cui_to = from + copied;
 
+               /* To address the deadlock in balance_dirty_pages() where
+                * this dirty page may be written back in the same thread. */
+               if (PageDirty(vmpage))
+                       unplug = true;
+
                /* We may have one full RPC, commit it soon */
                if (plist->pl_nr >= PTLRPC_MAX_BRW_PAGES)
                        unplug = true;