ext4: Convert mext_page_mkuptodate() to take a folio

Use a folio throughout.  Does not support large folios due to
an array sized for MAX_BUF_PER_PAGE, but it does remove a few
calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Link: https://lore.kernel.org/r/20230324180129.1220691-28-willy@infradead.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
This commit is contained in:
Matthew Wilcox 2023-03-24 18:01:27 +00:00 коммит произвёл Theodore Ts'o
Родитель f2b229a8c6
Коммит 3060b6ef05
1 изменённых файлов: 15 добавлений и 13 удалений

Просмотреть файл

@ -168,25 +168,27 @@ mext_folio_double_lock(struct inode *inode1, struct inode *inode2,
/* Force page buffers uptodate w/o dropping page's lock */
static int
mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
mext_page_mkuptodate(struct folio *folio, unsigned from, unsigned to)
{
struct inode *inode = page->mapping->host;
struct inode *inode = folio->mapping->host;
sector_t block;
struct buffer_head *bh, *head, *arr[MAX_BUF_PER_PAGE];
unsigned int blocksize, block_start, block_end;
int i, err, nr = 0, partial = 0;
BUG_ON(!PageLocked(page));
BUG_ON(PageWriteback(page));
BUG_ON(!folio_test_locked(folio));
BUG_ON(folio_test_writeback(folio));
if (PageUptodate(page))
if (folio_test_uptodate(folio))
return 0;
blocksize = i_blocksize(inode);
if (!page_has_buffers(page))
create_empty_buffers(page, blocksize, 0);
head = folio_buffers(folio);
if (!head) {
create_empty_buffers(&folio->page, blocksize, 0);
head = folio_buffers(folio);
}
head = page_buffers(page);
block = (sector_t)page->index << (PAGE_SHIFT - inode->i_blkbits);
block = (sector_t)folio->index << (PAGE_SHIFT - inode->i_blkbits);
for (bh = head, block_start = 0; bh != head || !block_start;
block++, block_start = block_end, bh = bh->b_this_page) {
block_end = block_start + blocksize;
@ -200,11 +202,11 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
if (!buffer_mapped(bh)) {
err = ext4_get_block(inode, block, bh, 0);
if (err) {
SetPageError(page);
folio_set_error(folio);
return err;
}
if (!buffer_mapped(bh)) {
zero_user(page, block_start, blocksize);
folio_zero_range(folio, block_start, blocksize);
set_buffer_uptodate(bh);
continue;
}
@ -226,7 +228,7 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to)
}
out:
if (!partial)
SetPageUptodate(page);
folio_mark_uptodate(folio);
return 0;
}
@ -354,7 +356,7 @@ again:
goto unlock_folios;
}
data_copy:
*err = mext_page_mkuptodate(&folio[0]->page, from, from + replaced_size);
*err = mext_page_mkuptodate(folio[0], from, from + replaced_size);
if (*err)
goto unlock_folios;