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>
This commit is contained in:
David Sterba 2018-03-01 17:56:34 +01:00
Родитель f50f435390
Коммит 57599c7e77
1 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -119,23 +119,22 @@ struct extent_page_data {
unsigned int sync_io:1; 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, struct extent_changeset *changeset,
int set) int set)
{ {
int ret; int ret;
if (!changeset) if (!changeset)
return; return 0;
if (set && (state->state & bits) == bits) if (set && (state->state & bits) == bits)
return; return 0;
if (!set && (state->state & bits) == 0) if (!set && (state->state & bits) == 0)
return; return 0;
changeset->bytes_changed += state->end - state->start + 1; changeset->bytes_changed += state->end - state->start + 1;
ret = ulist_add(&changeset->range_changed, state->start, state->end, ret = ulist_add(&changeset->range_changed, state->start, state->end,
GFP_ATOMIC); GFP_ATOMIC);
/* ENOMEM */ return ret;
BUG_ON(ret < 0);
} }
static void flush_write_bio(struct extent_page_data *epd); 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; struct extent_state *next;
unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS; unsigned bits_to_clear = *bits & ~EXTENT_CTLBITS;
int ret;
if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) { if ((bits_to_clear & EXTENT_DIRTY) && (state->state & EXTENT_DIRTY)) {
u64 range = state->end - state->start + 1; 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; tree->dirty_bytes -= range;
} }
clear_state_cb(tree, state, bits); 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 < 0);
state->state &= ~bits_to_clear; state->state &= ~bits_to_clear;
if (wake) if (wake)
wake_up(&state->wq); 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, struct extent_changeset *changeset)
{ {
unsigned bits_to_set = *bits & ~EXTENT_CTLBITS; unsigned bits_to_set = *bits & ~EXTENT_CTLBITS;
int ret;
set_state_cb(tree, state, bits); set_state_cb(tree, state, bits);
if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) { if ((bits_to_set & EXTENT_DIRTY) && !(state->state & EXTENT_DIRTY)) {
u64 range = state->end - state->start + 1; u64 range = state->end - state->start + 1;
tree->dirty_bytes += range; 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 < 0);
state->state |= bits_to_set; state->state |= bits_to_set;
} }