Fundamentals 8 min read

Implementing Block List Generation for EROFS to Accelerate OTA Packaging

This article explains how the Android block list feature, originally implemented for EXT4, was analyzed and re‑implemented for the EROFS file system, detailing the generation process, key code functions, and the resulting OTA packaging speed improvement of over 90 %.

Coolpad Technology Team
Coolpad Technology Team
Coolpad Technology Team
Implementing Block List Generation for EROFS to Accelerate OTA Packaging

We discovered that using the EROFS file system for OTA generation caused a performance drop compared to the default EXT4, because EROFS (including upstream) does not support Android file block mapping.

After analyzing EXT4’s implementation, we traced the block‑list generation flow, starting from the -B block_list command‑line option, through ino_iter_blocks , write_block_ranges , and the final end_new_file routine that writes the mount point, file name and block ranges.

Key helper functions include:

static errcode_t ino_iter_blocks(ext2_filsys fs, ext2_ino_t ino, struct walk_ext_priv_data *pdata) { … }
int write_block_ranges(FILE *f, struct block_range *range, char *sep) { … }

With this understanding we implemented the EROFS block‑list file generation, adapting the logic to the EROFS utilities (erofs‑utils v1.2). The core writing functions are:

int erofs_write_file(struct erofs_inode *inode) { … }
static int write_uncompressed_file_from_fd(struct erofs_inode *inode, int fd) { … }
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)); }

For compressed files, erofs_write_compressed_file determines the starting block address, increments it for each compressed block, and calculates compressed_blocks to decide whether to fall back to the uncompressed layout.

int erofs_write_compressed_file(struct erofs_inode *inode) { … compressed_blocks = ctx.blkaddr - blkaddr; … }

The tail‑end data is written separately, with optional inline packing to reduce I/O, as shown in erofs_write_tail_end .

int erofs_write_tail_end(struct erofs_inode *inode) { … dev_write(inode->idata, pos, inode->idata_size); … }

Testing shows that enabling the block‑list feature in OTA packaging can improve the build speed by more than 90 %, and the changes have been contributed upstream (commit 3afe21832d80f3cdbe4173809db91ee271b52a76).

The feature will continue to be maintained in Coolpad COOl 20 and future products.

linuxfile systemEROFSblock listOTA
Coolpad Technology Team
Written by

Coolpad Technology Team

Committed to advancing technology and supporting innovators. The Coolpad Technology Team regularly shares forward‑looking insights, product updates, and tech news. Tech experts are welcome to join; everyone is invited to follow us.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.