fs/writeback: skip AS_NO_DATA_INTEGRITY mappings in wait_sb_inodes()
Subsystems (5)
v3 cover fs/writeback: skip AS_NO_DATA_INTEGRITY mappings in wait_sb_inodes()
This patch adds a new mapping flag AS_NO_DATA_INTEGRITY which signifies that a mapping does not have data integrity guarantees, and skips waiting on writeout for these mappings in wait_sb_inodes(), as these mappings cannot guarantee that data is persistently stored. This patch sets this flag on fuse mappings.
This fixes the userspace regression reported by Athul and J. upstream in [1][2] where if there is a bug in a fuse server that causes the server to never complete writeback, it will make wait_sb_inodes() wait forever.
Thanks,
Joanne
[1] https://lore.kernel.org/regressions/CAJnrk1ZjQ8W8NzojsvJPRXiv9TuYPNdj8Ye7=Cgkj=iV_i8EaA@mail.gmail.com/T/#t
[2] https://lore.kernel.org/linux-fsdevel/[email protected]/
Changelog:
v2: https://lore.kernel.org/linux-fsdevel/[email protected]/
* Add comments to commit message (David) and to wait_sb_inodes() (Andrew)
* Add Bernd's Reviewed-by and J's Tested-by
v1: https://lore.kernel.org/linux-mm/[email protected]/
* Change AS_WRITEBACK_MAY_HANG to AS_NO_DATA_INTEGRITY and keep AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM as is.
Joanne Koong (1):
fs/writeback: skip AS_NO_DATA_INTEGRITY mappings in wait_sb_inodes()
fs/fs-writeback.c | 7 ++++++- fs/fuse/file.c | 4 +++- include/linux/pagemap.h | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-)
Signature · 1 line
2.47.3
PATCH v3 1/1 fs/writeback: skip AS_NO_DATA_INTEGRITY mappings in wait_sb_inodes()
Above the while() loop in wait_sb_inodes(), we document that we must wait for all pages under writeback for data integrity. Consequently, if a mapping, like fuse, traditionally does not have data integrity semantics, there is no need to wait at all; we can simply skip these inodes.
This restores fuse back to prior behavior where syncs are no-ops. This fixes a user regression where if a system is running a faulty fuse server that does not reply to issued write requests, this causes wait_sb_inodes() to wait forever.
--- fs/fs-writeback.c | 7 ++++++- fs/fuse/file.c | 4 +++- include/linux/pagemap.h | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-)
fs/fs-writeback.c +6 -1
@@ -2750,8 +2750,13 @@ static void wait_sb_inodes(struct super_block *sb)* The mapping can appear untagged while still on-list since we * do not have the mapping lock. Skip it here, wb completion * will remove it. +* +* If the mapping does not have data integrity semantics, +* there's no need to wait for the writeout to complete, as the +* mapping cannot guarantee that data is persistently stored. */ -if (!mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK )) +if (!mapping_tagged (mapping,PAGECACHE_TAG_WRITEBACK ) || +mapping_no_data_integrity (mapping))continue ;spin_unlock_irq (&sb->s_inode_wblist_lock);
fs/fuse/file.c +3 -1
@@ -3200,8 +3200,10 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags) inode->i_fop = &fuse_file_operations; inode->i_data.a_ops = &fuse_file_aops; -if (fc->writeback_cache) +if (fc->writeback_cache) {mapping_set_writeback_may_deadlock_on_reclaim (&inode->i_data); +mapping_set_no_data_integrity (&inode->i_data); + }INIT_LIST_HEAD (&fi->write_files);INIT_LIST_HEAD (&fi->queued_writes);
include/linux/pagemap.h +11 -0
@@ -210,6 +210,7 @@ enum mapping_flags {AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM =9 ,AS_KERNEL_FILE =10 ,/* mapping for a fake kernel file that shouldn't account usage to user cgroups */ +AS_NO_DATA_INTEGRITY =11 ,/* no data integrity guarantees */ /* Bits 16-25 are used for FOLIO_ORDER */ AS_FOLIO_ORDER_BITS =5 , AS_FOLIO_ORDER_MIN = 16,
@@ -345,6 +346,16 @@ static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct addresreturn test_bit (AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM , &mapping->flags); } +static inline void mapping_set_no_data_integrity (struct address_space *mapping) +{ +set_bit (AS_NO_DATA_INTEGRITY , &mapping->flags); +} + +static inline bool mapping_no_data_integrity (const struct address_space *mapping) +{ +return test_bit (AS_NO_DATA_INTEGRITY , &mapping->flags); +} +static inline gfp_t mapping_gfp_mask (const struct address_space *mapping) {return mapping->gfp_mask;
Signature · 1 line
2.47.3
Andrew Morton
maintainerQuoted 11 lines · On Mon, 5 Jan 2026 13:17:27 -0800 Joanne Koong <[email protected]> wrote:
Above the
while()loop inwait_sb_inodes(), we document that we must wait for all pages under writeback for data integrity. Consequently, if a mapping, like fuse, traditionally does not have data integrity semantics, there is no need to wait at all; we can simply skip these inodes.This restores fuse back to prior behavior where syncs are no-ops. This fixes a user regression where if a system is running a faulty fuse server that does not reply to issued write requests, this causes
wait_sb_inodes()to wait forever.
Quoted 7 lines
Fixes 0c58a97f919c ("fuse: remove tmp folio for writebacks and internal rb tree")Reported-by Athul Krishna <[email protected]>Reported-by J. Neuschäfer <[email protected]>Signed-off-by Joanne Koong <[email protected]>Reviewed-by Bernd Schubert <[email protected]>Tested-by J. Neuschäfer <[email protected]>
Thanks.
Quoted 4 lines
fs/fs-writeback.c | 7 ++++++- fs/fuse/file.c | 4 +++- include/linux/pagemap.h | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-)
I'll queue this in mm.git's mm-hotfixes branches for a 6.19-rcX merge.