Commit 783d0741 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Richard Weinberger

ubifs: Use a folio in do_truncation()

Convert from the old page APIs to the new folio APIs which saves
a few hidden calls to compound_head().
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
parent c35acef3
...@@ -1153,11 +1153,11 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, ...@@ -1153,11 +1153,11 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
if (offset) { if (offset) {
pgoff_t index = new_size >> PAGE_SHIFT; pgoff_t index = new_size >> PAGE_SHIFT;
struct page *page; struct folio *folio;
page = find_lock_page(inode->i_mapping, index); folio = filemap_lock_folio(inode->i_mapping, index);
if (page) { if (!IS_ERR(folio)) {
if (PageDirty(page)) { if (folio_test_dirty(folio)) {
/* /*
* 'ubifs_jnl_truncate()' will try to truncate * 'ubifs_jnl_truncate()' will try to truncate
* the last data node, but it contains * the last data node, but it contains
...@@ -1166,14 +1166,14 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, ...@@ -1166,14 +1166,14 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
* 'ubifs_jnl_truncate()' will see an already * 'ubifs_jnl_truncate()' will see an already
* truncated (and up to date) data node. * truncated (and up to date) data node.
*/ */
ubifs_assert(c, PagePrivate(page)); ubifs_assert(c, folio->private != NULL);
clear_page_dirty_for_io(page); folio_clear_dirty_for_io(folio);
if (UBIFS_BLOCKS_PER_PAGE_SHIFT) if (UBIFS_BLOCKS_PER_PAGE_SHIFT)
offset = new_size & offset = offset_in_folio(folio,
(PAGE_SIZE - 1); new_size);
err = do_writepage(page, offset); err = do_writepage(&folio->page, offset);
put_page(page); folio_put(folio);
if (err) if (err)
goto out_budg; goto out_budg;
/* /*
...@@ -1186,8 +1186,8 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode, ...@@ -1186,8 +1186,8 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
* to 'ubifs_jnl_truncate()' to save it from * to 'ubifs_jnl_truncate()' to save it from
* having to read it. * having to read it.
*/ */
unlock_page(page); folio_unlock(folio);
put_page(page); folio_put(folio);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment