summaryrefslogtreecommitdiff
path: root/libbcachefs/move.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-13 20:04:21 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2022-11-13 20:07:22 -0500
commitc1e4d447f6dd0ee60495b651436d2055db7777ed (patch)
tree36a657f7018cecc6bad43e0e178ef1913154eba0 /libbcachefs/move.c
parent980f7437e2588d100456640cb863908a3cc6fc77 (diff)
Update bcachefs sources to 8d3fc97ca3 bcachefs: Fixes for building in userspace
Diffstat (limited to 'libbcachefs/move.c')
-rw-r--r--libbcachefs/move.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/libbcachefs/move.c b/libbcachefs/move.c
index 74869204..1d11cf0d 100644
--- a/libbcachefs/move.c
+++ b/libbcachefs/move.c
@@ -53,9 +53,8 @@ struct moving_io {
struct bio_vec bi_inline_vecs[0];
};
-static void move_free(struct closure *cl)
+static void move_free(struct moving_io *io)
{
- struct moving_io *io = container_of(cl, struct moving_io, cl);
struct moving_context *ctxt = io->write.ctxt;
struct bch_fs *c = ctxt->c;
@@ -65,31 +64,30 @@ static void move_free(struct closure *cl)
kfree(io);
}
-static void move_write_done(struct closure *cl)
+static void move_write_done(struct bch_write_op *op)
{
- struct moving_io *io = container_of(cl, struct moving_io, cl);
+ struct moving_io *io = container_of(op, struct moving_io, write.op);
struct moving_context *ctxt = io->write.ctxt;
if (io->write.op.error)
ctxt->write_error = true;
atomic_sub(io->write_sectors, &io->write.ctxt->write_sectors);
- closure_return_with_destructor(cl, move_free);
+ move_free(io);
+ closure_put(&ctxt->cl);
}
-static void move_write(struct closure *cl)
+static void move_write(struct moving_io *io)
{
- struct moving_io *io = container_of(cl, struct moving_io, cl);
-
if (unlikely(io->rbio.bio.bi_status || io->rbio.hole)) {
- closure_return_with_destructor(cl, move_free);
+ move_free(io);
return;
}
+ closure_get(&io->write.ctxt->cl);
atomic_add(io->write_sectors, &io->write.ctxt->write_sectors);
- bch2_data_update_read_done(&io->write, io->rbio.pick.crc, cl);
- continue_at(cl, move_write_done, NULL);
+ bch2_data_update_read_done(&io->write, io->rbio.pick.crc);
}
static inline struct moving_io *next_pending_write(struct moving_context *ctxt)
@@ -121,7 +119,7 @@ static void do_pending_writes(struct moving_context *ctxt, struct btree_trans *t
while ((io = next_pending_write(ctxt))) {
list_del(&io->list);
- closure_call(&io->cl, move_write, NULL, &ctxt->cl);
+ move_write(io);
}
}
@@ -185,7 +183,7 @@ void bch2_moving_ctxt_init(struct moving_context *ctxt,
}
}
-void bch_move_stats_init(struct bch_move_stats *stats, char *name)
+void bch2_move_stats_init(struct bch_move_stats *stats, char *name)
{
memset(stats, 0, sizeof(*stats));
scnprintf(stats->name, sizeof(stats->name), "%s", name);
@@ -302,6 +300,7 @@ static int bch2_move_extent(struct btree_trans *trans,
goto err_free_pages;
io->write.ctxt = ctxt;
+ io->write.op.end_io = move_write_done;
atomic64_inc(&ctxt->stats->keys_moved);
atomic64_add(k.k->size, &ctxt->stats->sectors_moved);
@@ -956,7 +955,7 @@ int bch2_data_job(struct bch_fs *c,
switch (op.op) {
case BCH_DATA_OP_REREPLICATE:
- bch_move_stats_init(stats, "rereplicate");
+ bch2_move_stats_init(stats, "rereplicate");
stats->data_type = BCH_DATA_journal;
ret = bch2_journal_flush_device_pins(&c->journal, -1);
@@ -980,7 +979,7 @@ int bch2_data_job(struct bch_fs *c,
if (op.migrate.dev >= c->sb.nr_devices)
return -EINVAL;
- bch_move_stats_init(stats, "migrate");
+ bch2_move_stats_init(stats, "migrate");
stats->data_type = BCH_DATA_journal;
ret = bch2_journal_flush_device_pins(&c->journal, op.migrate.dev);
@@ -1001,7 +1000,7 @@ int bch2_data_job(struct bch_fs *c,
ret = bch2_replicas_gc2(c) ?: ret;
break;
case BCH_DATA_OP_REWRITE_OLD_NODES:
- bch_move_stats_init(stats, "rewrite_old_nodes");
+ bch2_move_stats_init(stats, "rewrite_old_nodes");
ret = bch2_scan_old_btree_nodes(c, stats);
break;
default: