diff mbox series

[07/13] fuse: convert writes (non-writeback) to use folios

Message ID 20241002165253.3872513-8-joannelkoong@gmail.com (mailing list archive)
State New
Headers show
Series fuse: use folios instead of pages for requests | expand

Commit Message

Joanne Koong Oct. 2, 2024, 4:52 p.m. UTC
Convert non-writeback write requests to use folios instead of pages.

No functional changes.

Signed-off-by: Joanne Koong <joannelkoong@gmail.com>
---
 fs/fuse/file.c   | 49 ++++++++++++++++++++++++------------------------
 fs/fuse/fuse_i.h |  2 +-
 2 files changed, 26 insertions(+), 25 deletions(-)
diff mbox series

Patch

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index ad419fafbd5d..0f01b4fa324c 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1190,8 +1190,8 @@  static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
 	bool short_write;
 	int err;
 
-	for (i = 0; i < ap->num_pages; i++)
-		fuse_wait_on_page_writeback(inode, ap->pages[i]->index);
+	for (i = 0; i < ap->num_folios; i++)
+		fuse_wait_on_folio_writeback(inode, ap->folios[i]);
 
 	fuse_write_args_fill(ia, ff, pos, count);
 	ia->write.in.flags = fuse_write_flags(iocb);
@@ -1203,10 +1203,10 @@  static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
 		err = -EIO;
 
 	short_write = ia->write.out.size < count;
-	offset = ap->descs[0].offset;
+	offset = ap->folio_descs[0].offset;
 	count = ia->write.out.size;
-	for (i = 0; i < ap->num_pages; i++) {
-		struct folio *folio = page_folio(ap->pages[i]);
+	for (i = 0; i < ap->num_folios; i++) {
+		struct folio *folio = ap->folios[i];
 
 		if (err) {
 			folio_clear_uptodate(folio);
@@ -1220,7 +1220,7 @@  static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
 			}
 			offset = 0;
 		}
-		if (ia->write.page_locked && (i == ap->num_pages - 1))
+		if (ia->write.folio_locked && (i == ap->num_folios - 1))
 			folio_unlock(folio);
 		folio_put(folio);
 	}
@@ -1228,10 +1228,10 @@  static ssize_t fuse_send_write_pages(struct fuse_io_args *ia,
 	return err;
 }
 
-static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
-				     struct address_space *mapping,
-				     struct iov_iter *ii, loff_t pos,
-				     unsigned int max_pages)
+static ssize_t fuse_fill_write_folios(struct fuse_io_args *ia,
+				      struct address_space *mapping,
+				      struct iov_iter *ii, loff_t pos,
+				      unsigned int max_folios)
 {
 	struct fuse_args_pages *ap = &ia->ap;
 	struct fuse_conn *fc = get_fuse_conn(mapping->host);
@@ -1240,7 +1240,7 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 	int err;
 
 	ap->args.in_pages = true;
-	ap->descs[0].offset = offset;
+	ap->folio_descs[0].offset = offset;
 
 	do {
 		size_t tmp;
@@ -1276,9 +1276,9 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 		}
 
 		err = 0;
-		ap->pages[ap->num_pages] = &folio->page;
-		ap->descs[ap->num_pages].length = tmp;
-		ap->num_pages++;
+		ap->folios[ap->num_folios] = folio;
+		ap->folio_descs[ap->num_folios].length = tmp;
+		ap->num_folios++;
 
 		count += tmp;
 		pos += tmp;
@@ -1293,19 +1293,19 @@  static ssize_t fuse_fill_write_pages(struct fuse_io_args *ia,
 		if (folio_test_uptodate(folio)) {
 			folio_unlock(folio);
 		} else {
-			ia->write.page_locked = true;
+			ia->write.folio_locked = true;
 			break;
 		}
 		if (!fc->big_writes)
 			break;
 	} while (iov_iter_count(ii) && count < fc->max_write &&
-		 ap->num_pages < max_pages && offset == 0);
+		 ap->num_folios < max_folios && offset == 0);
 
 	return count > 0 ? count : err;
 }
 
-static inline unsigned int fuse_wr_pages(loff_t pos, size_t len,
-				     unsigned int max_pages)
+static inline unsigned int fuse_wr_folios(loff_t pos, size_t len,
+					  unsigned int max_pages)
 {
 	return min_t(unsigned int,
 		     ((pos + len - 1) >> PAGE_SHIFT) -
@@ -1330,16 +1330,17 @@  static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii)
 		ssize_t count;
 		struct fuse_io_args ia = {};
 		struct fuse_args_pages *ap = &ia.ap;
-		unsigned int nr_pages = fuse_wr_pages(pos, iov_iter_count(ii),
-						      fc->max_pages);
+		unsigned int nr_folios = fuse_wr_folios(pos, iov_iter_count(ii),
+							fc->max_pages);
 
-		ap->pages = fuse_pages_alloc(nr_pages, GFP_KERNEL, &ap->descs);
-		if (!ap->pages) {
+		ap->uses_folios = true;
+		ap->folios = fuse_folios_alloc(nr_folios, GFP_KERNEL, &ap->folio_descs);
+		if (!ap->folios) {
 			err = -ENOMEM;
 			break;
 		}
 
-		count = fuse_fill_write_pages(&ia, mapping, ii, pos, nr_pages);
+		count = fuse_fill_write_folios(&ia, mapping, ii, pos, nr_folios);
 		if (count <= 0) {
 			err = count;
 		} else {
@@ -1356,7 +1357,7 @@  static ssize_t fuse_perform_write(struct kiocb *iocb, struct iov_iter *ii)
 					err = -EIO;
 			}
 		}
-		kfree(ap->pages);
+		kfree(ap->folios);
 	} while (!err && iov_iter_count(ii));
 
 	fuse_write_update_attr(inode, pos, res);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 2533313502de..52492c9bb264 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1090,7 +1090,7 @@  struct fuse_io_args {
 		struct {
 			struct fuse_write_in in;
 			struct fuse_write_out out;
-			bool page_locked;
+			bool folio_locked;
 		} write;
 	};
 	struct fuse_args_pages ap;