Skip to content

Commit dbd0408

Browse files
author
Kent Overstreet
committed
bcachefs: move replica_set from bch_dev to bch_fs
This is needed for the next patch - the write submit path has to be able to allocate a replica bio even when we weren't able to get a ref on the device. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 633cf06 commit dbd0408

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

fs/bcachefs/bcachefs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,6 @@ struct bch_dev {
569569

570570
struct bch_devs_mask self;
571571

572-
/* biosets used in cloned bios for writing multiple replicas */
573-
struct bio_set replica_set;
574-
575572
/*
576573
* Buckets:
577574
* Per-bucket arrays are protected by c->mark_lock, bucket_lock and
@@ -995,6 +992,7 @@ struct bch_fs {
995992
struct bio_set bio_read;
996993
struct bio_set bio_read_split;
997994
struct bio_set bio_write;
995+
struct bio_set replica_set;
998996
struct mutex bio_bounce_pages_lock;
999997
mempool_t bio_bounce_pages;
1000998
struct bucket_nocow_lock_table

fs/bcachefs/io_write.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,7 @@ void bch2_submit_wbio_replicas(struct bch_write_bio *wbio, struct bch_fs *c,
412412
struct bch_dev *ca = bch2_dev_bkey_exists(c, ptr->dev);
413413

414414
if (to_entry(ptr + 1) < ptrs.end) {
415-
n = to_wbio(bio_alloc_clone(NULL, &wbio->bio,
416-
GFP_NOFS, &ca->replica_set));
415+
n = to_wbio(bio_alloc_clone(NULL, &wbio->bio, GFP_NOFS, &c->replica_set));
417416

418417
n->bio.bi_end_io = wbio->bio.bi_end_io;
419418
n->bio.bi_private = wbio->bio.bi_private;
@@ -1667,13 +1666,14 @@ void bch2_write_op_to_text(struct printbuf *out, struct bch_write_op *op)
16671666
void bch2_fs_io_write_exit(struct bch_fs *c)
16681667
{
16691668
mempool_exit(&c->bio_bounce_pages);
1669+
bioset_exit(&c->replica_set);
16701670
bioset_exit(&c->bio_write);
16711671
}
16721672

16731673
int bch2_fs_io_write_init(struct bch_fs *c)
16741674
{
1675-
if (bioset_init(&c->bio_write, 1, offsetof(struct bch_write_bio, bio),
1676-
BIOSET_NEED_BVECS))
1675+
if (bioset_init(&c->bio_write, 1, offsetof(struct bch_write_bio, bio), BIOSET_NEED_BVECS) ||
1676+
bioset_init(&c->replica_set, 4, offsetof(struct bch_write_bio, bio), 0))
16771677
return -BCH_ERR_ENOMEM_bio_write_init;
16781678

16791679
if (mempool_init_page_pool(&c->bio_bounce_pages,

fs/bcachefs/super.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,6 @@ static void bch2_dev_free(struct bch_dev *ca)
11931193
bch2_dev_journal_exit(ca);
11941194

11951195
free_percpu(ca->io_done);
1196-
bioset_exit(&ca->replica_set);
11971196
bch2_dev_buckets_free(ca);
11981197
free_page((unsigned long) ca->sb_read_scratch);
11991198

@@ -1317,8 +1316,6 @@ static struct bch_dev *__bch2_dev_alloc(struct bch_fs *c,
13171316
PERCPU_REF_INIT_DEAD, GFP_KERNEL) ||
13181317
!(ca->sb_read_scratch = (void *) __get_free_page(GFP_KERNEL)) ||
13191318
bch2_dev_buckets_alloc(c, ca) ||
1320-
bioset_init(&ca->replica_set, 4,
1321-
offsetof(struct bch_write_bio, bio), 0) ||
13221319
!(ca->io_done = alloc_percpu(*ca->io_done)))
13231320
goto err;
13241321

0 commit comments

Comments
 (0)