From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ross Zwisler Subject: [PATCH] dax: fix deadlock in __dax_fault Date: Wed, 23 Sep 2015 14:40:00 -0600 Message-ID: <1443040800-5460-1-git-send-email-ross.zwisler@linux.intel.com> Cc: Ross Zwisler , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Andrew Morton , Dan Williams , Dave Chinner , "Kirill A. Shutemov" , linux-nvdimm@lists.01.org To: linux-kernel@vger.kernel.org Return-path: Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org Fix the deadlock exposed by xfstests generic/075. Here is the sequence that was causing us to deadlock: 1) enter __dax_fault() 2) page = find_get_page() gives us a page, so skip i_mmap_lock_write(mapping) 3) if (!buffer_mapped(&bh) && !buffer_unwritten(&bh) && !vmf->cow_page) passes, enter this block 4) if (vmf->flags & FAULT_FLAG_WRITE) fails, so do the else case and i_mmap_unlock_write(mapping); return dax_load_hole(mapping, page, vmf); This causes us to up_write() a semaphore that we weren't holding. The up_write() on a semaphore we didn't down_write() happens twice in a row, and then the next time we try and i_mmap_lock_write(), we hang. Signed-off-by: Ross Zwisler Reported-by: Dave Chinner --- fs/dax.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 7ae6df7..df1b0ac 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -405,7 +405,8 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf, if (error) goto unlock; } else { - i_mmap_unlock_write(mapping); + if (!page) + i_mmap_unlock_write(mapping); return dax_load_hole(mapping, page, vmf); } } -- 2.1.0