erofs-utils: fix missing tail blocks for directories
PATCH 1/2 erofs-utils: fix missing tail blocks for directories
Currently directory blocks will be allocated after inode metadata space is reserved, but miss to fix tail blocks.
Fixes 21d84349e79a ("erofs-utils: rearrange on-disk metadata")
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/internal.h | 1 + lib/inode.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-)
include/erofs/internal.h +1 -0
@@ -180,6 +180,7 @@ struct erofs_inode {/* inline tail-end packing size */ unsigned short idata_size;bool compressed_idata; +bool lazy_tailblock;unsigned int xattr_isize;unsigned int extent_isize;
lib/inode.c +15 -1
@@ -608,7 +608,12 @@ static int erofs_prepare_tail_block(struct erofs_inode *inode)if (bh) {/* expend a block as the tail block (should be successful) */ ret =erofs_bh_balloon (bh,erofs_blksiz ()); -DBG_BUGON (ret !=erofs_blksiz ()); +if (ret !=erofs_blksiz ()) { +DBG_BUGON (1 ); +return -EIO ; + } + }else { + inode->lazy_tailblock = true; }return 0 ; }
@@ -743,6 +748,15 @@ static int erofs_write_tail_end(struct erofs_inode *inode) inode->u.i_blkaddr = bh->block->blkaddr; inode->bh_data = bh; }else { +if (inode->lazy_tailblock) { +/* expend a tail block (should be successful) */ + ret =erofs_bh_balloon (bh,erofs_blksiz ()); +if (ret !=erofs_blksiz ()) { +DBG_BUGON (1 ); +return -EIO ; + } + inode->lazy_tailblock = false; + } ret =erofs_mapbh (bh->block); }DBG_BUGON (ret <0 );
Signature · 1 line
2.24.4
PATCH 2/2 erofs-utils: mkfs: fix EOD read when calculate sb checksum
Since images could be very small for smaller block sizes.
Fixes a4fb8ea13ac7 ("erofs-utils: support arbitrary block sizes")
Signed-off-by Gao Xiang <[email protected]>
--- mkfs/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mkfs/main.c +1 -1
@@ -614,7 +614,7 @@ static int erofs_mkfs_superblock_csum_set(void)unsigned int len;struct erofs_super_block *sb; - ret =blk_read (0 , buf,0 ,erofs_blknr (sizeof (buf))); + ret =blk_read (0 , buf,0 ,erofs_blknr (EROFS_SUPER_END ) +1 );if (ret) {erofs_err ("failed to read superblock to set checksum: %s" ,erofs_strerror (ret));
Signature · 1 line
2.24.4