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

Configure Feed

Select the types of activity you want to include in your feed.

fuse: remove fuse_readpages_end() null mapping check

Remove extra logic in fuse_readpages_end() that checks against null
folio mappings. This was added in commit ce534fb05292 ("fuse: allow
splice to move pages"):

"Since the remove_from_page_cache() + add_to_page_cache_locked()
are non-atomic it is possible that the page cache is repopulated in
between the two and add_to_page_cache_locked() will fail. This
could be fixed by creating a new atomic replace_page_cache_page()
function.

fuse_readpages_end() needed to be reworked so it works even if
page->mapping is NULL for some or all pages which can happen if the
add_to_page_cache_locked() failed."

Commit ef6a3c63112e ("mm: add replace_page_cache_page() function") added
atomic page cache replacement, which means the check against null
mappings can be removed.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

authored by

Joanne Koong and committed by
Miklos Szeredi
02d47e21 b3c7ab1d

+11 -13
+11 -13
fs/fuse/file.c
··· 865 865 struct fuse_args_pages *ap = &ia->ap; 866 866 size_t count = ia->read.in.size; 867 867 size_t num_read = args->out_args[0].size; 868 - struct address_space *mapping = NULL; 868 + struct address_space *mapping; 869 + struct inode *inode; 869 870 870 - for (i = 0; mapping == NULL && i < ap->num_folios; i++) 871 - mapping = ap->folios[i]->mapping; 871 + WARN_ON_ONCE(!ap->num_folios); 872 + mapping = ap->folios[0]->mapping; 873 + inode = mapping->host; 872 874 873 - if (mapping) { 874 - struct inode *inode = mapping->host; 875 + /* 876 + * Short read means EOF. If file size is larger, truncate it 877 + */ 878 + if (!err && num_read < count) 879 + fuse_short_read(inode, ia->read.attr_ver, num_read, ap); 875 880 876 - /* 877 - * Short read means EOF. If file size is larger, truncate it 878 - */ 879 - if (!err && num_read < count) 880 - fuse_short_read(inode, ia->read.attr_ver, num_read, ap); 881 - 882 - fuse_invalidate_atime(inode); 883 - } 881 + fuse_invalidate_atime(inode); 884 882 885 883 for (i = 0; i < ap->num_folios; i++) { 886 884 folio_end_read(ap->folios[i], !err);