Skip to content

Commit 4984572

Browse files
jankarabrauner
authored andcommitted
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: Christoph Hellwig <hch@lst.de> Acked-by: Gao Xiang <hsiangkao@linux.alibaba.com> Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Jan Kara <jack@suse.cz> Link: https://lore.kernel.org/r/20230927093442.25915-21-jack@suse.cz Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 86ec15d commit 4984572

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

fs/erofs/data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
222222
up_read(&devs->rwsem);
223223
return 0;
224224
}
225-
map->m_bdev = dif->bdev;
225+
map->m_bdev = dif->bdev_handle->bdev;
226226
map->m_daxdev = dif->dax_dev;
227227
map->m_dax_part_off = dif->dax_part_off;
228228
map->m_fscache = dif->fscache;
@@ -240,7 +240,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
240240
if (map->m_pa >= startoff &&
241241
map->m_pa < startoff + length) {
242242
map->m_pa -= startoff;
243-
map->m_bdev = dif->bdev;
243+
map->m_bdev = dif->bdev_handle->bdev;
244244
map->m_daxdev = dif->dax_dev;
245245
map->m_dax_part_off = dif->dax_part_off;
246246
map->m_fscache = dif->fscache;

fs/erofs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ typedef u32 erofs_blk_t;
4747
struct erofs_device_info {
4848
char *path;
4949
struct erofs_fscache *fscache;
50-
struct block_device *bdev;
50+
struct bdev_handle *bdev_handle;
5151
struct dax_device *dax_dev;
5252
u64 dax_part_off;
5353

fs/erofs/super.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static int erofs_init_device(struct erofs_buf *buf, struct super_block *sb,
227227
struct erofs_sb_info *sbi = EROFS_SB(sb);
228228
struct erofs_fscache *fscache;
229229
struct erofs_deviceslot *dis;
230-
struct block_device *bdev;
230+
struct bdev_handle *bdev_handle;
231231
void *ptr;
232232

233233
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,
251251
return PTR_ERR(fscache);
252252
dif->fscache = fscache;
253253
} else if (!sbi->devs->flatdev) {
254-
bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type,
255-
NULL);
256-
if (IS_ERR(bdev))
257-
return PTR_ERR(bdev);
258-
dif->bdev = bdev;
259-
dif->dax_dev = fs_dax_get_by_bdev(bdev, &dif->dax_part_off,
260-
NULL, NULL);
254+
bdev_handle = bdev_open_by_path(dif->path, BLK_OPEN_READ,
255+
sb->s_type, NULL);
256+
if (IS_ERR(bdev_handle))
257+
return PTR_ERR(bdev_handle);
258+
dif->bdev_handle = bdev_handle;
259+
dif->dax_dev = fs_dax_get_by_bdev(bdev_handle->bdev,
260+
&dif->dax_part_off, NULL, NULL);
261261
}
262262

263263
dif->blocks = le32_to_cpu(dis->blocks);
@@ -806,8 +806,8 @@ static int erofs_release_device_info(int id, void *ptr, void *data)
806806
struct erofs_device_info *dif = ptr;
807807

808808
fs_put_dax(dif->dax_dev, NULL);
809-
if (dif->bdev)
810-
blkdev_put(dif->bdev, &erofs_fs_type);
809+
if (dif->bdev_handle)
810+
bdev_release(dif->bdev_handle);
811811
erofs_fscache_unregister_cookie(dif->fscache);
812812
dif->fscache = NULL;
813813
kfree(dif->path);

0 commit comments

Comments
 (0)