Message ID | 20220214200017.3150590-2-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Various fixes around invalidate_page() | expand |
On Mon, Feb 14, 2022 at 08:00:08PM +0000, Matthew Wilcox (Oracle) wrote: > This saves a lot of calls to compound_head(). Looks good, Reviewed-by: Christoph Hellwig <hch@lst.de>
On 2022/2/15 4:00, Matthew Wilcox (Oracle) wrote: > This saves a lot of calls to compound_head(). > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> > --- > fs/splice.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > LGTM. Thanks. Reviewed-by: Miaohe Lin <linmiaohe@huawei.com> > diff --git a/fs/splice.c b/fs/splice.c > index 5dbce4dcc1a7..23ff9c303abc 100644 > --- a/fs/splice.c > +++ b/fs/splice.c > @@ -47,26 +47,27 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, > struct pipe_buffer *buf) > { > struct page *page = buf->page; > + struct folio *folio = page_folio(page); > struct address_space *mapping; > > - lock_page(page); > + folio_lock(folio); > > - mapping = page_mapping(page); > + mapping = folio_mapping(folio); > if (mapping) { > - WARN_ON(!PageUptodate(page)); > + WARN_ON(!folio_test_uptodate(folio)); > > /* > * At least for ext2 with nobh option, we need to wait on > - * writeback completing on this page, since we'll remove it > + * writeback completing on this folio, since we'll remove it > * from the pagecache. Otherwise truncate wont wait on the > - * page, allowing the disk blocks to be reused by someone else > + * folio, allowing the disk blocks to be reused by someone else > * before we actually wrote our data to them. fs corruption > * ensues. > */ > - wait_on_page_writeback(page); > + folio_wait_writeback(folio); > > - if (page_has_private(page) && > - !try_to_release_page(page, GFP_KERNEL)) > + if (folio_has_private(folio) && > + !filemap_release_folio(folio, GFP_KERNEL)) > goto out_unlock; > > /* > @@ -80,11 +81,11 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, > } > > /* > - * Raced with truncate or failed to remove page from current > + * Raced with truncate or failed to remove folio from current > * address space, unlock and return failure. > */ > out_unlock: > - unlock_page(page); > + folio_unlock(folio); > return false; > } > >
diff --git a/fs/splice.c b/fs/splice.c index 5dbce4dcc1a7..23ff9c303abc 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -47,26 +47,27 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, struct pipe_buffer *buf) { struct page *page = buf->page; + struct folio *folio = page_folio(page); struct address_space *mapping; - lock_page(page); + folio_lock(folio); - mapping = page_mapping(page); + mapping = folio_mapping(folio); if (mapping) { - WARN_ON(!PageUptodate(page)); + WARN_ON(!folio_test_uptodate(folio)); /* * At least for ext2 with nobh option, we need to wait on - * writeback completing on this page, since we'll remove it + * writeback completing on this folio, since we'll remove it * from the pagecache. Otherwise truncate wont wait on the - * page, allowing the disk blocks to be reused by someone else + * folio, allowing the disk blocks to be reused by someone else * before we actually wrote our data to them. fs corruption * ensues. */ - wait_on_page_writeback(page); + folio_wait_writeback(folio); - if (page_has_private(page) && - !try_to_release_page(page, GFP_KERNEL)) + if (folio_has_private(folio) && + !filemap_release_folio(folio, GFP_KERNEL)) goto out_unlock; /* @@ -80,11 +81,11 @@ static bool page_cache_pipe_buf_try_steal(struct pipe_inode_info *pipe, } /* - * Raced with truncate or failed to remove page from current + * Raced with truncate or failed to remove folio from current * address space, unlock and return failure. */ out_unlock: - unlock_page(page); + folio_unlock(folio); return false; }
This saves a lot of calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- fs/splice.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)