diff options
author | Josef Bacik <jbacik@fb.com> | 2016-01-13 11:48:06 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-02-18 11:22:24 +0100 |
commit | dc95f7bfc57fa4b75a77d0da84d5db249d74aa3f (patch) | |
tree | 701b1ece85b20b5082e816958bc28c51c8a5d9cd /fs | |
parent | fb4b10e5d56639389fbc46dc8a87e81578af0b64 (diff) | |
download | linux-dc95f7bfc57fa4b75a77d0da84d5db249d74aa3f.tar.gz linux-dc95f7bfc57fa4b75a77d0da84d5db249d74aa3f.tar.bz2 linux-dc95f7bfc57fa4b75a77d0da84d5db249d74aa3f.zip |
Btrfs: fix truncate_space_check
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>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/inode.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5f06eb1f4384..9b4a5ab279dc 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4211,11 +4211,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; } |