summaryrefslogtreecommitdiff
path: root/fs/bcachefs/move.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-14 01:31:10 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:51 -0400
commit4dcd1cae72912ab08d313ee5a730608022b211d4 (patch)
tree1e44e47d2061f60ef1e88d677354bbbde846567d /fs/bcachefs/move.c
parent792031116bee35e13be7c8ae8cf1b8eec141b136 (diff)
downloadlwn-4dcd1cae72912ab08d313ee5a730608022b211d4.tar.gz
lwn-4dcd1cae72912ab08d313ee5a730608022b211d4.zip
bcachefs: Data update support for unwritten extents
The data update path requires special support for unwritten extents - we still need to be able to move them, but there's no need to read or write anything. This patch adds a new error code to tell bch2_move_extent() that we're short circuiting the read, and adds bch2_update_unwritten_extent() to create a reservation then call __bch2_data_update_index_update(). Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/move.c')
-rw-r--r--fs/bcachefs/move.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/bcachefs/move.c b/fs/bcachefs/move.c
index 8eb4978cc043..52f126a0bb73 100644
--- a/fs/bcachefs/move.c
+++ b/fs/bcachefs/move.c
@@ -295,7 +295,7 @@ static int bch2_move_extent(struct btree_trans *trans,
ret = bch2_data_update_init(c, &io->write, ctxt->wp, io_opts,
data_opts, btree_id, k);
- if (ret)
+ if (ret && ret != -BCH_ERR_unwritten_extent_update)
goto err_free_pages;
io->write.ctxt = ctxt;
@@ -303,6 +303,15 @@ static int bch2_move_extent(struct btree_trans *trans,
atomic64_inc(&ctxt->stats->keys_moved);
atomic64_add(k.k->size, &ctxt->stats->sectors_moved);
+
+ if (ret == -BCH_ERR_unwritten_extent_update) {
+ bch2_update_unwritten_extent(trans, &io->write);
+ move_free(io);
+ return 0;
+ }
+
+ BUG_ON(ret);
+
this_cpu_add(c->counters[BCH_COUNTER_io_move], k.k->size);
this_cpu_add(c->counters[BCH_COUNTER_move_extent_read], k.k->size);
trace_move_extent_read(k.k);