Commit cd913c76 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dan Williams
Browse files

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/20211129102203.2243509-26-hch@lst.de


Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent 952da063
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -69,17 +69,20 @@ EXPORT_SYMBOL_GPL(dax_remove_host);
/**
 * fs_dax_get_by_bdev() - temporary lookup mechanism for filesystem-dax
 * @bdev: block device to find a dax_device for
 * @start_off: returns the byte offset into the dax_device that @bdev starts
 */
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev)
struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev, u64 *start_off)
{
	struct dax_device *dax_dev;
	u64 part_size;
	int id;

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

	if ((get_start_sect(bdev) * SECTOR_SIZE) % PAGE_SIZE ||
	    (bdev_nr_sectors(bdev) * SECTOR_SIZE) % PAGE_SIZE) {
	*start_off = get_start_sect(bdev) * SECTOR_SIZE;
	part_size = bdev_nr_sectors(bdev) * SECTOR_SIZE;
	if (*start_off % PAGE_SIZE || part_size % PAGE_SIZE) {
		pr_info("%pg: error: unaligned partition for dax\n", bdev);
		return NULL;
	}
+2 −2
Original line number Diff line number Diff line
@@ -637,7 +637,7 @@ static int open_table_device(struct table_device *td, dev_t dev,
			     struct mapped_device *md)
{
	struct block_device *bdev;

	u64 part_off;
	int r;

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

	td->dm_dev.bdev = bdev;
	td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev);
	td->dm_dev.dax_dev = fs_dax_get_by_bdev(bdev, &part_off);
	return 0;
}

+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ struct erofs_device_info {
	char *path;
	struct block_device *bdev;
	struct dax_device *dax_dev;
	u64 dax_part_off;

	u32 blocks;
	u32 mapped_blkaddr;
@@ -109,6 +110,7 @@ struct erofs_sb_info {
#endif	/* CONFIG_EROFS_FS_ZIP */
	struct erofs_dev_context *devs;
	struct dax_device *dax_dev;
	u64 dax_part_off;
	u64 total_blocks;
	u32 primarydevice_blocks;

+2 −2
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ static int erofs_init_devices(struct super_block *sb,
			goto err_out;
		}
		dif->bdev = bdev;
		dif->dax_dev = fs_dax_get_by_bdev(bdev);
		dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off);
		dif->blocks = le32_to_cpu(dis->blocks);
		dif->mapped_blkaddr = le32_to_cpu(dis->mapped_blkaddr);
		sbi->total_blocks += dif->blocks;
@@ -644,7 +644,7 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)

	sb->s_fs_info = sbi;
	sbi->opt = ctx->opt;
	sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
	sbi->dax_dev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->dax_part_off);
	sbi->devs = ctx->devs;
	ctx->devs = NULL;

+1 −0
Original line number Diff line number Diff line
@@ -118,6 +118,7 @@ struct ext2_sb_info {
	spinlock_t s_lock;
	struct mb_cache *s_ea_block_cache;
	struct dax_device *s_daxdev;
	u64 s_dax_part_off;
};

static inline spinlock_t *
Loading