[08/36] btrfs: dump block_rsv whe dumping space info
diff mbox series

Message ID 20180911175807.26181-9-josef@toxicpanda.com
State New
Headers show
Series
  • My current patch queue
Related show

Commit Message

Josef Bacik Sept. 11, 2018, 5:57 p.m. UTC
For enospc_debug having the block rsvs is super helpful to see if we've
done something wrong.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/extent-tree.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Omar Sandoval Sept. 11, 2018, 11:11 p.m. UTC | #1
On Tue, Sep 11, 2018 at 01:57:39PM -0400, Josef Bacik wrote:
> For enospc_debug having the block rsvs is super helpful to see if we've
> done something wrong.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  fs/btrfs/extent-tree.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index a3baa16d456f..1cf66a92829b 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -7918,6 +7918,16 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
>  	return ret;
>  }
>  
> +static void dump_block_rsv(struct btrfs_fs_info *fs_info,
> +			   struct btrfs_block_rsv *rsv)
> +{
> +	spin_lock(&rsv->lock);
> +	btrfs_info(fs_info, "%d: size %llu reserved %llu\n",
> +		   rsv->type, (unsigned long long)rsv->size,
> +		   (unsigned long long)rsv->reserved);

How about passing a string name for each of these instead of an ID which
we have to cross-reference with the source?

Besides that,

Reviewed-by: Omar Sandoval <osandov@fb.com>

> +	spin_unlock(&rsv->lock);
> +}
> +
>  static void dump_space_info(struct btrfs_fs_info *fs_info,
>  			    struct btrfs_space_info *info, u64 bytes,
>  			    int dump_block_groups)
> @@ -7937,6 +7947,12 @@ static void dump_space_info(struct btrfs_fs_info *fs_info,
>  		info->bytes_readonly);
>  	spin_unlock(&info->lock);
>  
> +	dump_block_rsv(fs_info, &fs_info->global_block_rsv);
> +	dump_block_rsv(fs_info, &fs_info->trans_block_rsv);
> +	dump_block_rsv(fs_info, &fs_info->chunk_block_rsv);
> +	dump_block_rsv(fs_info, &fs_info->delayed_block_rsv);
> +	dump_block_rsv(fs_info, &fs_info->delayed_refs_rsv);
> +
>  	if (!dump_block_groups)
>  		return;
>  
> -- 
> 2.14.3
>
David Sterba Sept. 12, 2018, 5:24 p.m. UTC | #2
On Tue, Sep 11, 2018 at 04:11:45PM -0700, Omar Sandoval wrote:
> On Tue, Sep 11, 2018 at 01:57:39PM -0400, Josef Bacik wrote:
> > For enospc_debug having the block rsvs is super helpful to see if we've
> > done something wrong.
> > 
> > Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> > ---
> >  fs/btrfs/extent-tree.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> > 
> > diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> > index a3baa16d456f..1cf66a92829b 100644
> > --- a/fs/btrfs/extent-tree.c
> > +++ b/fs/btrfs/extent-tree.c
> > @@ -7918,6 +7918,16 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
> >  	return ret;
> >  }
> >  
> > +static void dump_block_rsv(struct btrfs_fs_info *fs_info,
> > +			   struct btrfs_block_rsv *rsv)
> > +{
> > +	spin_lock(&rsv->lock);
> > +	btrfs_info(fs_info, "%d: size %llu reserved %llu\n",

no "\n" for the message helpers

> > +		   rsv->type, (unsigned long long)rsv->size,
> > +		   (unsigned long long)rsv->reserved);

u64 does  not need the (unsigned long long) typecast since long.

> How about passing a string name for each of these instead of an ID which
> we have to cross-reference with the source?

Agreed, this would be better. As this is a debugging stuff, we can use
macros to simplify it like:

#define		DUMP_BLOCK_RSV(fs_info, rsv_name)		\
do {								\
	struct btrfs_block_rsv *__rsv = &(fs_info)->rsv_name;	\
	spin_lock(&__rsv->lock);				\
	btrfs_info((fs_info), #rsv_name ": size ...");		\
	spin_unlock(&__rsv->lock);				\
} while(0)

and use as

DUMP_BLOCK_RSV(fs_info, global_block_rsv);

The name of the block reserve name remains greppable.

Patch
diff mbox series

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a3baa16d456f..1cf66a92829b 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -7918,6 +7918,16 @@  static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
 	return ret;
 }
 
+static void dump_block_rsv(struct btrfs_fs_info *fs_info,
+			   struct btrfs_block_rsv *rsv)
+{
+	spin_lock(&rsv->lock);
+	btrfs_info(fs_info, "%d: size %llu reserved %llu\n",
+		   rsv->type, (unsigned long long)rsv->size,
+		   (unsigned long long)rsv->reserved);
+	spin_unlock(&rsv->lock);
+}
+
 static void dump_space_info(struct btrfs_fs_info *fs_info,
 			    struct btrfs_space_info *info, u64 bytes,
 			    int dump_block_groups)
@@ -7937,6 +7947,12 @@  static void dump_space_info(struct btrfs_fs_info *fs_info,
 		info->bytes_readonly);
 	spin_unlock(&info->lock);
 
+	dump_block_rsv(fs_info, &fs_info->global_block_rsv);
+	dump_block_rsv(fs_info, &fs_info->trans_block_rsv);
+	dump_block_rsv(fs_info, &fs_info->chunk_block_rsv);
+	dump_block_rsv(fs_info, &fs_info->delayed_block_rsv);
+	dump_block_rsv(fs_info, &fs_info->delayed_refs_rsv);
+
 	if (!dump_block_groups)
 		return;