From: Gao Xiang hsiangkao@linux.alibaba.com
anolis inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT
Reference: https://gitee.com/anolis/cloud-kernel/commit/a0e45afbebb0
--------------------------------
ANBZ: #1666
commit 955b478e1b4ad5530cd10395d56d45119d3a3ff4 upstream.
Similar to the multi-device mode, erofs could be mounted from one primary data blob (mandatory) and multiple extra data blobs (optional).
Register fscache context for each extra data blob.
Signed-off-by: Jeffle Xu jefflexu@linux.alibaba.com Reviewed-by: Gao Xiang hsiangkao@linux.alibaba.com Link: https://lore.kernel.org/r/20220425122143.56815-17-jefflexu@linux.alibaba.com Acked-by: Chao Yu chao@kernel.org Signed-off-by: Gao Xiang hsiangkao@linux.alibaba.com Signed-off-by: Huang Jianan jnhuang@linux.alibaba.com Reviewed-by: Jeffle Xu jefflexu@linux.alibaba.com Signed-off-by: Baokun Li libaokun1@huawei.com --- fs/erofs/data.c | 3 +++ fs/erofs/internal.h | 2 ++ fs/erofs/super.c | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/fs/erofs/data.c b/fs/erofs/data.c index 1cfb2d510a30..8b4547dc32af 100644 --- a/fs/erofs/data.c +++ b/fs/erofs/data.c @@ -222,6 +222,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
/* primary device by default */ map->m_bdev = sb->s_bdev; + map->m_fscache = EROFS_SB(sb)->s_fscache;
if (map->m_deviceid) { down_read(&devs->rwsem); @@ -231,6 +232,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) return -ENODEV; } map->m_bdev = dif->bdev; + map->m_fscache = dif->fscache; up_read(&devs->rwsem); } else if (devs->extra_devices) { down_read(&devs->rwsem); @@ -246,6 +248,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map) map->m_pa < startoff + length) { map->m_pa -= startoff; map->m_bdev = dif->bdev; + map->m_fscache = dif->fscache; break; } } diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index 06aa8dc55cfc..e1d526ee5be4 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -49,6 +49,7 @@ typedef u32 erofs_blk_t;
struct erofs_device_info { char *path; + struct erofs_fscache *fscache; struct block_device *bdev;
u32 blocks; @@ -392,6 +393,7 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode, #endif /* !CONFIG_EROFS_FS_ZIP */
struct erofs_map_dev { + struct erofs_fscache *m_fscache; struct block_device *m_bdev;
erofs_off_t m_pa; diff --git a/fs/erofs/super.c b/fs/erofs/super.c index 7af2afd62c40..037369ff7081 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -163,7 +163,12 @@ static int erofs_init_devices(struct super_block *sb, } dis = ptr + erofs_blkoff(pos);
- if (!erofs_is_fscache_mode(sb)) { + if (erofs_is_fscache_mode(sb)) { + err = erofs_fscache_register_cookie(sb, &dif->fscache, + dif->path, false); + if (err) + break; + } else { bdev = blkdev_get_by_path(dif->path, FMODE_READ | FMODE_EXCL, sb->s_type); @@ -530,6 +535,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data)
if (dif->bdev) blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL); + erofs_fscache_unregister_cookie(&dif->fscache); kfree(dif->path); kfree(dif); return 0;