aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2018-03-01 11:56:34 -0500
committerDavid Sterba <dsterba@suse.com>2018-03-30 20:03:25 -0400
commit57599c7e7722daf5f8c2dba4b0e4628f5c500771 (patch)
treef2593c305cc3565ba422c6336d9b9d146199f8b0
parentf50f43539070c6c876bf5435fb23f898f9d81e72 (diff)
btrfs: lift errors from add_extent_changeset to the callers
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>
-rw-r--r--fs/btrfs/extent_io.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f27bad003f8e..47a8fe9d22e8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -119,23 +119,22 @@ struct extent_page_data {
119 unsigned int sync_io:1; 119 unsigned int sync_io:1;
120}; 120};
121 121
122static void add_extent_changeset(struct extent_state *state, unsigned bits, 122static int add_extent_changeset(struct extent_state *state, unsigned bits,
123 struct extent_changeset *changeset, 123 struct extent_changeset *changeset,
124 int set) 124 int set)
125{ 125{
126 int ret; 126 int ret;
127 127
128 if (!changeset) 128 if (!changeset)
129 return; 129 return 0;
130 if (set && (state->state & bits) == bits) 130 if (set && (state->state & bits) == bits)
131 return; 131 return 0;
132 if (!set && (state->state & bits) == 0) 132 if (!set && (state->state & bits) == 0)
133 return; 133 return 0;
134 changeset->bytes_changed += state->end - state->start + 1; 134 changeset->bytes_changed += state->end - state->start + 1;
135 ret = ulist_add(&changeset->range_changed, state->start, state->end, 135 ret = ulist_add(&changeset->range_changed, state->start, state->end,
136 GFP_ATOMIC); 136 GFP_ATOMIC);
137 /* ENOMEM */ 137 return ret;
138 BUG_ON(ret < 0);
139} 138}
140 139
141static void flush_write_bio(struct extent_page_data *epd); 140static 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,
527{ 526{
528 struct extent_state *next; 527 struct extent_state *next;
529 unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS; 528 unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS;
529 int ret;
530 530
531 if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) { 531 if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
532 u64 range = state->end - state->start + 1; 532 u64 range = state->end - state->start + 1;
@@ -534,7 +534,8 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
534 tree->dirty_bytes -= range; 534 tree->dirty_bytes -= range;
535 } 535 }
536 clear_state_cb(tree, state, bits); 536 clear_state_cb(tree, state, bits);
537 add_extent_changeset(state, bits_to_clear, changeset, 0); 537 ret = add_extent_changeset(state, bits_to_clear, changeset, 0);
538 BUG_ON(ret < 0);
538 state->state &= ~bits_to_clear; 539 state->state &= ~bits_to_clear;
539 if (wake) 540 if (wake)
540 wake_up(&state->wq); 541 wake_up(&state->wq);
@@ -805,13 +806,15 @@ static void set_state_bits(struct extent_io_tree *tree,
805 unsigned *bits, struct extent_changeset *changeset) 806 unsigned *bits, struct extent_changeset *changeset)
806{ 807{
807 unsigned bits_to_set = *bits & ~EXTENT_CTLBITS; 808 unsigned bits_to_set = *bits & ~EXTENT_CTLBITS;
809 int ret;
808 810
809 set_state_cb(tree, state, bits); 811 set_state_cb(tree, state, bits);
810 if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) { 812 if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
811 u64 range = state->end - state->start + 1; 813 u64 range = state->end - state->start + 1;
812 tree->dirty_bytes += range; 814 tree->dirty_bytes += range;
813 } 815 }
814 add_extent_changeset(state, bits_to_set, changeset, 1); 816 ret = add_extent_changeset(state, bits_to_set, changeset, 1);
817 BUG_ON(ret < 0);
815 state->state |= bits_to_set; 818 state->state |= bits_to_set;
816} 819}
817 820