[v2,1/2] btrfs: qgroup: Fix wrong parameter order for trace events
diff mbox series

Message ID 20191017023837.32264-2-wqu@suse.com
State New
Headers show
Series
  • btrfs: qgroup: Bug fixes for trace events
Related show

Commit Message

Qu Wenruo Oct. 17, 2019, 2:38 a.m. UTC
[BUG]
For btrfs:qgroup_meta_reserve event, the trace event can output garbage:
qgroup_meta_reserve: 9c7f6acc-b342-4037-bc47-7f6e4d2232d7: refroot=5(FS_TREE) type=DATA diff=2

The diff should always be alinged to sector size (4k), so there is
definitely something wrong.

[CAUSE]
For the wrong @diff, it's caused by wrong parameter order.
The correct parameters are:
  struct btrfs_root, s64 diff, int type.

However the parameters used are:
  struct btrfs_root, int type, s64 diff.

[FIX]
Fix the super stupid bug.

Fixes: 4ee0d8832c2e ("btrfs: qgroup: Update trace events for metadata reservation")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/qgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nikolay Borisov Oct. 17, 2019, 6:37 a.m. UTC | #1
On 17.10.19 г. 5:38 ч., Qu Wenruo wrote:
> [BUG]
> For btrfs:qgroup_meta_reserve event, the trace event can output garbage:
> qgroup_meta_reserve: 9c7f6acc-b342-4037-bc47-7f6e4d2232d7: refroot=5(FS_TREE) type=DATA diff=2
> 
> The diff should always be alinged to sector size (4k), so there is
> definitely something wrong.
> 
> [CAUSE]
> For the wrong @diff, it's caused by wrong parameter order.
> The correct parameters are:
>   struct btrfs_root, s64 diff, int type.
> 
> However the parameters used are:
>   struct btrfs_root, int type, s64 diff.
> 
> [FIX]
> Fix the super stupid bug.
> 
> Fixes: 4ee0d8832c2e ("btrfs: qgroup: Update trace events for metadata reservation")
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/qgroup.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index c4bb69941c77..3ad151655eb8 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3629,7 +3629,7 @@ int __btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
>  		return 0;
>  
>  	BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
> -	trace_qgroup_meta_reserve(root, type, (s64)num_bytes);
> +	trace_qgroup_meta_reserve(root, (s64)num_bytes, type);
>  	ret = qgroup_reserve(root, num_bytes, enforce, type);
>  	if (ret < 0)
>  		return ret;
> @@ -3676,7 +3676,7 @@ void __btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes,
>  	 */
>  	num_bytes = sub_root_meta_rsv(root, num_bytes, type);
>  	BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
> -	trace_qgroup_meta_reserve(root, type, -(s64)num_bytes);
> +	trace_qgroup_meta_reserve(root, -(s64)num_bytes, type);
>  	btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid,
>  				  num_bytes, type);
>  }
>

Patch
diff mbox series

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index c4bb69941c77..3ad151655eb8 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3629,7 +3629,7 @@  int __btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
 		return 0;
 
 	BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
-	trace_qgroup_meta_reserve(root, type, (s64)num_bytes);
+	trace_qgroup_meta_reserve(root, (s64)num_bytes, type);
 	ret = qgroup_reserve(root, num_bytes, enforce, type);
 	if (ret < 0)
 		return ret;
@@ -3676,7 +3676,7 @@  void __btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes,
 	 */
 	num_bytes = sub_root_meta_rsv(root, num_bytes, type);
 	BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
-	trace_qgroup_meta_reserve(root, type, -(s64)num_bytes);
+	trace_qgroup_meta_reserve(root, -(s64)num_bytes, type);
 	btrfs_qgroup_free_refroot(fs_info, root->root_key.objectid,
 				  num_bytes, type);
 }