Message ID | 20201113125149.140836-25-wqu@suse.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | btrfs: preparation patches for subpage support | expand |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index f305777ee1a3..55115f485d09 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -5310,14 +5310,13 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info, goto free_eb; } exists = NULL; + WARN_ON(PageDirty(p)); /* * Do this so attach doesn't complain and we need to * drop the ref the old guy had. */ - ClearPagePrivate(p); - WARN_ON(PageDirty(p)); - put_page(p); + detach_page_private(page); } attach_extent_buffer_page(eb, p); spin_unlock(&mapping->private_lock);
In alloc_extent_buffer(), after we got a page from btree inode, we check if that page has private pointer attached. If attached, we check if the existing extent buffer has a proper refs. If not (the eb is being freed), we will detach that private eb pointer. The point here is, we are detaching that eb pointer by calling: - ClearPagePrivate() - put_page() The put_page() here is especially confusing, as it's decreaing the ref caused by attach_page_private(). Without knowing that, it looks like the put_page() is for the find_or_create_page() call, confusing the read. Since we're always modifing page private with attach_page_private() and detach_page_private(), the only open-coded detach_page_private() here is really confusing. Fix it by calling detach_page_private(). Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/btrfs/extent_io.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)