Skip to content

Commit 83ccd9b

Browse files
author
Kent Overstreet
committed
bcachefs: bch_fs.rw_devs_change_count
Add a counter that's incremented whenever rw devices change; this will be used for erasure coding so that it can keep ec_stripe_head in sync and not deadlock on a new stripe when a device it wants goes away. Signed-off-by: Kent Overstreet <[email protected]>
1 parent ad8d1f7 commit 83ccd9b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

fs/bcachefs/alloc_background.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2463,13 +2463,15 @@ static bool bch2_dev_has_open_write_point(struct bch_fs *c, struct bch_dev *ca)
24632463
/* device goes ro: */
24642464
void bch2_dev_allocator_remove(struct bch_fs *c, struct bch_dev *ca)
24652465
{
2466-
unsigned i;
2466+
lockdep_assert_held(&c->state_lock);
24672467

24682468
/* First, remove device from allocation groups: */
24692469

2470-
for (i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
2470+
for (unsigned i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
24712471
clear_bit(ca->dev_idx, c->rw_devs[i].d);
24722472

2473+
c->rw_devs_change_count++;
2474+
24732475
/*
24742476
* Capacity is calculated based off of devices in allocation groups:
24752477
*/
@@ -2498,11 +2500,13 @@ void bch2_dev_allocator_remove(struct bch_fs *c, struct bch_dev *ca)
24982500
/* device goes rw: */
24992501
void bch2_dev_allocator_add(struct bch_fs *c, struct bch_dev *ca)
25002502
{
2501-
unsigned i;
2503+
lockdep_assert_held(&c->state_lock);
25022504

2503-
for (i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
2505+
for (unsigned i = 0; i < ARRAY_SIZE(c->rw_devs); i++)
25042506
if (ca->mi.data_allowed & (1 << i))
25052507
set_bit(ca->dev_idx, c->rw_devs[i].d);
2508+
2509+
c->rw_devs_change_count++;
25062510
}
25072511

25082512
void bch2_dev_allocator_background_exit(struct bch_dev *ca)

fs/bcachefs/bcachefs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ struct bch_fs {
871871

872872
/* ALLOCATION */
873873
struct bch_devs_mask rw_devs[BCH_DATA_NR];
874+
unsigned long rw_devs_change_count;
874875

875876
u64 capacity; /* sectors */
876877
u64 reserved; /* sectors */

0 commit comments

Comments
 (0)