From: Jinshan Xiong Date: Tue, 29 Apr 2014 04:52:54 +0000 (-0700) Subject: LU-4977 llite: Fix the deadlock in balance_dirty_pages() X-Git-Tag: 2.5.59~3 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1fab3bba187c927a85c827c4ff481e30914b5b2a LU-4977 llite: Fix the deadlock in balance_dirty_pages() 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 Change-Id: Iae7f6bd8956e5fc134568d776c9aa3a6b68b1ec5 Reviewed-on: http://review.whamcloud.com/10149 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 24414c9..c3fe272 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -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;