Skip to content

Commit 955b478

Browse files
lostjefflehsiangkao
authored andcommitted
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 <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Chao Yu <[email protected]> Signed-off-by: Gao Xiang <[email protected]>
1 parent 37c90c5 commit 955b478

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

fs/erofs/data.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
199199
map->m_bdev = sb->s_bdev;
200200
map->m_daxdev = EROFS_SB(sb)->dax_dev;
201201
map->m_dax_part_off = EROFS_SB(sb)->dax_part_off;
202+
map->m_fscache = EROFS_SB(sb)->s_fscache;
202203

203204
if (map->m_deviceid) {
204205
down_read(&devs->rwsem);
@@ -210,6 +211,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
210211
map->m_bdev = dif->bdev;
211212
map->m_daxdev = dif->dax_dev;
212213
map->m_dax_part_off = dif->dax_part_off;
214+
map->m_fscache = dif->fscache;
213215
up_read(&devs->rwsem);
214216
} else if (devs->extra_devices) {
215217
down_read(&devs->rwsem);
@@ -227,6 +229,7 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
227229
map->m_bdev = dif->bdev;
228230
map->m_daxdev = dif->dax_dev;
229231
map->m_dax_part_off = dif->dax_part_off;
232+
map->m_fscache = dif->fscache;
230233
break;
231234
}
232235
}

fs/erofs/internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ typedef u32 erofs_blk_t;
4949

5050
struct erofs_device_info {
5151
char *path;
52+
struct erofs_fscache *fscache;
5253
struct block_device *bdev;
5354
struct dax_device *dax_dev;
5455
u64 dax_part_off;
@@ -457,6 +458,7 @@ static inline int z_erofs_map_blocks_iter(struct inode *inode,
457458
#endif /* !CONFIG_EROFS_FS_ZIP */
458459

459460
struct erofs_map_dev {
461+
struct erofs_fscache *m_fscache;
460462
struct block_device *m_bdev;
461463
struct dax_device *m_daxdev;
462464
u64 m_dax_part_off;

fs/erofs/super.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@ static int erofs_init_devices(struct super_block *sb,
260260
}
261261
dis = ptr + erofs_blkoff(pos);
262262

263-
if (!erofs_is_fscache_mode(sb)) {
263+
if (erofs_is_fscache_mode(sb)) {
264+
err = erofs_fscache_register_cookie(sb, &dif->fscache,
265+
dif->path, false);
266+
if (err)
267+
break;
268+
} else {
264269
bdev = blkdev_get_by_path(dif->path,
265270
FMODE_READ | FMODE_EXCL,
266271
sb->s_type);
@@ -750,6 +755,7 @@ static int erofs_release_device_info(int id, void *ptr, void *data)
750755
fs_put_dax(dif->dax_dev);
751756
if (dif->bdev)
752757
blkdev_put(dif->bdev, FMODE_READ | FMODE_EXCL);
758+
erofs_fscache_unregister_cookie(&dif->fscache);
753759
kfree(dif->path);
754760
kfree(dif);
755761
return 0;

0 commit comments

Comments
 (0)