ufs: convert ufs_change_blocknr() to use folios
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Mon, 16 Oct 2023 20:11:12 +0000 (21:11 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 25 Oct 2023 23:47:09 +0000 (16:47 -0700)
Convert the locked_page argument to a folio, then use folios throughout.
Saves three hidden calls to compound_head().

Link: https://lkml.kernel.org/r/20231016201114.1928083-26-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Cc: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/ufs/balloc.c

index 2436e3f82147fd4ede1a6b24c845133cc63c0d5e..53c11be2b2c149292209f71e642c56c6fdcbec6d 100644 (file)
@@ -240,6 +240,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
                               unsigned int count, sector_t oldb,
                               sector_t newb, struct page *locked_page)
 {
+       struct folio *folio, *locked_folio = page_folio(locked_page);
        const unsigned blks_per_page =
                1 << (PAGE_SHIFT - inode->i_blkbits);
        const unsigned mask = blks_per_page - 1;
@@ -247,42 +248,39 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
        pgoff_t index, cur_index, last_index;
        unsigned pos, j, lblock;
        sector_t end, i;
-       struct page *page;
        struct buffer_head *head, *bh;
 
        UFSD("ENTER, ino %lu, count %u, oldb %llu, newb %llu\n",
              inode->i_ino, count,
             (unsigned long long)oldb, (unsigned long long)newb);
 
-       BUG_ON(!locked_page);
-       BUG_ON(!PageLocked(locked_page));
+       BUG_ON(!folio_test_locked(locked_folio));
 
-       cur_index = locked_page->index;
+       cur_index = locked_folio->index;
        end = count + beg;
        last_index = end >> (PAGE_SHIFT - inode->i_blkbits);
        for (i = beg; i < end; i = (i | mask) + 1) {
                index = i >> (PAGE_SHIFT - inode->i_blkbits);
 
                if (likely(cur_index != index)) {
-                       page = ufs_get_locked_page(mapping, index);
-                       if (!page)/* it was truncated */
+                       folio = ufs_get_locked_folio(mapping, index);
+                       if (!folio) /* it was truncated */
                                continue;
-                       if (IS_ERR(page)) {/* or EIO */
+                       if (IS_ERR(folio)) {/* or EIO */
                                ufs_error(inode->i_sb, __func__,
                                          "read of page %llu failed\n",
                                          (unsigned long long)index);
                                continue;
                        }
                } else
-                       page = locked_page;
+                       folio = locked_folio;
 
-               head = page_buffers(page);
+               head = folio_buffers(folio);
                bh = head;
                pos = i & mask;
                for (j = 0; j < pos; ++j)
                        bh = bh->b_this_page;
 
-
                if (unlikely(index == last_index))
                        lblock = end & mask;
                else
@@ -313,7 +311,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
                } while (bh != head);
 
                if (likely(cur_index != index))
-                       ufs_put_locked_page(page);
+                       ufs_put_locked_folio(folio);
        }
        UFSD("EXIT\n");
 }