linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Output more info for enospc_debug mount option
@ 2016-03-01  8:08 Qu Wenruo
  2016-03-11 15:43 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2016-03-01  8:08 UTC (permalink / raw)
  To: linux-btrfs

As one user in mail list report reproducible balance ENOSPC error, it's
better to add more debug info for enospc_debug mount option.

Reported-by: Marc Haber <mh+linux-btrfs@zugschlus.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 fs/btrfs/extent-tree.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 083783b..a95d247 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -9386,15 +9386,23 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 	u64 dev_min = 1;
 	u64 dev_nr = 0;
 	u64 target;
+	int debug;
 	int index;
 	int full = 0;
 	int ret = 0;
 
+	debug = btrfs_test_opt(root, ENOSPC_DEBUG);
+
 	block_group = btrfs_lookup_block_group(root->fs_info, bytenr);
 
 	/* odd, couldn't find the block group, leave it alone */
-	if (!block_group)
+	if (!block_group) {
+		if (debug)
+			btrfs_warn(root->fs_info,
+				   "Can't find block group %llu\n",
+				   bytenr);
 		return -1;
+	}
 
 	min_free = btrfs_block_group_used(&block_group->item);
 
@@ -9448,8 +9456,11 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 		 * this is just a balance, so if we were marked as full
 		 * we know there is no space for a new chunk
 		 */
-		if (full)
+		if (full) {
+			if (debug)
+				btrfs_warn(root->fs_info, "space info full");
 			goto out;
+		}
 
 		index = get_block_group_index(block_group);
 	}
@@ -9496,6 +9507,8 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 			ret = -1;
 		}
 	}
+	if (debug && ret == -1)
+		btrfs_warn(root->fs_info, "no space to allocate a new chunk");
 	mutex_unlock(&root->fs_info->chunk_mutex);
 	btrfs_end_transaction(trans, root);
 out:
-- 
2.7.2




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] btrfs: Output more info for enospc_debug mount option
  2016-03-01  8:08 [PATCH] btrfs: Output more info for enospc_debug mount option Qu Wenruo
@ 2016-03-11 15:43 ` David Sterba
  0 siblings, 0 replies; 3+ messages in thread
From: David Sterba @ 2016-03-11 15:43 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Tue, Mar 01, 2016 at 04:08:21PM +0800, Qu Wenruo wrote:
> As one user in mail list report reproducible balance ENOSPC error, it's
> better to add more debug info for enospc_debug mount option.
> 
> Reported-by: Marc Haber <mh+linux-btrfs@zugschlus.de>
> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
> ---
>  fs/btrfs/extent-tree.c | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 083783b..a95d247 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -9386,15 +9386,23 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
>  	u64 dev_min = 1;
>  	u64 dev_nr = 0;
>  	u64 target;
> +	int debug;
>  	int index;
>  	int full = 0;
>  	int ret = 0;
>  
> +	debug = btrfs_test_opt(root, ENOSPC_DEBUG);
> +
>  	block_group = btrfs_lookup_block_group(root->fs_info, bytenr);
>  
>  	/* odd, couldn't find the block group, leave it alone */
> -	if (!block_group)
> +	if (!block_group) {
> +		if (debug)
> +			btrfs_warn(root->fs_info,
> +				   "Can't find block group %llu\n",

no newline, no capital 'C'

> +				   bytenr);
>  		return -1;
> +	}
>  
>  	min_free = btrfs_block_group_used(&block_group->item);
>  
> @@ -9448,8 +9456,11 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
>  		 * this is just a balance, so if we were marked as full
>  		 * we know there is no space for a new chunk
>  		 */
> -		if (full)
> +		if (full) {
> +			if (debug)
> +				btrfs_warn(root->fs_info, "space info full");

the block group bytenr should be printed as well

>  			goto out;
> +		}
>  
>  		index = get_block_group_index(block_group);
>  	}
> @@ -9496,6 +9507,8 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
>  			ret = -1;
>  		}
>  	}
> +	if (debug && ret == -1)
> +		btrfs_warn(root->fs_info, "no space to allocate a new chunk");

same here, add bytenr

>  	mutex_unlock(&root->fs_info->chunk_mutex);
>  	btrfs_end_transaction(trans, root);
>  out:
> -- 
> 2.7.2
> 
> 
> 
> --
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] btrfs: Output more info for enospc_debug mount option
@ 2016-03-23  3:38 Qu Wenruo
  0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2016-03-23  3:38 UTC (permalink / raw)
  To: linux-btrfs

As one user in mail list report reproducible balance ENOSPC error, it's
better to add more debug info for enospc_debug mount option.

Reported-by: Marc Haber <mh+linux-btrfs@zugschlus.de>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
changelog:
  v2: Add output for block group bytenr
---
 fs/btrfs/extent-tree.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 53e1297..8507484 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -9386,15 +9386,23 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 	u64 dev_min = 1;
 	u64 dev_nr = 0;
 	u64 target;
+	int debug;
 	int index;
 	int full = 0;
 	int ret = 0;
 
+	debug = btrfs_test_opt(root, ENOSPC_DEBUG);
+
 	block_group = btrfs_lookup_block_group(root->fs_info, bytenr);
 
 	/* odd, couldn't find the block group, leave it alone */
-	if (!block_group)
+	if (!block_group) {
+		if (debug)
+			btrfs_warn(root->fs_info,
+				   "can't find block group for bytenr %llu",
+				   bytenr);
 		return -1;
+	}
 
 	min_free = btrfs_block_group_used(&block_group->item);
 
@@ -9448,8 +9456,13 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 		 * this is just a balance, so if we were marked as full
 		 * we know there is no space for a new chunk
 		 */
-		if (full)
+		if (full) {
+			if (debug)
+				btrfs_warn(root->fs_info,
+					"no space to alloc new chunk for block group %llu",
+					block_group->key.objectid);
 			goto out;
+		}
 
 		index = get_block_group_index(block_group);
 	}
@@ -9496,6 +9509,10 @@ int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr)
 			ret = -1;
 		}
 	}
+	if (debug && ret == -1)
+		btrfs_warn(root->fs_info,
+			"no space to allocate a new chunk for block group %llu",
+			block_group->key.objectid);
 	mutex_unlock(&root->fs_info->chunk_mutex);
 	btrfs_end_transaction(trans, root);
 out:
-- 
2.7.4




^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-23  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-01  8:08 [PATCH] btrfs: Output more info for enospc_debug mount option Qu Wenruo
2016-03-11 15:43 ` David Sterba
  -- strict thread matches above, loose matches on Subject: below --
2016-03-23  3:38 Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).