erofs-utils: add extra blob device support
RFC PATCH 1/1 erofs-utils: add extra blob device support
In this patch, blob data from chunked-based files is redirected to another blob file.
In order to redirect that, "--blobdev" should be used to specify the output blob file/device for all chunk-based files, e.g.
mkfs.erofs --blobdev blob.erofs --chunksize 4096 foo.erofs foo
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/blobchunk.h | 3 +- include/erofs/cache.h | 5 ++++ include/erofs/config.h | 1 + include/erofs/internal.h | 4 +++ include/erofs_fs.h | 19 +++++++++++-- lib/blobchunk.c | 58 +++++++++++++++++++++++++++++++++++---- mkfs/main.c | 15 +++++++++- 7 files changed, 96 insertions(+), 9 deletions(-)
include/erofs/blobchunk.h +2 -1
@@ -13,6 +13,7 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode, erofs_off_t off);int erofs_blob_write_chunked_file (struct erofs_inode *inode);int erofs_blob_remap (void );void erofs_blob_exit (void ); -int erofs_blob_init (void ); +int erofs_blob_init (const char *); +int erofs_generate_devtable (void );#endif
include/erofs/cache.h +5 -0
@@ -19,6 +19,8 @@ struct erofs_buffer_block;#define INODE 2/* shared xattrs */ #define XATTR 3 +/* device table */ +#define DEVT 4struct erofs_bhops {bool (*preflush)(struct erofs_buffer_head *bh);
@@ -56,6 +58,9 @@ static inline const int get_alignsize(int type, int *type_ret) }else if (type ==XATTR ) { *type_ret =META ;return sizeof (struct erofs_xattr_entry ); + }else if (type ==DEVT ) { + *type_ret =META ; +return EROFS_DEVT_SLOT_SIZE ; }if (type ==META )
include/erofs/config.h +1 -0
@@ -51,6 +51,7 @@ struct erofs_configure {/* related arguments for mkfs.erofs */ char *c_img_path;char *c_src_path; +char *c_blobdev_path;char *c_compress_hints_file;char *c_compr_alg_master;int c_compr_level_master;
include/erofs/internal.h +4 -0
@@ -82,6 +82,9 @@ struct erofs_sb_info {u16 available_compr_algs;u16 lz4_max_distance; + +u16 extra_devices; +u16 devt_slotoff; };/* global sbi */
@@ -110,6 +113,7 @@ EROFS_FEATURE_FUNCS(lz4_0padding, incompat, INCOMPAT_LZ4_0PADDING) EROFS_FEATURE_FUNCS(compr_cfgs, incompat, INCOMPAT_COMPR_CFGS) EROFS_FEATURE_FUNCS(big_pcluster, incompat, INCOMPAT_BIG_PCLUSTER) EROFS_FEATURE_FUNCS(chunked_file, incompat, INCOMPAT_CHUNKED_FILE) +EROFS_FEATURE_FUNCS(device_table, incompat, INCOMPAT_DEVICE_TABLE) EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)#define EROFS_I_EA_INITED (1 << 0)
include/erofs_fs.h +17 -2
@@ -22,14 +22,27 @@#define EROFS_FEATURE_INCOMPAT_COMPR_CFGS 0x00000002#define EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER 0x00000002#define EROFS_FEATURE_INCOMPAT_CHUNKED_FILE 0x00000004 +#define EROFS_FEATURE_INCOMPAT_DEVICE_TABLE 0x00000008#define EROFS_ALL_FEATURE_INCOMPAT \ (EROFS_FEATURE_INCOMPAT_LZ4_0PADDING | \ EROFS_FEATURE_INCOMPAT_COMPR_CFGS | \ EROFS_FEATURE_INCOMPAT_BIG_PCLUSTER | \ - EROFS_FEATURE_INCOMPAT_CHUNKED_FILE) + EROFS_FEATURE_INCOMPAT_CHUNKED_FILE | \ + EROFS_FEATURE_INCOMPAT_DEVICE_TABLE)#define EROFS_SB_EXTSLOT_SIZE 16 +struct erofs_deviceslot { +union { +u8 uuid[16 ];/* used for device manager later */ +u8 userdata[64 ];/* digest(sha256), etc. */ + } u; +__le32 blocks; +__le32 mapped_blkaddr; +u8 reserved[56 ]; +}; +#define EROFS_DEVT_SLOT_SIZE sizeof(struct erofs_deviceslot) +/* erofs on-disk super block (currently 128 bytes) */ struct erofs_super_block {__le32 magic;/* file system magic number */
@@ -55,7 +68,9 @@ struct erofs_super_block {/* customized sliding window size instead of 64k by default */ __le16 lz4_max_distance; }__packed u1; -__u8 reserved2[42 ]; +__le16 extra_devices;/* # of devices besides the primary device */ +__le16 devt_slotoff;/* startoff = devt_slotoff * devt_slotsize */ +__u8 reserved2[38 ]; };/*
lib/blobchunk.c +53 -5
100 lines not on this page · raw message
mkfs/main.c +14 -1
@@ -46,6 +46,7 @@ static struct option long_options[] = { {"max-extent-bytes", required_argument, NULL, 9}, {"compress-hints", required_argument, NULL, 10}, {"chunksize", required_argument, NULL, 11}, + {"blobdev", required_argument, NULL, 12}, #ifdef WITH_ANDROID {"mount-point", required_argument, NULL, 512}, {"product-out", required_argument, NULL, 513},
@@ -82,6 +83,7 @@ static void usage(void) " -UX use a given filesystem UUID\n"#endif " --all-root make all files owned by root\n" +" --blobdev=X specify an extra device X for chunk data\n" " --chunksize=# generate chunk-based files with #-byte chunks\n" " --compress-hints=X specify a file to configure per-file compression strategy\n" " --exclude-path=X avoid including file X (X = exact literal path)\n"
@@ -344,6 +346,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])erofs_sb_set_chunked_file ();erofs_warn ("EXPERIMENTAL chunked file feature in use. Use at your own risk!" );break ; +case 12 : + cfg.c_blobdev_path = optarg; +break ;case 1 :usage ();
@@ -396,6 +401,8 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, .feature_incompat = cpu_to_le32(sbi.feature_incompat), .feature_compat = cpu_to_le32(sbi.feature_compat & ~EROFS_FEATURE_COMPAT_SB_CHKSUM), + .extra_devices = cpu_to_le16(sbi.extra_devices), + .devt_slotoff = cpu_to_le16(sbi.devt_slotoff), };const unsigned int sb_blksize =round_up (EROFS_SUPER_END ,EROFS_BLKSIZ );
@@ -552,7 +559,7 @@ int main(int argc, char **argv) }if (cfg.c_chunkbits) { - err =erofs_blob_init (); + err =erofs_blob_init (cfg.c_blobdev_path);if (err)return 1 ; }
@@ -628,6 +635,12 @@ int main(int argc, char **argv) goto exit; } + err =erofs_generate_devtable (); +if (err) { +erofs_err ("Failed to generate device table: %s" , +erofs_strerror (err)); + goto exit; + }#ifdef HAVE_LIBUUID uuid_unparse_lower (sbi.uuid, uuid_str);#endif
Signature · 1 line
2.24.4