Skip to content

Commit 8ba73f5

Browse files
author
Kent Overstreet
committed
bcachefs: copygc now skips non-rw devices
There's no point in doing copygc on non-rw devices: the fragmentation doesn't matter if we're not writing to them, and we may not have anywhere to put the data on our other devices. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 33255c1 commit 8ba73f5

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

fs/bcachefs/movinggc.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -74,34 +74,33 @@ static int bch2_bucket_is_movable(struct btree_trans *trans,
7474
struct move_bucket *b, u64 time)
7575
{
7676
struct bch_fs *c = trans->c;
77-
struct btree_iter iter;
78-
struct bkey_s_c k;
79-
struct bch_alloc_v4 _a;
80-
const struct bch_alloc_v4 *a;
81-
int ret;
8277

83-
if (bch2_bucket_is_open(trans->c,
84-
b->k.bucket.inode,
85-
b->k.bucket.offset))
78+
if (bch2_bucket_is_open(c, b->k.bucket.inode, b->k.bucket.offset))
8679
return 0;
8780

88-
k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_alloc,
89-
b->k.bucket, BTREE_ITER_cached);
90-
ret = bkey_err(k);
81+
struct btree_iter iter;
82+
struct bkey_s_c k = bch2_bkey_get_iter(trans, &iter, BTREE_ID_alloc,
83+
b->k.bucket, BTREE_ITER_cached);
84+
int ret = bkey_err(k);
9185
if (ret)
9286
return ret;
9387

9488
struct bch_dev *ca = bch2_dev_tryget(c, k.k->p.inode);
9589
if (!ca)
9690
goto out;
9791

98-
a = bch2_alloc_to_v4(k, &_a);
92+
if (ca->mi.state != BCH_MEMBER_STATE_rw ||
93+
!bch2_dev_is_online(ca))
94+
goto out_put;
95+
96+
struct bch_alloc_v4 _a;
97+
const struct bch_alloc_v4 *a = bch2_alloc_to_v4(k, &_a);
9998
b->k.gen = a->gen;
10099
b->sectors = bch2_bucket_sectors_dirty(*a);
101100
u64 lru_idx = alloc_lru_idx_fragmentation(*a, ca);
102101

103102
ret = lru_idx && lru_idx <= time;
104-
103+
out_put:
105104
bch2_dev_put(ca);
106105
out:
107106
bch2_trans_iter_exit(trans, &iter);

0 commit comments

Comments
 (0)