All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: lift errors from add_extent_changeset to the callers
@ 2018-03-27 17:44 David Sterba
  2018-03-28 13:57 ` David Sterba
  0 siblings, 1 reply; 2+ messages in thread
From: David Sterba @ 2018-03-27 17:44 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The missing error handling in add_extent_changeset was hidden, so make
it at least visible in the callers.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent_io.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f27bad003f8e..f141d0fd7a65 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -119,23 +119,22 @@ struct extent_page_data {
 	unsigned int sync_io:1;
 };
 
-static void add_extent_changeset(struct extent_state *state, unsigned bits,
+static int add_extent_changeset(struct extent_state *state, unsigned bits,
 				 struct extent_changeset *changeset,
 				 int set)
 {
 	int ret;
 
 	if (!changeset)
-		return;
+		return 0;
 	if (set && (state->state & bits) == bits)
-		return;
+		return 0;
 	if (!set && (state->state & bits) == 0)
-		return;
+		return 0;
 	changeset->bytes_changed += state->end - state->start + 1;
 	ret = ulist_add(&changeset->range_changed, state->start, state->end,
 			GFP_ATOMIC);
-	/* ENOMEM */
-	BUG_ON(ret < 0);
+	return ret;
 }
 
 static void flush_write_bio(struct extent_page_data *epd);
@@ -527,6 +526,7 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 {
 	struct extent_state *next;
 	unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS;
+	int ret;
 
 	if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
 		u64 range = state->end - state->start + 1;
@@ -534,7 +534,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 		tree->dirty_bytes -= range;
 	}
 	clear_state_cb(tree, state, bits);
-	add_extent_changeset(state, bits_to_clear, changeset, 0);
+	ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
+	BUG_ON(ret);
 	state->state &= ~bits_to_clear;
 	if (wake)
 		wake_up(&state->wq);
@@ -805,13 +806,15 @@ static void set_state_bits(struct extent_io_tree *tree,
 			   unsigned *bits, struct extent_changeset *changeset)
 {
 	unsigned bits_to_set = *bits & ~EXTENT_CTLBITS;
+	int ret;
 
 	set_state_cb(tree, state, bits);
 	if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
 		u64 range = state->end - state->start + 1;
 		tree->dirty_bytes += range;
 	}
-	add_extent_changeset(state, bits_to_set, changeset, 1);
+	ret = add_extent_changeset(state, bits_to_set, changeset, 1);
+	BUG_ON(ret);
 	state->state |= bits_to_set;
 }
 
-- 
2.16.2


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

* Re: [PATCH] btrfs: lift errors from add_extent_changeset to the callers
  2018-03-27 17:44 [PATCH] btrfs: lift errors from add_extent_changeset to the callers David Sterba
@ 2018-03-28 13:57 ` David Sterba
  0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2018-03-28 13:57 UTC (permalink / raw)
  To: David Sterba; +Cc: linux-btrfs

On Tue, Mar 27, 2018 at 07:44:03PM +0200, David Sterba wrote:
> The missing error handling in add_extent_changeset was hidden, so make
> it at least visible in the callers.
> 
> Signed-off-by: David Sterba <dsterba@suse.com>
> ---
>  fs/btrfs/extent_io.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> index f27bad003f8e..f141d0fd7a65 100644
> --- a/fs/btrfs/extent_io.c
> +++ b/fs/btrfs/extent_io.c
> @@ -119,23 +119,22 @@ struct extent_page_data {
>  	unsigned int sync_io:1;
>  };
>  
> -static void add_extent_changeset(struct extent_state *state, unsigned bits,
> +static int add_extent_changeset(struct extent_state *state, unsigned bits,
>  				 struct extent_changeset *changeset,
>  				 int set)
>  {
>  	int ret;
>  
>  	if (!changeset)
> -		return;
> +		return 0;
>  	if (set && (state->state & bits) == bits)
> -		return;
> +		return 0;
>  	if (!set && (state->state & bits) == 0)
> -		return;
> +		return 0;
>  	changeset->bytes_changed += state->end - state->start + 1;
>  	ret = ulist_add(&changeset->range_changed, state->start, state->end,
>  			GFP_ATOMIC);
> -	/* ENOMEM */
> -	BUG_ON(ret < 0);
> +	return ret;
>  }
>  
>  static void flush_write_bio(struct extent_page_data *epd);
> @@ -527,6 +526,7 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
>  {
>  	struct extent_state *next;
>  	unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS;
> +	int ret;
>  
>  	if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
>  		u64 range = state->end - state->start + 1;
> @@ -534,7 +534,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
>  		tree->dirty_bytes -= range;
>  	}
>  	clear_state_cb(tree, state, bits);
> -	add_extent_changeset(state, bits_to_clear, changeset, 0);
> +	ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
> +	BUG_ON(ret);

This must be BUG_ON(ret < 0) of course.

>  	state->state &= ~bits_to_clear;
>  	if (wake)
>  		wake_up(&state->wq);
> @@ -805,13 +806,15 @@ static void set_state_bits(struct extent_io_tree *tree,
>  			   unsigned *bits, struct extent_changeset *changeset)
>  {
>  	unsigned bits_to_set = *bits & ~EXTENT_CTLBITS;
> +	int ret;
>  
>  	set_state_cb(tree, state, bits);
>  	if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
>  		u64 range = state->end - state->start + 1;
>  		tree->dirty_bytes += range;
>  	}
> -	add_extent_changeset(state, bits_to_set, changeset, 1);
> +	ret = add_extent_changeset(state, bits_to_set, changeset, 1);
> +	BUG_ON(ret);

Same.

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

end of thread, other threads:[~2018-03-28 14:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 17:44 [PATCH] btrfs: lift errors from add_extent_changeset to the callers David Sterba
2018-03-28 13:57 ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.