Skip to content

Commit

Permalink
ubifs: Use a folio in do_truncation()
Browse files Browse the repository at this point in the history
Convert from the old page APIs to the new folio APIs which saves
a few hidden calls to compound_head().

Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
Reviewed-by: Zhihao Cheng <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
  • Loading branch information
Matthew Wilcox (Oracle) authored and richardweinberger committed Feb 25, 2024
1 parent c35acef commit 783d074
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions fs/ubifs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,11 +1153,11 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,

if (offset) {
pgoff_t index = new_size >> PAGE_SHIFT;
struct page *page;
struct folio *folio;

page = find_lock_page(inode->i_mapping, index);
if (page) {
if (PageDirty(page)) {
folio = filemap_lock_folio(inode->i_mapping, index);
if (!IS_ERR(folio)) {
if (folio_test_dirty(folio)) {
/*
* 'ubifs_jnl_truncate()' will try to truncate
* the last data node, but it contains
Expand All @@ -1166,14 +1166,14 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
* 'ubifs_jnl_truncate()' will see an already
* 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)
offset = new_size &
(PAGE_SIZE - 1);
err = do_writepage(page, offset);
put_page(page);
offset = offset_in_folio(folio,
new_size);
err = do_writepage(&folio->page, offset);
folio_put(folio);
if (err)
goto out_budg;
/*
Expand All @@ -1186,8 +1186,8 @@ static int do_truncation(struct ubifs_info *c, struct inode *inode,
* to 'ubifs_jnl_truncate()' to save it from
* having to read it.
*/
unlock_page(page);
put_page(page);
folio_unlock(folio);
folio_put(folio);
}
}
}
Expand Down

0 comments on commit 783d074

Please sign in to comment.