Skip to content
  • Hugh Dickins's avatar
    tmpfs: undo fallocation on failure · 1635f6a7
    Hugh Dickins authored
    
    
    In the previous episode, we left the already-fallocated pages attached to
    the file when shmem_fallocate() fails part way through.
    
    Now try to do better, by extending the earlier optimization of !Uptodate
    pages (then always under page lock) to !Uptodate pages (outside of page
    lock), representing fallocated pages.  And don't waste time clearing them
    at the time of fallocate(), leave that until later if necessary.
    
    Adapt shmem_truncate_range() to shmem_undo_range(), so that a failing
    fallocate can recognize and remove precisely those !Uptodate allocations
    which it added (and were not independently allocated by racing tasks).
    
    But unless we start playing with swapfile.c and memcontrol.c too, once one
    of our fallocated pages reaches shmem_writepage(), we do then have to
    instantiate it as an ordinarily allocated page, before swapping out.  This
    is unsatisfactory, but improved in the next episode.
    
    Signed-off-by: default avatarHugh Dickins <hughd@google.com>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: Cong Wang <amwang@redhat.com>
    Cc: Kay Sievers <kay@vrfy.org>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    1635f6a7