Skip to content

Commit 6b812f1

Browse files
author
Kent Overstreet
committed
bcachefs: bch2_dev_remove_alloc() -> alloc_background.c
Signed-off-by: Kent Overstreet <[email protected]>
1 parent 8ed4ba3 commit 6b812f1

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,35 @@ int bch2_fs_freespace_init(struct bch_fs *c)
22982298
return 0;
22992299
}
23002300

2301+
/* device removal */
2302+
2303+
int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
2304+
{
2305+
struct bpos start = POS(ca->dev_idx, 0);
2306+
struct bpos end = POS(ca->dev_idx, U64_MAX);
2307+
int ret;
2308+
2309+
/*
2310+
* We clear the LRU and need_discard btrees first so that we don't race
2311+
* with bch2_do_invalidates() and bch2_do_discards()
2312+
*/
2313+
ret = bch2_btree_delete_range(c, BTREE_ID_lru, start, end,
2314+
BTREE_TRIGGER_norun, NULL) ?:
2315+
bch2_btree_delete_range(c, BTREE_ID_need_discard, start, end,
2316+
BTREE_TRIGGER_norun, NULL) ?:
2317+
bch2_btree_delete_range(c, BTREE_ID_freespace, start, end,
2318+
BTREE_TRIGGER_norun, NULL) ?:
2319+
bch2_btree_delete_range(c, BTREE_ID_backpointers, start, end,
2320+
BTREE_TRIGGER_norun, NULL) ?:
2321+
bch2_btree_delete_range(c, BTREE_ID_alloc, start, end,
2322+
BTREE_TRIGGER_norun, NULL) ?:
2323+
bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end,
2324+
BTREE_TRIGGER_norun, NULL) ?:
2325+
bch2_dev_usage_remove(c, ca->dev_idx);
2326+
bch_err_msg(ca, ret, "removing dev alloc info");
2327+
return ret;
2328+
}
2329+
23012330
/* Bucket IO clocks: */
23022331

23032332
int bch2_bucket_io_time_reset(struct btree_trans *trans, unsigned dev,

fs/bcachefs/alloc_background.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ static inline const struct bch_backpointer *alloc_v4_backpointers_c(const struct
338338

339339
int bch2_dev_freespace_init(struct bch_fs *, struct bch_dev *, u64, u64);
340340
int bch2_fs_freespace_init(struct bch_fs *);
341+
int bch2_dev_remove_alloc(struct bch_fs *, struct bch_dev *);
341342

342343
void bch2_recalc_capacity(struct bch_fs *);
343344
u64 bch2_min_rw_member_capacity(struct bch_fs *);

fs/bcachefs/super.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,33 +1592,6 @@ int bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca,
15921592

15931593
/* Device add/removal: */
15941594

1595-
static int bch2_dev_remove_alloc(struct bch_fs *c, struct bch_dev *ca)
1596-
{
1597-
struct bpos start = POS(ca->dev_idx, 0);
1598-
struct bpos end = POS(ca->dev_idx, U64_MAX);
1599-
int ret;
1600-
1601-
/*
1602-
* We clear the LRU and need_discard btrees first so that we don't race
1603-
* with bch2_do_invalidates() and bch2_do_discards()
1604-
*/
1605-
ret = bch2_btree_delete_range(c, BTREE_ID_lru, start, end,
1606-
BTREE_TRIGGER_norun, NULL) ?:
1607-
bch2_btree_delete_range(c, BTREE_ID_need_discard, start, end,
1608-
BTREE_TRIGGER_norun, NULL) ?:
1609-
bch2_btree_delete_range(c, BTREE_ID_freespace, start, end,
1610-
BTREE_TRIGGER_norun, NULL) ?:
1611-
bch2_btree_delete_range(c, BTREE_ID_backpointers, start, end,
1612-
BTREE_TRIGGER_norun, NULL) ?:
1613-
bch2_btree_delete_range(c, BTREE_ID_alloc, start, end,
1614-
BTREE_TRIGGER_norun, NULL) ?:
1615-
bch2_btree_delete_range(c, BTREE_ID_bucket_gens, start, end,
1616-
BTREE_TRIGGER_norun, NULL) ?:
1617-
bch2_dev_usage_remove(c, ca->dev_idx);
1618-
bch_err_msg(c, ret, "removing dev alloc info");
1619-
return ret;
1620-
}
1621-
16221595
int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags)
16231596
{
16241597
struct bch_member *m;

0 commit comments

Comments
 (0)