Prevent ext[234] filesystems corruption

Some underlying device driver, e.g. the UML UBD driver, may manage holes
incorrectly which will prevent to retrieve all usefull zero ranges in
filesystem, e.g. when using 'bmaptool create'
Assigning UNIX_IO_NOZEROOUT environment variable prevent mkfs.ext[234]
utilities to create zero range spaces using fallocate with
FALLOC_FL_ZERO_RANGE or FALLOC_FL_PUNCH_HOLE

Signed-off-by: Frédéric Danis <frederic.danis@collabora.com>
This commit is contained in:
Frédéric Danis
2022-01-28 11:43:32 +01:00
committed by Sjoerd Simons
parent aac45966c9
commit b324040f0f

View File

@@ -350,6 +350,19 @@ func (i ImagePartitionAction) formatPartition(p *Partition, context debos.DebosC
cmdline = append(cmdline, path)
cmd := debos.Command{}
/* Some underlying device driver, e.g. the UML UBD driver, may manage holes
* incorrectly which will prevent to retrieve all usefull zero ranges in
* filesystem, e.g. when using 'bmaptool create', see patch
* http://lists.infradead.org/pipermail/linux-um/2022-January/002074.html
*
* Adding UNIX_IO_NOZEROOUT environment variable prevent mkfs.ext[234]
* utilities to create zero range spaces using fallocate with
* FALLOC_FL_ZERO_RANGE or FALLOC_FL_PUNCH_HOLE */
if p.FS == "ext2" || p.FS == "ext3" || p.FS == "ext4" {
cmd.AddEnv("UNIX_IO_NOZEROOUT=1")
}
if err := cmd.Run(label, cmdline...); err != nil {
return err
}