btrfs: don't clear qgroup reserved bit in release_folio
authorBoris Burkov <boris@bur.io>
Fri, 1 Dec 2023 21:00:12 +0000 (13:00 -0800)
committerDavid Sterba <dsterba@suse.com>
Wed, 6 Dec 2023 21:32:52 +0000 (22:32 +0100)
The EXTENT_QGROUP_RESERVED bit is used to "lock" regions of the file for
duplicate reservations. That is two writes to that range in one
transaction shouldn't create two reservations, as the reservation will
only be freed once when the write finally goes down. Therefore, it is
never OK to clear that bit without freeing the associated qgroup
reserve. At this point, we don't want to be freeing the reserve, so mask
off the bit.

CC: stable@vger.kernel.org # 5.15+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent_io.c

index e6230a6ffa9859fd26046b12e9cc295e5cf78d35..8f724c54fc8e9c8a38f720df77526f7b722b6f44 100644 (file)
@@ -2302,7 +2302,8 @@ static int try_release_extent_state(struct extent_io_tree *tree,
                ret = 0;
        } else {
                u32 clear_bits = ~(EXTENT_LOCKED | EXTENT_NODATASUM |
-                                  EXTENT_DELALLOC_NEW | EXTENT_CTLBITS);
+                                  EXTENT_DELALLOC_NEW | EXTENT_CTLBITS |
+                                  EXTENT_QGROUP_RESERVED);
 
                /*
                 * At this point we can safely clear everything except the