summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-02-28 23:23:37 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2025-04-29 13:44:32 -0400
commit9b5701441bdaa6e8f6fdb4441494b83d84997b55 (patch)
tree6ddb1372b641152a6e316bda470cd52c65316541
parentbb8d05128f8818831d2c77515be7254502cbb4a1 (diff)
bcachefs: bch_write_step
Prep work and refactoring for the next patch, BCH_WRITE_WAIT_FOR_EC. This changes the control flow so that __bch2_write_index() returns the next thing to be; next patch will be adding to the new enum. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/io_write.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c
index 1c0d5503aa3c..570759337f03 100644
--- a/fs/bcachefs/io_write.c
+++ b/fs/bcachefs/io_write.c
@@ -552,11 +552,16 @@ static noinline int bch2_write_drop_io_error_ptrs(struct bch_write_op *op)
return 0;
}
+enum bch_write_step {
+ BCH_WRITE_STEP_MORE,
+ BCH_WRITE_STEP_DONE,
+};
+
/**
* __bch2_write_index - after a write, update index to point to new data
* @op: bch_write_op to process
*/
-static void __bch2_write_index(struct bch_write_op *op)
+static enum bch_write_step __bch2_write_index(struct bch_write_op *op)
{
struct bch_fs *c = op->c;
struct keylist *keys = &op->insert_keys;
@@ -597,7 +602,9 @@ out:
bch2_open_bucket_write_error(c, &op->open_buckets, dev, -BCH_ERR_data_write_io);
bch2_open_buckets_put(c, &op->open_buckets);
- return;
+ return op->flags & BCH_WRITE_DONE
+ ? BCH_WRITE_STEP_DONE
+ : BCH_WRITE_STEP_MORE;
err:
keys->top = keys->keys;
op->error = ret;
@@ -685,12 +692,24 @@ void bch2_write_point_do_index_updates(struct work_struct *work)
op->flags |= BCH_WRITE_in_worker;
+<<<<<<< HEAD
__bch2_write_index(op);
if (!(op->flags & BCH_WRITE_submitted))
+||||||| parent of 8b2899517024 (bcachefs: bch_write_step)
+ __bch2_write_index(op);
+
+ if (!(op->flags & BCH_WRITE_SUBMITTED))
+=======
+ switch (__bch2_write_index(op)) {
+ case BCH_WRITE_STEP_MORE:
+>>>>>>> 8b2899517024 (bcachefs: bch_write_step)
__bch2_write(op);
- else
+ break;
+ case BCH_WRITE_STEP_DONE:
bch2_write_done(&op->cl);
+ break;
+ }
}
}
@@ -1631,11 +1650,13 @@ err:
!(op->flags & BCH_WRITE_in_worker))) {
bch2_wait_on_allocator(c, &op->cl);
- __bch2_write_index(op);
-
- if (!(op->flags & BCH_WRITE_submitted))
+ switch (__bch2_write_index(op)) {
+ case BCH_WRITE_STEP_MORE:
goto again;
- bch2_write_done(&op->cl);
+ case BCH_WRITE_STEP_DONE:
+ bch2_write_done(&op->cl);
+ break;
+ }
} else {
bch2_write_queue(op, wp);
continue_at(&op->cl, bch2_write_index, NULL);
@@ -1684,7 +1705,7 @@ static void bch2_write_data_inline(struct bch_write_op *op, unsigned data_len)
set_bkey_val_bytes(&id->k, data_len);
bch2_keylist_push(&op->insert_keys);
- __bch2_write_index(op);
+ BUG_ON(__bch2_write_index(op) != BCH_WRITE_STEP_DONE);
err:
bch2_write_done(&op->cl);
}