Skip to content

Commit f9a49aa

Browse files
joannekoongakpm00
authored andcommitted
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: 0c58a97 ("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>
1 parent be31340 commit f9a49aa

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

fs/fs-writeback.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2750,8 +2750,13 @@ static void wait_sb_inodes(struct super_block *sb)
27502750
* The mapping can appear untagged while still on-list since we
27512751
* do not have the mapping lock. Skip it here, wb completion
27522752
* 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.
27532757
*/
2754-
if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK))
2758+
if (!mapping_tagged(mapping, PAGECACHE_TAG_WRITEBACK) ||
2759+
mapping_no_data_integrity(mapping))
27552760
continue;
27562761

27572762
spin_unlock_irq(&sb->s_inode_wblist_lock);

fs/fuse/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3200,8 +3200,10 @@ void fuse_init_file_inode(struct inode *inode, unsigned int flags)
32003200

32013201
inode->i_fop = &fuse_file_operations;
32023202
inode->i_data.a_ops = &fuse_file_aops;
3203-
if (fc->writeback_cache)
3203+
if (fc->writeback_cache) {
32043204
mapping_set_writeback_may_deadlock_on_reclaim(&inode->i_data);
3205+
mapping_set_no_data_integrity(&inode->i_data);
3206+
}
32053207

32063208
INIT_LIST_HEAD(&fi->write_files);
32073209
INIT_LIST_HEAD(&fi->queued_writes);

include/linux/pagemap.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ enum mapping_flags {
210210
AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM = 9,
211211
AS_KERNEL_FILE = 10, /* mapping for a fake kernel file that shouldn't
212212
account usage to user cgroups */
213+
AS_NO_DATA_INTEGRITY = 11, /* no data integrity guarantees */
213214
/* Bits 16-25 are used for FOLIO_ORDER */
214215
AS_FOLIO_ORDER_BITS = 5,
215216
AS_FOLIO_ORDER_MIN = 16,
@@ -345,6 +346,16 @@ static inline bool mapping_writeback_may_deadlock_on_reclaim(const struct addres
345346
return test_bit(AS_WRITEBACK_MAY_DEADLOCK_ON_RECLAIM, &mapping->flags);
346347
}
347348

349+
static inline void mapping_set_no_data_integrity(struct address_space *mapping)
350+
{
351+
set_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);
352+
}
353+
354+
static inline bool mapping_no_data_integrity(const struct address_space *mapping)
355+
{
356+
return test_bit(AS_NO_DATA_INTEGRITY, &mapping->flags);
357+
}
358+
348359
static inline gfp_t mapping_gfp_mask(const struct address_space *mapping)
349360
{
350361
return mapping->gfp_mask;

0 commit comments

Comments
 (0)