summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-01-14 15:20:04 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2025-03-06 18:15:01 -0500
commit80da5c23ee83daaa409756e0ebf468d0b241bbae (patch)
tree69a5b37407b8799dd5aa16d2fcdceeaad0ec6761
parent9b8e1efed210902bd18f73c4aabcb1e5544b1a5a (diff)
bcachefs: rbio_init_fragment()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/io_read.c18
-rw-r--r--fs/bcachefs/io_read.h14
2 files changed, 21 insertions, 11 deletions
diff --git a/fs/bcachefs/io_read.c b/fs/bcachefs/io_read.c
index c54d9e79837b..6800d50bf9a2 100644
--- a/fs/bcachefs/io_read.c
+++ b/fs/bcachefs/io_read.c
@@ -177,6 +177,7 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
struct bch_io_failures *failed)
{
struct bch_fs *c = trans->c;
+ struct bch_read_bio *orig = *rbio;
struct promote_op *op = NULL;
struct bio *bio;
unsigned pages = DIV_ROUND_UP(sectors, PAGE_SECTORS);
@@ -206,7 +207,7 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
goto err;
}
- rbio_init(&(*rbio)->bio, opts);
+ rbio_init_fragment(&(*rbio)->bio, orig);
bio_init(&(*rbio)->bio, NULL, (*rbio)->bio.bi_inline_vecs, pages, 0);
if (bch2_bio_alloc_pages(&(*rbio)->bio, sectors << 9, GFP_KERNEL)) {
@@ -215,7 +216,6 @@ static struct promote_op *__promote_alloc(struct btree_trans *trans,
}
(*rbio)->bounce = true;
- (*rbio)->split = true;
(*rbio)->kmalloc = true;
if (rhashtable_lookup_insert_fast(&c->promote_table, &op->hash,
@@ -1033,16 +1033,15 @@ get_bio:
} else if (bounce) {
unsigned sectors = pick.crc.compressed_size;
- rbio = rbio_init(bio_alloc_bioset(NULL,
+ rbio = rbio_init_fragment(bio_alloc_bioset(NULL,
DIV_ROUND_UP(sectors, PAGE_SECTORS),
0,
GFP_NOFS,
&c->bio_read_split),
- orig->opts);
+ orig);
bch2_bio_alloc_pages_pool(c, &rbio->bio, sectors << 9);
rbio->bounce = true;
- rbio->split = true;
} else if (flags & BCH_READ_must_clone) {
/*
* Have to clone if there were any splits, due to error
@@ -1052,11 +1051,10 @@ get_bio:
* from the whole bio, in which case we don't want to retry and
* lose the error)
*/
- rbio = rbio_init(bio_alloc_clone(NULL, &orig->bio, GFP_NOFS,
+ rbio = rbio_init_fragment(bio_alloc_clone(NULL, &orig->bio, GFP_NOFS,
&c->bio_read_split),
- orig->opts);
+ orig);
rbio->bio.bi_iter = iter;
- rbio->split = true;
} else {
rbio = orig;
rbio->bio.bi_iter = iter;
@@ -1067,9 +1065,7 @@ get_bio:
rbio->c = c;
rbio->submit_time = local_clock();
- if (rbio->split)
- rbio->parent = orig;
- else
+ if (!rbio->split)
rbio->end_io = orig->bio.bi_end_io;
rbio->bvec_iter = iter;
rbio->offset_into_extent= offset_into_extent;
diff --git a/fs/bcachefs/io_read.h b/fs/bcachefs/io_read.h
index ef5603daf122..11fdf73a38b1 100644
--- a/fs/bcachefs/io_read.h
+++ b/fs/bcachefs/io_read.h
@@ -162,6 +162,20 @@ static inline void bch2_read(struct bch_fs *c, struct bch_read_bio *rbio,
BCH_READ_user_mapped);
}
+
+static inline struct bch_read_bio *rbio_init_fragment(struct bio *bio,
+ struct bch_read_bio *orig)
+{
+ struct bch_read_bio *rbio = to_rbio(bio);
+
+ rbio->_state = 0;
+ rbio->split = true;
+ rbio->parent = orig;
+ rbio->promote = NULL;
+ rbio->opts = orig->opts;
+ return rbio;
+}
+
static inline struct bch_read_bio *rbio_init(struct bio *bio,
struct bch_io_opts opts)
{