summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffle Xu <jefflexu@linux.alibaba.com>2022-04-25 20:21:38 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2022-05-18 00:11:20 +0800
commit955b478e1b4ad5530cd10395d56d45119d3a3ff4 (patch)
tree76aa7f79d933f3f62618b32d6f28a4a26886bdf3
parent37c90c5fae701983e21cc80396649e3aca7f4fa1 (diff)
downloadlinux-955b478e1b4ad5530cd10395d56d45119d3a3ff4.tar.bz2
erofs: register fscache context for extra data blobs
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>
-rw-r--r--fs/erofs/data.c3
-rw-r--r--fs/erofs/internal.h2
-rw-r--r--fs/erofs/super.c8
3 files changed, 12 insertions, 1 deletions
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index bc22642358ec..14b64d960541 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -199,6 +199,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
map->m_bdev = sb->s_bdev;
map->m_daxdev = EROFS_SB(sb)->dax_dev;
map->m_dax_part_off = EROFS_SB(sb)->dax_part_off;
+ map->m_fscache = EROFS_SB(sb)->s_fscache;
if (map->m_deviceid) {
down_read(&devs->rwsem);
@@ -210,6 +211,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
map->m_bdev = dif->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
+ map->m_fscache = dif->fscache;
up_read(&devs->rwsem);
} else if (devs->extra_devices) {
down_read(&devs->rwsem);
@@ -227,6 +229,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
map->m_bdev = dif->bdev;
map->m_daxdev = dif->dax_dev;
map->m_dax_part_off = dif->dax_part_off;
+ map->m_fscache = dif->fscache;
break;
}
}
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 1a5eb6193932..6459ffecf196 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;
struct dax_device *dax_dev;
u64 dax_part_off;
@@ -457,6 +458,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;
struct dax_device *m_daxdev;
u64 m_dax_part_off;
diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 84b976636d22..a67c19dc0620 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -260,7 +260,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);
@@ -750,6 +755,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data)
fs_put_dax(dif->dax_dev);
if (dif->bdev)
blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL);
+ erofs_fscache_unregister_cookie(&dif->fscache);
kfree(dif->path);
kfree(dif);
return 0;