Skip to content
  • Hugh Dickins's avatar
    [PATCH] holepunch: fix shmem_truncate_range punching too far · a2646d1e
    Hugh Dickins authored
    
    
    Miklos Szeredi observes BUG_ON(!entry) in shmem_writepage() triggered in rare
    circumstances, because shmem_truncate_range() erroneously removes partially
    truncated directory pages at the end of the range: later reclaim on pages
    pointing to these removed directories triggers the BUG.  Indeed, and it can
    also cause data loss beyond the hole.
    
    Fix this as in the patch proposed by Miklos, but distinguish between "limit"
    (how far we need to search: ignore truncation's next_index optimization in the
    holepunch case - if there are races it's more consistent to act on the whole
    range specified) and "upper_limit" (how far we can free directory pages:
    generally we must be careful to keep partially punched pages, but can relax at
    end of file - i_size being held stable by i_mutex).
    
    Signed-off-by: default avatarHugh Dickins <hugh@veritas.com>
    Cc: Miklos Szeredi <mszeredi@suse.cs>
    Cc: Badari Pulavarty <pbadari@us.ibm.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    a2646d1e