[12/14] Btrfs: fix release reserved extents trace points
diff mbox

Message ID 1458926760-17563-13-git-send-email-jbacik@fb.com
State Accepted
Headers show

Commit Message

Josef Bacik March 25, 2016, 5:25 p.m. UTC
We were doing trace_btrfs_release_reserved_extent() in pin_down_extent which
isn't quite right because we will go through and free that extent later when we
unpin, so it messes up apps that are accounting for the reservation space.  We
were also unconditionally doing it in __btrfs_free_reserved_extent(), when we
only actually free the reservation instead of pinning the extent.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
---
 fs/btrfs/extent-tree.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

Comments

Liu Bo May 9, 2016, 9:33 p.m. UTC | #1
On Fri, Mar 25, 2016 at 01:25:58PM -0400, Josef Bacik wrote:
> We were doing trace_btrfs_release_reserved_extent() in pin_down_extent which
> isn't quite right because we will go through and free that extent later when we
> unpin, so it messes up apps that are accounting for the reservation space.  We
> were also unconditionally doing it in __btrfs_free_reserved_extent(), when we
> only actually free the reservation instead of pinning the extent.  Thanks,

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo
> 
> Signed-off-by: Josef Bacik <jbacik@fb.com>
> ---
>  fs/btrfs/extent-tree.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 0ecceea..273e18d 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -6253,8 +6253,6 @@ static int pin_down_extent(struct btrfs_root *root,
>  				      cache->space_info->flags, num_bytes, 1);
>  	set_extent_dirty(root->fs_info->pinned_extents, bytenr,
>  			 bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
> -	if (reserved)
> -		trace_btrfs_reserved_extent_free(root, bytenr, num_bytes);
>  	return 0;
>  }
>  
> @@ -7877,12 +7875,10 @@ static int __btrfs_free_reserved_extent(struct btrfs_root *root,
>  			ret = btrfs_discard_extent(root, start, len, NULL);
>  		btrfs_add_free_space(cache, start, len);
>  		btrfs_update_reserved_bytes(cache, len, RESERVE_FREE, delalloc);
> +		trace_btrfs_reserved_extent_free(root, start, len);
>  	}
>  
>  	btrfs_put_block_group(cache);
> -
> -	trace_btrfs_reserved_extent_free(root, start, len);
> -
>  	return ret;
>  }
>  
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0ecceea..273e18d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6253,8 +6253,6 @@  static int pin_down_extent(struct btrfs_root *root,
 				      cache->space_info->flags, num_bytes, 1);
 	set_extent_dirty(root->fs_info->pinned_extents, bytenr,
 			 bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL);
-	if (reserved)
-		trace_btrfs_reserved_extent_free(root, bytenr, num_bytes);
 	return 0;
 }
 
@@ -7877,12 +7875,10 @@  static int __btrfs_free_reserved_extent(struct btrfs_root *root,
 			ret = btrfs_discard_extent(root, start, len, NULL);
 		btrfs_add_free_space(cache, start, len);
 		btrfs_update_reserved_bytes(cache, len, RESERVE_FREE, delalloc);
+		trace_btrfs_reserved_extent_free(root, start, len);
 	}
 
 	btrfs_put_block_group(cache);
-
-	trace_btrfs_reserved_extent_free(root, start, len);
-
 	return ret;
 }