[This additional to the "cifs: Fix cifs_writepages_region()" patch that I posted] The inefficiency derived from filemap_get_folios_tag() get a batch of contiguous folios in Vishal's change to afs that got copied into cifs can be reduced by skipping over those folios that have been passed by the start position rather than going through the process of locking, checking and trying to write them. A similar change would need to be made in afs, in addition to fixing the bugs there. There's also a fix in cifs_write_back_from_locked_folio() where it doesn't return the amount of data dispatched to the server as ->async_writev() just returns 0 on success. Signed-off-by: David Howells <dhowells@xxxxxxxxxx> --- diff --git a/fs/cifs/file.c b/fs/cifs/file.c index ebfcaae8c437..bae1a9709e32 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2839,6 +2839,7 @@ static ssize_t cifs_write_back_from_locked_folio(struct address_space *mapping, free_xid(xid); if (rc == 0) { wbc->nr_to_write = count; + rc = len; } else if (is_retryable_error(rc)) { cifs_pages_write_redirty(inode, start, len); } else { @@ -2873,6 +2874,13 @@ static int cifs_writepages_region(struct address_space *mapping, for (int i = 0; i < nr; i++) { ssize_t ret; struct folio *folio = fbatch.folios[i]; + unsigned long long fstart; + + fstart = folio_pos(folio); /* May go backwards with THPs */ + if (fstart < start && + folio_size(folio) <= start - fstart) + continue; + start = fstart; redo_folio: start = folio_pos(folio); /* May regress with THPs */