From 50eeb38a8c1ca26c5837149aa442288af8d4fc45 Mon Sep 17 00:00:00 2001 From: Jinshan Xiong Date: Thu, 10 Apr 2014 11:40:49 -0400 Subject: [PATCH] LU-4873 llite: avoid a deadlock in page write For a partial page write, it will have to issue a READ RPC firstly to get a full uptodate page. If another page is already locked by this thread it can easily cause deadlock. Signed-off-by: Jinshan Xiong Change-Id: I3bf01b51c8842666dfb923b9df073acbcc533950 Reviewed-on: http://review.whamcloud.com/9928 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bobi Jam Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/llite/rw26.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 77151de..64a06f9 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -554,8 +554,9 @@ static int ll_write_begin(struct file *file, struct address_space *mapping, env = lcc->lcc_env; io = lcc->lcc_io; - /* To avoid deadlock, try to lock page first. */ - vmpage = grab_cache_page_nowait(mapping, index); + 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 == NULL || PageDirty(vmpage) || PageWriteback(vmpage))) { struct ccc_io *cio = ccc_env_io(env); -- 1.8.3.1