• Kent Overstreet's avatar
    bcachefs: Change when we allow overwrites · 35a067b4
    Kent Overstreet authored
    Originally, we'd check for -ENOSPC when getting a disk reservation
    whenever the new extent took up more space on disk than the old extent.
    
    Erasure coding screwed this up, because with erasure coding writes are
    initially replicated, and then in the background the extra replicas are
    dropped when the stripe is created. This means that with erasure coding
    enabled, writes will always take up more space on disk than the data
    they're overwriting - but, according to posix, overwrites aren't
    supposed to return ENOSPC.
    
    So, in this patch we fudge things: if the new extent has more replicas
    than the _effective_ replicas of the old extent, or if the old extent is
    compressed and the new one isn't, we check for ENOSPC when getting the
    disk reservation - otherwise, we don't.
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    35a067b4
fs-io.c 74.9 KB