On Sat, Feb 04, 2023 at 02:58:38PM +0000, Shiyang Ruan wrote: > + if (mf_flags & MF_MEM_PRE_REMOVE) { > + xfs_info(mp, "device is about to be removed!"); > + down_write(&mp->m_super->s_umount); > + error = sync_filesystem(mp->m_super); > + /* invalidate_inode_pages2() invalidates dax mapping */ > + super_drop_pagecache(mp->m_super, invalidate_inode_pages2); OK, there's a better way to handle all of this. First, an essentially untyped interface with a void * argument is bad. Second, we can do all this with invalidate_inode_pages2_range() and invalidate_mapping_pages() without introducing a new function. Here's the proposal: void super_drop_pagecache(struct super_block *sb, int (*invalidate)(struct address_space *, pgoff_t start, pgoff_t end)) In fs/drop-caches.c: static void drop_pagecache_sb(struct super_block *sb, void *unused) { super_drop_pagecache(sb, invalidate_mapping_pages); } In XFS: super_drop_pagecache(mp->m_super, invalidate_inode_pages2_range); Much smaller change ...