Skip to content

Commit

Permalink
btrfs: defrag: also check PagePrivate for subpage cases in cluster_pa…
Browse files Browse the repository at this point in the history
…ges_for_defrag()

In function cluster_pages_for_defrag() we have a window where we unlock
page, either start the ordered range or read the content from disk.

When we re-lock the page, we need to make sure it still has the correct
page->private for subpage.

Thus add the extra PagePrivate check here to handle subpage cases
properly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Qu Wenruo authored and David Sterba committed Oct 26, 2021
1 parent 1ccc2e8 commit cae7968
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1278,7 +1278,8 @@ static int cluster_pages_for_defrag(struct inode *inode,
* we unlocked the page above, so we need check if
* it was released or not.
*/
if (page->mapping != inode->i_mapping) {
if (page->mapping != inode->i_mapping ||
!PagePrivate(page)) {
unlock_page(page);
put_page(page);
goto again;
Expand All @@ -1296,7 +1297,7 @@ static int cluster_pages_for_defrag(struct inode *inode,
}
}

if (page->mapping != inode->i_mapping) {
if (page->mapping != inode->i_mapping || !PagePrivate(page)) {
unlock_page(page);
put_page(page);
goto again;
Expand Down

0 comments on commit cae7968

Please sign in to comment.