Re: [RFC PATCH] mm/filemap: make release_folio mandatory and add block_release_folio

From: Matthew Wilcox

Date: Mon Dec 22 2025 - 10:13:29 EST


On Mon, Dec 22, 2025 at 01:38:51PM +0100, Jan Kara wrote:
> > Filesystems updated: adfs, affs, bfs, exfat, ext2, fat, hpfs, isofs,
> > jfs, minix, nilfs2, ntfs3, omfs, udf, ufs, plus block/fops.c
>
> I think affs_aops_ofs need .release_folio as well...
>
> Also befs_aops, ecryptfs_aops, efs_aops, vxfs_aops, hfs_aops, hfsplus_aops,
> nilfs_buffer_cache_aops, qnx4_aops, qnx6_aops definitely need .release_folio. ntfs_aops_cmpr
> might need it as well - not sure.

If we were using a real programming language, we'd have a class for
BH-based filesystems, inherit from it and override each method. But since
we aren't, let's see what we can do in C ...

#define BH_DEFAULT_AOPS \
.dirty_folio = block_dirty_folio, \
.invalidate_folio = block_invalidate_folio, \
.migrate_folio = buffer_migrate_folio, \
.is_partially_uptodate = block_is_partially_uptodate, \
.error_remove_folio = generic_error_remove_folio,

As I understand C, later initialisers override earlier ones [1].

GCC does have an optional warning (-Woverride-init) which is included in
-W but not -Wall. Some parts of the kernel explicitly turn this off, either
like this:

arch/arm64/kvm/Makefile:CFLAGS_sys_regs.o += -Wno-override-init

or like this:

drivers/gpu/drm/i915/display/intel_display_device.c:__diag_ignore_all("-Woverride-init", "Allow field initialization overrides for display info");

I'd be happy to do either of those for filesystems.


[1] Test program:

struct ops { void (*frob)(void); };

static void my_frob(void) { return; }
void generic_frob(void);

struct ops my_ops = {
.frob = generic_frob,
.frob = my_frob,
};

int main(void)
{
return 0;
}

$ gcc -Wall -o test2 test2.c

links without any missing symbols