erofs: register fscache context for extra data blobs
authorJeffle Xu <jefflexu@linux.alibaba.com>
Mon, 25 Apr 2022 12:21:38 +0000 (20:21 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 17 May 2022 16:11:20 +0000 (00:11 +0800)
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>
fs/erofs/data.c
fs/erofs/internal.h
fs/erofs/super.c

index bc22642358ecaf623c5a45556a8ccbb452d3de0a..14b64d960541169e3c35bb245c2eb8efbb20e58d 100644 (file)
@@ -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;
                        }
                }
index 1a5eb619393286e1fa370392a8d616e6844820a7..6459ffecf1968a94e8cfc1f0f6f4238733add59e 100644 (file)
@@ -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;
index 84b976636d22deb38fd640b0b536831e6c2cd24a..a67c19dc06201abd0111fac444179fefe57746b0 100644 (file)
@@ -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;