Skip to content
  • Andreas Gruenbacher's avatar
    gfs2: Special-case rindex for gfs2_grow · 0fe57094
    Andreas Gruenbacher authored
    [ Upstream commit 77612578
    
     ]
    
    To speed up the common case of appending to a file,
    gfs2_write_alloc_required presumes that writing beyond the end of a file
    will always require additional blocks to be allocated.  This assumption
    is incorrect for preallocates files, but there are no negative
    consequences as long as *some* space is still left on the filesystem.
    
    One special file that always has some space preallocated beyond the end
    of the file is the rindex: when growing a filesystem, gfs2_grow adds one
    or more new resource groups and appends records describing those
    resource groups to the rindex; the preallocated space ensures that this
    is always possible.
    
    However, when a filesystem is completely full, gfs2_write_alloc_required
    will indicate that an additional allocation is required, and appending
    the next record to the rindex will fail even though space for that
    record has already been preallocated.  To fix that, skip the incorrect
    optimization in gfs2_write_alloc_required, but for the rindex only.
    Other writes to preallocated space beyond the end of the file are still
    allowed to fail on completely full filesystems.
    
    Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
    Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
    Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0fe57094