]> git.hungrycats.org Git - linux/commitdiff
Btrfs: fix truncate_space_check
authorJosef Bacik <jbacik@fb.com>
Wed, 13 Jan 2016 16:45:56 +0000 (11:45 -0500)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Tue, 19 Jan 2016 05:23:57 +0000 (00:23 -0500)
truncate_space_check is using btrfs_csum_bytes_to_leaves() but forgetting to
multiply by nodesize so we get an actual byte count.  We need a tracepoint here
so that we have the matching reserve for the release that will come later.  Also
add a comment to make clear what the intent of truncate_space_check is.

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit f6af4b00d93ede652038357d95e2487bedcc492a)
(cherry picked from commit cd23fed42909f9e375fe254560972e8c9b059c5c)

fs/btrfs/inode.c

index 4e38071285b3d12743863113fa1a19bc66bd1339..3e4f5cb93f5847c45f3e2c40048c3dcd30da76ea 100644 (file)
@@ -4159,11 +4159,20 @@ static int truncate_space_check(struct btrfs_trans_handle *trans,
 {
        int ret;
 
+       /*
+        * This is only used to apply pressure to the enospc system, we don't
+        * intend to use this reservation at all.
+        */
        bytes_deleted = btrfs_csum_bytes_to_leaves(root, bytes_deleted);
+       bytes_deleted *= root->nodesize;
        ret = btrfs_block_rsv_add(root, &root->fs_info->trans_block_rsv,
                                  bytes_deleted, BTRFS_RESERVE_NO_FLUSH);
-       if (!ret)
+       if (!ret) {
+               trace_btrfs_space_reservation(root->fs_info, "transaction",
+                                             trans->transid,
+                                             bytes_deleted, 1);
                trans->bytes_reserved += bytes_deleted;
+       }
        return ret;
 
 }