linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: Remove never-reached WARN_ON
@ 2017-08-17  7:52 Nikolay Borisov
  2017-08-17 11:46 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2017-08-17  7:52 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

We have a WARN_ON(!var) inside an if branch which is executed (among others)
only when var is true.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 21c78c48e15b..8552d550a048 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6755,7 +6755,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
 			u64 to_add = len;
-			WARN_ON(!return_free_space);
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
 				to_add = min(len, global_rsv->size -
-- 
2.7.4


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

* Re: [PATCH] btrfs: Remove never-reached WARN_ON
  2017-08-17  7:52 [PATCH] btrfs: Remove never-reached WARN_ON Nikolay Borisov
@ 2017-08-17 11:46 ` David Sterba
  2017-08-17 14:04   ` [PATCH v2] " Nikolay Borisov
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2017-08-17 11:46 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Thu, Aug 17, 2017 at 10:52:28AM +0300, Nikolay Borisov wrote:
> We have a WARN_ON(!var) inside an if branch which is executed (among others)
> only when var is true.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  fs/btrfs/extent-tree.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 21c78c48e15b..8552d550a048 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -6755,7 +6755,6 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
>  		if (!readonly && return_free_space &&
>  		    global_rsv->space_info == space_info) {
>  			u64 to_add = len;
> -			WARN_ON(!return_free_space);

Right. And also an example where the coding style can be improved as a
sideefect, ie. the missing line between declarations and statements.

>  			spin_lock(&global_rsv->lock);
>  			if (!global_rsv->full) {
>  				to_add = min(len, global_rsv->size -
> -- 
> 2.7.4
> 
> --
> 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 v2] btrfs: Remove never-reached WARN_ON
  2017-08-17 11:46 ` David Sterba
@ 2017-08-17 14:04   ` Nikolay Borisov
  0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2017-08-17 14:04 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs, Nikolay Borisov

We have a WARN_ON(!var) inside an if branch which is executed (among others)
only when var is true.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/extent-tree.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 21c78c48e15b..8b32e53236ea 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6755,7 +6755,7 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 		if (!readonly && return_free_space &&
 		    global_rsv->space_info == space_info) {
 			u64 to_add = len;
-			WARN_ON(!return_free_space);
+
 			spin_lock(&global_rsv->lock);
 			if (!global_rsv->full) {
 				to_add = min(len, global_rsv->size -
@@ -6771,6 +6771,7 @@ static int unpin_extent_range(struct btrfs_fs_info *fs_info,
 				len -= to_add;
 			}
 			spin_unlock(&global_rsv->lock);
+
 			/* Add to any tickets we may have */
 			if (len)
 				space_info_add_new_bytes(fs_info, space_info,
-- 
2.7.4


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

end of thread, other threads:[~2017-08-17 14:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-17  7:52 [PATCH] btrfs: Remove never-reached WARN_ON Nikolay Borisov
2017-08-17 11:46 ` David Sterba
2017-08-17 14:04   ` [PATCH v2] " Nikolay Borisov

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).