btrfs: add assertions for releasing trans handle reservations
authorJosef Bacik <josef@toxicpanda.com>
Fri, 29 Sep 2017 19:44:05 +0000 (15:44 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 30 Oct 2017 11:28:01 +0000 (12:28 +0100)
These are useful for debugging problems where we mess with
trans->block_rsv to make sure we're not screwing something up.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c

index 423d89145bac1a4c010b4658ba90460050b27355..4f874d02f31049489a616521b86059843e94a6a5 100644 (file)
@@ -5823,12 +5823,15 @@ static void release_global_block_rsv(struct btrfs_fs_info *fs_info)
 void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans,
                                  struct btrfs_fs_info *fs_info)
 {
-       if (!trans->block_rsv)
+       if (!trans->block_rsv) {
+               ASSERT(!trans->bytes_reserved);
                return;
+       }
 
        if (!trans->bytes_reserved)
                return;
 
+       ASSERT(trans->block_rsv == &fs_info->trans_block_rsv);
        trace_btrfs_space_reservation(fs_info, "transaction",
                                      trans->transid, trans->bytes_reserved, 0);
        btrfs_block_rsv_release(fs_info, trans->block_rsv,