Btrfs: fix delalloc reservation amount tracepoint
authorJosef Bacik <jbacik@fb.com>
Fri, 25 Mar 2016 17:25:55 +0000 (13:25 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 7 Jul 2016 16:45:53 +0000 (18:45 +0200)
We can sometimes drop the reservation we had for our inode, so we need to remove
that amount from to_reserve so that our tracepoint reports a valid amount of
space.

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

index 9aa64f1aa41344604a2cf60ce80ed994a49486cd..5d24ec44d99b3d69c83d79fed6280d1e334dab8b 100644 (file)
@@ -6000,8 +6000,10 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
 
        spin_lock(&BTRFS_I(inode)->lock);
        if (test_and_set_bit(BTRFS_INODE_DELALLOC_META_RESERVED,
-                            &BTRFS_I(inode)->runtime_flags))
+                            &BTRFS_I(inode)->runtime_flags)) {
+               to_reserve -= btrfs_calc_trans_metadata_size(root, 1);
                release_extra = true;
+       }
        BTRFS_I(inode)->reserved_extents += nr_extents;
        spin_unlock(&BTRFS_I(inode)->lock);