]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit - misc/mke2fs.c
mke2fs: add extended option for prezeroed storage devices
authorSarthak Kukreti <sarthakkukreti@chromium.org>
Mon, 27 Sep 2021 10:39:10 +0000 (03:39 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 25 Oct 2021 04:14:26 +0000 (00:14 -0400)
commitbd2e72c5c5521b561d20a881c843a64a5832721a
tree8fffde71f68dabebc6236f3d26ef1d000e1589dc
parenta8f525888f608d6966e49637ed62c88887177532
mke2fs: add extended option for prezeroed storage devices

This patch adds an extended option "assume_storage_prezeroed" to
mke2fs. When enabled, this option acts as a hint to mke2fs that the
underlying block device was zeroed before mke2fs was called.  This
allows mke2fs to optimize out the zeroing of the inode table and the
journal, which speeds up the filesystem creation time.

Additionally, on thinly provisioned storage devices (like Ceph,
dm-thin, newly created sparse loopback files), reads on unmapped
extents return zero. This property allows mke2fs (with
assume_storage_prezeroed) to avoid pre-allocating metadata space for
inode tables for the entire filesystem and saves space that would
normally be preallocated for zero inode tables.

Tests
-----
1) Running 'mke2fs -t ext4' on 10G sparse files on an ext4
filesystem drops the time taken by mke2fs from 0.09s to 0.04s
and reduces the initial metadata space allocation (stat on
sparse file) from 139736 blocks (545M) to 8672 blocks (34M).

2) On ChromeOS (running linux kernel 4.19) with dm-thin
and 200GB thin logical volumes using 'mke2fs -t ext4 <dev>':

- Time taken by mke2fs drops from 1.07s to 0.08s.
- Avoiding zeroing out the inode table and journal reduces the
  initial metadata space allocation from 0.48% to 0.01%.
- Lazy inode table zeroing results in a further 1.45% of logical
  volume space getting allocated for inode tables, even if no file
  data is added to the filesystem. With assume_storage_prezeroed,
  the metadata allocation remains at 0.01%.

[ Fixed regression test to work on newer versions of e2fsprogs -- TYT ]

Signed-off-by: Sarthak Kukreti <sarthakkukreti@chromium.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/mke2fs.8.in
misc/mke2fs.c
tests/m_assume_storage_prezeroed/expect [new file with mode: 0644]
tests/m_assume_storage_prezeroed/script [new file with mode: 0644]