diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-04-30 17:15:39 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:21 -0400 |
commit | ae0ff7b8b0ccf0643ea4d3968faabb2d5ee98c1c (patch) | |
tree | 059b8cb3b184eda983bed7f13e7d8910d5753804 /fs/bcachefs/migrate.c | |
parent | 9516950c0690b6a8bef4cc1c7ae269da996973d8 (diff) |
bcachefs: Redo replicas gc mechanism
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/migrate.c')
-rw-r--r-- | fs/bcachefs/migrate.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/fs/bcachefs/migrate.c b/fs/bcachefs/migrate.c index f9e6c9d9ef04..6b17d7918aa4 100644 --- a/fs/bcachefs/migrate.c +++ b/fs/bcachefs/migrate.c @@ -48,10 +48,6 @@ static int bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags) iter = bch2_trans_get_iter(&trans, BTREE_ID_EXTENTS, POS_MIN, BTREE_ITER_PREFETCH); - mutex_lock(&c->replicas_gc_lock); - bch2_replicas_gc_start(c, (1 << BCH_DATA_USER)|(1 << BCH_DATA_CACHED)); - - while ((k = bch2_btree_iter_peek(iter)).k && !(ret = bkey_err(k))) { if (!bkey_extent_is_data(k.k) || @@ -97,12 +93,9 @@ static int bch2_dev_usrdata_drop(struct bch_fs *c, unsigned dev_idx, int flags) break; } - BUG_ON(ret == -EINTR); - - bch2_trans_exit(&trans); + ret = bch2_trans_exit(&trans) ?: ret; - bch2_replicas_gc_end(c, ret); - mutex_unlock(&c->replicas_gc_lock); + BUG_ON(ret == -EINTR); return ret; } @@ -123,9 +116,6 @@ static int bch2_dev_metadata_drop(struct bch_fs *c, unsigned dev_idx, int flags) bch2_trans_init(&trans, c); closure_init_stack(&cl); - mutex_lock(&c->replicas_gc_lock); - bch2_replicas_gc_start(c, 1 << BCH_DATA_BTREE); - for (id = 0; id < BTREE_ID_NR; id++) { for_each_btree_node(&trans, iter, id, POS_MIN, BTREE_ITER_PREFETCH, b) { @@ -178,10 +168,9 @@ retry: ret = 0; err: - bch2_trans_exit(&trans); + ret = bch2_trans_exit(&trans) ?: ret; - ret = bch2_replicas_gc_end(c, ret); - mutex_unlock(&c->replicas_gc_lock); + BUG_ON(ret == -EINTR); return ret; } @@ -189,5 +178,6 @@ err: int bch2_dev_data_drop(struct bch_fs *c, unsigned dev_idx, int flags) { return bch2_dev_usrdata_drop(c, dev_idx, flags) ?: - bch2_dev_metadata_drop(c, dev_idx, flags); + bch2_dev_metadata_drop(c, dev_idx, flags) ?: + bch2_replicas_gc2(c); } |