linux/fs/nilfs2
Ryusuke Konishi 6309b8ce98 nilfs2: fix buffer head leaks in calls to truncate_inode_pages()
When block_invalidatepage was converted to block_invalidate_folio, the
fallback to block_invalidatepage in folio_invalidate() if the
address_space_operations method invalidatepage (currently
invalidate_folio) was not set, was removed.

Unfortunately, some pseudo-inodes in nilfs2 use empty_aops set by
inode_init_always_gfp() as is, or explicitly set it to
address_space_operations.  Therefore, with this change,
block_invalidatepage() is no longer called from folio_invalidate(), and as
a result, the buffer_head structures attached to these pages/folios are no
longer freed via try_to_free_buffers().

Thus, these buffer heads are now leaked by truncate_inode_pages(), which
cleans up the page cache from inode evict(), etc.

Three types of caches use empty_aops: gc inode caches and the DAT shadow
inode used by GC, and b-tree node caches.  Of these, b-tree node caches
explicitly call invalidate_mapping_pages() during cleanup, which involves
calling try_to_free_buffers(), so the leak was not visible during normal
operation but worsened when GC was performed.

Fix this issue by using address_space_operations with invalidate_folio set
to block_invalidate_folio instead of empty_aops, which will ensure the
same behavior as before.

Link: https://lkml.kernel.org/r/20241212164556.21338-1-konishi.ryusuke@gmail.com
Fixes: 7ba13abbd3 ("fs: Turn block_invalidatepage into block_invalidate_folio")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>	[5.18+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-12-18 19:04:45 -08:00
..
alloc.c nilfs2: remove nilfs_palloc_block_get_entry() 2024-11-05 17:12:39 -08:00
alloc.h nilfs2: remove nilfs_palloc_block_get_entry() 2024-11-05 17:12:39 -08:00
bmap.c
bmap.h
btnode.c nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-18 19:04:45 -08:00
btnode.h
btree.c
btree.h
cpfile.c nilfs2: convert checkpoint file to be folio-based 2024-11-05 17:12:39 -08:00
cpfile.h
dat.c nilfs2: convert DAT file to be folio-based 2024-11-05 17:12:38 -08:00
dat.h
dir.c nilfs2: fix potential out-of-bounds memory access in nilfs_find_entry() 2024-12-05 19:54:43 -08:00
direct.c
direct.h
export.h
file.c
gcinode.c nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-18 19:04:45 -08:00
ifile.c nilfs2: convert inode file to be folio-based 2024-11-05 17:12:38 -08:00
ifile.h nilfs2: convert inode file to be folio-based 2024-11-05 17:12:38 -08:00
inode.c nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-18 19:04:45 -08:00
ioctl.c
Kconfig
Makefile
mdt.c - The series "resource: A couple of cleanups" from Andy Shevchenko 2024-11-25 16:09:48 -08:00
mdt.h
namei.c nilfs2: prevent use of deleted inode 2024-12-18 19:04:44 -08:00
nilfs.h nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-18 19:04:45 -08:00
page.c - The series "resource: A couple of cleanups" from Andy Shevchenko 2024-11-25 16:09:48 -08:00
page.h nilfs2: convert nilfs_page_count_clean_buffers() to take a folio 2024-11-05 17:12:39 -08:00
recovery.c nilfs2: convert nilfs_recovery_copy_block() to take a folio 2024-11-05 17:12:40 -08:00
segbuf.c nilfs2: convert segment buffer to be folio-based 2024-11-05 17:12:37 -08:00
segbuf.h
segment.c
segment.h
sufile.c nilfs2: convert segment usage file to be folio-based 2024-11-05 17:12:38 -08:00
sufile.h
super.c
sysfs.c
sysfs.h
the_nilfs.c
the_nilfs.h