Skip to content

Commit

Permalink
Prevent ext[234] filesystems corruption
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
fdanis-oss authored and sjoerdsimons committed Apr 19, 2022
1 parent aac4596 commit b324040
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions actions/image_partition_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b324040

Please sign in to comment.