summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVishal Moola (Oracle) <vishal.moola@gmail.com>2023-01-05 00:14:34 +0300
committerAndrew Morton <akpm@linux-foundation.org>2023-02-03 09:33:15 +0300
commit4cda80f3a7a53a0bc66cd9f16f7872524cfdd87d (patch)
treefcd3b6a8bfe269838601593ce0e0da88e316a1ed
parent590a2b5f0a9b740e415e0d52bd8a0f87fc15b87b (diff)
downloadlinux-4cda80f3a7a53a0bc66cd9f16f7872524cfdd87d.tar.xz
cifs: convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag()
This is in preparation for the removal of find_get_pages_range_tag(). Now also supports the use of large folios. Since tofind might be larger than the max number of folios in a folio_batch (15), we loop through filling in wdata->pages pulling more batches until we either reach tofind pages or run out of folios. This function may not return all pages in the last found folio before tofind pages are reached. Link: https://lkml.kernel.org/r/20230104211448.4804-10-vishal.moola@gmail.com Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com> Acked-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Cc: Tom Talpey <tom@talpey.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r--fs/cifs/file.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 22dfc1f8b4f1..8cdd2f67af24 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -2527,14 +2527,40 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping,
unsigned int *found_pages)
{
struct cifs_writedata *wdata;
-
+ struct folio_batch fbatch;
+ unsigned int i, idx, p, nr;
wdata = cifs_writedata_alloc((unsigned int)tofind,
cifs_writev_complete);
if (!wdata)
return NULL;
- *found_pages = find_get_pages_range_tag(mapping, index, end,
- PAGECACHE_TAG_DIRTY, tofind, wdata->pages);
+ folio_batch_init(&fbatch);
+ *found_pages = 0;
+
+again:
+ nr = filemap_get_folios_tag(mapping, index, end,
+ PAGECACHE_TAG_DIRTY, &fbatch);
+ if (!nr)
+ goto out; /* No dirty pages left in the range */
+
+ for (i = 0; i < nr; i++) {
+ struct folio *folio = fbatch.folios[i];
+
+ idx = 0;
+ p = folio_nr_pages(folio);
+add_more:
+ wdata->pages[*found_pages] = folio_page(folio, idx);
+ folio_get(folio);
+ if (++*found_pages == tofind) {
+ folio_batch_release(&fbatch);
+ goto out;
+ }
+ if (++idx < p)
+ goto add_more;
+ }
+ folio_batch_release(&fbatch);
+ goto again;
+out:
return wdata;
}