Commit 49845720 authored by Jan Kara's avatar Jan Kara Committed by Christian Brauner

erofs: Convert to use bdev_open_by_path()

Convert erofs to use bdev_open_by_path() and pass the handle around.

CC: Gao Xiang <xiang@kernel.org>
CC: Chao Yu <chao@kernel.org>
CC: linux-erofs@lists.ozlabs.org
Acked-by: default avatarChristoph Hellwig <hch@lst.de>
Acked-by: default avatarGao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20230927093442.25915-21-jack@suse.czSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
parent 86ec15d0
...@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) ...@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
up_read(&devs->rwsem); up_read(&devs->rwsem);
return 0; return 0;
} }
map->m_bdev = dif->bdev; map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev; map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off; map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache; map->m_fscache = dif->fscache;
...@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) ...@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
if (map->m_pa >= startoff && if (map->m_pa >= startoff &&
map->m_pa < startoff + length) { map->m_pa < startoff + length) {
map->m_pa -= startoff; map->m_pa -= startoff;
map->m_bdev = dif->bdev; map->m_bdev = dif->bdev_handle->bdev;
map->m_daxdev = dif->dax_dev; map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off; map->m_dax_part_off = dif->dax_part_off;
map->m_fscache = dif->fscache; map->m_fscache = dif->fscache;
......
...@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t; ...@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t;
struct erofs_device_info { struct erofs_device_info {
char *path; char *path;
struct erofs_fscache *fscache; struct erofs_fscache *fscache;
struct block_device *bdev; struct bdev_handle *bdev_handle;
struct dax_device *dax_dev; struct dax_device *dax_dev;
u64 dax_part_off; u64 dax_part_off;
......
...@@ -227,7 +227,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, ...@@ -227,7 +227,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
struct erofs_sb_info *sbi = EROFS_SB(sb); struct erofs_sb_info *sbi = EROFS_SB(sb);
struct erofs_fscache *fscache; struct erofs_fscache *fscache;
struct erofs_deviceslot *dis; struct erofs_deviceslot *dis;
struct block_device *bdev; struct bdev_handle *bdev_handle;
void *ptr; void *ptr;
ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP); ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP);
...@@ -251,13 +251,13 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb, ...@@ -251,13 +251,13 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
return PTR_ERR(fscache); return PTR_ERR(fscache);
dif->fscache = fscache; dif->fscache = fscache;
} else if (!sbi->devs->flatdev) { } else if (!sbi->devs->flatdev) {
bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type, bdev_handle = bdev_open_by_path(dif->path, BLK_OPEN_READ,
NULL); sb->s_type, NULL);
if (IS_ERR(bdev)) if (IS_ERR(bdev_handle))
return PTR_ERR(bdev); return PTR_ERR(bdev_handle);
dif->bdev = bdev; dif->bdev_handle = bdev_handle;
dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off, dif->dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev,
NULL, NULL); &dif->dax_part_off, NULL, NULL);
} }
dif->blocks = le32_to_cpu(dis->blocks); dif->blocks = le32_to_cpu(dis->blocks);
...@@ -806,8 +806,8 @@ static int erofs_release_device_info(int id, void *ptr, void *data) ...@@ -806,8 +806,8 @@ static int erofs_release_device_info(int id, void *ptr, void *data)
struct erofs_device_info *dif = ptr; struct erofs_device_info *dif = ptr;
fs_put_dax(dif->dax_dev, NULL); fs_put_dax(dif->dax_dev, NULL);
if (dif->bdev) if (dif->bdev_handle)
blkdev_put(dif->bdev, &erofs_fs_type); bdev_release(dif->bdev_handle);
erofs_fscache_unregister_cookie(dif->fscache); erofs_fscache_unregister_cookie(dif->fscache);
dif->fscache = NULL; dif->fscache = NULL;
kfree(dif->path); kfree(dif->path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment