]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ceph: convert ceph_zero_partial_page() to use a folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 12 Jun 2025 14:34:40 +0000 (15:34 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:42:09 +0000 (22:42 -0700)
Retrieve a folio from the pagecache instead of a page and operate on it.
Removes several hidden calls to compound_head() along with calls to
deprecated functions like wait_on_page_writeback() and find_lock_page().

[dan.carpenter@linaro.org: fix NULL vs IS_ERR() bug in ceph_zero_partial_page()]
Link: https://lkml.kernel.org/r/685c1424.050a0220.baa8.d6a1@mx.google.com
Link: https://lkml.kernel.org/r/20250612143443.2848197-5-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Ilya Dryomov <idryomov@gmail.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Xiubo Li <xiubli@redhat.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Alex Markuze <amarkuze@redhat.com>
Cc: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ceph/file.c

index a7254cab44cc2e24186f5aa67169f11857e7b8de..f6e63265c516e9d1271e467bfe5d912a1919bd2b 100644 (file)
@@ -2530,19 +2530,19 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
        return generic_file_llseek(file, offset, whence);
 }
 
-static inline void ceph_zero_partial_page(
-       struct inode *inode, loff_t offset, unsigned size)
+static inline void ceph_zero_partial_page(struct inode *inode,
+               loff_t offset, size_t size)
 {
-       struct page *page;
-       pgoff_t index = offset >> PAGE_SHIFT;
+       struct folio *folio;
 
-       page = find_lock_page(inode->i_mapping, index);
-       if (page) {
-               wait_on_page_writeback(page);
-               zero_user(page, offset & (PAGE_SIZE - 1), size);
-               unlock_page(page);
-               put_page(page);
-       }
+       folio = filemap_lock_folio(inode->i_mapping, offset >> PAGE_SHIFT);
+       if (IS_ERR(folio))
+               return;
+
+       folio_wait_writeback(folio);
+       folio_zero_range(folio, offset_in_folio(folio, offset), size);
+       folio_unlock(folio);
+       folio_put(folio);
 }
 
 static void ceph_zero_pagecache_range(struct inode *inode, loff_t offset,