lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <150362135374.39142.4099127163740487151.stgit@dwillia2-desk3.amr.corp.intel.com>
Date:   Thu, 24 Aug 2017 17:35:53 -0700
From:   Dan Williams <dan.j.williams@...el.com>
To:     linux-fsdevel@...r.kernel.org
Cc:     Theodore Ts'o <tytso@....edu>, linux-nvdimm@...ts.01.org,
        linux-kernel@...r.kernel.org,
        Andreas Dilger <adilger.kernel@...ger.ca>,
        Jan Kara <jack@...e.com>, jack@...e.cz, hch@....de
Subject: [PATCH 2/2] ext2, ext4: cache dax_device lookup result

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 <jack@...e.com>
Cc: "Theodore Ts'o" <tytso@....edu>
Cc: Andreas Dilger <adilger.kernel@...ger.ca>
Reported-by: Christoph Hellwig <hch@....de>
Signed-off-by: Dan Williams <dan.j.williams@...el.com>
---
 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;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ