erofs-utils: mkfs: validate chunk/pcluster sizes in the end
PATCH v2 1/4 erofs-utils: mkfs: validate chunk/pcluster sizes in the end
Laterly, erofs-utils will support sub-page block sizes and an arbitrary block size can be given at any position of the command line.
Therefore, chunk/pcluster sizes needs to be validated in the end.
---
v2: no change.
mkfs/main.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-)
mkfs/main.c +32 -12
@@ -126,6 +126,8 @@ static void usage(void)print_available_compressors (stderr,", " ); } +static unsigned int pclustersize_packed, pclustersize_max; +static int parse_extended_opts (const char *opts) {#define MATCH_EXTENTED_OPT (opt, token, keylen) \
@@ -222,13 +224,12 @@ handle_fragment: cfg.c_fragments = true;if (vallen) { i =strtoull (value, &endptr,0 ); -if (endptr - value != vallen || - i <EROFS_BLKSIZ || i %EROFS_BLKSIZ ) { +if (endptr - value != vallen) {erofs_err ("invalid pcluster size for the packed file %s" , next);return -EINVAL ; } - cfg.c_pclusterblks_packed = i /EROFS_BLKSIZ ; + pclustersize_packed = i; } }
@@ -415,14 +416,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])#endif case 'C' : i =strtoull (optarg, &endptr,0 ); -if (*endptr !='\0' || - i <EROFS_BLKSIZ || i %EROFS_BLKSIZ ) { +if (*endptr !='\0' ) {erofs_err ("invalid physical clustersize %s" , optarg);return -EINVAL ; } - cfg.c_pclusterblks_max = i /EROFS_BLKSIZ ; - cfg.c_pclusterblks_def = cfg.c_pclusterblks_max; + pclustersize_max = i;break ;case 11 : i =strtol (optarg, &endptr,0 );
@@ -436,11 +435,6 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) optarg);return -EINVAL ; } -if (i <EROFS_BLKSIZ ) { -erofs_err ("chunksize %s must be larger than block size" , - optarg); -return -EINVAL ; - }erofs_sb_set_chunked_file ();break ;case 12 :
@@ -521,6 +515,32 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) cfg.c_dbg_lvl =EROFS_ERR ; cfg.c_showprogress = false; } + +if (pclustersize_max) { +if (pclustersize_max <EROFS_BLKSIZ || + pclustersize_max %EROFS_BLKSIZ ) { +erofs_err ("invalid physical clustersize %u" , + pclustersize_max); +return -EINVAL ; + } + cfg.c_pclusterblks_max = pclustersize_max /EROFS_BLKSIZ ; + cfg.c_pclusterblks_def = cfg.c_pclusterblks_max; + } +if (cfg.c_chunkbits &&1u << cfg.c_chunkbits <EROFS_BLKSIZ ) { +erofs_err ("chunksize %u must be larger than block size" , +1u << cfg.c_chunkbits); +return -EINVAL ; + } + +if (pclustersize_packed) { +if (pclustersize_max <EROFS_BLKSIZ || + pclustersize_max %EROFS_BLKSIZ ) { +erofs_err ("invalid pcluster size for the packed file %u" , + pclustersize_packed); +return -EINVAL ; + } + cfg.c_pclusterblks_packed = pclustersize_packed /EROFS_BLKSIZ ; + }return 0 ; }
Signature · 1 line
2.24.4
PATCH v2 2/4 erofs-utils: add per-sb block size
Will be used for subpage blocksize support.
---
v2: fold in runtime blkszbits modification from 4/4.
include/erofs/internal.h | 1 + lib/super.c | 7 +++---- mkfs/main.c | 1 + 3 files changed, 5 insertions(+), 4 deletions(-)
include/erofs/internal.h +1 -0
@@ -88,6 +88,7 @@ struct erofs_sb_info {u32 build_time_nsec;unsigned char islotbits; +unsigned char blkszbits;/* what we really care is nid, rather than ino.. */ erofs_nid_t root_nid;
lib/super.c +3 -4
@@ -70,7 +70,6 @@ int erofs_read_superblock(void) {char data[EROFS_BLKSIZ ];struct erofs_super_block *dsb; -unsigned int blkszbits;int ret; ret =blk_read (0 , data,0 ,1 );
@@ -88,11 +87,11 @@ int erofs_read_superblock(void) sbi.feature_compat =le32_to_cpu (dsb->feature_compat); - blkszbits = dsb->blkszbits; + sbi.blkszbits = dsb->blkszbits;/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ -if (blkszbits !=LOG_BLOCK_SIZE ) { +if (sbi.blkszbits !=LOG_BLOCK_SIZE ) {erofs_err ("blksize %d isn't supported on this platform" , -1 << blkszbits); +1 << sbi.blkszbits);return ret; }
mkfs/main.c +1 -0
@@ -641,6 +641,7 @@ static void erofs_mkfs_default_options(void) { cfg.c_showprogress = true; cfg.c_legacy_compress = false; + sbi.blkszbits =ilog2 (PAGE_SIZE ); sbi.feature_incompat =EROFS_FEATURE_INCOMPAT_LZ4_0PADDING ; sbi.feature_compat =EROFS_FEATURE_COMPAT_SB_CHKSUM |EROFS_FEATURE_COMPAT_MTIME ;
Signature · 1 line
2.24.4
PATCH v2 3/4 erofs-utils: drop hard-coded block size
In reply to Gao XiangNow block sizes can be less than PAGE_SIZE.
--- dump/main.c | 4 +- fsck/main.c | 10 ++--- fuse/main.c | 2 +- include/erofs/cache.h | 4 +- include/erofs/internal.h | 36 +++++++----------- include/erofs/io.h | 6 +-- include/erofs/xattr.h | 4 +- lib/blobchunk.c | 14 +++---- lib/cache.c | 36 +++++++++--------- lib/compress.c | 80 ++++++++++++++++++++-------------------- lib/compress_hints.c | 8 ++-- lib/compressor.c | 10 ++--- lib/data.c | 34 ++++++++--------- lib/decompress.c | 16 ++++---- lib/dir.c | 6 +-- lib/inode.c | 56 ++++++++++++++-------------- lib/io.c | 14 +++---- lib/namei.c | 11 +++--- lib/super.c | 6 +-- lib/xattr.c | 24 ++++++------ lib/zmap.c | 12 +++--- mkfs/main.c | 29 +++++++-------- 22 files changed, 204 insertions(+), 218 deletions(-)
dump/main.c +2 -2
@@ -203,7 +203,7 @@ static int erofsdump_get_occupied_size(struct erofs_inode *inode,case EROFS_INODE_FLAT_COMPRESSION_LEGACY :case EROFS_INODE_FLAT_COMPRESSION : stats.compressed_files++; - *size = inode->u.i_blocks *EROFS_BLKSIZ ; + *size = inode->u.i_blocks *erofs_blksiz ();break ;default :erofs_err ("unknown datalayout" );
@@ -448,7 +448,7 @@ static void erofsdump_show_fileinfo(bool show_extent) .m_deviceid = map.m_deviceid, .m_pa = map.m_pa, }; - err =erofs_map_dev (&sbi, &mdev); + err =erofs_map_dev (&mdev);if (err) {erofs_err ("failed to map device" );return ;
fsck/main.c +5 -5
@@ -259,7 +259,7 @@ static void erofsfsck_set_attributes(struct erofs_inode *inode, char *path)static int erofs_check_sb_chksum (void ) {int ret; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u32 crc;struct erofs_super_block *sb;
@@ -273,7 +273,7 @@ static int erofs_check_sb_chksum(void) sb = (struct erofs_super_block *)(buf +EROFS_SUPER_OFFSET ); sb->checksum =0 ; - crc =erofs_crc32c (~0 , (u8 *)sb,EROFS_BLKSIZ -EROFS_SUPER_OFFSET ); + crc =erofs_crc32c (~0 , (u8 *)sb,erofs_blksiz () -EROFS_SUPER_OFFSET );if (crc != sbi.checksum) {erofs_err ("superblock chksum doesn't match: saved(%08xh) calculated(%08xh)" , sbi.checksum, crc);
@@ -292,7 +292,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)struct erofs_xattr_ibody_header *ih;struct erofs_xattr_entry *entry;int i, remaining = inode->xattr_isize, ret =0 ; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];if (inode->xattr_isize == xattr_hdr_size) { erofs_err("xattr_isize %d of nid %llu is not supported yet",
@@ -322,8 +322,8 @@ static int erofs_verify_xattr(struct erofs_inode *inode) addr += xattr_hdr_size; remaining -= xattr_hdr_size;for (i =0 ; i < xattr_shared_count; ++i) { -if (ofs >=EROFS_BLKSIZ ) { -if (ofs !=EROFS_BLKSIZ ) { +if (ofs >=erofs_blksiz ()) { +if (ofs !=erofs_blksiz ()) {erofs_err ("unaligned xattr entry in xattr shared area @ nid %llu" , inode->nid |0ULL ); ret = -EFSCORRUPTED ;
fuse/main.c +1 -1
@@ -95,7 +95,7 @@ static int erofsfuse_getattr(const char *path, struct stat *stbuf) stbuf->st_mode = vi.i_mode; stbuf->st_nlink = vi.i_nlink; stbuf->st_size = vi.i_size; - stbuf->st_blocks =roundup (vi.i_size,EROFS_BLKSIZ ) >>9 ; + stbuf->st_blocks =roundup (vi.i_size,erofs_blksiz ()) >>9 ; stbuf->st_uid = vi.i_uid; stbuf->st_gid = vi.i_gid;if (S_ISBLK (vi.i_mode) ||S_ISCHR (vi.i_mode))
include/erofs/cache.h +2 -2
@@ -55,7 +55,7 @@ struct erofs_buffer_block {static inline const int get_alignsize (int type,int *type_ret) {if (type ==DATA ) -return EROFS_BLKSIZ ; +return erofs_blksiz ();if (type ==INODE ) { *type_ret =META ;
@@ -84,7 +84,7 @@ static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)if (bb->blkaddr ==NULL_ADDR )return NULL_ADDR_UL ; -return blknr_to_addr (bb->blkaddr) + +return erofs_pos (bb->blkaddr) + (end ?list_next_entry (bh, list)->off : bh->off); }
include/erofs/internal.h +13 -23
@@ -35,17 +35,7 @@ typedef unsigned short umode_t;#define PAGE_SIZE (1U << PAGE_SHIFT)#endif -/* no obvious reason to support explicit PAGE_SIZE != 4096 for now */ -#if PAGE_SIZE !=4096 -#warning EROFS may be incompatible on your platform -#endif - -#ifndef PAGE_MASK -#define PAGE_MASK (~(PAGE_SIZE-1)) -#endif - -#define LOG_BLOCK_SIZE (12) -#define EROFS_BLKSIZ (1U << LOG_BLOCK_SIZE) +#define EROFS_MAX_BLOCK_SIZE PAGE_SIZE#define EROFS_ISLOTBITS 5#define EROFS_SLOTSIZE (1U << EROFS_ISLOTBITS)
@@ -58,11 +48,15 @@ typedef u32 erofs_blk_t;#define NULL_ADDR ((unsigned int)-1)#define NULL_ADDR_UL ((unsigned long)-1) -#define erofs_blknr (addr) ((addr) / EROFS_BLKSIZ) -#define erofs_blkoff (addr) ((addr) % EROFS_BLKSIZ) -#define blknr_to_addr (nr) ((erofs_off_t)(nr) * EROFS_BLKSIZ) +/* global sbi */ +extern struct erofs_sb_info sbi; -#define BLK_ROUND_UP (addr) DIV_ROUND_UP(addr, EROFS_BLKSIZ) +#define erofs_blksiz () (1u << sbi.blkszbits) +#define erofs_blknr (addr) ((addr) >> sbi.blkszbits) +#define erofs_blkoff (addr) ((addr) & (erofs_blksiz() - 1)) +#define erofs_pos (nr) ((erofs_off_t)(nr) << sbi.blkszbits) + +#define BLK_ROUND_UP (addr) DIV_ROUND_UP(addr, 1u << sbi.blkszbits)struct erofs_buffer_head ;
@@ -110,16 +104,12 @@ struct erofs_sb_info {erofs_nid_t packed_nid; }; -/* make sure that any user of the erofs headers has atleast 64bit off_t type */ extern int erofs_assert_largefile[sizeof (off_t)-8 ]; -/* global sbi */ -extern struct erofs_sb_info sbi; -static inline erofs_off_t iloc (erofs_nid_t nid) { -return blknr_to_addr (sbi.meta_blkaddr) + (nid << sbi.islotbits); +return erofs_pos (sbi.meta_blkaddr) + (nid << sbi.islotbits); }#define EROFS_FEATURE_FUNCS (name, compat, feature) \
@@ -311,7 +301,7 @@ enum {#define EROFS_MAP_PARTIAL_REF (1 << BH_Partialref)struct erofs_map_blocks { -char mpage[EROFS_BLKSIZ ]; +char mpage[EROFS_MAX_BLOCK_SIZE ];erofs_off_t m_pa, m_la;u64 m_plen, m_llen;
@@ -355,7 +345,7 @@ int erofs_pread(struct erofs_inode *inode, char *buf, erofs_off_t count, erofs_off_t offset);int erofs_map_blocks (struct erofs_inode *inode,struct erofs_map_blocks *map,int flags); -int erofs_map_dev (struct erofs_sb_info *sbi,struct erofs_map_dev *map); +int erofs_map_dev (struct erofs_map_dev *map);int erofs_read_one_data (struct erofs_map_blocks *map,char *buffer,u64 offset,size_t len); int z_erofs_read_one_data(struct erofs_inode *inode,
@@ -374,7 +364,7 @@ static inline int erofs_get_occupied_size(const struct erofs_inode *inode,break ;case EROFS_INODE_FLAT_COMPRESSION_LEGACY :case EROFS_INODE_FLAT_COMPRESSION : - *size = inode->u.i_blocks *EROFS_BLKSIZ ; + *size = inode->u.i_blocks *erofs_blksiz ();break ;default :return -ENOTSUP ;
include/erofs/io.h +2 -4
@@ -43,15 +43,13 @@ ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,static inline int blk_write (const void *buf,erofs_blk_t blkaddr,u32 nblocks) { -return dev_write (buf,blknr_to_addr (blkaddr), -blknr_to_addr (nblocks)); +return dev_write (buf,erofs_pos (blkaddr),erofs_pos (nblocks)); }static inline int blk_read (int device_id,void *buf,erofs_blk_t start,u32 nblocks) { -return dev_read (device_id, buf,blknr_to_addr (start), -blknr_to_addr (nblocks)); +return dev_read (device_id, buf,erofs_pos (start),erofs_pos (nblocks)); }#ifdef __cplusplus
include/erofs/xattr.h +2 -2
@@ -27,12 +27,12 @@ static inline unsigned int inlinexattr_header_size(struct erofs_inode *vi)static inline erofs_blk_t xattrblock_addr (unsigned int xattr_id) {return sbi.xattr_blkaddr + - xattr_id *sizeof (__u32) /EROFS_BLKSIZ ; + ((xattr_id *sizeof (__u32)) >> sbi.blkszbits); }static inline unsigned int xattrblock_offset (unsigned int xattr_id) { -return (xattr_id *sizeof (__u32)) %EROFS_BLKSIZ ; +return (xattr_id *sizeof (__u32)) & (erofs_blksiz () -1 ); }#define EROFS_INODE_XATTR_ICOUNT (_size) ({\
lib/blobchunk.c +7 -7
@@ -32,7 +32,7 @@ struct erofs_blobchunk erofs_holechunk = {static struct erofs_blobchunk *erofs_blob_getchunk (int fd,erofs_off_t chunksize) { -static u8 zeroed[EROFS_BLKSIZ ]; +static u8 zeroed[EROFS_MAX_BLOCK_SIZE ];u8 *chunkdata, sha256[32 ];int ret;unsigned int hash;
@@ -72,7 +72,7 @@ static struct erofs_blobchunk *erofs_blob_getchunk(int fd,erofs_dbg ("Writing chunk (%u bytes) to %u" , chunksize, chunk->blkaddr); ret =fwrite (chunkdata, chunksize,1 , blobfile);if (ret ==1 &&erofs_blkoff (chunksize)) - ret =fwrite (zeroed,EROFS_BLKSIZ -erofs_blkoff (chunksize), + ret =fwrite (zeroed,erofs_blksiz () -erofs_blkoff (chunksize),1 , blobfile);if (ret <1 ) {struct hashmap_entry key;
@@ -181,15 +181,15 @@ int erofs_blob_write_chunked_file(struct erofs_inode *inode)/* if the file is fully sparsed, use one big chunk instead */ if (lseek (fd,0 ,SEEK_DATA ) <0 && errno ==ENXIO ) { chunkbits =ilog2 (inode->i_size -1 ) +1 ; -if (chunkbits <LOG_BLOCK_SIZE ) - chunkbits =LOG_BLOCK_SIZE ; +if (chunkbits < sbi.blkszbits) + chunkbits = sbi.blkszbits; }#endif -if (chunkbits -LOG_BLOCK_SIZE >EROFS_CHUNK_FORMAT_BLKBITS_MASK ) - chunkbits =EROFS_CHUNK_FORMAT_BLKBITS_MASK +LOG_BLOCK_SIZE ; +if (chunkbits - sbi.blkszbits >EROFS_CHUNK_FORMAT_BLKBITS_MASK ) + chunkbits =EROFS_CHUNK_FORMAT_BLKBITS_MASK + sbi.blkszbits; chunksize =1ULL << chunkbits; count =DIV_ROUND_UP (inode->i_size, chunksize); - inode->u.chunkformat |= chunkbits -LOG_BLOCK_SIZE ; + inode->u.chunkformat |= chunkbits - sbi.blkszbits;if (multidev) inode->u.chunkformat |=EROFS_CHUNK_FORMAT_INDEXES ;
lib/cache.c +18 -18
@@ -17,7 +17,7 @@ static struct erofs_buffer_block blkh = {static erofs_blk_t tail_blkaddr;/* buckets for all mapped buffer blocks to boost up allocation */ -static struct list_head mapped_buckets[META +1 ][EROFS_BLKSIZ ]; +static struct list_head mapped_buckets[META +1 ][EROFS_MAX_BLOCK_SIZE ];/* last mapped buffer block to accelerate erofs_mapbh() */ static struct erofs_buffer_block *last_mapped_block = &blkh;
@@ -86,7 +86,7 @@ static void erofs_bupdate_mapped(struct erofs_buffer_block *bb)if (bb->blkaddr ==NULL_ADDR )return ; - bkt = mapped_buckets[bb->type] + bb->buffers.off %EROFS_BLKSIZ ; + bkt = mapped_buckets[bb->type] + bb->buffers.off %erofs_blksiz ();list_del (&bb->mapped_list);list_add_tail (&bb->mapped_list, bkt); }
@@ -100,9 +100,9 @@ static int __erofs_battach(struct erofs_buffer_block *bb, bool dryrun) {const erofs_off_t alignedoffset =roundup (bb->buffers.off, alignsize); -const int oob =cmpsgn (roundup ((bb->buffers.off -1 ) %EROFS_BLKSIZ +1 , +const int oob =cmpsgn (roundup ((bb->buffers.off -1 ) %erofs_blksiz () +1 , alignsize) + incr + extrasize, -EROFS_BLKSIZ ); +erofs_blksiz ());bool tailupdate = false;erofs_blk_t blkaddr;
@@ -132,7 +132,7 @@ static int __erofs_battach(struct erofs_buffer_block *bb, tail_blkaddr = blkaddr +BLK_ROUND_UP (bb->buffers.off);erofs_bupdate_mapped (bb); } -return (alignedoffset + incr -1 ) %EROFS_BLKSIZ +1 ; +return (alignedoffset + incr -1 ) %erofs_blksiz () +1 ; }int erofs_bh_balloon (struct erofs_buffer_head *bh,erofs_off_t incr)
@@ -156,12 +156,12 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,unsigned int used0, used_before, usedmax, used;int ret; - used0 = (size + required_ext) %EROFS_BLKSIZ + inline_ext; + used0 = (size + required_ext) %erofs_blksiz () + inline_ext;/* inline data should be in the same fs block */ -if (used0 >EROFS_BLKSIZ ) +if (used0 >erofs_blksiz ())return -ENOSPC ; -if (!used0 || alignsize ==EROFS_BLKSIZ ) { +if (!used0 || alignsize ==erofs_blksiz ()) { *bbp =NULL ;return 0 ; }
@@ -170,10 +170,10 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, bb =NULL ;/* try to find a most-fit mapped buffer block first */ -if (size + required_ext + inline_ext >=EROFS_BLKSIZ ) +if (size + required_ext + inline_ext >=erofs_blksiz ()) goto skip_mapped; - used_before =rounddown (EROFS_BLKSIZ - + used_before =rounddown (erofs_blksiz () - (size + required_ext + inline_ext), alignsize);for (; used_before; --used_before) {struct list_head *bt = mapped_buckets[type] + used_before;
@@ -191,7 +191,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,DBG_BUGON (cur->type != type);DBG_BUGON (cur->blkaddr ==NULL_ADDR ); -DBG_BUGON (used_before != cur->buffers.off %EROFS_BLKSIZ ); +DBG_BUGON (used_before != cur->buffers.off %erofs_blksiz ()); ret =__erofs_battach (cur,NULL , size, alignsize, required_ext + inline_ext, true);
@@ -202,7 +202,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,/* should contain all data in the current block */ used = ret + required_ext + inline_ext; -DBG_BUGON (used >EROFS_BLKSIZ ); +DBG_BUGON (used >erofs_blksiz ()); bb = cur; usedmax = used;
@@ -215,7 +215,7 @@ skip_mapped:if (cur == &blkh) cur =list_next_entry (cur, list);for (; cur != &blkh; cur =list_next_entry (cur, list)) { - used_before = cur->buffers.off %EROFS_BLKSIZ ; + used_before = cur->buffers.off %erofs_blksiz ();/* skip if buffer block is just full */ if (!used_before)
@@ -230,10 +230,10 @@ skip_mapped:if (ret <0 )continue ; - used = (ret + required_ext) %EROFS_BLKSIZ + inline_ext; + used = (ret + required_ext) %erofs_blksiz () + inline_ext;/* should contain inline data in current block */ -if (used >EROFS_BLKSIZ ) +if (used >erofs_blksiz ())continue ;/*
@@ -396,9 +396,9 @@ bool erofs_bflush(struct erofs_buffer_block *bb)if (skip)continue ; - padding =EROFS_BLKSIZ - p->buffers.off %EROFS_BLKSIZ ; -if (padding !=EROFS_BLKSIZ ) -dev_fillzero (blknr_to_addr (blkaddr) - padding, + padding =erofs_blksiz () - p->buffers.off %erofs_blksiz (); +if (padding !=erofs_blksiz ()) +dev_fillzero (erofs_pos (blkaddr) - padding, padding, true);DBG_BUGON (!list_empty (&p->buffers.list));
lib/compress.c +40 -40
249 lines not on this page · raw message
lib/compress_hints.c +4 -4
@@ -133,21 +133,21 @@ int erofs_load_compress_hints(void) } } -if (pclustersize %EROFS_BLKSIZ ) { +if (pclustersize %erofs_blksiz ()) {erofs_warn ("invalid physical clustersize %u, " "use default pclusterblks %u" , pclustersize, cfg.c_pclusterblks_def);continue ; }erofs_insert_compress_hints (pattern, - pclustersize /EROFS_BLKSIZ , ccfg); + pclustersize /erofs_blksiz (), ccfg);if (pclustersize > max_pclustersize) max_pclustersize = pclustersize; } -if (cfg.c_pclusterblks_max *EROFS_BLKSIZ < max_pclustersize) { - cfg.c_pclusterblks_max = max_pclustersize /EROFS_BLKSIZ ; +if (cfg.c_pclusterblks_max *erofs_blksiz () < max_pclustersize) { + cfg.c_pclusterblks_max = max_pclustersize /erofs_blksiz ();erofs_warn ("update max pclusterblks to %u" , cfg.c_pclusterblks_max); } out:
lib/compressor.c +5 -5
@@ -38,10 +38,10 @@ int erofs_compress_destsize(const struct erofs_compress *c,if (ret <0 )return ret; -/* XXX: ret >= EROFS_BLKSIZ is a temporary hack for ztailpacking */ -if (inblocks || ret >=EROFS_BLKSIZ || +/* XXX: ret >= erofs_blksiz() is a temporary hack for ztailpacking */ +if (inblocks || ret >=erofs_blksiz () || uncompressed_capacity != *srcsize) - compressed_size =roundup (ret,EROFS_BLKSIZ ); + compressed_size =roundup (ret,erofs_blksiz ());else compressed_size = ret;DBG_BUGON (c->compress_threshold <100 );
@@ -76,8 +76,8 @@ int erofs_compressor_init(struct erofs_compress *c, char *alg_name) c->compress_threshold =100 ;/* optimize for 4k size page */ - c->destsize_alignsize =EROFS_BLKSIZ ; - c->destsize_redzone_begin =EROFS_BLKSIZ -16 ; + c->destsize_alignsize =erofs_blksiz (); + c->destsize_redzone_begin =erofs_blksiz () -16 ; c->destsize_redzone_end =EROFS_CONFIG_COMPR_DEF_BOUNDARY ;if (!alg_name) {
lib/data.c +17 -17
@@ -28,9 +28,9 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,/* there is no hole in flatmode */ map->m_flags =EROFS_MAP_MAPPED ; -if (offset <blknr_to_addr (lastblk)) { - map->m_pa =blknr_to_addr (vi->u.i_blkaddr) + map->m_la; - map->m_plen =blknr_to_addr (lastblk) - offset; +if (offset <erofs_pos (lastblk)) { + map->m_pa =erofs_pos (vi->u.i_blkaddr) + map->m_la; + map->m_plen =erofs_pos (lastblk) - offset; }else if (tailendpacking) {/* 2 - inode inline B: inode, [xattrs], inline last blk... */ map->m_pa = iloc(vi->nid) + vi->inode_isize +
@@ -38,7 +38,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode, map->m_plen = inode->i_size - offset;/* inline data should be located in the same meta block */ -if (erofs_blkoff (map->m_pa) + map->m_plen >EROFS_BLKSIZ ) { +if (erofs_blkoff (map->m_pa) + map->m_plen >erofs_blksiz ()) {erofs_err ("inline data cross block boundary @ nid %" PRIu64, vi->nid);DBG_BUGON (1 );
@@ -66,7 +66,7 @@ int erofs_map_blocks(struct erofs_inode *inode, {struct erofs_inode *vi = inode;struct erofs_inode_chunk_index *idx; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u64 chunknr;unsigned int unit;erofs_off_t pos;
@@ -98,7 +98,7 @@ int erofs_map_blocks(struct erofs_inode *inode, map->m_la = chunknr << vi->u.chunkbits; map->m_plen =min_t (erofs_off_t,1UL << vi->u.chunkbits, -roundup (inode->i_size - map->m_la,EROFS_BLKSIZ )); +roundup (inode->i_size - map->m_la,erofs_blksiz ()));/* handle block map */ if (!(vi->u.chunkformat &EROFS_CHUNK_FORMAT_INDEXES )) {
@@ -107,7 +107,7 @@ int erofs_map_blocks(struct erofs_inode *inode,if (le32_to_cpu (*blkaddr) ==EROFS_NULL_ADDR ) { map->m_flags =0 ; }else { - map->m_pa =blknr_to_addr (le32_to_cpu (*blkaddr)); + map->m_pa =erofs_pos (le32_to_cpu (*blkaddr)); map->m_flags =EROFS_MAP_MAPPED ; } goto out;
@@ -121,7 +121,7 @@ int erofs_map_blocks(struct erofs_inode *inode,default : map->m_deviceid =le16_to_cpu (idx->device_id) & sbi.device_id_mask; - map->m_pa =blknr_to_addr (le32_to_cpu (idx->blkaddr)); + map->m_pa =erofs_pos (le32_to_cpu (idx->blkaddr)); map->m_flags =EROFS_MAP_MAPPED ;break ; }
@@ -130,23 +130,23 @@ out:return err; } -int erofs_map_dev (struct erofs_sb_info *sbi,struct erofs_map_dev *map) +int erofs_map_dev (struct erofs_map_dev *map) {struct erofs_device_info *dif;int id;if (map->m_deviceid) { -if (sbi->extra_devices < map->m_deviceid) +if (sbi.extra_devices < map->m_deviceid)return -ENODEV ; - }else if (sbi->extra_devices) { -for (id =0 ; id < sbi->extra_devices; ++id) { + }else if (sbi.extra_devices) { +for (id =0 ; id < sbi.extra_devices; ++id) {erofs_off_t startoff, length; - dif = sbi->devs + id; + dif = sbi.devs + id;if (!dif->mapped_blkaddr)continue ; - startoff =blknr_to_addr (dif->mapped_blkaddr); - length =blknr_to_addr (dif->blocks); + startoff =erofs_pos (dif->mapped_blkaddr); + length =erofs_pos (dif->blocks);if (map->m_pa >= startoff && map->m_pa < startoff + length) {
@@ -168,7 +168,7 @@ int erofs_read_one_data(struct erofs_map_blocks *map, char *buffer, u64 offset, .m_deviceid = map->m_deviceid, .m_pa = map->m_pa, }; - ret =erofs_map_dev (&sbi, &mdev); + ret =erofs_map_dev (&mdev);if (ret)return ret;
@@ -253,7 +253,7 @@ int z_erofs_read_one_data(struct erofs_inode *inode, mdev = (struct erofs_map_dev ) { .m_pa = map->m_pa, }; - ret =erofs_map_dev (&sbi, &mdev); + ret =erofs_map_dev (&mdev);if (ret) {DBG_BUGON (1 );return ret;
lib/decompress.c +8 -8
@@ -22,8 +22,8 @@ static int z_erofs_decompress_lzma(struct z_erofs_decompress_req *rq)lzma_stream strm;lzma_ret ret2; -while (!src[inputmargin & ~PAGE_MASK ]) -if (!(++inputmargin & ~PAGE_MASK )) +while (!src[inputmargin & ~(erofs_blksiz () -1 )]) +if (!(++inputmargin & ~(erofs_blksiz () -1 )))break ;if (inputmargin >= rq->inputsize)
@@ -85,8 +85,8 @@ static int z_erofs_decompress_lz4(struct z_erofs_decompress_req *rq)if (erofs_sb_has_lz4_0padding ()) { support_0padding = true; -while (!src[inputmargin & ~PAGE_MASK ]) -if (!(++inputmargin & ~PAGE_MASK )) +while (!src[inputmargin & ~(erofs_blksiz () -1 )]) +if (!(++inputmargin & ~(erofs_blksiz () -1 )))break ;if (inputmargin >= rq->inputsize)
@@ -134,15 +134,15 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq)if (rq->alg ==Z_EROFS_COMPRESSION_INTERLACED ) {unsigned int count, rightpart, skip; -/* XXX: should support inputsize >= EROFS_BLKSIZ later */ -if (rq->inputsize >EROFS_BLKSIZ ) +/* XXX: should support inputsize >= erofs_blksiz() later */ +if (rq->inputsize >erofs_blksiz ())return -EFSCORRUPTED ; -DBG_BUGON (rq->decodedlength >EROFS_BLKSIZ ); +DBG_BUGON (rq->decodedlength >erofs_blksiz ());DBG_BUGON (rq->decodedlength < rq->decodedskip); count = rq->decodedlength - rq->decodedskip; skip =erofs_blkoff (rq->interlaced_offset + rq->decodedskip); - rightpart =min (EROFS_BLKSIZ - skip, count); + rightpart =min (erofs_blksiz () - skip, count);memcpy (rq->out, rq->in + skip, rightpart);memcpy (rq->out + rightpart, rq->in, count - rightpart);return 0 ;
lib/dir.c +3 -3
@@ -125,7 +125,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)struct erofs_inode *dir = ctx->dir;int err =0 ;erofs_off_t pos; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];if (!S_ISDIR (dir->i_mode))return -ENOTDIR ;
@@ -135,7 +135,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)while (pos < dir->i_size) {erofs_blk_t lblk =erofs_blknr (pos);erofs_off_t maxsize =min_t (erofs_off_t, - dir->i_size - pos,EROFS_BLKSIZ ); + dir->i_size - pos,erofs_blksiz ());const struct erofs_dirent *de = (const void *)buf;unsigned int nameoff;
@@ -148,7 +148,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck) nameoff =le16_to_cpu (de->nameoff);if (nameoff <sizeof (struct erofs_dirent ) || - nameoff >=EROFS_BLKSIZ ) { + nameoff >=erofs_blksiz ()) {erofs_err ("invalid de[0].nameoff %u @ nid %llu, lblk %u" , nameoff, dir->nid |0ULL , lblk);return -EFSCORRUPTED ;
lib/inode.c +28 -28
166 lines not on this page · raw message
lib/io.c +7 -7
@@ -82,7 +82,7 @@ int dev_open(const char *dev)close (fd);return ret; } - erofs_devsz =round_down (erofs_devsz,EROFS_BLKSIZ ); + erofs_devsz =round_down (erofs_devsz,erofs_blksiz ());break ;case S_IFREG : ret =ftruncate (fd,0 );
@@ -192,7 +192,7 @@ int dev_write(const void *buf, u64 offset, size_t len)int dev_fillzero (u64 offset,size_t len,bool padding) { -static const char zero[EROFS_BLKSIZ ] = {0 }; +static const char zero[EROFS_MAX_BLOCK_SIZE ] = {0 };int ret;if (cfg.c_dry_run)
@@ -203,12 +203,12 @@ int dev_fillzero(u64 offset, size_t len, bool padding) FALLOC_FL_KEEP_SIZE, offset, len) >= 0)return 0 ;#endif -while (len >EROFS_BLKSIZ ) { - ret =dev_write (zero, offset,EROFS_BLKSIZ ); +while (len >erofs_blksiz ()) { + ret =dev_write (zero, offset,erofs_blksiz ());if (ret)return ret; - len -=EROFS_BLKSIZ ; - offset +=EROFS_BLKSIZ ; + len -=erofs_blksiz (); + offset +=erofs_blksiz (); }return dev_write (zero, offset, len); }
@@ -240,7 +240,7 @@ int dev_resize(unsigned int blocks)return -errno; } - length = (u64 )blocks *EROFS_BLKSIZ ; + length = (u64 )blocks *erofs_blksiz ();if (st.st_size == length)return 0 ;if (st.st_size > length)
lib/namei.c +5 -6
@@ -134,7 +134,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi) vi->u.chunkformat, vi->nid | 0ULL);return -EOPNOTSUPP ; } - vi->u.chunkbits =LOG_BLOCK_SIZE + + vi->u.chunkbits = sbi.blkszbits + (vi->u.chunkformat &EROFS_CHUNK_FORMAT_BLKBITS_MASK ); }else if (erofs_inode_is_data_compressed (vi->datalayout))return z_erofs_fill_inode (vi);
@@ -186,12 +186,11 @@ struct nameidata {unsigned int ftype; }; -int erofs_namei (struct nameidata *nd, -const char *name,unsigned int len) +int erofs_namei (struct nameidata *nd,const char *name,unsigned int len) {erofs_nid_t nid = nd->nid;int ret; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];struct erofs_inode vi = { .nid = nid };erofs_off_t offset;
@@ -202,7 +201,7 @@ int erofs_namei(struct nameidata *nd, offset =0 ;while (offset < vi.i_size) {erofs_off_t maxsize =min_t (erofs_off_t, - vi.i_size - offset,EROFS_BLKSIZ ); + vi.i_size - offset,erofs_blksiz ());struct erofs_dirent *de = (void *)buf;unsigned int nameoff;
@@ -212,7 +211,7 @@ int erofs_namei(struct nameidata *nd, nameoff =le16_to_cpu (de->nameoff);if (nameoff <sizeof (struct erofs_dirent ) || - nameoff >=EROFS_BLKSIZ ) { + nameoff >=erofs_blksiz ()) {erofs_err ("invalid de[0].nameoff %u @ nid %llu" , nameoff, nid |0ULL );return -EFSCORRUPTED ;
lib/super.c +3 -3
@@ -68,7 +68,7 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,int erofs_read_superblock (void ) { -char data[EROFS_BLKSIZ ]; +char data[EROFS_MAX_BLOCK_SIZE ];struct erofs_super_block *dsb;int ret;
@@ -89,9 +89,9 @@ int erofs_read_superblock(void) sbi.blkszbits = dsb->blkszbits;/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ -if (sbi.blkszbits !=LOG_BLOCK_SIZE ) { +if (1u << sbi.blkszbits !=PAGE_SIZE ) {erofs_err ("blksize %d isn't supported on this platform" , -1 << sbi.blkszbits); +erofs_blksiz ());return ret; }
lib/xattr.c +12 -12
@@ -619,8 +619,8 @@ int erofs_build_shared_xattrs_from_path(const char *path)erofs_mapbh (bh->block); off =erofs_btell (bh, false); - sbi.xattr_blkaddr = off /EROFS_BLKSIZ ; - off %=EROFS_BLKSIZ ; + sbi.xattr_blkaddr = off /erofs_blksiz (); + off %=erofs_blksiz (); p =0 ; sorted_n =malloc (shared_xattrs_count *sizeof (n));
@@ -716,7 +716,7 @@ char *erofs_export_xattr_ibody(struct list_head *ixattrs, unsigned int size) }struct xattr_iter { -char page[EROFS_BLKSIZ ]; +char page[EROFS_MAX_BLOCK_SIZE ];void *kaddr;
@@ -775,9 +775,9 @@ static int init_inode_xattrs(struct erofs_inode *vi) it.ofs +=sizeof (struct erofs_xattr_ibody_header );for (i =0 ; i < vi->xattr_shared_count; ++i) { -if (it.ofs >=EROFS_BLKSIZ ) { +if (it.ofs >=erofs_blksiz ()) {/* cannot be unaligned */ -DBG_BUGON (it.ofs !=EROFS_BLKSIZ ); +DBG_BUGON (it.ofs !=erofs_blksiz ()); ret =blk_read (0 , it.page, ++it.blkaddr,1 );if (ret <0 ) {
@@ -819,7 +819,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *it) {int ret; -if (it->ofs <EROFS_BLKSIZ ) +if (it->ofs <erofs_blksiz ())return 0 ; it->blkaddr +=erofs_blknr (it->ofs);
@@ -906,8 +906,8 @@ static int xattr_foreach(struct xattr_iter *it, processed =0 ;while (processed < entry.e_name_len) { -if (it->ofs >=EROFS_BLKSIZ ) { -DBG_BUGON (it->ofs >EROFS_BLKSIZ ); +if (it->ofs >=erofs_blksiz ()) { +DBG_BUGON (it->ofs >erofs_blksiz ()); err =xattr_iter_fixup (it);if (err)
@@ -915,7 +915,7 @@ static int xattr_foreach(struct xattr_iter *it, it->ofs =0 ; } - slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs, + slice = min_t(unsigned int, erofs_blksiz() - it->ofs, entry.e_name_len - processed);/* handle name */
@@ -941,8 +941,8 @@ static int xattr_foreach(struct xattr_iter *it, }while (processed < value_sz) { -if (it->ofs >=EROFS_BLKSIZ ) { -DBG_BUGON (it->ofs >EROFS_BLKSIZ ); +if (it->ofs >=erofs_blksiz ()) { +DBG_BUGON (it->ofs >erofs_blksiz ()); err =xattr_iter_fixup (it);if (err)
@@ -950,7 +950,7 @@ static int xattr_foreach(struct xattr_iter *it, it->ofs =0 ; } - slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs, + slice = min_t(unsigned int, erofs_blksiz() - it->ofs, value_sz - processed); op->value (it, processed, it->kaddr + it->ofs, slice); it->ofs += slice;
lib/zmap.c +6 -6
@@ -22,7 +22,7 @@ int z_erofs_fill_inode(struct erofs_inode *vi) vi->z_advise =0 ; vi->z_algorithmtype[0 ] =0 ; vi->z_algorithmtype[1 ] =0 ; - vi->z_logical_clusterbits =LOG_BLOCK_SIZE ; + vi->z_logical_clusterbits = sbi.blkszbits; vi->flags |=EROFS_I_Z_INITED ; }
@@ -66,7 +66,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi)return -EOPNOTSUPP ; } - vi->z_logical_clusterbits =LOG_BLOCK_SIZE + (h->h_clusterbits &7 ); + vi->z_logical_clusterbits = sbi.blkszbits + (h->h_clusterbits &7 );if (vi->datalayout ==EROFS_INODE_FLAT_COMPRESSION && !(vi->z_advise &Z_EROFS_ADVISE_BIG_PCLUSTER_1 ) ^ !(vi->z_advise &Z_EROFS_ADVISE_BIG_PCLUSTER_2 )) {
@@ -82,7 +82,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi) ret =z_erofs_do_map_blocks (vi, &map,EROFS_GET_BLOCKS_FINDTAIL );if (!map.m_plen || -erofs_blkoff (map.m_pa) + map.m_plen >EROFS_BLKSIZ ) { +erofs_blkoff (map.m_pa) + map.m_plen >erofs_blksiz ()) {erofs_err ("invalid tail-packing pclustersize %llu" , map.m_plen |0ULL );return -EFSCORRUPTED ;
@@ -496,7 +496,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. */ - m->compressedblks =1 << (lclusterbits -LOG_BLOCK_SIZE ); + m->compressedblks =1 << (lclusterbits - sbi.blkszbits);break ;case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD :if (m->delta[0 ] !=1 )
@@ -511,7 +511,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,return -EFSCORRUPTED ; } out: - map->m_plen = m->compressedblks <<LOG_BLOCK_SIZE ; + map->m_plen = m->compressedblks << sbi.blkszbits;return 0 ; err_bonus_cblkcnt: erofs_err("bogus CBLKCNT @ lcn %lu of nid %llu",
@@ -640,7 +640,7 @@ static int z_erofs_do_map_blocks(struct erofs_inode *vi, }else if (fragment && m.lcn == vi->z_tailextent_headlcn) { map->m_flags |=EROFS_MAP_FRAGMENT ; }else { - map->m_pa =blknr_to_addr (m.pblk); + map->m_pa =erofs_pos (m.pblk); err =z_erofs_get_extent_compressedlen (&m, initial_lcn);if (err) goto out;
mkfs/main.c +14 -15
@@ -474,7 +474,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) } } -if (cfg.c_blobdev_path && cfg.c_chunkbits <LOG_BLOCK_SIZE ) { +if (cfg.c_blobdev_path && cfg.c_chunkbits < sbi.blkszbits) {erofs_err ("--blobdev must be used together with --chunksize" );return -EINVAL ; }
@@ -517,29 +517,29 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) }if (pclustersize_max) { -if (pclustersize_max <EROFS_BLKSIZ || - pclustersize_max %EROFS_BLKSIZ ) { +if (pclustersize_max <erofs_blksiz () || + pclustersize_max %erofs_blksiz ()) {erofs_err ("invalid physical clustersize %u" , pclustersize_max);return -EINVAL ; } - cfg.c_pclusterblks_max = pclustersize_max /EROFS_BLKSIZ ; + cfg.c_pclusterblks_max = pclustersize_max >> sbi.blkszbits; cfg.c_pclusterblks_def = cfg.c_pclusterblks_max; } -if (cfg.c_chunkbits &&1u << cfg.c_chunkbits <EROFS_BLKSIZ ) { +if (cfg.c_chunkbits && cfg.c_chunkbits < sbi.blkszbits) {erofs_err ("chunksize %u must be larger than block size" ,1u << cfg.c_chunkbits);return -EINVAL ; }if (pclustersize_packed) { -if (pclustersize_max <EROFS_BLKSIZ || - pclustersize_max %EROFS_BLKSIZ ) { +if (pclustersize_max <erofs_blksiz () || + pclustersize_max %erofs_blksiz ()) {erofs_err ("invalid pcluster size for the packed file %u" , pclustersize_packed);return -EINVAL ; } - cfg.c_pclusterblks_packed = pclustersize_packed /EROFS_BLKSIZ ; + cfg.c_pclusterblks_packed = pclustersize_packed >> sbi.blkszbits; }return 0 ; }
@@ -551,7 +551,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, {struct erofs_super_block sb = { .magic =cpu_to_le32 (EROFS_SUPER_MAGIC_V1 ), - .blkszbits =LOG_BLOCK_SIZE , + .blkszbits = sbi.blkszbits, .inos =cpu_to_le64 (sbi.inos), .build_time =cpu_to_le64 (sbi.build_time), .build_time_nsec =cpu_to_le32 (sbi.build_time_nsec),
@@ -564,8 +564,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, .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 ); +const u32 sb_blksize =round_up (EROFS_SUPER_END ,erofs_blksiz ());char *buf; *blocks =erofs_mapbh (NULL );
@@ -596,7 +595,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,static int erofs_mkfs_superblock_csum_set (void ) {int ret; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u32 crc;struct erofs_super_block *sb;
@@ -621,7 +620,7 @@ static int erofs_mkfs_superblock_csum_set(void)/* turn on checksum feature */ sb->feature_compat =cpu_to_le32 (le32_to_cpu (sb->feature_compat) |EROFS_FEATURE_COMPAT_SB_CHKSUM ); - crc =erofs_crc32c (~0 , (u8 *)sb,EROFS_BLKSIZ -EROFS_SUPER_OFFSET ); + crc =erofs_crc32c (~0 , (u8 *)sb,erofs_blksiz () -EROFS_SUPER_OFFSET );/* set up checksum field to erofs_super_block */ sb->checksum =cpu_to_le32 (crc);
@@ -801,9 +800,9 @@ int main(int argc, char **argv)if (cfg.c_dedupe) {if (!cfg.c_compr_alg[0 ]) {erofs_err ("Compression is not enabled. Turn on chunk-based data deduplication instead." ); - cfg.c_chunkbits =LOG_BLOCK_SIZE ; + cfg.c_chunkbits = sbi.blkszbits; }else { - err =z_erofs_dedupe_init (EROFS_BLKSIZ ); + err =z_erofs_dedupe_init (erofs_blksiz ());if (err) {erofs_err ("failed to initialize deduplication: %s" ,erofs_strerror (err));
Signature · 1 line
2.24.4
PATCH v3 3/4 erofs-utils: drop hard-coded block size
Now block sizes can be less than PAGE_SIZE.
---
v3: fix wrong calculation of zero_padding in lib/decompress.c
dump/main.c | 4 +- fsck/main.c | 10 ++--- fuse/main.c | 2 +- include/erofs/cache.h | 4 +- include/erofs/internal.h | 36 +++++++----------- include/erofs/io.h | 6 +-- include/erofs/xattr.h | 4 +- lib/blobchunk.c | 14 +++---- lib/cache.c | 36 +++++++++--------- lib/compress.c | 80 ++++++++++++++++++++-------------------- lib/compress_hints.c | 8 ++-- lib/compressor.c | 10 ++--- lib/data.c | 34 ++++++++--------- lib/decompress.c | 16 ++++---- lib/dir.c | 6 +-- lib/inode.c | 56 ++++++++++++++-------------- lib/io.c | 14 +++---- lib/namei.c | 11 +++--- lib/super.c | 6 +-- lib/xattr.c | 24 ++++++------ lib/zmap.c | 12 +++--- mkfs/main.c | 29 +++++++-------- 22 files changed, 204 insertions(+), 218 deletions(-)
dump/main.c +2 -2
@@ -203,7 +203,7 @@ static int erofsdump_get_occupied_size(struct erofs_inode *inode,case EROFS_INODE_FLAT_COMPRESSION_LEGACY :case EROFS_INODE_FLAT_COMPRESSION : stats.compressed_files++; - *size = inode->u.i_blocks *EROFS_BLKSIZ ; + *size = inode->u.i_blocks *erofs_blksiz ();break ;default :erofs_err ("unknown datalayout" );
@@ -448,7 +448,7 @@ static void erofsdump_show_fileinfo(bool show_extent) .m_deviceid = map.m_deviceid, .m_pa = map.m_pa, }; - err =erofs_map_dev (&sbi, &mdev); + err =erofs_map_dev (&mdev);if (err) {erofs_err ("failed to map device" );return ;
fsck/main.c +5 -5
@@ -259,7 +259,7 @@ static void erofsfsck_set_attributes(struct erofs_inode *inode, char *path)static int erofs_check_sb_chksum (void ) {int ret; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u32 crc;struct erofs_super_block *sb;
@@ -273,7 +273,7 @@ static int erofs_check_sb_chksum(void) sb = (struct erofs_super_block *)(buf +EROFS_SUPER_OFFSET ); sb->checksum =0 ; - crc =erofs_crc32c (~0 , (u8 *)sb,EROFS_BLKSIZ -EROFS_SUPER_OFFSET ); + crc =erofs_crc32c (~0 , (u8 *)sb,erofs_blksiz () -EROFS_SUPER_OFFSET );if (crc != sbi.checksum) {erofs_err ("superblock chksum doesn't match: saved(%08xh) calculated(%08xh)" , sbi.checksum, crc);
@@ -292,7 +292,7 @@ static int erofs_verify_xattr(struct erofs_inode *inode)struct erofs_xattr_ibody_header *ih;struct erofs_xattr_entry *entry;int i, remaining = inode->xattr_isize, ret =0 ; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];if (inode->xattr_isize == xattr_hdr_size) { erofs_err("xattr_isize %d of nid %llu is not supported yet",
@@ -322,8 +322,8 @@ static int erofs_verify_xattr(struct erofs_inode *inode) addr += xattr_hdr_size; remaining -= xattr_hdr_size;for (i =0 ; i < xattr_shared_count; ++i) { -if (ofs >=EROFS_BLKSIZ ) { -if (ofs !=EROFS_BLKSIZ ) { +if (ofs >=erofs_blksiz ()) { +if (ofs !=erofs_blksiz ()) {erofs_err ("unaligned xattr entry in xattr shared area @ nid %llu" , inode->nid |0ULL ); ret = -EFSCORRUPTED ;
fuse/main.c +1 -1
@@ -95,7 +95,7 @@ static int erofsfuse_getattr(const char *path, struct stat *stbuf) stbuf->st_mode = vi.i_mode; stbuf->st_nlink = vi.i_nlink; stbuf->st_size = vi.i_size; - stbuf->st_blocks =roundup (vi.i_size,EROFS_BLKSIZ ) >>9 ; + stbuf->st_blocks =roundup (vi.i_size,erofs_blksiz ()) >>9 ; stbuf->st_uid = vi.i_uid; stbuf->st_gid = vi.i_gid;if (S_ISBLK (vi.i_mode) ||S_ISCHR (vi.i_mode))
include/erofs/cache.h +2 -2
@@ -55,7 +55,7 @@ struct erofs_buffer_block {static inline const int get_alignsize (int type,int *type_ret) {if (type ==DATA ) -return EROFS_BLKSIZ ; +return erofs_blksiz ();if (type ==INODE ) { *type_ret =META ;
@@ -84,7 +84,7 @@ static inline erofs_off_t erofs_btell(struct erofs_buffer_head *bh, bool end)if (bb->blkaddr ==NULL_ADDR )return NULL_ADDR_UL ; -return blknr_to_addr (bb->blkaddr) + +return erofs_pos (bb->blkaddr) + (end ?list_next_entry (bh, list)->off : bh->off); }
include/erofs/internal.h +13 -23
@@ -35,17 +35,7 @@ typedef unsigned short umode_t;#define PAGE_SIZE (1U << PAGE_SHIFT)#endif -/* no obvious reason to support explicit PAGE_SIZE != 4096 for now */ -#if PAGE_SIZE !=4096 -#warning EROFS may be incompatible on your platform -#endif - -#ifndef PAGE_MASK -#define PAGE_MASK (~(PAGE_SIZE-1)) -#endif - -#define LOG_BLOCK_SIZE (12) -#define EROFS_BLKSIZ (1U << LOG_BLOCK_SIZE) +#define EROFS_MAX_BLOCK_SIZE PAGE_SIZE#define EROFS_ISLOTBITS 5#define EROFS_SLOTSIZE (1U << EROFS_ISLOTBITS)
@@ -58,11 +48,15 @@ typedef u32 erofs_blk_t;#define NULL_ADDR ((unsigned int)-1)#define NULL_ADDR_UL ((unsigned long)-1) -#define erofs_blknr (addr) ((addr) / EROFS_BLKSIZ) -#define erofs_blkoff (addr) ((addr) % EROFS_BLKSIZ) -#define blknr_to_addr (nr) ((erofs_off_t)(nr) * EROFS_BLKSIZ) +/* global sbi */ +extern struct erofs_sb_info sbi; -#define BLK_ROUND_UP (addr) DIV_ROUND_UP(addr, EROFS_BLKSIZ) +#define erofs_blksiz () (1u << sbi.blkszbits) +#define erofs_blknr (addr) ((addr) >> sbi.blkszbits) +#define erofs_blkoff (addr) ((addr) & (erofs_blksiz() - 1)) +#define erofs_pos (nr) ((erofs_off_t)(nr) << sbi.blkszbits) + +#define BLK_ROUND_UP (addr) DIV_ROUND_UP(addr, 1u << sbi.blkszbits)struct erofs_buffer_head ;
@@ -110,16 +104,12 @@ struct erofs_sb_info {erofs_nid_t packed_nid; }; -/* make sure that any user of the erofs headers has atleast 64bit off_t type */ extern int erofs_assert_largefile[sizeof (off_t)-8 ]; -/* global sbi */ -extern struct erofs_sb_info sbi; -static inline erofs_off_t iloc (erofs_nid_t nid) { -return blknr_to_addr (sbi.meta_blkaddr) + (nid << sbi.islotbits); +return erofs_pos (sbi.meta_blkaddr) + (nid << sbi.islotbits); }#define EROFS_FEATURE_FUNCS (name, compat, feature) \
@@ -311,7 +301,7 @@ enum {#define EROFS_MAP_PARTIAL_REF (1 << BH_Partialref)struct erofs_map_blocks { -char mpage[EROFS_BLKSIZ ]; +char mpage[EROFS_MAX_BLOCK_SIZE ];erofs_off_t m_pa, m_la;u64 m_plen, m_llen;
@@ -355,7 +345,7 @@ int erofs_pread(struct erofs_inode *inode, char *buf, erofs_off_t count, erofs_off_t offset);int erofs_map_blocks (struct erofs_inode *inode,struct erofs_map_blocks *map,int flags); -int erofs_map_dev (struct erofs_sb_info *sbi,struct erofs_map_dev *map); +int erofs_map_dev (struct erofs_map_dev *map);int erofs_read_one_data (struct erofs_map_blocks *map,char *buffer,u64 offset,size_t len); int z_erofs_read_one_data(struct erofs_inode *inode,
@@ -374,7 +364,7 @@ static inline int erofs_get_occupied_size(const struct erofs_inode *inode,break ;case EROFS_INODE_FLAT_COMPRESSION_LEGACY :case EROFS_INODE_FLAT_COMPRESSION : - *size = inode->u.i_blocks *EROFS_BLKSIZ ; + *size = inode->u.i_blocks *erofs_blksiz ();break ;default :return -ENOTSUP ;
include/erofs/io.h +2 -4
@@ -43,15 +43,13 @@ ssize_t erofs_copy_file_range(int fd_in, erofs_off_t *off_in,static inline int blk_write (const void *buf,erofs_blk_t blkaddr,u32 nblocks) { -return dev_write (buf,blknr_to_addr (blkaddr), -blknr_to_addr (nblocks)); +return dev_write (buf,erofs_pos (blkaddr),erofs_pos (nblocks)); }static inline int blk_read (int device_id,void *buf,erofs_blk_t start,u32 nblocks) { -return dev_read (device_id, buf,blknr_to_addr (start), -blknr_to_addr (nblocks)); +return dev_read (device_id, buf,erofs_pos (start),erofs_pos (nblocks)); }#ifdef __cplusplus
include/erofs/xattr.h +2 -2
@@ -27,12 +27,12 @@ static inline unsigned int inlinexattr_header_size(struct erofs_inode *vi)static inline erofs_blk_t xattrblock_addr (unsigned int xattr_id) {return sbi.xattr_blkaddr + - xattr_id *sizeof (__u32) /EROFS_BLKSIZ ; + ((xattr_id *sizeof (__u32)) >> sbi.blkszbits); }static inline unsigned int xattrblock_offset (unsigned int xattr_id) { -return (xattr_id *sizeof (__u32)) %EROFS_BLKSIZ ; +return (xattr_id *sizeof (__u32)) & (erofs_blksiz () -1 ); }#define EROFS_INODE_XATTR_ICOUNT (_size) ({\
lib/blobchunk.c +7 -7
@@ -32,7 +32,7 @@ struct erofs_blobchunk erofs_holechunk = {static struct erofs_blobchunk *erofs_blob_getchunk (int fd,erofs_off_t chunksize) { -static u8 zeroed[EROFS_BLKSIZ ]; +static u8 zeroed[EROFS_MAX_BLOCK_SIZE ];u8 *chunkdata, sha256[32 ];int ret;unsigned int hash;
@@ -72,7 +72,7 @@ static struct erofs_blobchunk *erofs_blob_getchunk(int fd,erofs_dbg ("Writing chunk (%u bytes) to %u" , chunksize, chunk->blkaddr); ret =fwrite (chunkdata, chunksize,1 , blobfile);if (ret ==1 &&erofs_blkoff (chunksize)) - ret =fwrite (zeroed,EROFS_BLKSIZ -erofs_blkoff (chunksize), + ret =fwrite (zeroed,erofs_blksiz () -erofs_blkoff (chunksize),1 , blobfile);if (ret <1 ) {struct hashmap_entry key;
@@ -181,15 +181,15 @@ int erofs_blob_write_chunked_file(struct erofs_inode *inode)/* if the file is fully sparsed, use one big chunk instead */ if (lseek (fd,0 ,SEEK_DATA ) <0 && errno ==ENXIO ) { chunkbits =ilog2 (inode->i_size -1 ) +1 ; -if (chunkbits <LOG_BLOCK_SIZE ) - chunkbits =LOG_BLOCK_SIZE ; +if (chunkbits < sbi.blkszbits) + chunkbits = sbi.blkszbits; }#endif -if (chunkbits -LOG_BLOCK_SIZE >EROFS_CHUNK_FORMAT_BLKBITS_MASK ) - chunkbits =EROFS_CHUNK_FORMAT_BLKBITS_MASK +LOG_BLOCK_SIZE ; +if (chunkbits - sbi.blkszbits >EROFS_CHUNK_FORMAT_BLKBITS_MASK ) + chunkbits =EROFS_CHUNK_FORMAT_BLKBITS_MASK + sbi.blkszbits; chunksize =1ULL << chunkbits; count =DIV_ROUND_UP (inode->i_size, chunksize); - inode->u.chunkformat |= chunkbits -LOG_BLOCK_SIZE ; + inode->u.chunkformat |= chunkbits - sbi.blkszbits;if (multidev) inode->u.chunkformat |=EROFS_CHUNK_FORMAT_INDEXES ;
lib/cache.c +18 -18
@@ -17,7 +17,7 @@ static struct erofs_buffer_block blkh = {static erofs_blk_t tail_blkaddr;/* buckets for all mapped buffer blocks to boost up allocation */ -static struct list_head mapped_buckets[META +1 ][EROFS_BLKSIZ ]; +static struct list_head mapped_buckets[META +1 ][EROFS_MAX_BLOCK_SIZE ];/* last mapped buffer block to accelerate erofs_mapbh() */ static struct erofs_buffer_block *last_mapped_block = &blkh;
@@ -86,7 +86,7 @@ static void erofs_bupdate_mapped(struct erofs_buffer_block *bb)if (bb->blkaddr ==NULL_ADDR )return ; - bkt = mapped_buckets[bb->type] + bb->buffers.off %EROFS_BLKSIZ ; + bkt = mapped_buckets[bb->type] + bb->buffers.off %erofs_blksiz ();list_del (&bb->mapped_list);list_add_tail (&bb->mapped_list, bkt); }
@@ -100,9 +100,9 @@ static int __erofs_battach(struct erofs_buffer_block *bb, bool dryrun) {const erofs_off_t alignedoffset =roundup (bb->buffers.off, alignsize); -const int oob =cmpsgn (roundup ((bb->buffers.off -1 ) %EROFS_BLKSIZ +1 , +const int oob =cmpsgn (roundup ((bb->buffers.off -1 ) %erofs_blksiz () +1 , alignsize) + incr + extrasize, -EROFS_BLKSIZ ); +erofs_blksiz ());bool tailupdate = false;erofs_blk_t blkaddr;
@@ -132,7 +132,7 @@ static int __erofs_battach(struct erofs_buffer_block *bb, tail_blkaddr = blkaddr +BLK_ROUND_UP (bb->buffers.off);erofs_bupdate_mapped (bb); } -return (alignedoffset + incr -1 ) %EROFS_BLKSIZ +1 ; +return (alignedoffset + incr -1 ) %erofs_blksiz () +1 ; }int erofs_bh_balloon (struct erofs_buffer_head *bh,erofs_off_t incr)
@@ -156,12 +156,12 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,unsigned int used0, used_before, usedmax, used;int ret; - used0 = (size + required_ext) %EROFS_BLKSIZ + inline_ext; + used0 = (size + required_ext) %erofs_blksiz () + inline_ext;/* inline data should be in the same fs block */ -if (used0 >EROFS_BLKSIZ ) +if (used0 >erofs_blksiz ())return -ENOSPC ; -if (!used0 || alignsize ==EROFS_BLKSIZ ) { +if (!used0 || alignsize ==erofs_blksiz ()) { *bbp =NULL ;return 0 ; }
@@ -170,10 +170,10 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size, bb =NULL ;/* try to find a most-fit mapped buffer block first */ -if (size + required_ext + inline_ext >=EROFS_BLKSIZ ) +if (size + required_ext + inline_ext >=erofs_blksiz ()) goto skip_mapped; - used_before =rounddown (EROFS_BLKSIZ - + used_before =rounddown (erofs_blksiz () - (size + required_ext + inline_ext), alignsize);for (; used_before; --used_before) {struct list_head *bt = mapped_buckets[type] + used_before;
@@ -191,7 +191,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,DBG_BUGON (cur->type != type);DBG_BUGON (cur->blkaddr ==NULL_ADDR ); -DBG_BUGON (used_before != cur->buffers.off %EROFS_BLKSIZ ); +DBG_BUGON (used_before != cur->buffers.off %erofs_blksiz ()); ret =__erofs_battach (cur,NULL , size, alignsize, required_ext + inline_ext, true);
@@ -202,7 +202,7 @@ static int erofs_bfind_for_attach(int type, erofs_off_t size,/* should contain all data in the current block */ used = ret + required_ext + inline_ext; -DBG_BUGON (used >EROFS_BLKSIZ ); +DBG_BUGON (used >erofs_blksiz ()); bb = cur; usedmax = used;
@@ -215,7 +215,7 @@ skip_mapped:if (cur == &blkh) cur =list_next_entry (cur, list);for (; cur != &blkh; cur =list_next_entry (cur, list)) { - used_before = cur->buffers.off %EROFS_BLKSIZ ; + used_before = cur->buffers.off %erofs_blksiz ();/* skip if buffer block is just full */ if (!used_before)
@@ -230,10 +230,10 @@ skip_mapped:if (ret <0 )continue ; - used = (ret + required_ext) %EROFS_BLKSIZ + inline_ext; + used = (ret + required_ext) %erofs_blksiz () + inline_ext;/* should contain inline data in current block */ -if (used >EROFS_BLKSIZ ) +if (used >erofs_blksiz ())continue ;/*
@@ -396,9 +396,9 @@ bool erofs_bflush(struct erofs_buffer_block *bb)if (skip)continue ; - padding =EROFS_BLKSIZ - p->buffers.off %EROFS_BLKSIZ ; -if (padding !=EROFS_BLKSIZ ) -dev_fillzero (blknr_to_addr (blkaddr) - padding, + padding =erofs_blksiz () - p->buffers.off %erofs_blksiz (); +if (padding !=erofs_blksiz ()) +dev_fillzero (erofs_pos (blkaddr) - padding, padding, true);DBG_BUGON (!list_empty (&p->buffers.list));
lib/compress.c +40 -40
249 lines not on this page · raw message
lib/compress_hints.c +4 -4
@@ -133,21 +133,21 @@ int erofs_load_compress_hints(void) } } -if (pclustersize %EROFS_BLKSIZ ) { +if (pclustersize %erofs_blksiz ()) {erofs_warn ("invalid physical clustersize %u, " "use default pclusterblks %u" , pclustersize, cfg.c_pclusterblks_def);continue ; }erofs_insert_compress_hints (pattern, - pclustersize /EROFS_BLKSIZ , ccfg); + pclustersize /erofs_blksiz (), ccfg);if (pclustersize > max_pclustersize) max_pclustersize = pclustersize; } -if (cfg.c_pclusterblks_max *EROFS_BLKSIZ < max_pclustersize) { - cfg.c_pclusterblks_max = max_pclustersize /EROFS_BLKSIZ ; +if (cfg.c_pclusterblks_max *erofs_blksiz () < max_pclustersize) { + cfg.c_pclusterblks_max = max_pclustersize /erofs_blksiz ();erofs_warn ("update max pclusterblks to %u" , cfg.c_pclusterblks_max); } out:
lib/compressor.c +5 -5
@@ -38,10 +38,10 @@ int erofs_compress_destsize(const struct erofs_compress *c,if (ret <0 )return ret; -/* XXX: ret >= EROFS_BLKSIZ is a temporary hack for ztailpacking */ -if (inblocks || ret >=EROFS_BLKSIZ || +/* XXX: ret >= erofs_blksiz() is a temporary hack for ztailpacking */ +if (inblocks || ret >=erofs_blksiz () || uncompressed_capacity != *srcsize) - compressed_size =roundup (ret,EROFS_BLKSIZ ); + compressed_size =roundup (ret,erofs_blksiz ());else compressed_size = ret;DBG_BUGON (c->compress_threshold <100 );
@@ -76,8 +76,8 @@ int erofs_compressor_init(struct erofs_compress *c, char *alg_name) c->compress_threshold =100 ;/* optimize for 4k size page */ - c->destsize_alignsize =EROFS_BLKSIZ ; - c->destsize_redzone_begin =EROFS_BLKSIZ -16 ; + c->destsize_alignsize =erofs_blksiz (); + c->destsize_redzone_begin =erofs_blksiz () -16 ; c->destsize_redzone_end =EROFS_CONFIG_COMPR_DEF_BOUNDARY ;if (!alg_name) {
lib/data.c +17 -17
@@ -28,9 +28,9 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode,/* there is no hole in flatmode */ map->m_flags =EROFS_MAP_MAPPED ; -if (offset <blknr_to_addr (lastblk)) { - map->m_pa =blknr_to_addr (vi->u.i_blkaddr) + map->m_la; - map->m_plen =blknr_to_addr (lastblk) - offset; +if (offset <erofs_pos (lastblk)) { + map->m_pa =erofs_pos (vi->u.i_blkaddr) + map->m_la; + map->m_plen =erofs_pos (lastblk) - offset; }else if (tailendpacking) {/* 2 - inode inline B: inode, [xattrs], inline last blk... */ map->m_pa = iloc(vi->nid) + vi->inode_isize +
@@ -38,7 +38,7 @@ static int erofs_map_blocks_flatmode(struct erofs_inode *inode, map->m_plen = inode->i_size - offset;/* inline data should be located in the same meta block */ -if (erofs_blkoff (map->m_pa) + map->m_plen >EROFS_BLKSIZ ) { +if (erofs_blkoff (map->m_pa) + map->m_plen >erofs_blksiz ()) {erofs_err ("inline data cross block boundary @ nid %" PRIu64, vi->nid);DBG_BUGON (1 );
@@ -66,7 +66,7 @@ int erofs_map_blocks(struct erofs_inode *inode, {struct erofs_inode *vi = inode;struct erofs_inode_chunk_index *idx; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u64 chunknr;unsigned int unit;erofs_off_t pos;
@@ -98,7 +98,7 @@ int erofs_map_blocks(struct erofs_inode *inode, map->m_la = chunknr << vi->u.chunkbits; map->m_plen =min_t (erofs_off_t,1UL << vi->u.chunkbits, -roundup (inode->i_size - map->m_la,EROFS_BLKSIZ )); +roundup (inode->i_size - map->m_la,erofs_blksiz ()));/* handle block map */ if (!(vi->u.chunkformat &EROFS_CHUNK_FORMAT_INDEXES )) {
@@ -107,7 +107,7 @@ int erofs_map_blocks(struct erofs_inode *inode,if (le32_to_cpu (*blkaddr) ==EROFS_NULL_ADDR ) { map->m_flags =0 ; }else { - map->m_pa =blknr_to_addr (le32_to_cpu (*blkaddr)); + map->m_pa =erofs_pos (le32_to_cpu (*blkaddr)); map->m_flags =EROFS_MAP_MAPPED ; } goto out;
@@ -121,7 +121,7 @@ int erofs_map_blocks(struct erofs_inode *inode,default : map->m_deviceid =le16_to_cpu (idx->device_id) & sbi.device_id_mask; - map->m_pa =blknr_to_addr (le32_to_cpu (idx->blkaddr)); + map->m_pa =erofs_pos (le32_to_cpu (idx->blkaddr)); map->m_flags =EROFS_MAP_MAPPED ;break ; }
@@ -130,23 +130,23 @@ out:return err; } -int erofs_map_dev (struct erofs_sb_info *sbi,struct erofs_map_dev *map) +int erofs_map_dev (struct erofs_map_dev *map) {struct erofs_device_info *dif;int id;if (map->m_deviceid) { -if (sbi->extra_devices < map->m_deviceid) +if (sbi.extra_devices < map->m_deviceid)return -ENODEV ; - }else if (sbi->extra_devices) { -for (id =0 ; id < sbi->extra_devices; ++id) { + }else if (sbi.extra_devices) { +for (id =0 ; id < sbi.extra_devices; ++id) {erofs_off_t startoff, length; - dif = sbi->devs + id; + dif = sbi.devs + id;if (!dif->mapped_blkaddr)continue ; - startoff =blknr_to_addr (dif->mapped_blkaddr); - length =blknr_to_addr (dif->blocks); + startoff =erofs_pos (dif->mapped_blkaddr); + length =erofs_pos (dif->blocks);if (map->m_pa >= startoff && map->m_pa < startoff + length) {
@@ -168,7 +168,7 @@ int erofs_read_one_data(struct erofs_map_blocks *map, char *buffer, u64 offset, .m_deviceid = map->m_deviceid, .m_pa = map->m_pa, }; - ret =erofs_map_dev (&sbi, &mdev); + ret =erofs_map_dev (&mdev);if (ret)return ret;
@@ -253,7 +253,7 @@ int z_erofs_read_one_data(struct erofs_inode *inode, mdev = (struct erofs_map_dev ) { .m_pa = map->m_pa, }; - ret =erofs_map_dev (&sbi, &mdev); + ret =erofs_map_dev (&mdev);if (ret) {DBG_BUGON (1 );return ret;
lib/decompress.c +8 -8
@@ -22,8 +22,8 @@ static int z_erofs_decompress_lzma(struct z_erofs_decompress_req *rq)lzma_stream strm;lzma_ret ret2; -while (!src[inputmargin & ~PAGE_MASK ]) -if (!(++inputmargin & ~PAGE_MASK )) +while (!src[inputmargin & (erofs_blksiz () -1 )]) +if (!(++inputmargin & (erofs_blksiz () -1 )))break ;if (inputmargin >= rq->inputsize)
@@ -85,8 +85,8 @@ static int z_erofs_decompress_lz4(struct z_erofs_decompress_req *rq)if (erofs_sb_has_lz4_0padding ()) { support_0padding = true; -while (!src[inputmargin & ~PAGE_MASK ]) -if (!(++inputmargin & ~PAGE_MASK )) +while (!src[inputmargin & (erofs_blksiz () -1 )]) +if (!(++inputmargin & (erofs_blksiz () -1 )))break ;if (inputmargin >= rq->inputsize)
@@ -134,15 +134,15 @@ int z_erofs_decompress(struct z_erofs_decompress_req *rq)if (rq->alg ==Z_EROFS_COMPRESSION_INTERLACED ) {unsigned int count, rightpart, skip; -/* XXX: should support inputsize >= EROFS_BLKSIZ later */ -if (rq->inputsize >EROFS_BLKSIZ ) +/* XXX: should support inputsize >= erofs_blksiz() later */ +if (rq->inputsize >erofs_blksiz ())return -EFSCORRUPTED ; -DBG_BUGON (rq->decodedlength >EROFS_BLKSIZ ); +DBG_BUGON (rq->decodedlength >erofs_blksiz ());DBG_BUGON (rq->decodedlength < rq->decodedskip); count = rq->decodedlength - rq->decodedskip; skip =erofs_blkoff (rq->interlaced_offset + rq->decodedskip); - rightpart =min (EROFS_BLKSIZ - skip, count); + rightpart =min (erofs_blksiz () - skip, count);memcpy (rq->out, rq->in + skip, rightpart);memcpy (rq->out + rightpart, rq->in, count - rightpart);return 0 ;
lib/dir.c +3 -3
@@ -125,7 +125,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)struct erofs_inode *dir = ctx->dir;int err =0 ;erofs_off_t pos; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];if (!S_ISDIR (dir->i_mode))return -ENOTDIR ;
@@ -135,7 +135,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck)while (pos < dir->i_size) {erofs_blk_t lblk =erofs_blknr (pos);erofs_off_t maxsize =min_t (erofs_off_t, - dir->i_size - pos,EROFS_BLKSIZ ); + dir->i_size - pos,erofs_blksiz ());const struct erofs_dirent *de = (const void *)buf;unsigned int nameoff;
@@ -148,7 +148,7 @@ int erofs_iterate_dir(struct erofs_dir_context *ctx, bool fsck) nameoff =le16_to_cpu (de->nameoff);if (nameoff <sizeof (struct erofs_dirent ) || - nameoff >=EROFS_BLKSIZ ) { + nameoff >=erofs_blksiz ()) {erofs_err ("invalid de[0].nameoff %u @ nid %llu, lblk %u" , nameoff, dir->nid |0ULL , lblk);return -EFSCORRUPTED ;
lib/inode.c +28 -28
166 lines not on this page · raw message
lib/io.c +7 -7
@@ -82,7 +82,7 @@ int dev_open(const char *dev)close (fd);return ret; } - erofs_devsz =round_down (erofs_devsz,EROFS_BLKSIZ ); + erofs_devsz =round_down (erofs_devsz,erofs_blksiz ());break ;case S_IFREG : ret =ftruncate (fd,0 );
@@ -192,7 +192,7 @@ int dev_write(const void *buf, u64 offset, size_t len)int dev_fillzero (u64 offset,size_t len,bool padding) { -static const char zero[EROFS_BLKSIZ ] = {0 }; +static const char zero[EROFS_MAX_BLOCK_SIZE ] = {0 };int ret;if (cfg.c_dry_run)
@@ -203,12 +203,12 @@ int dev_fillzero(u64 offset, size_t len, bool padding) FALLOC_FL_KEEP_SIZE, offset, len) >= 0)return 0 ;#endif -while (len >EROFS_BLKSIZ ) { - ret =dev_write (zero, offset,EROFS_BLKSIZ ); +while (len >erofs_blksiz ()) { + ret =dev_write (zero, offset,erofs_blksiz ());if (ret)return ret; - len -=EROFS_BLKSIZ ; - offset +=EROFS_BLKSIZ ; + len -=erofs_blksiz (); + offset +=erofs_blksiz (); }return dev_write (zero, offset, len); }
@@ -240,7 +240,7 @@ int dev_resize(unsigned int blocks)return -errno; } - length = (u64 )blocks *EROFS_BLKSIZ ; + length = (u64 )blocks *erofs_blksiz ();if (st.st_size == length)return 0 ;if (st.st_size > length)
lib/namei.c +5 -6
@@ -134,7 +134,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi) vi->u.chunkformat, vi->nid | 0ULL);return -EOPNOTSUPP ; } - vi->u.chunkbits =LOG_BLOCK_SIZE + + vi->u.chunkbits = sbi.blkszbits + (vi->u.chunkformat &EROFS_CHUNK_FORMAT_BLKBITS_MASK ); }else if (erofs_inode_is_data_compressed (vi->datalayout))return z_erofs_fill_inode (vi);
@@ -186,12 +186,11 @@ struct nameidata {unsigned int ftype; }; -int erofs_namei (struct nameidata *nd, -const char *name,unsigned int len) +int erofs_namei (struct nameidata *nd,const char *name,unsigned int len) {erofs_nid_t nid = nd->nid;int ret; -char buf[EROFS_BLKSIZ ]; +char buf[EROFS_MAX_BLOCK_SIZE ];struct erofs_inode vi = { .nid = nid };erofs_off_t offset;
@@ -202,7 +201,7 @@ int erofs_namei(struct nameidata *nd, offset =0 ;while (offset < vi.i_size) {erofs_off_t maxsize =min_t (erofs_off_t, - vi.i_size - offset,EROFS_BLKSIZ ); + vi.i_size - offset,erofs_blksiz ());struct erofs_dirent *de = (void *)buf;unsigned int nameoff;
@@ -212,7 +211,7 @@ int erofs_namei(struct nameidata *nd, nameoff =le16_to_cpu (de->nameoff);if (nameoff <sizeof (struct erofs_dirent ) || - nameoff >=EROFS_BLKSIZ ) { + nameoff >=erofs_blksiz ()) {erofs_err ("invalid de[0].nameoff %u @ nid %llu" , nameoff, nid |0ULL );return -EFSCORRUPTED ;
lib/super.c +3 -3
@@ -68,7 +68,7 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,int erofs_read_superblock (void ) { -char data[EROFS_BLKSIZ ]; +char data[EROFS_MAX_BLOCK_SIZE ];struct erofs_super_block *dsb;int ret;
@@ -89,9 +89,9 @@ int erofs_read_superblock(void) sbi.blkszbits = dsb->blkszbits;/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ -if (sbi.blkszbits !=LOG_BLOCK_SIZE ) { +if (1u << sbi.blkszbits !=PAGE_SIZE ) {erofs_err ("blksize %d isn't supported on this platform" , -1 << sbi.blkszbits); +erofs_blksiz ());return ret; }
lib/xattr.c +12 -12
@@ -619,8 +619,8 @@ int erofs_build_shared_xattrs_from_path(const char *path)erofs_mapbh (bh->block); off =erofs_btell (bh, false); - sbi.xattr_blkaddr = off /EROFS_BLKSIZ ; - off %=EROFS_BLKSIZ ; + sbi.xattr_blkaddr = off /erofs_blksiz (); + off %=erofs_blksiz (); p =0 ; sorted_n =malloc (shared_xattrs_count *sizeof (n));
@@ -716,7 +716,7 @@ char *erofs_export_xattr_ibody(struct list_head *ixattrs, unsigned int size) }struct xattr_iter { -char page[EROFS_BLKSIZ ]; +char page[EROFS_MAX_BLOCK_SIZE ];void *kaddr;
@@ -775,9 +775,9 @@ static int init_inode_xattrs(struct erofs_inode *vi) it.ofs +=sizeof (struct erofs_xattr_ibody_header );for (i =0 ; i < vi->xattr_shared_count; ++i) { -if (it.ofs >=EROFS_BLKSIZ ) { +if (it.ofs >=erofs_blksiz ()) {/* cannot be unaligned */ -DBG_BUGON (it.ofs !=EROFS_BLKSIZ ); +DBG_BUGON (it.ofs !=erofs_blksiz ()); ret =blk_read (0 , it.page, ++it.blkaddr,1 );if (ret <0 ) {
@@ -819,7 +819,7 @@ static inline int xattr_iter_fixup(struct xattr_iter *it) {int ret; -if (it->ofs <EROFS_BLKSIZ ) +if (it->ofs <erofs_blksiz ())return 0 ; it->blkaddr +=erofs_blknr (it->ofs);
@@ -906,8 +906,8 @@ static int xattr_foreach(struct xattr_iter *it, processed =0 ;while (processed < entry.e_name_len) { -if (it->ofs >=EROFS_BLKSIZ ) { -DBG_BUGON (it->ofs >EROFS_BLKSIZ ); +if (it->ofs >=erofs_blksiz ()) { +DBG_BUGON (it->ofs >erofs_blksiz ()); err =xattr_iter_fixup (it);if (err)
@@ -915,7 +915,7 @@ static int xattr_foreach(struct xattr_iter *it, it->ofs =0 ; } - slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs, + slice = min_t(unsigned int, erofs_blksiz() - it->ofs, entry.e_name_len - processed);/* handle name */
@@ -941,8 +941,8 @@ static int xattr_foreach(struct xattr_iter *it, }while (processed < value_sz) { -if (it->ofs >=EROFS_BLKSIZ ) { -DBG_BUGON (it->ofs >EROFS_BLKSIZ ); +if (it->ofs >=erofs_blksiz ()) { +DBG_BUGON (it->ofs >erofs_blksiz ()); err =xattr_iter_fixup (it);if (err)
@@ -950,7 +950,7 @@ static int xattr_foreach(struct xattr_iter *it, it->ofs =0 ; } - slice = min_t(unsigned int, EROFS_BLKSIZ - it->ofs, + slice = min_t(unsigned int, erofs_blksiz() - it->ofs, value_sz - processed); op->value (it, processed, it->kaddr + it->ofs, slice); it->ofs += slice;
lib/zmap.c +6 -6
@@ -22,7 +22,7 @@ int z_erofs_fill_inode(struct erofs_inode *vi) vi->z_advise =0 ; vi->z_algorithmtype[0 ] =0 ; vi->z_algorithmtype[1 ] =0 ; - vi->z_logical_clusterbits =LOG_BLOCK_SIZE ; + vi->z_logical_clusterbits = sbi.blkszbits; vi->flags |=EROFS_I_Z_INITED ; }
@@ -66,7 +66,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi)return -EOPNOTSUPP ; } - vi->z_logical_clusterbits =LOG_BLOCK_SIZE + (h->h_clusterbits &7 ); + vi->z_logical_clusterbits = sbi.blkszbits + (h->h_clusterbits &7 );if (vi->datalayout ==EROFS_INODE_FLAT_COMPRESSION && !(vi->z_advise &Z_EROFS_ADVISE_BIG_PCLUSTER_1 ) ^ !(vi->z_advise &Z_EROFS_ADVISE_BIG_PCLUSTER_2 )) {
@@ -82,7 +82,7 @@ static int z_erofs_fill_inode_lazy(struct erofs_inode *vi) ret =z_erofs_do_map_blocks (vi, &map,EROFS_GET_BLOCKS_FINDTAIL );if (!map.m_plen || -erofs_blkoff (map.m_pa) + map.m_plen >EROFS_BLKSIZ ) { +erofs_blkoff (map.m_pa) + map.m_plen >erofs_blksiz ()) {erofs_err ("invalid tail-packing pclustersize %llu" , map.m_plen |0ULL );return -EFSCORRUPTED ;
@@ -496,7 +496,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,* if the 1st NONHEAD lcluster is actually PLAIN or HEAD type * rather than CBLKCNT, it's a 1 lcluster-sized pcluster. */ - m->compressedblks =1 << (lclusterbits -LOG_BLOCK_SIZE ); + m->compressedblks =1 << (lclusterbits - sbi.blkszbits);break ;case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD :if (m->delta[0 ] !=1 )
@@ -511,7 +511,7 @@ static int z_erofs_get_extent_compressedlen(struct z_erofs_maprecorder *m,return -EFSCORRUPTED ; } out: - map->m_plen = m->compressedblks <<LOG_BLOCK_SIZE ; + map->m_plen = m->compressedblks << sbi.blkszbits;return 0 ; err_bonus_cblkcnt: erofs_err("bogus CBLKCNT @ lcn %lu of nid %llu",
@@ -640,7 +640,7 @@ static int z_erofs_do_map_blocks(struct erofs_inode *vi, }else if (fragment && m.lcn == vi->z_tailextent_headlcn) { map->m_flags |=EROFS_MAP_FRAGMENT ; }else { - map->m_pa =blknr_to_addr (m.pblk); + map->m_pa =erofs_pos (m.pblk); err =z_erofs_get_extent_compressedlen (&m, initial_lcn);if (err) goto out;
mkfs/main.c +14 -15
@@ -474,7 +474,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) } } -if (cfg.c_blobdev_path && cfg.c_chunkbits <LOG_BLOCK_SIZE ) { +if (cfg.c_blobdev_path && cfg.c_chunkbits < sbi.blkszbits) {erofs_err ("--blobdev must be used together with --chunksize" );return -EINVAL ; }
@@ -517,29 +517,29 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) }if (pclustersize_max) { -if (pclustersize_max <EROFS_BLKSIZ || - pclustersize_max %EROFS_BLKSIZ ) { +if (pclustersize_max <erofs_blksiz () || + pclustersize_max %erofs_blksiz ()) {erofs_err ("invalid physical clustersize %u" , pclustersize_max);return -EINVAL ; } - cfg.c_pclusterblks_max = pclustersize_max /EROFS_BLKSIZ ; + cfg.c_pclusterblks_max = pclustersize_max >> sbi.blkszbits; cfg.c_pclusterblks_def = cfg.c_pclusterblks_max; } -if (cfg.c_chunkbits &&1u << cfg.c_chunkbits <EROFS_BLKSIZ ) { +if (cfg.c_chunkbits && cfg.c_chunkbits < sbi.blkszbits) {erofs_err ("chunksize %u must be larger than block size" ,1u << cfg.c_chunkbits);return -EINVAL ; }if (pclustersize_packed) { -if (pclustersize_max <EROFS_BLKSIZ || - pclustersize_max %EROFS_BLKSIZ ) { +if (pclustersize_max <erofs_blksiz () || + pclustersize_max %erofs_blksiz ()) {erofs_err ("invalid pcluster size for the packed file %u" , pclustersize_packed);return -EINVAL ; } - cfg.c_pclusterblks_packed = pclustersize_packed /EROFS_BLKSIZ ; + cfg.c_pclusterblks_packed = pclustersize_packed >> sbi.blkszbits; }return 0 ; }
@@ -551,7 +551,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, {struct erofs_super_block sb = { .magic =cpu_to_le32 (EROFS_SUPER_MAGIC_V1 ), - .blkszbits =LOG_BLOCK_SIZE , + .blkszbits = sbi.blkszbits, .inos =cpu_to_le64 (sbi.inos), .build_time =cpu_to_le64 (sbi.build_time), .build_time_nsec =cpu_to_le32 (sbi.build_time_nsec),
@@ -564,8 +564,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh, .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 ); +const u32 sb_blksize =round_up (EROFS_SUPER_END ,erofs_blksiz ());char *buf; *blocks =erofs_mapbh (NULL );
@@ -596,7 +595,7 @@ int erofs_mkfs_update_super_block(struct erofs_buffer_head *bh,static int erofs_mkfs_superblock_csum_set (void ) {int ret; -u8 buf[EROFS_BLKSIZ ]; +u8 buf[EROFS_MAX_BLOCK_SIZE ];u32 crc;struct erofs_super_block *sb;
@@ -621,7 +620,7 @@ static int erofs_mkfs_superblock_csum_set(void)/* turn on checksum feature */ sb->feature_compat =cpu_to_le32 (le32_to_cpu (sb->feature_compat) |EROFS_FEATURE_COMPAT_SB_CHKSUM ); - crc =erofs_crc32c (~0 , (u8 *)sb,EROFS_BLKSIZ -EROFS_SUPER_OFFSET ); + crc =erofs_crc32c (~0 , (u8 *)sb,erofs_blksiz () -EROFS_SUPER_OFFSET );/* set up checksum field to erofs_super_block */ sb->checksum =cpu_to_le32 (crc);
@@ -801,9 +800,9 @@ int main(int argc, char **argv)if (cfg.c_dedupe) {if (!cfg.c_compr_alg[0 ]) {erofs_err ("Compression is not enabled. Turn on chunk-based data deduplication instead." ); - cfg.c_chunkbits =LOG_BLOCK_SIZE ; + cfg.c_chunkbits = sbi.blkszbits; }else { - err =z_erofs_dedupe_init (EROFS_BLKSIZ ); + err =z_erofs_dedupe_init (erofs_blksiz ());if (err) {erofs_err ("failed to initialize deduplication: %s" ,erofs_strerror (err));
Signature · 1 line
2.24.4
PATCH v2 4/4 erofs-utils: support arbitary block sizes
In reply to Gao Xiang- Add a new command option for mkfs.erofs;
- fuse/dump/fsck supports arbitary block sizes (uncompressed files).
--- lib/namei.c | 5 ++++- lib/super.c | 6 +++--- mkfs/main.c | 27 +++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 8 deletions(-)
lib/namei.c +4 -1
@@ -136,8 +136,11 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi) } vi->u.chunkbits = sbi.blkszbits + (vi->u.chunkformat &EROFS_CHUNK_FORMAT_BLKBITS_MASK ); - }else if (erofs_inode_is_data_compressed (vi->datalayout)) + }else if (erofs_inode_is_data_compressed (vi->datalayout)) { +if (erofs_blksiz () !=PAGE_SIZE ) +return -EOPNOTSUPP ;return z_erofs_fill_inode (vi); + }return 0 ; bogusimode:erofs_err ("bogus i_mode (%o) @ nid %llu" , vi->i_mode, vi->nid |0ULL );
lib/super.c +3 -3
@@ -68,11 +68,11 @@ static int erofs_init_devices(struct erofs_sb_info *sbi,int erofs_read_superblock (void ) { -char data[EROFS_MAX_BLOCK_SIZE ]; +u8 data[EROFS_MAX_BLOCK_SIZE ];struct erofs_super_block *dsb;int ret; - ret =blk_read (0 , data,0 ,1 ); + ret =blk_read (0 , data,0 ,erofs_blknr (sizeof (data)));if (ret <0 ) {erofs_err ("cannot read erofs superblock: %d" , ret);return -EIO ;
@@ -89,7 +89,7 @@ int erofs_read_superblock(void) sbi.blkszbits = dsb->blkszbits;/* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ -if (1u << sbi.blkszbits !=PAGE_SIZE ) { +if (sbi.blkszbits <9 ) {erofs_err ("blksize %d isn't supported on this platform" ,erofs_blksiz ());return ret;
mkfs/main.c +23 -4
@@ -82,6 +82,7 @@ static void usage(void) {fputs ("usage: [options] FILE DIRECTORY\n\n" "Generate erofs image from DIRECTORY to FILE, and [options] are:\n" +" -b# set block size to # (# = page size by default)\n" " -d# set output message level to # (maximum 9)\n" " -x# set xattr tolerance to # (< 0, disable xattrs; default 2)\n" " -zX[,Y][:..] X=compressor (Y=compression level, optional)\n"
@@ -273,7 +274,7 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])int opt, i;bool quiet = false; -while ((opt =getopt_long (argc, argv,"C:E:L:T:U:d:x:z:" , +while ((opt =getopt_long (argc, argv,"C:E:L:T:U:b:d:x:z:" , long_options,NULL )) !=-1 ) {switch (opt) {case 'z' :
@@ -287,6 +288,15 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])return i;break ; +case 'b' : + i =atoi (optarg); +if (i <512 || i >EROFS_MAX_BLOCK_SIZE ) { +erofs_err ("invalid block size %s" , optarg); +return -EINVAL ; + } + sbi.blkszbits =ilog2 (i); +break ; +case 'd' : i =atoi (optarg);if (i <EROFS_MSG_MIN || i >EROFS_MSG_MAX ) {
@@ -515,7 +525,11 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) cfg.c_dbg_lvl =EROFS_ERR ; cfg.c_showprogress = false; } - +if (cfg.c_compr_alg[0 ] &&erofs_blksiz () !=PAGE_SIZE ) { +erofs_err ("compression is unsupported for now with block size %u" , +erofs_blksiz ()); +return -EINVAL ; + }if (pclustersize_max) {if (pclustersize_max <erofs_blksiz () || pclustersize_max %erofs_blksiz ()) {
@@ -597,9 +611,10 @@ static int erofs_mkfs_superblock_csum_set(void)int ret;u8 buf[EROFS_MAX_BLOCK_SIZE ];u32 crc; +unsigned int len;struct erofs_super_block *sb; - ret =blk_read (0 , buf,0 ,1 ); + ret =blk_read (0 , buf,0 ,erofs_blknr (sizeof (buf)));if (ret) {erofs_err ("failed to read superblock to set checksum: %s" ,erofs_strerror (ret));
@@ -620,7 +635,11 @@ static int erofs_mkfs_superblock_csum_set(void)/* turn on checksum feature */ sb->feature_compat =cpu_to_le32 (le32_to_cpu (sb->feature_compat) |EROFS_FEATURE_COMPAT_SB_CHKSUM ); - crc =erofs_crc32c (~0 , (u8 *)sb,erofs_blksiz () -EROFS_SUPER_OFFSET ); +if (erofs_blksiz () >EROFS_SUPER_OFFSET ) + len =erofs_blksiz () -EROFS_SUPER_OFFSET ; +else + len =erofs_blksiz (); + crc =erofs_crc32c (~0 , (u8 *)sb, len);/* set up checksum field to erofs_super_block */ sb->checksum =cpu_to_le32 (crc);
Signature · 1 line
2.24.4