Commit e0eaf862 authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: Factor out bch2_write_drop_io_error_ptrs()

Move slowpath code to a separate, non-inline function.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 99e2146b
...@@ -615,17 +615,11 @@ static void bch2_write_done(struct closure *cl) ...@@ -615,17 +615,11 @@ static void bch2_write_done(struct closure *cl)
op->end_io(op); op->end_io(op);
} }
/** static noinline int bch2_write_drop_io_error_ptrs(struct bch_write_op *op)
* bch_write_index - after a write, update index to point to new data
*/
static void __bch2_write_index(struct bch_write_op *op)
{ {
struct bch_fs *c = op->c;
struct keylist *keys = &op->insert_keys; struct keylist *keys = &op->insert_keys;
struct bch_extent_ptr *ptr; struct bch_extent_ptr *ptr;
struct bkey_i *src, *dst = keys->keys, *n, *k; struct bkey_i *src, *dst = keys->keys, *n;
unsigned dev;
int ret = 0;
for (src = keys->keys; src != keys->top; src = n) { for (src = keys->keys; src != keys->top; src = n) {
n = bkey_next(src); n = bkey_next(src);
...@@ -634,10 +628,8 @@ static void __bch2_write_index(struct bch_write_op *op) ...@@ -634,10 +628,8 @@ static void __bch2_write_index(struct bch_write_op *op)
bch2_bkey_drop_ptrs(bkey_i_to_s(src), ptr, bch2_bkey_drop_ptrs(bkey_i_to_s(src), ptr,
test_bit(ptr->dev, op->failed.d)); test_bit(ptr->dev, op->failed.d));
if (!bch2_bkey_nr_ptrs(bkey_i_to_s_c(src))) { if (!bch2_bkey_nr_ptrs(bkey_i_to_s_c(src)))
ret = -EIO; return -EIO;
goto err;
}
} }
if (dst != src) if (dst != src)
...@@ -646,6 +638,25 @@ static void __bch2_write_index(struct bch_write_op *op) ...@@ -646,6 +638,25 @@ static void __bch2_write_index(struct bch_write_op *op)
} }
keys->top = dst; keys->top = dst;
return 0;
}
/**
* bch_write_index - after a write, update index to point to new data
*/
static void __bch2_write_index(struct bch_write_op *op)
{
struct bch_fs *c = op->c;
struct keylist *keys = &op->insert_keys;
struct bkey_i *k;
unsigned dev;
int ret = 0;
if (unlikely(op->flags & BCH_WRITE_IO_ERROR)) {
ret = bch2_write_drop_io_error_ptrs(op);
if (ret)
goto err;
}
/* /*
* probably not the ideal place to hook this in, but I don't * probably not the ideal place to hook this in, but I don't
...@@ -787,8 +798,10 @@ static void bch2_write_endio(struct bio *bio) ...@@ -787,8 +798,10 @@ static void bch2_write_endio(struct bio *bio)
op->pos.inode, op->pos.inode,
op->pos.offset - bio_sectors(bio), /* XXX definitely wrong */ op->pos.offset - bio_sectors(bio), /* XXX definitely wrong */
"data write error: %s", "data write error: %s",
bch2_blk_status_to_str(bio->bi_status))) bch2_blk_status_to_str(bio->bi_status))) {
set_bit(wbio->dev, op->failed.d); set_bit(wbio->dev, op->failed.d);
op->flags |= BCH_WRITE_IO_ERROR;
}
if (wbio->have_ioref) { if (wbio->have_ioref) {
bch2_latency_acct(ca, wbio->submit_time, WRITE); bch2_latency_acct(ca, wbio->submit_time, WRITE);
......
...@@ -43,6 +43,7 @@ enum bch_write_flags { ...@@ -43,6 +43,7 @@ enum bch_write_flags {
__BCH_WRITE_JOURNAL_SEQ_PTR, __BCH_WRITE_JOURNAL_SEQ_PTR,
__BCH_WRITE_IN_WORKER, __BCH_WRITE_IN_WORKER,
__BCH_WRITE_DONE, __BCH_WRITE_DONE,
__BCH_WRITE_IO_ERROR,
}; };
#define BCH_WRITE_ALLOC_NOWAIT (1U << __BCH_WRITE_ALLOC_NOWAIT) #define BCH_WRITE_ALLOC_NOWAIT (1U << __BCH_WRITE_ALLOC_NOWAIT)
...@@ -61,6 +62,7 @@ enum bch_write_flags { ...@@ -61,6 +62,7 @@ enum bch_write_flags {
#define BCH_WRITE_JOURNAL_SEQ_PTR (1U << __BCH_WRITE_JOURNAL_SEQ_PTR) #define BCH_WRITE_JOURNAL_SEQ_PTR (1U << __BCH_WRITE_JOURNAL_SEQ_PTR)
#define BCH_WRITE_IN_WORKER (1U << __BCH_WRITE_IN_WORKER) #define BCH_WRITE_IN_WORKER (1U << __BCH_WRITE_IN_WORKER)
#define BCH_WRITE_DONE (1U << __BCH_WRITE_DONE) #define BCH_WRITE_DONE (1U << __BCH_WRITE_DONE)
#define BCH_WRITE_IO_ERROR (1U << __BCH_WRITE_IO_ERROR)
static inline u64 *op_journal_seq(struct bch_write_op *op) static inline u64 *op_journal_seq(struct bch_write_op *op)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment