From 3aff4ebb95b20ad8db2c1447e8c52097d89af5a7 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 9 May 2012 14:30:35 -0400 Subject: NFS: Prevent a deadlock in the new writeback code We have to unlock the nfs_page before we call nfs_end_page_writeback to avoid races with functions that expect the page to be unlocked when PG_locked and PG_writeback are not set. The problem is that nfs_unlock_request also releases the nfs_page, causing a deadlock if the release of the nfs_open_context triggers an iput() while the PG_writeback flag is still set... The solution is to separate the unlocking and release of the nfs_page, so that we can do the former before nfs_end_page_writeback and the latter after. Signed-off-by: Trond Myklebust Cc: Fred Isaman --- fs/nfs/write.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'fs/nfs/write.c') diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 6f263daac748..fd36b31ee72e 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -628,8 +628,9 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr) remove_req: nfs_inode_remove_request(req); next: - nfs_unlock_request(req); + nfs_unlock_request_dont_release(req); nfs_end_page_writeback(page); + nfs_release_request(req); } out: hdr->release(hdr); @@ -1042,8 +1043,9 @@ static void nfs_redirty_request(struct nfs_page *req) struct page *page = req->wb_page; nfs_mark_request_dirty(req); - nfs_unlock_request(req); + nfs_unlock_request_dont_release(req); nfs_end_page_writeback(page); + nfs_release_request(req); } static void nfs_async_write_error(struct list_head *head) -- cgit v1.2.2