diff options
| author | Kent Overstreet <kent.overstreet@linux.dev> | 2025-03-29 23:11:08 -0400 |
|---|---|---|
| committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-04-02 10:24:34 -0400 |
| commit | dcffc3b1ae3251d796a25c673f614e3099ca83d3 (patch) | |
| tree | 7b5a5ada3f5ca8e5bda8ab38a396f2c3730fd792 /fs/bcachefs/io_write.c | |
| parent | bcachefs: fix ref leak in btree_node_read_all_replicas (diff) | |
| download | linux-dcffc3b1ae3251d796a25c673f614e3099ca83d3.tar.gz linux-dcffc3b1ae3251d796a25c673f614e3099ca83d3.zip | |
bcachefs: Split up bch_dev.io_ref
We now have separate per device io_refs for read and write access.
This fixes a device removal bug where the discard workers were still
running while we're removing alloc info for that device.
It's also a bit of hardening; we no longer allow writes to devices that
are read-only.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/io_write.c')
| -rw-r--r-- | fs/bcachefs/io_write.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/bcachefs/io_write.c b/fs/bcachefs/io_write.c index 0503ac1952cd..4f6a574cf23b 100644 --- a/fs/bcachefs/io_write.c +++ b/fs/bcachefs/io_write.c @@ -445,6 +445,11 @@ void bch2_submit_wbio_replicas(struct bch_write_bio *wbio, struct bch_fs *c, BUG_ON(c->opts.nochanges); bkey_for_each_ptr(ptrs, ptr) { + /* + * XXX: btree writes should be using io_ref[WRITE], but we + * aren't retrying failed btree writes yet (due to device + * removal/ro): + */ struct bch_dev *ca = nocow ? bch2_dev_have_ref(c, ptr->dev) : bch2_dev_get_ioref(c, ptr->dev, type == BCH_DATA_btree ? READ : WRITE); @@ -722,7 +727,7 @@ static void bch2_write_endio(struct bio *bio) } if (wbio->have_ioref) - percpu_ref_put(&ca->io_ref); + percpu_ref_put(&ca->io_ref[WRITE]); if (wbio->bounce) bch2_bio_free_pages_pool(c, bio); @@ -1421,7 +1426,7 @@ err: return; err_get_ioref: darray_for_each(buckets, i) - percpu_ref_put(&bch2_dev_have_ref(c, i->b.inode)->io_ref); + percpu_ref_put(&bch2_dev_have_ref(c, i->b.inode)->io_ref[WRITE]); /* Fall back to COW path: */ goto out; |
