mm: return an ERR_PTR from __filemap_get_folio
Instead of returning NULL for all errors, distinguish between: - no entry found and not asked to allocated (-ENOENT) - failed to allocate memory (-ENOMEM) - would block (-EAGAIN) so that callers don't have to guess the error based on the passed in flags. Also pass through the error through the direct callers: filemap_get_folio, filemap_lock_folio filemap_grab_folio and filemap_get_incore_folio. [hch@lst.de: fix null-pointer deref] Link: https://lkml.kernel.org/r/20230310070023.GA13563@lst.de Link: https://lkml.kernel.org/r/20230310043137.GA1624890@u2004 Link: https://lkml.kernel.org/r/20230307143410.28031-8-hch@lst.de Signed-off-by:Christoph Hellwig <hch@lst.de> Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com> [nilfs2] Cc: Andreas Gruenbacher <agruenba@redhat.com> Cc: Hugh Dickins <hughd@google.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev> Signed-off-by:
Andrew Morton <akpm@linux-foundation.org>
Showing
- fs/afs/dir.c 5 additions, 5 deletionsfs/afs/dir.c
- fs/afs/dir_edit.c 1 addition, 1 deletionfs/afs/dir_edit.c
- fs/afs/write.c 2 additions, 2 deletionsfs/afs/write.c
- fs/ext4/inode.c 1 addition, 1 deletionfs/ext4/inode.c
- fs/ext4/move_extent.c 4 additions, 4 deletionsfs/ext4/move_extent.c
- fs/hugetlbfs/inode.c 1 addition, 1 deletionfs/hugetlbfs/inode.c
- fs/iomap/buffered-io.c 2 additions, 9 deletionsfs/iomap/buffered-io.c
- fs/netfs/buffered_read.c 2 additions, 2 deletionsfs/netfs/buffered_read.c
- fs/nfs/file.c 2 additions, 2 deletionsfs/nfs/file.c
- fs/nilfs2/page.c 3 additions, 3 deletionsfs/nilfs2/page.c
- include/linux/pagemap.h 6 additions, 5 deletionsinclude/linux/pagemap.h
- mm/filemap.c 8 additions, 6 deletionsmm/filemap.c
- mm/folio-compat.c 1 addition, 1 deletionmm/folio-compat.c
- mm/huge_memory.c 1 addition, 1 deletionmm/huge_memory.c
- mm/hugetlb.c 4 additions, 2 deletionsmm/hugetlb.c
- mm/memcontrol.c 1 addition, 1 deletionmm/memcontrol.c
- mm/mincore.c 1 addition, 1 deletionmm/mincore.c
- mm/shmem.c 2 additions, 2 deletionsmm/shmem.c
- mm/swap_state.c 10 additions, 7 deletionsmm/swap_state.c
- mm/swapfile.c 2 additions, 2 deletionsmm/swapfile.c
Please register or sign in to comment