git: hammer2 - Finally fix the 'file winds up with some zeros' bug

Matthew Dillon dillon at
Tue Nov 19 12:06:32 PST 2019

commit 75a42a58ff9c00802f6b953a8ae1532725ee7116
Author: Matthew Dillon <dillon at>
Date:   Tue Nov 19 12:02:39 2019 -0800

    hammer2 - Finally fix the 'file winds up with some zeros' bug
    * Fix this bug, which has been reported several times this year
      but until nikita's hands-on I couldn't find it.
    * The bug occurs when H2 must transition from the 512 bytes of
      file data directly embedded in the inode to a block table as
      a file grows past 512 bytes.
      Basically what happens is that the buffer cache buffer holding
      the data in-transition can get lost.
      The result is that the first write() that overlaps seek offset
      512 in a small file can sometimes cause the prior data at the
      start of the file to be lost.
    * To solve the problem the buffer is now held across the transition
      and explicitly dirtied to force it to be flushed to the now-
      realized block table.
    Reported-by: nikita and several others this year

Summary of changes:
 sys/vfs/hammer2/hammer2_vnops.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list