summaryrefslogtreecommitdiff
path: root/libbcachefs/move.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-12-13 18:27:31 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2022-12-13 18:27:31 -0500
commit3c0484687d00f3f2818d13c0c6f65123abcf4517 (patch)
treebf288e3d6c1f0c085db0af3fb472f2214c7775f0 /libbcachefs/move.c
parenta06dee6da2babd19a392ff30a399b89b85018a36 (diff)
Update bcachefs sources to 84505cfd37 bcachefs: Go RW before check_alloc_info()
Diffstat (limited to 'libbcachefs/move.c')
-rw-r--r--libbcachefs/move.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/libbcachefs/move.c b/libbcachefs/move.c
index 47b77b3c..b308354a 100644
--- a/libbcachefs/move.c
+++ b/libbcachefs/move.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "bcachefs.h"
+#include "alloc_background.h"
#include "alloc_foreground.h"
#include "backpointers.h"
#include "bkey_buf.h"
@@ -257,7 +258,7 @@ static int bch2_move_extent(struct btree_trans *trans,
}
if (!percpu_ref_tryget_live(&c->writes))
- return -EROFS;
+ return -BCH_ERR_erofs_no_writes;
/*
* Before memory allocations & taking nocow locks in
@@ -661,13 +662,29 @@ int __bch2_evacuate_bucket(struct moving_context *ctxt,
struct btree_iter iter;
struct bkey_buf sk;
struct bch_backpointer bp;
+ struct bch_alloc_v4 a_convert;
+ const struct bch_alloc_v4 *a;
+ struct bkey_s_c k;
struct data_update_opts data_opts;
+ unsigned dirty_sectors, bucket_size;
u64 bp_offset = 0, cur_inum = U64_MAX;
int ret = 0;
bch2_bkey_buf_init(&sk);
bch2_trans_init(&trans, c, 0, 0);
+ bch2_trans_iter_init(&trans, &iter, BTREE_ID_alloc,
+ bucket, BTREE_ITER_CACHED);
+ ret = lockrestart_do(&trans,
+ bkey_err(k = bch2_btree_iter_peek_slot(&iter)));
+ bch2_trans_iter_exit(&trans, &iter);
+
+ if (!ret) {
+ a = bch2_alloc_to_v4(k, &a_convert);
+ dirty_sectors = a->dirty_sectors;
+ bucket_size = bch_dev_bkey_exists(c, bucket.inode)->mi.bucket_size;
+ }
+
while (!(ret = move_ratelimit(&trans, ctxt))) {
bch2_trans_begin(&trans);
@@ -765,6 +782,8 @@ int __bch2_evacuate_bucket(struct moving_context *ctxt,
bp_offset++;
}
+ trace_evacuate_bucket(c, &bucket, dirty_sectors, bucket_size, ret);
+
if (IS_ENABLED(CONFIG_BCACHEFS_DEBUG) && gen >= 0) {
bch2_trans_unlock(&trans);
move_ctxt_wait_event(ctxt, NULL, list_empty(&ctxt->reads));