Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 297e908f authored by Jinshan Xiong's avatar Jinshan Xiong Committed by Greg Kroah-Hartman
Browse files

staging: lustre: 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: default avatarJinshan Xiong <jinshan.xiong@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-4977
Reviewed-on: http://review.whamcloud.com/10149


Reviewed-by: default avatarBobi Jam <bobijam@gmail.com>
Reviewed-by: default avatarLai Siyao <lai.siyao@intel.com>
Reviewed-by: default avatarOleg Drokin <oleg.drokin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d6099af2
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -506,7 +506,6 @@ 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);
	if (unlikely(!vmpage || PageDirty(vmpage) || PageWriteback(vmpage))) {
@@ -617,6 +616,13 @@ static int ll_write_end(struct file *file, struct address_space *mapping,
			LASSERT(from == 0);
		vio->u.write.vui_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;