bool erofs_bflush(struct erofs_buffer_block *bb);
void erofs_bdrop(struct erofs_buffer_head *bh, bool tryrevoke);
+erofs_blk_t erofs_total_metablocks(void);
#ifdef __cplusplus
}
u64 devsz;
unsigned int nblobs;
unsigned int blobfd[256];
+
+ struct list_head list;
+
+ u64 saved_by_deduplication;
};
/* make sure that any user of the erofs headers has atleast 64bit off_t type */
chunk = hashmap_get_from_hash(&blob_hashmap, hash, sha256);
if (chunk) {
DBG_BUGON(chunksize != chunk->chunksize);
+ sbi->saved_by_deduplication += chunksize;
erofs_dbg("Found duplicated chunk at %u", chunk->blkaddr);
return chunk;
}
.list = LIST_HEAD_INIT(blkh.list),
.blkaddr = NULL_ADDR,
};
-static erofs_blk_t tail_blkaddr;
+static erofs_blk_t tail_blkaddr, erofs_metablkcnt;
/* buckets for all mapped buffer blocks to boost up allocation */
static struct list_head mapped_buckets[META + 1][EROFS_MAX_BLOCK_SIZE];
dev_fillzero(&sbi, erofs_pos(&sbi, blkaddr) - padding,
padding, true);
+ if (p->type != DATA)
+ erofs_metablkcnt += BLK_ROUND_UP(&sbi, p->buffers.off);
erofs_dbg("block %u to %u flushed", p->blkaddr, blkaddr - 1);
erofs_bfree(p);
}
if (!list_empty(&bb->buffers.list))
return;
+ if (!rollback && bb->type != DATA)
+ erofs_metablkcnt += BLK_ROUND_UP(&sbi, bb->buffers.off);
erofs_bfree(bb);
-
if (rollback)
tail_blkaddr = blkaddr;
}
+
+erofs_blk_t erofs_total_metablocks(void)
+{
+ return erofs_metablkcnt;
+}
ctx->e.length -= delta;
}
+ sbi->saved_by_deduplication +=
+ dctx.e.compressedblks * erofs_blksiz(sbi);
erofs_dbg("Dedupe %u %scompressed data (delta %d) to %u of %u blocks",
dctx.e.length, dctx.e.raw ? "un" : "",
delta, dctx.e.blkaddr, dctx.e.compressedblks);
z_erofs_dedupe_commit(false);
z_erofs_write_mapheader(inode, compressmeta);
+ if (!ctx.fragemitted)
+ sbi->saved_by_deduplication += inode->fragment_size;
+
/* if the entire file is a fragment, a simplified form is used. */
if (inode->i_size == inode->fragment_size) {
DBG_BUGON(inode->fragmentoff >> 63);
printf("%s %s\n", basename(argv[0]), cfg.c_version);
}
+static void erofs_mkfs_showsummaries(erofs_blk_t nblocks)
+{
+ char uuid_str[37] = {};
+
+ if (!(cfg.c_dbg_lvl > EROFS_ERR && cfg.c_showprogress))
+ return;
+
+ erofs_uuid_unparse_lower(sbi.uuid, uuid_str);
+
+ fprintf(stdout, "------\nFilesystem UUID: %s\n"
+ "Filesystem total blocks: %u (of %u-byte blocks)\n"
+ "Filesystem total inodes: %llu\n"
+ "Filesystem total metadata blocks: %u\n"
+ "Filesystem total deduplicated bytes (of source files): %llu\n",
+ uuid_str, nblocks, 1U << sbi.blkszbits, sbi.inos | 0ULL,
+ erofs_total_metablocks(),
+ sbi.saved_by_deduplication | 0ULL);
+}
+
int main(int argc, char **argv)
{
int err = 0;
struct stat st;
erofs_blk_t nblocks;
struct timeval t;
- char uuid_str[37];
FILE *packedfile = NULL;
erofs_init_configure();
erofs_strerror(err));
goto exit;
}
- erofs_uuid_unparse_lower(sbi.uuid, uuid_str);
- erofs_info("filesystem UUID: %s", uuid_str);
erofs_inode_manager_init();
erofs_iput(root_inode);
if (erofstar.index_mode || cfg.c_chunkbits) {
- erofs_info("total metadata: %u blocks", erofs_mapbh(NULL));
if (erofstar.index_mode && !erofstar.mapfile)
sbi.devs[0].blocks =
BLK_ROUND_UP(&sbi, erofstar.offset);
erofs_err("\tCould not format the device : %s\n",
erofs_strerror(err));
return 1;
- } else {
- erofs_update_progressinfo("Build completed.\n");
}
+ erofs_update_progressinfo("Build completed.\n");
+ erofs_mkfs_showsummaries(nblocks);
return 0;
}