freenode
Kernel & Low-Level

Google proposes F2FS mounts for 4KB images on 16KB-page kernels

The change would let Android userdata survive a move from 4KB to 16KB pages without rewriting the on-disk format.

Google engineer Daeho Jeong has posted a 20-patch update that would let the Flash-Friendly File System mount images whose block size is smaller than the kernel page size. F2FS has long required those two sizes to match. On a kernel built with 16KB pages, that rule means an existing image with 4KB blocks cannot be mounted, including the userdata partition of an Android device that moves from a 4KB-page kernel to a 16KB-page one.

The on-disk format does not change. The work builds on large-folio support from Nanzhe Zhao and tracks which blocks inside a memory page are up to date or dirty, so reads, writes, garbage collection, and most other paths can operate on filesystem blocks rather than whole pages. When the block size already equals the page size, Jeong wrote that behavior does not change, aside from fixes that are not limited to the new case.

Those fixes matter on their own. Extending direct writes now update the file size before the page cache of the written range is invalidated, matching ext4, so a concurrent read cannot hide data that was just written. Collapse and insert range hold locks until moved blocks are written back and the cache is dropped, closing a window in which a store to a neighboring block could write old data back over a hole or over the moved contents. Defragmentation of compressed files is changed so a block missing from the cache is read through the normal path and decompressed; the old path could write compressed bytes back as ordinary file data.

Swap still works in page-sized units, so a partial tail page is ignored and extents must be page-aligned. Compression is more constrained: a cluster must cover at least one page, which raises the minimum cluster size only when a page holds more than four blocks, for example to 64KB for 4KB blocks on a 64KB-page kernel. A file that already uses a smaller cluster can still be looked up and removed, but opening it fails. Online resize is treated as already independent of page size and is allowed.