]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
btrfs: defrag: also check PagePrivate for subpage cases in cluster_pages_for_defrag()
authorQu Wenruo <wqu@suse.com>
Fri, 6 Aug 2021 08:12:33 +0000 (16:12 +0800)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Oct 2021 17:05:18 +0000 (19:05 +0200)
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>
fs/btrfs/ioctl.c

index 033726aed96e46fbe4fd53cefd31f418e5cf1ebd..b8b30e11a226851b8c831a2c5bf4d50aab6523bc 100644 (file)
@@ -1278,7 +1278,8 @@ again:
                         * 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;
@@ -1296,7 +1297,7 @@ again:
                        }
                }
 
-               if (page->mapping != inode->i_mapping) {
+               if (page->mapping != inode->i_mapping || !PagePrivate(page)) {
                        unlock_page(page);
                        put_page(page);
                        goto again;