ufs: convert ufs_change_blocknr() to use folios
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>
This commit is contained in:
parent
e7ca7f1725
commit
c7e8812ce5
|
@ -240,6 +240,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
|
||||||
unsigned int count, sector_t oldb,
|
unsigned int count, sector_t oldb,
|
||||||
sector_t newb, struct page *locked_page)
|
sector_t newb, struct page *locked_page)
|
||||||
{
|
{
|
||||||
|
struct folio *folio, *locked_folio = page_folio(locked_page);
|
||||||
const unsigned blks_per_page =
|
const unsigned blks_per_page =
|
||||||
1 << (PAGE_SHIFT - inode->i_blkbits);
|
1 << (PAGE_SHIFT - inode->i_blkbits);
|
||||||
const unsigned mask = blks_per_page - 1;
|
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;
|
pgoff_t index, cur_index, last_index;
|
||||||
unsigned pos, j, lblock;
|
unsigned pos, j, lblock;
|
||||||
sector_t end, i;
|
sector_t end, i;
|
||||||
struct page *page;
|
|
||||||
struct buffer_head *head, *bh;
|
struct buffer_head *head, *bh;
|
||||||
|
|
||||||
UFSD("ENTER, ino %lu, count %u, oldb %llu, newb %llu\n",
|
UFSD("ENTER, ino %lu, count %u, oldb %llu, newb %llu\n",
|
||||||
inode->i_ino, count,
|
inode->i_ino, count,
|
||||||
(unsigned long long)oldb, (unsigned long long)newb);
|
(unsigned long long)oldb, (unsigned long long)newb);
|
||||||
|
|
||||||
BUG_ON(!locked_page);
|
BUG_ON(!folio_test_locked(locked_folio));
|
||||||
BUG_ON(!PageLocked(locked_page));
|
|
||||||
|
|
||||||
cur_index = locked_page->index;
|
cur_index = locked_folio->index;
|
||||||
end = count + beg;
|
end = count + beg;
|
||||||
last_index = end >> (PAGE_SHIFT - inode->i_blkbits);
|
last_index = end >> (PAGE_SHIFT - inode->i_blkbits);
|
||||||
for (i = beg; i < end; i = (i | mask) + 1) {
|
for (i = beg; i < end; i = (i | mask) + 1) {
|
||||||
index = i >> (PAGE_SHIFT - inode->i_blkbits);
|
index = i >> (PAGE_SHIFT - inode->i_blkbits);
|
||||||
|
|
||||||
if (likely(cur_index != index)) {
|
if (likely(cur_index != index)) {
|
||||||
page = ufs_get_locked_page(mapping, index);
|
folio = ufs_get_locked_folio(mapping, index);
|
||||||
if (!page)/* it was truncated */
|
if (!folio) /* it was truncated */
|
||||||
continue;
|
continue;
|
||||||
if (IS_ERR(page)) {/* or EIO */
|
if (IS_ERR(folio)) {/* or EIO */
|
||||||
ufs_error(inode->i_sb, __func__,
|
ufs_error(inode->i_sb, __func__,
|
||||||
"read of page %llu failed\n",
|
"read of page %llu failed\n",
|
||||||
(unsigned long long)index);
|
(unsigned long long)index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
page = locked_page;
|
folio = locked_folio;
|
||||||
|
|
||||||
head = page_buffers(page);
|
head = folio_buffers(folio);
|
||||||
bh = head;
|
bh = head;
|
||||||
pos = i & mask;
|
pos = i & mask;
|
||||||
for (j = 0; j < pos; ++j)
|
for (j = 0; j < pos; ++j)
|
||||||
bh = bh->b_this_page;
|
bh = bh->b_this_page;
|
||||||
|
|
||||||
|
|
||||||
if (unlikely(index == last_index))
|
if (unlikely(index == last_index))
|
||||||
lblock = end & mask;
|
lblock = end & mask;
|
||||||
else
|
else
|
||||||
|
@ -313,7 +311,7 @@ static void ufs_change_blocknr(struct inode *inode, sector_t beg,
|
||||||
} while (bh != head);
|
} while (bh != head);
|
||||||
|
|
||||||
if (likely(cur_index != index))
|
if (likely(cur_index != index))
|
||||||
ufs_put_locked_page(page);
|
ufs_put_locked_folio(folio);
|
||||||
}
|
}
|
||||||
UFSD("EXIT\n");
|
UFSD("EXIT\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue