From patchwork Mon Nov 16 12:09:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yigal Korman X-Patchwork-Id: 7624581 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 2D70A9F2E2 for ; Mon, 16 Nov 2015 12:09:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 345F7205B5 for ; Mon, 16 Nov 2015 12:09:50 +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 CA708205B1 for ; Mon, 16 Nov 2015 12:09:48 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9CF401A1F0B; Mon, 16 Nov 2015 04:09:48 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6BC3E1A1F0B for ; Mon, 16 Nov 2015 04:09:46 -0800 (PST) Received: by wmww144 with SMTP id w144so116043287wmw.0 for ; Mon, 16 Nov 2015 04:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plexistor_com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=CdGmh9SEcBG2D0vAURv9q7csPHwWvJ5Eijjwma1AwAI=; b=b1S6tjg9I6ll9CrzqjcjmKxoM73B7rAVuGhrf7IdtLptsMiij5T1erEgOA3PmBwLXG iw5gTE7dzNJrMMITZKFo2K42N0K+0keNGdz7NnT9HiPR6QyU+wFNz0XOIw2iiiYgAX+X tkWPINUHhVsuWceY5IK2Ds7N6Dce1FJR7FUwlSuWdfXGMfwXLXkfUbRWSf0ur8QmEW0P tjFozs4QXQ3zDiYahTVQStphsBPU6II9bASvlABVauplkJhKe2fMJpzEqndv2jaAtERS BpIHTNIjI8d6FSlznjIvYiaeEhXGUTXRyKDflwUjiDWYe7fOXnL+xn71PYNO/GwZSF5k exug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=CdGmh9SEcBG2D0vAURv9q7csPHwWvJ5Eijjwma1AwAI=; b=UedkaLHdSVgJszbis+QeisaezJbEBaibuwEnKcWRx+kR4tZ8K//SEajSCEBZPg3q9x 7cbPFSd30HilqB2v5J7IKJICTGBIV7cQ2maJanxEuyJ2OnXMjxLY3WkKzhf15LkXpCGB 01W96jIFFwLcmW5r5D79if83uHIoLW38Qg0oexwbMTHeX0OHKOTbGoqHR4O0tbHGwx/n alvufOe8xem8y1BNBWAYhtPHqV4tE54dl/CzC1kwKOLKIwc1p62ds5GJRZEL0Le80EaV hDCRM+rSVbATgJlsUhegq2NIucaMPUwZq75ebZxl/dfDYDH7oVZtJFVXaPDmoEETo/H+ v5cQ== X-Gm-Message-State: ALoCoQlitwAWjCy9pv5kTN5WRA7MSrFSMd5GztOHzgZBZ0S7ouKJ2uqwDajGNvW8L86NmWbmDujb X-Received: by 10.28.143.1 with SMTP id r1mr19537161wmd.80.1447675784630; Mon, 16 Nov 2015 04:09:44 -0800 (PST) Received: from yigal-pc.plexistor.com.localdomain ([207.232.55.62]) by smtp.gmail.com with ESMTPSA id ej10sm33356691wjd.32.2015.11.16.04.09.41 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2015 04:09:43 -0800 (PST) From: Yigal Korman To: linux-kernel@vger.kernel.org Subject: [PATCH] mm, dax: fix DAX deadlocks (COW fault) Date: Mon, 16 Nov 2015 14:09:15 +0200 Message-Id: <1447675755-5692-1-git-send-email-yigal@plexistor.com> X-Mailer: git-send-email 1.9.3 Cc: "Kirill A. Shutemov" , linux-nvdimm@lists.01.org, Jan Kara , david@fromorbit.com, Stable Tree , linux-mm@kvack.org, Alexander Viro , Dave Chinner , linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org, Matthew Wilcox 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=-3.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,T_DKIM_INVALID,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 DAX handling of COW faults has wrong locking sequence: dax_fault does i_mmap_lock_read do_cow_fault does i_mmap_unlock_write Ross's commit[1] missed a fix[2] that Kirill added to Matthew's commit[3]. Original COW locking logic was introduced by Matthew here[4]. This should be applied to v4.3 as well. [1] 0f90cc6609c7 mm, dax: fix DAX deadlocks [2] 52a2b53ffde6 mm, dax: use i_mmap_unlock_write() in do_cow_fault() [3] 843172978bb9 dax: fix race between simultaneous faults [4] 2e4cdab0584f mm: allow page fault handlers to perform the COW Signed-off-by: Yigal Korman Cc: Stable Tree Cc: Boaz Harrosh Cc: Ross Zwisler Cc: Alexander Viro Cc: Dan Williams Cc: Dave Chinner Cc: Jan Kara Cc: "Kirill A. Shutemov" Cc: Matthew Wilcox --- mm/memory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index c716913..e5071af 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3015,9 +3015,9 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma, } else { /* * The fault handler has no page to lock, so it holds - * i_mmap_lock for write to protect against truncate. + * i_mmap_lock for read to protect against truncate. */ - i_mmap_unlock_write(vma->vm_file->f_mapping); + i_mmap_unlock_read(vma->vm_file->f_mapping); } goto uncharge_out; } @@ -3031,9 +3031,9 @@ static int do_cow_fault(struct mm_struct *mm, struct vm_area_struct *vma, } else { /* * The fault handler has no page to lock, so it holds - * i_mmap_lock for write to protect against truncate. + * i_mmap_lock for read to protect against truncate. */ - i_mmap_unlock_write(vma->vm_file->f_mapping); + i_mmap_unlock_read(vma->vm_file->f_mapping); } return ret; uncharge_out: