erofs: reference struct erofs_device_info for erofs_map_dev
[ Upstream commit f8d920a402aec3482931cb5f1539ed438740fc49 ] Record `m_sb` and `m_dif` to replace `m_fscache`, `m_daxdev`, `m_fp` and `m_dax_part_off` in order to simplify the codebase. Note that `m_bdev` is still left since it can be assigned from `sb->s_bdev` directly. Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com> Link: https://lore.kernel.org/r/20241212235401.2857246-1-hsiangkao@linux.alibaba.com Stable-dep-of: 6422cde1b0d5 ("erofs: use buffered I/O for file-backed mounts by default") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3e0d81efcb
commit
f067d3f69d
+10
-16
@@ -186,19 +186,13 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void erofs_fill_from_devinfo(struct erofs_map_dev *map,
|
static void erofs_fill_from_devinfo(struct erofs_map_dev *map,
|
||||||
struct erofs_device_info *dif)
|
struct super_block *sb, struct erofs_device_info *dif)
|
||||||
{
|
{
|
||||||
|
map->m_sb = sb;
|
||||||
|
map->m_dif = dif;
|
||||||
map->m_bdev = NULL;
|
map->m_bdev = NULL;
|
||||||
map->m_fp = NULL;
|
if (dif->file && S_ISBLK(file_inode(dif->file)->i_mode))
|
||||||
if (dif->file) {
|
map->m_bdev = file_bdev(dif->file);
|
||||||
if (S_ISBLK(file_inode(dif->file)->i_mode))
|
|
||||||
map->m_bdev = file_bdev(dif->file);
|
|
||||||
else
|
|
||||||
map->m_fp = dif->file;
|
|
||||||
}
|
|
||||||
map->m_daxdev = dif->dax_dev;
|
|
||||||
map->m_dax_part_off = dif->dax_part_off;
|
|
||||||
map->m_fscache = dif->fscache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
||||||
@@ -208,7 +202,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
|
|||||||
erofs_off_t startoff, length;
|
erofs_off_t startoff, length;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
erofs_fill_from_devinfo(map, &EROFS_SB(sb)->dif0);
|
erofs_fill_from_devinfo(map, sb, &EROFS_SB(sb)->dif0);
|
||||||
map->m_bdev = sb->s_bdev; /* use s_bdev for the primary device */
|
map->m_bdev = sb->s_bdev; /* use s_bdev for the primary device */
|
||||||
if (map->m_deviceid) {
|
if (map->m_deviceid) {
|
||||||
down_read(&devs->rwsem);
|
down_read(&devs->rwsem);
|
||||||
@@ -222,7 +216,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;
|
||||||
}
|
}
|
||||||
erofs_fill_from_devinfo(map, dif);
|
erofs_fill_from_devinfo(map, sb, dif);
|
||||||
up_read(&devs->rwsem);
|
up_read(&devs->rwsem);
|
||||||
} else if (devs->extra_devices && !devs->flatdev) {
|
} else if (devs->extra_devices && !devs->flatdev) {
|
||||||
down_read(&devs->rwsem);
|
down_read(&devs->rwsem);
|
||||||
@@ -235,7 +229,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;
|
||||||
erofs_fill_from_devinfo(map, dif);
|
erofs_fill_from_devinfo(map, sb, dif);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,7 +299,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
|||||||
|
|
||||||
iomap->offset = map.m_la;
|
iomap->offset = map.m_la;
|
||||||
if (flags & IOMAP_DAX)
|
if (flags & IOMAP_DAX)
|
||||||
iomap->dax_dev = mdev.m_daxdev;
|
iomap->dax_dev = mdev.m_dif->dax_dev;
|
||||||
else
|
else
|
||||||
iomap->bdev = mdev.m_bdev;
|
iomap->bdev = mdev.m_bdev;
|
||||||
iomap->length = map.m_llen;
|
iomap->length = map.m_llen;
|
||||||
@@ -334,7 +328,7 @@ static int erofs_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
|
|||||||
iomap->type = IOMAP_MAPPED;
|
iomap->type = IOMAP_MAPPED;
|
||||||
iomap->addr = mdev.m_pa;
|
iomap->addr = mdev.m_pa;
|
||||||
if (flags & IOMAP_DAX)
|
if (flags & IOMAP_DAX)
|
||||||
iomap->addr += mdev.m_dax_part_off;
|
iomap->addr += mdev.m_dif->dax_part_off;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -67,7 +67,7 @@ static struct erofs_fileio_rq *erofs_fileio_rq_alloc(struct erofs_map_dev *mdev)
|
|||||||
GFP_KERNEL | __GFP_NOFAIL);
|
GFP_KERNEL | __GFP_NOFAIL);
|
||||||
|
|
||||||
bio_init(&rq->bio, NULL, rq->bvecs, BIO_MAX_VECS, REQ_OP_READ);
|
bio_init(&rq->bio, NULL, rq->bvecs, BIO_MAX_VECS, REQ_OP_READ);
|
||||||
rq->iocb.ki_filp = mdev->m_fp;
|
rq->iocb.ki_filp = mdev->m_dif->file;
|
||||||
return rq;
|
return rq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -198,7 +198,7 @@ struct bio *erofs_fscache_bio_alloc(struct erofs_map_dev *mdev)
|
|||||||
|
|
||||||
io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
|
io = kmalloc(sizeof(*io), GFP_KERNEL | __GFP_NOFAIL);
|
||||||
bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
|
bio_init(&io->bio, NULL, io->bvecs, BIO_MAX_VECS, REQ_OP_READ);
|
||||||
io->io.private = mdev->m_fscache->cookie;
|
io->io.private = mdev->m_dif->fscache->cookie;
|
||||||
io->io.end_io = erofs_fscache_bio_endio;
|
io->io.end_io = erofs_fscache_bio_endio;
|
||||||
refcount_set(&io->io.ref, 1);
|
refcount_set(&io->io.ref, 1);
|
||||||
return &io->bio;
|
return &io->bio;
|
||||||
@@ -316,7 +316,7 @@ static int erofs_fscache_data_read_slice(struct erofs_fscache_rq *req)
|
|||||||
if (!io)
|
if (!io)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
iov_iter_xarray(&io->iter, ITER_DEST, &mapping->i_pages, pos, count);
|
iov_iter_xarray(&io->iter, ITER_DEST, &mapping->i_pages, pos, count);
|
||||||
ret = erofs_fscache_read_io_async(mdev.m_fscache->cookie,
|
ret = erofs_fscache_read_io_async(mdev.m_dif->fscache->cookie,
|
||||||
mdev.m_pa + (pos - map.m_la), io);
|
mdev.m_pa + (pos - map.m_la), io);
|
||||||
erofs_fscache_req_io_put(io);
|
erofs_fscache_req_io_put(io);
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -366,11 +366,9 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct erofs_map_dev {
|
struct erofs_map_dev {
|
||||||
struct erofs_fscache *m_fscache;
|
struct super_block *m_sb;
|
||||||
|
struct erofs_device_info *m_dif;
|
||||||
struct block_device *m_bdev;
|
struct block_device *m_bdev;
|
||||||
struct dax_device *m_daxdev;
|
|
||||||
struct file *m_fp;
|
|
||||||
u64 m_dax_part_off;
|
|
||||||
|
|
||||||
erofs_off_t m_pa;
|
erofs_off_t m_pa;
|
||||||
unsigned int m_deviceid;
|
unsigned int m_deviceid;
|
||||||
|
|||||||
Reference in New Issue
Block a user