From patchwork Tue Nov 1 21:06:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9408131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 69FD760585 for ; Tue, 1 Nov 2016 21:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D8F329A50 for ; Tue, 1 Nov 2016 21:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 523FB29A73; Tue, 1 Nov 2016 21:22:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 88CBC29A5B for ; Tue, 1 Nov 2016 21:22:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 562E881D49; Tue, 1 Nov 2016 14:22:15 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E441B81D3C for ; Tue, 1 Nov 2016 14:22:13 -0700 (PDT) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 058B6AD9C; Tue, 1 Nov 2016 21:22:14 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 51CCA1E0F99; Tue, 1 Nov 2016 22:06:27 +0100 (CET) From: Jan Kara To: linux-ext4@vger.kernel.org Subject: [PATCH 08/11] ext4: Convert DAX faults to iomap infrastructure Date: Tue, 1 Nov 2016 22:06:18 +0100 Message-Id: <1478034381-19037-9-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 In-Reply-To: <1478034381-19037-1-git-send-email-jack@suse.cz> References: <1478034381-19037-1-git-send-email-jack@suse.cz> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Dave Chinner , Jan Kara , Ted Tso , linux-nvdimm@lists.01.org MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Convert DAX faults to use iomap infrastructure. We would not have to start transaction in ext4_dax_fault() anymore since ext4_iomap_begin takes care of that but so far we do that to avoid lock inversion of transaction start with DAX entry lock which gets acquired in dax_iomap_fault() before calling ->iomap_begin handler. Signed-off-by: Jan Kara --- fs/ext4/ext4.h | 1 + fs/ext4/file.c | 9 +++++---- fs/ext4/inode.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 098b39910001..2714eb6174ab 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -3272,6 +3272,7 @@ static inline bool ext4_aligned_io(struct inode *inode, loff_t off, loff_t len) } extern struct iomap_ops ext4_iomap_ops; +extern struct iomap_ops ext4_iomap_fault_ops; #endif /* __KERNEL__ */ diff --git a/fs/ext4/file.c b/fs/ext4/file.c index d7ab0e90d1b8..da44e49c8276 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -273,7 +273,7 @@ static int ext4_dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf) if (IS_ERR(handle)) result = VM_FAULT_SIGBUS; else - result = dax_fault(vma, vmf, ext4_dax_get_block); + result = dax_iomap_fault(vma, vmf, &ext4_iomap_fault_ops); if (write) { if (!IS_ERR(handle)) @@ -307,9 +307,10 @@ static int ext4_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr, if (IS_ERR(handle)) result = VM_FAULT_SIGBUS; - else - result = dax_pmd_fault(vma, addr, pmd, flags, - ext4_dax_get_block); + else { + result = dax_iomap_pmd_fault(vma, addr, pmd, flags, + &ext4_iomap_fault_ops); + } if (write) { if (!IS_ERR(handle)) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 635518dde20e..001fef06ea97 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3419,11 +3419,29 @@ static int ext4_iomap_end(struct inode *inode, loff_t offset, loff_t length, return 0; } +/* + * For faults we don't allocate any blocks outside of isize and we don't want + * to change it so we use a dedicated function for it... + */ +static int ext4_iomap_fault_end(struct inode *inode, loff_t offset, + loff_t length, ssize_t written, unsigned flags, + struct iomap *iomap) +{ + if (flags & IOMAP_WRITE) + ext4_journal_stop(ext4_journal_current_handle()); + return 0; +} + struct iomap_ops ext4_iomap_ops = { .iomap_begin = ext4_iomap_begin, .iomap_end = ext4_iomap_end, }; +struct iomap_ops ext4_iomap_fault_ops = { + .iomap_begin = ext4_iomap_begin, + .iomap_end = ext4_iomap_fault_end, +}; + #else /* Just define empty function, it will never get called. */ int ext4_dax_get_block(struct inode *inode, sector_t iblock,