]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: rbio_init_fragment()
authorKent Overstreet <kent.overstreet@linux.dev>
Tue, 14 Jan 2025 20:20:04 +0000 (15:20 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 15 Mar 2025 01:02:11 +0000 (21:02 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/io_read.c
fs/bcachefs/io_read.h

index 539b48f94523198ae9935a57af0e8e7936179055..3b474c679fb49e83d08282b85a4a8a46d689f6a7 100644 (file)
@@ -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,
@@ -1024,16 +1024,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
@@ -1043,11 +1042,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;
@@ -1058,9 +1056,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;
index ef5603daf122f03a18447b7ee9874d4c895be961..11fdf73a38b1dd07d6923c10671c2ab27d769312 100644 (file)
@@ -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)
 {