From patchwork Fri Aug 25 00:35:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9921139 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 C9FEE602A0 for ; Fri, 25 Aug 2017 00:42:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD3520001 for ; Fri, 25 Aug 2017 00:42:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFAC5200F5; Fri, 25 Aug 2017 00:42:35 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F5B720001 for ; Fri, 25 Aug 2017 00:42:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754304AbdHYAmU (ORCPT ); Thu, 24 Aug 2017 20:42:20 -0400 Received: from mga05.intel.com ([192.55.52.43]:57920 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753803AbdHYAmS (ORCPT ); Thu, 24 Aug 2017 20:42:18 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 24 Aug 2017 17:42:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,423,1498546800"; d="scan'208";a="144324485" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by fmsmga006.fm.intel.com with ESMTP; 24 Aug 2017 17:42:17 -0700 Subject: [PATCH 2/2] ext2, ext4: cache dax_device lookup result From: Dan Williams To: linux-fsdevel@vger.kernel.org Cc: Theodore Ts'o , linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org, Andreas Dilger , Jan Kara , jack@suse.cz, hch@lst.de Date: Thu, 24 Aug 2017 17:35:53 -0700 Message-ID: <150362135374.39142.4099127163740487151.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <150362134292.39142.1715377949592729029.stgit@dwillia2-desk3.amr.corp.intel.com> References: <150362134292.39142.1715377949592729029.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The ->iomap_begin() operation is a hot path, so cache the fs_dax_get_by_host() result to avoid the incurring the hash lookup overhead. Cc: Jan Kara Cc: "Theodore Ts'o" Cc: Andreas Dilger Reported-by: Christoph Hellwig Signed-off-by: Dan Williams --- fs/ext2/inode.c | 11 +++++++---- fs/ext4/inode.c | 11 +++++++---- include/linux/fs.h | 3 +++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 30163d007b2f..910e6d502137 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c @@ -801,6 +801,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, unsigned flags, struct iomap *iomap) { struct block_device *bdev; + struct dax_device *dax_dev; unsigned int blkbits = inode->i_blkbits; unsigned long first_block = offset >> blkbits; unsigned long max_blocks = (length + (1 << blkbits) - 1) >> blkbits; @@ -817,10 +818,12 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length, bdev = inode->i_sb->s_bdev; iomap->bdev = bdev; iomap->offset = (u64)first_block << blkbits; - if (blk_queue_dax(bdev->bd_queue)) - iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name); - else - iomap->dax_dev = NULL; + dax_dev = inode->i_sb->s_daxdev; + if (blk_queue_dax(bdev->bd_queue) && !dax_dev) { + dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name); + inode->i_sb->s_daxdev = dax_dev; + } + iomap->dax_dev = dax_dev; if (ret == 0) { iomap->type = IOMAP_HOLE; diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index c774bdc22759..36a4bcab9e0c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3405,6 +3405,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, unsigned flags, struct iomap *iomap) { struct block_device *bdev; + struct dax_device *dax_dev; unsigned int blkbits = inode->i_blkbits; unsigned long first_block = offset >> blkbits; unsigned long last_block = (offset + length - 1) >> blkbits; @@ -3475,10 +3476,12 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->flags = 0; bdev = inode->i_sb->s_bdev; iomap->bdev = bdev; - if (blk_queue_dax(bdev->bd_queue)) - iomap->dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name); - else - iomap->dax_dev = NULL; + dax_dev = inode->i_sb->s_daxdev; + if (blk_queue_dax(bdev->bd_queue) && !dax_dev) { + dax_dev = fs_dax_get_by_host(bdev->bd_disk->disk_name); + inode->i_sb->s_daxdev = dax_dev; + } + iomap->dax_dev = dax_dev; iomap->offset = first_block << blkbits; if (ret == 0) { diff --git a/include/linux/fs.h b/include/linux/fs.h index 6e1fd5d21248..0594867a172a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1334,6 +1334,9 @@ struct super_block { struct hlist_bl_head s_anon; /* anonymous dentries for (nfs) exporting */ struct list_head s_mounts; /* list of mounts; _not_ for fs use */ struct block_device *s_bdev; +#ifdef CONFIG_FS_DAX + struct dax_device *s_daxdev; /* cached dax_device */ +#endif struct backing_dev_info *s_bdi; struct mtd_info *s_mtd; struct hlist_node s_instances;