btrfs: use attach/detach_page_private
Since the new pair function is introduced, we can call them to clean the code in btrfs. Signed-off-by: Guoqing Jiang <guoqing.jiang@cloud.ionos.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: David Sterba <dsterba@suse.com> Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <josef@toxicpanda.com> Link: http://lkml.kernel.org/r/20200517214718.468-4-guoqing.jiang@cloud.ionos.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
db2c1d86cc
commit
d1b89bc042
@@ -980,9 +980,7 @@ static void btree_invalidatepage(struct page *page, unsigned int offset,
|
|||||||
btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info,
|
btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info,
|
||||||
"page private not zero on page %llu",
|
"page private not zero on page %llu",
|
||||||
(unsigned long long)page_offset(page));
|
(unsigned long long)page_offset(page));
|
||||||
ClearPagePrivate(page);
|
detach_page_private(page);
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3076,22 +3076,16 @@ static int submit_extent_page(unsigned int opf,
|
|||||||
static void attach_extent_buffer_page(struct extent_buffer *eb,
|
static void attach_extent_buffer_page(struct extent_buffer *eb,
|
||||||
struct page *page)
|
struct page *page)
|
||||||
{
|
{
|
||||||
if (!PagePrivate(page)) {
|
if (!PagePrivate(page))
|
||||||
SetPagePrivate(page);
|
attach_page_private(page, eb);
|
||||||
get_page(page);
|
else
|
||||||
set_page_private(page, (unsigned long)eb);
|
|
||||||
} else {
|
|
||||||
WARN_ON(page->private != (unsigned long)eb);
|
WARN_ON(page->private != (unsigned long)eb);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_page_extent_mapped(struct page *page)
|
void set_page_extent_mapped(struct page *page)
|
||||||
{
|
{
|
||||||
if (!PagePrivate(page)) {
|
if (!PagePrivate(page))
|
||||||
SetPagePrivate(page);
|
attach_page_private(page, (void *)EXTENT_PAGE_PRIVATE);
|
||||||
get_page(page);
|
|
||||||
set_page_private(page, EXTENT_PAGE_PRIVATE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct extent_map *
|
static struct extent_map *
|
||||||
@@ -4910,10 +4904,7 @@ static void btrfs_release_extent_buffer_pages(struct extent_buffer *eb)
|
|||||||
* We need to make sure we haven't be attached
|
* We need to make sure we haven't be attached
|
||||||
* to a new eb.
|
* to a new eb.
|
||||||
*/
|
*/
|
||||||
ClearPagePrivate(page);
|
detach_page_private(page);
|
||||||
set_page_private(page, 0);
|
|
||||||
/* One for the page private */
|
|
||||||
put_page(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapped)
|
if (mapped)
|
||||||
|
|||||||
@@ -8301,11 +8301,8 @@ static void btrfs_readahead(struct readahead_control *rac)
|
|||||||
static int __btrfs_releasepage(struct page *page, gfp_t gfp_flags)
|
static int __btrfs_releasepage(struct page *page, gfp_t gfp_flags)
|
||||||
{
|
{
|
||||||
int ret = try_release_extent_mapping(page, gfp_flags);
|
int ret = try_release_extent_mapping(page, gfp_flags);
|
||||||
if (ret == 1) {
|
if (ret == 1)
|
||||||
ClearPagePrivate(page);
|
detach_page_private(page);
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8327,14 +8324,8 @@ static int btrfs_migratepage(struct address_space *mapping,
|
|||||||
if (ret != MIGRATEPAGE_SUCCESS)
|
if (ret != MIGRATEPAGE_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (page_has_private(page)) {
|
if (page_has_private(page))
|
||||||
ClearPagePrivate(page);
|
attach_page_private(newpage, detach_page_private(page));
|
||||||
get_page(newpage);
|
|
||||||
set_page_private(newpage, page_private(page));
|
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
SetPagePrivate(newpage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PagePrivate2(page)) {
|
if (PagePrivate2(page)) {
|
||||||
ClearPagePrivate2(page);
|
ClearPagePrivate2(page);
|
||||||
@@ -8456,11 +8447,7 @@ again:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ClearPageChecked(page);
|
ClearPageChecked(page);
|
||||||
if (PagePrivate(page)) {
|
detach_page_private(page);
|
||||||
ClearPagePrivate(page);
|
|
||||||
set_page_private(page, 0);
|
|
||||||
put_page(page);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user