@@ -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;
@@ -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;
@@ -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
@@ -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;
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(+)