Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Link: https://lkml.kernel.org/r/20260105211737.4105620-2-joannelkoong@gmail.com
Fixes: 0c58a97f919c ("fuse: remove tmp folio for writebacks and internal rb tree")
Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Reported-by: Athul Krishna <athul.krishna.kr@protonmail.com>
Reported-by: J. Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Bernd Schubert <bschubert@ddn.com>
Tested-by: J. Neuschäfer <j.neuschaefer@gmx.net>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Bernd Schubert <bschubert@ddn.com>
Cc: Bonaccorso Salvatore <carnil@debian.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: "Liam R. Howlett" <Liam.Howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Joanne Koong and committed by
Andrew Morton
f9a49aa3 be31340a

+20 -2
+6 -1
fs/fs-writeback.c
··· 2750 2750 * The mapping can appear untagged while still on-list since we 2751 2751 * do not have the mapping lock. Skip it here, wb completion 2752 2752 * will remove it. 2753 + * 2754 + * If the mapping does not have data integrity semantics, 2755 + * there's no need to wait for the writeout to complete, as the 2756 + * mapping cannot guarantee that data is persistently stored. 2753 2757 */ 2754 - if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK)) 2758 + if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) || 2759 + mapping_no_data_integrity(mapping)) 2755 2760 continue; 2756 2761 2757 2762 spin_unlock_irq(&sb->s_inode_wblist_lock);
+3 -1
fs/fuse/file.c
··· 3200 3200 3201 3201 inode->i_fop = &fuse_file_operations; 3202 3202 inode->i_data.a_ops = &fuse_file_aops; 3203 - if (fc->writeback_cache) 3203 + if (fc->writeback_cache) { 3204 3204 mapping_set_writeback_may_deadlock_on_reclaim(&inode->i_data); 3205 + mapping_set_no_data_integrity(&inode->i_data); 3206 + } 3205 3207 3206 3208 INIT_LIST_HEAD(&fi->write_files); 3207 3209 INIT_LIST_HEAD(&fi->queued_writes);
+11
include/linux/pagemap.h
··· 210 210 AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9, 211 211 AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't 212 212 account usage to user cgroups */ 213 + AS_NO_DATA_INTEGRITY = 11, /* no data integrity guarantees */ 213 214 /* Bits 16-25 are used for FOLIO_ORDER */ 214 215 AS_FOLIO_ORDER_BITS = 5, 215 216 AS_FOLIO_ORDER_MIN = 16, ··· 344 343 static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct address_space *mapping) 345 344 { 346 345 return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags); 346 + } 347 + 348 + static inline void mapping_set_no_data_integrity(struct address_space *mapping) 349 + { 350 + set_bit(AS_NO_DATA_INTEGRITY, &mapping->flags); 351 + } 352 + 353 + static inline bool mapping_no_data_integrity(const struct address_space *mapping) 354 + { 355 + return test_bit(AS_NO_DATA_INTEGRITY, &mapping->flags); 347 356 } 348 357 349 358 static inline gfp_t mapping_gfp_mask(const struct address_space *mapping)