From patchwork Wed Sep 23 20:40:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 7252411 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F22EB9F40A for ; Wed, 23 Sep 2015 20:40:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12CAD208D9 for ; Wed, 23 Sep 2015 20:40:21 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0120F208CB for ; Wed, 23 Sep 2015 20:40:20 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E1DAC6128C; Wed, 23 Sep 2015 13:40:19 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ml01.01.org (Postfix) with ESMTP id B8C366127C for ; Wed, 23 Sep 2015 13:40:17 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 23 Sep 2015 13:40:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,579,1437462000"; d="scan'208";a="795879660" Received: from theros.lm.intel.com ([10.232.112.190]) by fmsmga001.fm.intel.com with ESMTP; 23 Sep 2015 13:40:17 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.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 Cc: Andrew Morton , linux-nvdimm@lists.01.org, Dave Chinner , Alexander Viro , linux-fsdevel@vger.kernel.org, "Kirill A. Shutemov" X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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); } }