summaryrefslogtreecommitdiff
path: root/fs/erofs/data.c
diff options
context:
space:
mode:
authorJia Zhu <zhujia.zj@bytedance.com>2023-03-02 10:17:51 +0300
committerGao Xiang <hsiangkao@linux.alibaba.com>2023-04-16 20:15:46 +0300
commit8b465fecc35a434e61728a6184d188c6daa37a5d (patch)
tree5e5edf8ece3a4a97d14b69f082f281ecf6efa766 /fs/erofs/data.c
parentd3c4bdcc756e60b95365c66ff58844ce75d1c8f8 (diff)
downloadlinux-8b465fecc35a434e61728a6184d188c6daa37a5d.tar.xz
erofs: support flattened block device for multi-blob images
In order to support mounting multi-blobs container image as a single block device, add flattened block device feature for EROFS. In this mode, all meta/data contents will be mapped into one block space. User could compose a block device(by nbd/ublk/virtio-blk/ vhost-user-blk) from multiple sources and mount the block device by EROFS directly. It can reduce the number of block devices used, and it's also benefits in both VM file passthrough and distributed storage scenarios. You can test this using the method mentioned by: https://github.com/dragonflyoss/image-service/pull/1139 1. Compose a (nbd)block device from multi-blobs. 2. Mount EROFS on mntdir/. 3. Compare the md5sum between source dir and mntdir/. Later, we could also use it to refer original tar blobs. Signed-off-by: Jia Zhu <zhujia.zj@bytedance.com> Signed-off-by: Xin Yin <yinxin.x@bytedance.com> Reviewed-by: Jingbo Xu <jefflexu@linux.alibaba.com> Acked-by: Chao Yu <chao@kernel.org> Tested-by: Jiang Liu <gerry@linux.alibaba.com> Link: https://lore.kernel.org/r/20230302071751.48425-1-zhujia.zj@bytedance.com [ Gao Xiang: refine commit message and use erofs_pos(). ] Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Diffstat (limited to 'fs/erofs/data.c')
-rw-r--r--fs/erofs/data.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/erofs/data.c b/fs/erofs/data.c
index 1c931e32d28e..03c6ffdfcbfb 100644
--- a/fs/erofs/data.c
+++ b/fs/erofs/data.c
@@ -200,7 +200,6 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
struct erofs_device_info *dif;
int id;
- /* primary device by default */
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;
@@ -213,12 +212,17 @@ int erofs_map_dev(struct super_block *sb, struct erofs_map_dev *map)
up_read(&devs->rwsem);
return -ENODEV;
}
+ if (devs->flatdev) {
+ map->m_pa += erofs_pos(sb, dif->mapped_blkaddr);
+ up_read(&devs->rwsem);
+ return 0;
+ }
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) {
+ } else if (devs->extra_devices && !devs->flatdev) {
down_read(&devs->rwsem);
idr_for_each_entry(&devs->tree, dif, id) {
erofs_off_t startoff, length;