diff mbox series

[13/15] ceph: Convert ceph_fill_inline_data() to take a folio

Message ID 20230825201225.348148-14-willy@infradead.org (mailing list archive)
State New, archived
Headers show
Series Many folio conversions for ceph | expand

Commit Message

Matthew Wilcox Aug. 25, 2023, 8:12 p.m. UTC
Its one caller now has a folio, so use the folio API within this
function.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ceph/addr.c  | 44 ++++++++++++++++++++------------------------
 fs/ceph/inode.c |  2 +-
 fs/ceph/super.h |  2 +-
 3 files changed, 22 insertions(+), 26 deletions(-)
diff mbox series

Patch

diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 09178a8ebbde..79d8f2fddd49 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1748,47 +1748,43 @@  static vm_fault_t ceph_page_mkwrite(struct vm_fault *vmf)
 	return ret;
 }
 
-void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
+void ceph_fill_inline_data(struct inode *inode, struct folio *locked_folio,
 			   char	*data, size_t len)
 {
 	struct address_space *mapping = inode->i_mapping;
-	struct page *page;
+	struct folio *folio;
 
-	if (locked_page) {
-		page = locked_page;
+	if (locked_folio) {
+		folio = locked_folio;
 	} else {
 		if (i_size_read(inode) == 0)
 			return;
-		page = find_or_create_page(mapping, 0,
-					   mapping_gfp_constraint(mapping,
-					   ~__GFP_FS));
-		if (!page)
+		folio = __filemap_get_folio(mapping, 0,
+				FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+				mapping_gfp_constraint(mapping, ~__GFP_FS));
+		if (IS_ERR(folio))
 			return;
-		if (PageUptodate(page)) {
-			unlock_page(page);
-			put_page(page);
+		if (folio_test_uptodate(folio)) {
+			folio_unlock(folio);
+			folio_put(folio);
 			return;
 		}
 	}
 
-	dout("fill_inline_data %p %llx.%llx len %zu locked_page %p\n",
-	     inode, ceph_vinop(inode), len, locked_page);
+	dout("fill_inline_data %p %llx.%llx len %zu locked_folio %lu\n",
+	     inode, ceph_vinop(inode), len, locked_folio->index);
 
-	if (len > 0) {
-		void *kaddr = kmap_atomic(page);
-		memcpy(kaddr, data, len);
-		kunmap_atomic(kaddr);
-	}
+	memcpy_to_folio(folio, 0, data, len);
 
-	if (page != locked_page) {
+	if (folio != locked_folio) {
 		if (len < PAGE_SIZE)
-			zero_user_segment(page, len, PAGE_SIZE);
+			folio_zero_segment(folio, len, PAGE_SIZE);
 		else
-			flush_dcache_page(page);
+			flush_dcache_folio(folio);
 
-		SetPageUptodate(page);
-		unlock_page(page);
-		put_page(page);
+		folio_mark_uptodate(folio);
+		folio_unlock(folio);
+		folio_put(folio);
 	}
 }
 
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index d5f0fe39b92f..70f7f68ba078 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -1277,7 +1277,7 @@  int ceph_fill_inode(struct inode *inode, struct folio *locked_folio,
 	ceph_fscache_register_inode_cookie(inode);
 
 	if (fill_inline)
-		ceph_fill_inline_data(inode, &locked_folio->page,
+		ceph_fill_inline_data(inode, locked_folio,
 				      iinfo->inline_data, iinfo->inline_len);
 
 	if (wake)
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index d741a9d15f52..a986928c3000 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1311,7 +1311,7 @@  extern ssize_t __ceph_sync_read(struct inode *inode, loff_t *ki_pos,
 				struct iov_iter *to, int *retry_op,
 				u64 *last_objver);
 extern int ceph_release(struct inode *inode, struct file *filp);
-extern void ceph_fill_inline_data(struct inode *inode, struct page *locked_page,
+void ceph_fill_inline_data(struct inode *inode, struct folio *locked_folio,
 				  char *data, size_t len);
 
 /* dir.c */