HomeFreeBSD

makefs/zfs: Ensure that the last block of a file has the right size

Description

makefs/zfs: Ensure that the last block of a file has the right size

When copying a file's contents into the pool, a loop copies blocks of
the maximum size (128KB), allocating space from the vdev for each block.
The space allocator rounds up to the nearest block size, but for files
larger than the maximum size, this can result in the last block having a
smaller logical size than the rest of the blocks belonging to that
dnode. This violates some ZFS invariants when appending to that file.

Modify fs_populate_file() to use the same block size for the final
block.

Approved by: re (gjb)
Reported by: cperciva
MFC after: 1 week
Sponsored by: The FreeBSD Foundation

(cherry picked from commit ef20cd33d3287ebead0d30f2e177fc57a97dc2d5)
(cherry picked from commit 5175923ef4acb6faff370177fb60700721f13f92)

Details

Provenance
markjAuthored on Sep 28 2023, 8:16 PM
Parents
rG5e78399dda05: makefs/zfs: Remove a nonsensical comment
Branches
Unknown
Tags
Unknown