Skip to content

Commit 51608e9

Browse files
author
Matthew Wilcox (Oracle)
committed
splice: Use a folio in page_cache_pipe_buf_try_steal()
This saves a lot of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Miaohe Lin <[email protected]>
1 parent b890092 commit 51608e9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

fs/splice.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,27 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe,
4747
struct pipe_buffer *buf)
4848
{
4949
struct page *page = buf->page;
50+
struct folio *folio = page_folio(page);
5051
struct address_space *mapping;
5152

52-
lock_page(page);
53+
folio_lock(folio);
5354

54-
mapping = page_mapping(page);
55+
mapping = folio_mapping(folio);
5556
if (mapping) {
56-
WARN_ON(!PageUptodate(page));
57+
WARN_ON(!folio_test_uptodate(folio));
5758

5859
/*
5960
* At least for ext2 with nobh option, we need to wait on
60-
* writeback completing on this page, since we'll remove it
61+
* writeback completing on this folio, since we'll remove it
6162
* from the pagecache. Otherwise truncate wont wait on the
62-
* page, allowing the disk blocks to be reused by someone else
63+
* folio, allowing the disk blocks to be reused by someone else
6364
* before we actually wrote our data to them. fs corruption
6465
* ensues.
6566
*/
66-
wait_on_page_writeback(page);
67+
folio_wait_writeback(folio);
6768

68-
if (page_has_private(page) &&
69-
!try_to_release_page(page, GFP_KERNEL))
69+
if (folio_has_private(folio) &&
70+
!filemap_release_folio(folio, GFP_KERNEL))
7071
goto out_unlock;
7172

7273
/*
@@ -80,11 +81,11 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe,
8081
}
8182

8283
/*
83-
* Raced with truncate or failed to remove page from current
84+
* Raced with truncate or failed to remove folio from current
8485
* address space, unlock and return failure.
8586
*/
8687
out_unlock:
87-
unlock_page(page);
88+
folio_unlock(folio);
8889
return false;
8990
}
9091

0 commit comments

Comments
 (0)