gfs2: Convert stuffed_readpage to folios
authorAndreas Gruenbacher <agruenba@redhat.com>
Fri, 21 Jul 2023 21:58:04 +0000 (23:58 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 6 Nov 2023 00:51:25 +0000 (01:51 +0100)
Change stuffed_readpage() to take a folio instead of a page.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/aops.c

index 494484427ee303ec94737770f16d01c532d3d295..98bc02f890d167eebc2ad5de2f4ab6bf13f90b92 100644 (file)
@@ -403,27 +403,27 @@ static int gfs2_jdata_writepages(struct address_space *mapping,
 }
 
 /**
- * stuffed_readpage - Fill in a Linux page with stuffed file data
+ * stuffed_readpage - Fill in a Linux folio with stuffed file data
  * @ip: the inode
- * @page: the page
+ * @folio: the folio
  *
  * Returns: errno
  */
-static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
+static int stuffed_readpage(struct gfs2_inode *ip, struct folio *folio)
 {
        struct buffer_head *dibh;
-       u64 dsize = i_size_read(&ip->i_inode);
-       void *kaddr;
+       size_t i_size = i_size_read(&ip->i_inode);
+       void *data;
        int error;
 
        /*
         * Due to the order of unstuffing files and ->fault(), we can be
-        * asked for a zero page in the case of a stuffed file being extended,
+        * asked for a zero folio in the case of a stuffed file being extended,
         * so we need to supply one here. It doesn't happen often.
         */
-       if (unlikely(page->index)) {
-               zero_user(page, 0, PAGE_SIZE);
-               SetPageUptodate(page);
+       if (unlikely(folio->index)) {
+               folio_zero_range(folio, 0, folio_size(folio));
+               folio_mark_uptodate(folio);
                return 0;
        }
 
@@ -431,13 +431,11 @@ static int stuffed_readpage(struct gfs2_inode *ip, struct page *page)
        if (error)
                return error;
 
-       kaddr = kmap_local_page(page);
-       memcpy(kaddr, dibh->b_data + sizeof(struct gfs2_dinode), dsize);
-       memset(kaddr + dsize, 0, PAGE_SIZE - dsize);
-       kunmap_local(kaddr);
-       flush_dcache_page(page);
+       data = dibh->b_data + sizeof(struct gfs2_dinode);
+       memcpy_to_folio(folio, 0, data, i_size);
+       folio_zero_range(folio, i_size, folio_size(folio) - i_size);
        brelse(dibh);
-       SetPageUptodate(page);
+       folio_mark_uptodate(folio);
 
        return 0;
 }
@@ -458,7 +456,7 @@ static int gfs2_read_folio(struct file *file, struct folio *folio)
            (i_blocksize(inode) == PAGE_SIZE && !folio_buffers(folio))) {
                error = iomap_read_folio(folio, &gfs2_iomap_ops);
        } else if (gfs2_is_stuffed(ip)) {
-               error = stuffed_readpage(ip, &folio->page);
+               error = stuffed_readpage(ip, folio);
                folio_unlock(folio);
        } else {
                error = mpage_read_folio(folio, gfs2_block_map);