Skip to content

Commit cd913c7

Browse files
Christoph Hellwigdjbw
authored andcommitted
dax: return the partition offset from fs_dax_get_by_bdev
Prepare for the removal of the block_device from the DAX I/O path by returning the partition offset from fs_dax_get_by_bdev so that the file systems have it at hand for use during I/O. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Dan Williams <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dan Williams <[email protected]>
1 parent 952da06 commit cd913c7

File tree

11 files changed

+22
-12
lines changed

11 files changed

+22
-12
lines changed

drivers/dax/super.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,20 @@ EXPORT_SYMBOL_GPL(dax_remove_host);
6969
/**
7070
* fs_dax_get_by_bdev() - temporary lookup mechanism for filesystem-dax
7171
* @bdev: block device to find a dax_device for
72+
* @start_off: returns the byte offset into the dax_device that @bdev starts
7273
*/
73-
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
74+
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start_off)
7475
{
7576
struct dax_device *dax_dev;
77+
u64 part_size;
7678
int id;
7779

7880
if (!blk_queue_dax(bdev->bd_disk->queue))
7981
return NULL;
8082

81-
if ((get_start_sect(bdev) * SECTOR_SIZE) % PAGE_SIZE ||
82-
(bdev_nr_sectors(bdev) * SECTOR_SIZE) % PAGE_SIZE) {
83+
*start_off = get_start_sect(bdev) * SECTOR_SIZE;
84+
part_size = bdev_nr_sectors(bdev) * SECTOR_SIZE;
85+
if (*start_off % PAGE_SIZE || part_size % PAGE_SIZE) {
8386
pr_info("%pg: error: unaligned partition for dax\n", bdev);
8487
return NULL;
8588
}

drivers/md/dm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ static int open_table_device(struct table_device *td, dev_t dev,
637637
struct mapped_device *md)
638638
{
639639
struct block_device *bdev;
640-
640+
u64 part_off;
641641
int r;
642642

643643
BUG_ON(td->dm_dev.bdev);
@@ -653,7 +653,7 @@ static int open_table_device(struct table_device *td, dev_t dev,
653653
}
654654

655655
td->dm_dev.bdev = bdev;
656-
td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev);
656+
td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev, &part_off);
657657
return 0;
658658
}
659659

fs/erofs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ struct erofs_device_info {
5151
char *path;
5252
struct block_device *bdev;
5353
struct dax_device *dax_dev;
54+
u64 dax_part_off;
5455

5556
u32 blocks;
5657
u32 mapped_blkaddr;
@@ -109,6 +110,7 @@ struct erofs_sb_info {
109110
#endif /* CONFIG_EROFS_FS_ZIP */
110111
struct erofs_dev_context *devs;
111112
struct dax_device *dax_dev;
113+
u64 dax_part_off;
112114
u64 total_blocks;
113115
u32 primarydevice_blocks;
114116

fs/erofs/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ static int erofs_init_devices(struct super_block *sb,
312312
goto err_out;
313313
}
314314
dif->bdev = bdev;
315-
dif->dax_dev = fs_dax_get_by_bdev(bdev);
315+
dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off);
316316
dif->blocks = le32_to_cpu(dis->blocks);
317317
dif->mapped_blkaddr = le32_to_cpu(dis->mapped_blkaddr);
318318
sbi->total_blocks += dif->blocks;
@@ -644,7 +644,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
644644

645645
sb->s_fs_info = sbi;
646646
sbi->opt = ctx->opt;
647-
sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
647+
sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->dax_part_off);
648648
sbi->devs = ctx->devs;
649649
ctx->devs = NULL;
650650

fs/ext2/ext2.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct ext2_sb_info {
118118
spinlock_t s_lock;
119119
struct mb_cache *s_ea_block_cache;
120120
struct dax_device *s_daxdev;
121+
u64 s_dax_part_off;
121122
};
122123

123124
static inline spinlock_t *

fs/ext2/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
831831
}
832832
sb->s_fs_info = sbi;
833833
sbi->s_sb_block = sb_block;
834-
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev);
834+
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off);
835835

836836
spin_lock_init(&sbi->s_lock);
837837
ret = -EINVAL;

fs/ext4/ext4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,6 +1697,7 @@ struct ext4_sb_info {
16971697
*/
16981698
struct percpu_rw_semaphore s_writepages_rwsem;
16991699
struct dax_device *s_daxdev;
1700+
u64 s_dax_part_off;
17001701
#ifdef CONFIG_EXT4_DEBUG
17011702
unsigned long s_simulate_fail;
17021703
#endif

fs/ext4/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3913,7 +3913,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
39133913
if (!sbi->s_blockgroup_lock)
39143914
goto out_free_base;
39153915

3916-
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev);
3916+
sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off);
39173917
sb->s_fs_info = sbi;
39183918
sbi->s_sb = sb;
39193919
sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS;

fs/xfs/xfs_buf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,7 @@ xfs_alloc_buftarg(
19451945
btp->bt_mount = mp;
19461946
btp->bt_dev = bdev->bd_dev;
19471947
btp->bt_bdev = bdev;
1948-
btp->bt_daxdev = fs_dax_get_by_bdev(bdev);
1948+
btp->bt_daxdev = fs_dax_get_by_bdev(bdev, &btp->bt_dax_part_off);
19491949

19501950
/*
19511951
* Buffer IO error rate limiting. Limit it to no more than 10 messages

fs/xfs/xfs_buf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ typedef struct xfs_buftarg {
8989
dev_t bt_dev;
9090
struct block_device *bt_bdev;
9191
struct dax_device *bt_daxdev;
92+
u64 bt_dax_part_off;
9293
struct xfs_mount *bt_mount;
9394
unsigned int bt_meta_sectorsize;
9495
size_t bt_meta_sectormask;

0 commit comments

Comments
 (0)