linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org,
	dan.j.williams@intel.com, hch@infradead.org
Cc: vgoyal@redhat.com, dm-devel@redhat.com, jack@suse.cz
Subject: [PATCH 2/6] dax,iomap,ext4,ext2,xfs: Save dax_offset in "struct iomap"
Date: Wed, 12 Feb 2020 12:07:29 -0500	[thread overview]
Message-ID: <20200212170733.8092-3-vgoyal@redhat.com> (raw)
In-Reply-To: <20200212170733.8092-1-vgoyal@redhat.com>

Add a new field "sector_t dax_offset" to "struct iomap". This will be
filled by filesystems and dax code will make use of this to convert
sector into page offset (dax_pgoff()), instead of bdev_dax_pgoff(). This
removes the dependency of having to pass in block device for dax operations.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
---
 fs/ext2/inode.c       | 1 +
 fs/ext4/inode.c       | 1 +
 fs/xfs/xfs_iomap.c    | 2 ++
 include/linux/iomap.h | 1 +
 4 files changed, 5 insertions(+)

diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index c885cf7d724b..5c3379e78d49 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -823,6 +823,7 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
 	iomap->bdev = inode->i_sb->s_bdev;
 	iomap->offset = (u64)first_block << blkbits;
 	iomap->dax_dev = sbi->s_daxdev;
+	iomap->dax_offset = get_start_sect(iomap->bdev);
 
 	if (ret == 0) {
 		iomap->type = IOMAP_HOLE;
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 1305b810c44a..0ea7fbb8076f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3330,6 +3330,7 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
 
 	iomap->bdev = inode->i_sb->s_bdev;
 	iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
+	iomap->dax_offset = get_start_sect(iomap->bdev);
 	iomap->offset = (u64) map->m_lblk << blkbits;
 	iomap->length = (u64) map->m_len << blkbits;
 
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index bb590a267a7f..ad8b18fc96fd 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -80,6 +80,7 @@ xfs_bmbt_to_iomap(
 	iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
 	iomap->bdev = target->bt_bdev;
 	iomap->dax_dev = target->bt_daxdev;
+	iomap->dax_offset = get_start_sect(iomap->bdev);
 	iomap->flags = flags;
 
 	if (xfs_ipincount(ip) &&
@@ -103,6 +104,7 @@ xfs_hole_to_iomap(
 	iomap->length = XFS_FSB_TO_B(ip->i_mount, end_fsb - offset_fsb);
 	iomap->bdev = target->bt_bdev;
 	iomap->dax_dev = target->bt_daxdev;
+	iomap->dax_offset = get_start_sect(iomap->bdev);
 }
 
 static inline xfs_fileoff_t
diff --git a/include/linux/iomap.h b/include/linux/iomap.h
index 8b09463dae0d..cac5d667aa74 100644
--- a/include/linux/iomap.h
+++ b/include/linux/iomap.h
@@ -84,6 +84,7 @@ struct iomap {
 	u16			flags;	/* flags for mapping */
 	struct block_device	*bdev;	/* block device for I/O */
 	struct dax_device	*dax_dev; /* dax_dev for dax operations */
+	sector_t		dax_offset; /* offset in dax device */
 	void			*inline_data;
 	void			*private; /* filesystem private */
 	const struct iomap_page_ops *page_ops;
-- 
2.20.1


  parent reply	other threads:[~2020-02-12 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-12 17:07 [RFC PATCH 0/6] dax: Replace bdev_dax_pgoff() with dax_pgoff() Vivek Goyal
2020-02-12 17:07 ` [PATCH 1/6] dax: Define a helper dax_pgoff() which takes in dax_offset as argument Vivek Goyal
2020-02-17 13:30   ` Christoph Hellwig
2020-02-17 13:37   ` Matthew Wilcox
2020-02-12 17:07 ` Vivek Goyal [this message]
2020-02-17 13:31   ` [PATCH 2/6] dax,iomap,ext4,ext2,xfs: Save dax_offset in "struct iomap" Christoph Hellwig
2020-02-12 17:07 ` [PATCH 3/6] fs/dax.c: Start using dax_pgoff() instead of bdev_dax_pgoff() Vivek Goyal
2020-02-12 17:07 ` [PATCH 4/6] dax, dm/md: Use " Vivek Goyal
2020-02-12 17:07 ` [PATCH 5/6] drivers/dax: " Vivek Goyal
2020-02-12 17:07 ` [PATCH 6/6] dax: Remove bdev_dax_pgoff() helper Vivek Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200212170733.8092-3-vgoyal@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@infradead.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).