Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jan Kara and committed by
Christian Brauner
49845720 86ec15d0

+13 -13
+2 -2
fs/erofs/data.c
··· 222 222 up_read(&devs->rwsem); 223 223 return 0; 224 224 } 225 - map->m_bdev = dif->bdev; 225 + map->m_bdev = dif->bdev_handle->bdev; 226 226 map->m_daxdev = dif->dax_dev; 227 227 map->m_dax_part_off = dif->dax_part_off; 228 228 map->m_fscache = dif->fscache; ··· 240 240 if (map->m_pa >= startoff && 241 241 map->m_pa < startoff + length) { 242 242 map->m_pa -= startoff; 243 - map->m_bdev = dif->bdev; 243 + map->m_bdev = dif->bdev_handle->bdev; 244 244 map->m_daxdev = dif->dax_dev; 245 245 map->m_dax_part_off = dif->dax_part_off; 246 246 map->m_fscache = dif->fscache;
+1 -1
fs/erofs/internal.h
··· 47 47 struct erofs_device_info { 48 48 char *path; 49 49 struct erofs_fscache *fscache; 50 - struct block_device *bdev; 50 + struct bdev_handle *bdev_handle; 51 51 struct dax_device *dax_dev; 52 52 u64 dax_part_off; 53 53
+10 -10
fs/erofs/super.c
··· 227 227 struct erofs_sb_info *sbi = EROFS_SB(sb); 228 228 struct erofs_fscache *fscache; 229 229 struct erofs_deviceslot *dis; 230 - struct block_device *bdev; 230 + struct bdev_handle *bdev_handle; 231 231 void *ptr; 232 232 233 233 ptr = erofs_read_metabuf(buf, sb, erofs_blknr(sb, *pos), EROFS_KMAP); ··· 251 251 return PTR_ERR(fscache); 252 252 dif->fscache = fscache; 253 253 } 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); 261 261 } 262 262 263 263 dif->blocks = le32_to_cpu(dis->blocks); ··· 806 806 struct erofs_device_info *dif = ptr; 807 807 808 808 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); 811 811 erofs_fscache_unregister_cookie(dif->fscache); 812 812 dif->fscache = NULL; 813 813 kfree(dif->path);