From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755233AbbIWUkT (ORCPT ); Wed, 23 Sep 2015 16:40:19 -0400 Received: from mga09.intel.com ([134.134.136.24]:18517 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbbIWUkS (ORCPT ); Wed, 23 Sep 2015 16:40:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,579,1437462000"; d="scan'208";a="795879660" From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , Alexander Viro , Matthew Wilcox , linux-fsdevel@vger.kernel.org, Andrew Morton , Dan Williams , Dave Chinner , "Kirill A. Shutemov" , linux-nvdimm@ml01.01.org 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> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@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