mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
fsdax: shift partition offset handling into the file systems
Remove the last user of ->bdev in dax.c by requiring the file system to pass in an address that already includes the DAX offset. As part of the only set ->bdev or ->daxdev when actually required in the ->iomap_begin methods. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com> [erofs] Reviewed-by: Darrick J. Wong <djwong@kernel.org> Link: https://lore.kernel.org/r/20211129102203.2243509-27-hch@lst.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
This commit is contained in:
parent
cd913c76f4
commit
de20511477
6
fs/dax.c
6
fs/dax.c
@ -711,11 +711,7 @@ int dax_invalidate_mapping_entry_sync(struct address_space *mapping,
|
||||
|
||||
static pgoff_t dax_iomap_pgoff(const struct iomap *iomap, loff_t pos)
|
||||
{
|
||||
phys_addr_t paddr = iomap->addr + (pos & PAGE_MASK) - iomap->offset;
|
||||
|
||||
if (iomap->bdev)
|
||||
paddr += (get_start_sect(iomap->bdev) << SECTOR_SHIFT);
|
||||
return PHYS_PFN(paddr);
|
||||
return PHYS_PFN(iomap->addr + (pos & PAGE_MASK) - iomap->offset);
|
||||
}
|
||||
|
||||
static int copy_cow_page_dax(struct vm_fault *vmf, const struct iomap_iter *iter)
|
||||
|
@ -159,6 +159,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
||||
/* primary device by default */
|
||||
map->m_bdev = sb->s_bdev;
|
||||
map->m_daxdev = EROFS_SB(sb)->dax_dev;
|
||||
map->m_dax_part_off = EROFS_SB(sb)->dax_part_off;
|
||||
|
||||
if (map->m_deviceid) {
|
||||
down_read(&devs->rwsem);
|
||||
@ -169,6 +170,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
||||
}
|
||||
map->m_bdev = dif->bdev;
|
||||
map->m_daxdev = dif->dax_dev;
|
||||
map->m_dax_part_off = dif->dax_part_off;
|
||||
up_read(&devs->rwsem);
|
||||
} else if (devs->extra_devices) {
|
||||
down_read(&devs->rwsem);
|
||||
@ -185,6 +187,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
||||
map->m_pa -= startoff;
|
||||
map->m_bdev = dif->bdev;
|
||||
map->m_daxdev = dif->dax_dev;
|
||||
map->m_dax_part_off = dif->dax_part_off;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -215,9 +218,13 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
iomap->bdev = mdev.m_bdev;
|
||||
iomap->dax_dev = mdev.m_daxdev;
|
||||
iomap->offset = map.m_la;
|
||||
if (flags & IOMAP_DAX) {
|
||||
iomap->dax_dev = mdev.m_daxdev;
|
||||
iomap->offset += mdev.m_dax_part_off;
|
||||
} else {
|
||||
iomap->bdev = mdev.m_bdev;
|
||||
}
|
||||
iomap->length = map.m_llen;
|
||||
iomap->flags = 0;
|
||||
iomap->private = NULL;
|
||||
|
@ -438,6 +438,7 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
|
||||
struct erofs_map_dev {
|
||||
struct block_device *m_bdev;
|
||||
struct dax_device *m_daxdev;
|
||||
u64 m_dax_part_off;
|
||||
|
||||
erofs_off_t m_pa;
|
||||
unsigned int m_deviceid;
|
||||
|
@ -817,9 +817,11 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
||||
return ret;
|
||||
|
||||
iomap->flags = 0;
|
||||
iomap->bdev = inode->i_sb->s_bdev;
|
||||
iomap->offset = (u64)first_block << blkbits;
|
||||
iomap->dax_dev = sbi->s_daxdev;
|
||||
if (flags & IOMAP_DAX)
|
||||
iomap->dax_dev = sbi->s_daxdev;
|
||||
else
|
||||
iomap->bdev = inode->i_sb->s_bdev;
|
||||
|
||||
if (ret == 0) {
|
||||
iomap->type = IOMAP_HOLE;
|
||||
@ -828,6 +830,8 @@ static int ext2_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
||||
} else {
|
||||
iomap->type = IOMAP_MAPPED;
|
||||
iomap->addr = (u64)bno << blkbits;
|
||||
if (flags & IOMAP_DAX)
|
||||
iomap->addr += sbi->s_dax_part_off;
|
||||
iomap->length = (u64)ret << blkbits;
|
||||
iomap->flags |= IOMAP_F_MERGED;
|
||||
}
|
||||
|
@ -3272,7 +3272,7 @@ static bool ext4_inode_datasync_dirty(struct inode *inode)
|
||||
|
||||
static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
|
||||
struct ext4_map_blocks *map, loff_t offset,
|
||||
loff_t length)
|
||||
loff_t length, unsigned int flags)
|
||||
{
|
||||
u8 blkbits = inode->i_blkbits;
|
||||
|
||||
@ -3289,8 +3289,10 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
|
||||
if (map->m_flags & EXT4_MAP_NEW)
|
||||
iomap->flags |= IOMAP_F_NEW;
|
||||
|
||||
iomap->bdev = inode->i_sb->s_bdev;
|
||||
iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
|
||||
if (flags & IOMAP_DAX)
|
||||
iomap->dax_dev = EXT4_SB(inode->i_sb)->s_daxdev;
|
||||
else
|
||||
iomap->bdev = inode->i_sb->s_bdev;
|
||||
iomap->offset = (u64) map->m_lblk << blkbits;
|
||||
iomap->length = (u64) map->m_len << blkbits;
|
||||
|
||||
@ -3310,9 +3312,13 @@ static void ext4_set_iomap(struct inode *inode, struct iomap *iomap,
|
||||
if (map->m_flags & EXT4_MAP_UNWRITTEN) {
|
||||
iomap->type = IOMAP_UNWRITTEN;
|
||||
iomap->addr = (u64) map->m_pblk << blkbits;
|
||||
if (flags & IOMAP_DAX)
|
||||
iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off;
|
||||
} else if (map->m_flags & EXT4_MAP_MAPPED) {
|
||||
iomap->type = IOMAP_MAPPED;
|
||||
iomap->addr = (u64) map->m_pblk << blkbits;
|
||||
if (flags & IOMAP_DAX)
|
||||
iomap->addr += EXT4_SB(inode->i_sb)->s_dax_part_off;
|
||||
} else {
|
||||
iomap->type = IOMAP_HOLE;
|
||||
iomap->addr = IOMAP_NULL_ADDR;
|
||||
@ -3421,7 +3427,7 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
out:
|
||||
ext4_set_iomap(inode, iomap, &map, offset, length);
|
||||
ext4_set_iomap(inode, iomap, &map, offset, length, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -3541,7 +3547,7 @@ static int ext4_iomap_begin_report(struct inode *inode, loff_t offset,
|
||||
delalloc = ext4_iomap_is_delalloc(inode, &map);
|
||||
|
||||
set_iomap:
|
||||
ext4_set_iomap(inode, iomap, &map, offset, length);
|
||||
ext4_set_iomap(inode, iomap, &map, offset, length, flags);
|
||||
if (delalloc && iomap->type == IOMAP_HOLE)
|
||||
iomap->type = IOMAP_DELALLOC;
|
||||
|
||||
|
@ -71,15 +71,21 @@ xfs_bmbt_to_iomap(
|
||||
iomap->type = IOMAP_DELALLOC;
|
||||
} else {
|
||||
iomap->addr = BBTOB(xfs_fsb_to_db(ip, imap->br_startblock));
|
||||
if (mapping_flags & IOMAP_DAX)
|
||||
iomap->addr += target->bt_dax_part_off;
|
||||
|
||||
if (imap->br_state == XFS_EXT_UNWRITTEN)
|
||||
iomap->type = IOMAP_UNWRITTEN;
|
||||
else
|
||||
iomap->type = IOMAP_MAPPED;
|
||||
|
||||
}
|
||||
iomap->offset = XFS_FSB_TO_B(mp, imap->br_startoff);
|
||||
iomap->length = XFS_FSB_TO_B(mp, imap->br_blockcount);
|
||||
iomap->bdev = target->bt_bdev;
|
||||
iomap->dax_dev = target->bt_daxdev;
|
||||
if (mapping_flags & IOMAP_DAX)
|
||||
iomap->dax_dev = target->bt_daxdev;
|
||||
else
|
||||
iomap->bdev = target->bt_bdev;
|
||||
iomap->flags = iomap_flags;
|
||||
|
||||
if (xfs_ipincount(ip) &&
|
||||
|
Loading…
Reference in New Issue
Block a user