Skip to content

Commit ad0d9e7

Browse files
Mike Christieaxboe
authored andcommitted
bcache: use bio op accessors
Separate the op from the rq_flag_bits and have bcache set/get the bio using bio_set_op_attrs/bio_op. Signed-off-by: Mike Christie <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent e604714 commit ad0d9e7

File tree

7 files changed

+31
-28
lines changed

7 files changed

+31
-28
lines changed

drivers/md/bcache/btree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,10 @@ static void bch_btree_node_read(struct btree *b)
294294
closure_init_stack(&cl);
295295

296296
bio = bch_bbio_alloc(b->c);
297-
bio->bi_rw = REQ_META|READ_SYNC;
298297
bio->bi_iter.bi_size = KEY_SIZE(&b->key) << 9;
299298
bio->bi_end_io = btree_node_read_endio;
300299
bio->bi_private = &cl;
300+
bio_set_op_attrs(bio, REQ_OP_READ, REQ_META|READ_SYNC);
301301

302302
bch_bio_map(bio, b->keys.set[0].data);
303303

@@ -396,8 +396,8 @@ static void do_btree_node_write(struct btree *b)
396396

397397
b->bio->bi_end_io = btree_node_write_endio;
398398
b->bio->bi_private = cl;
399-
b->bio->bi_rw = REQ_META|WRITE_SYNC|REQ_FUA;
400399
b->bio->bi_iter.bi_size = roundup(set_bytes(i), block_bytes(b->c));
400+
bio_set_op_attrs(b->bio, REQ_OP_WRITE, REQ_META|WRITE_SYNC|REQ_FUA);
401401
bch_bio_map(b->bio, i);
402402

403403
/*

drivers/md/bcache/debug.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void bch_btree_verify(struct btree *b)
5252
bio->bi_bdev = PTR_CACHE(b->c, &b->key, 0)->bdev;
5353
bio->bi_iter.bi_sector = PTR_OFFSET(&b->key, 0);
5454
bio->bi_iter.bi_size = KEY_SIZE(&v->key) << 9;
55-
bio->bi_rw = REQ_META|READ_SYNC;
55+
bio_set_op_attrs(bio, REQ_OP_READ, REQ_META|READ_SYNC);
5656
bch_bio_map(bio, sorted);
5757

5858
submit_bio_wait(bio);
@@ -114,7 +114,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
114114
check = bio_clone(bio, GFP_NOIO);
115115
if (!check)
116116
return;
117-
check->bi_rw |= READ_SYNC;
117+
bio_set_op_attrs(check, REQ_OP_READ, READ_SYNC);
118118

119119
if (bio_alloc_pages(check, GFP_NOIO))
120120
goto out_put;

drivers/md/bcache/journal.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ reread: left = ca->sb.bucket_size - offset;
5454
bio_reset(bio);
5555
bio->bi_iter.bi_sector = bucket + offset;
5656
bio->bi_bdev = ca->bdev;
57-
bio->bi_rw = READ;
5857
bio->bi_iter.bi_size = len << 9;
5958

6059
bio->bi_end_io = journal_read_endio;
6160
bio->bi_private = &cl;
61+
bio_set_op_attrs(bio, REQ_OP_READ, 0);
6262
bch_bio_map(bio, data);
6363

6464
closure_bio_submit(bio, &cl);
@@ -449,10 +449,10 @@ static void do_journal_discard(struct cache *ca)
449449
atomic_set(&ja->discard_in_flight, DISCARD_IN_FLIGHT);
450450

451451
bio_init(bio);
452+
bio_set_op_attrs(bio, REQ_OP_DISCARD, 0);
452453
bio->bi_iter.bi_sector = bucket_to_sector(ca->set,
453454
ca->sb.d[ja->discard_idx]);
454455
bio->bi_bdev = ca->bdev;
455-
bio->bi_rw = REQ_WRITE|REQ_DISCARD;
456456
bio->bi_max_vecs = 1;
457457
bio->bi_io_vec = bio->bi_inline_vecs;
458458
bio->bi_iter.bi_size = bucket_bytes(ca);
@@ -626,11 +626,12 @@ static void journal_write_unlocked(struct closure *cl)
626626
bio_reset(bio);
627627
bio->bi_iter.bi_sector = PTR_OFFSET(k, i);
628628
bio->bi_bdev = ca->bdev;
629-
bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA;
630629
bio->bi_iter.bi_size = sectors << 9;
631630

632631
bio->bi_end_io = journal_write_endio;
633632
bio->bi_private = w;
633+
bio_set_op_attrs(bio, REQ_OP_WRITE,
634+
REQ_SYNC|REQ_META|REQ_FLUSH|REQ_FUA);
634635
bch_bio_map(bio, w->data);
635636

636637
trace_bcache_journal_write(bio);

drivers/md/bcache/movinggc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static void read_moving(struct cache_set *c)
163163
moving_init(io);
164164
bio = &io->bio.bio;
165165

166-
bio->bi_rw = READ;
166+
bio_set_op_attrs(bio, REQ_OP_READ, 0);
167167
bio->bi_end_io = read_moving_endio;
168168

169169
if (bio_alloc_pages(bio, GFP_KERNEL))

drivers/md/bcache/request.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static void bch_data_insert_start(struct closure *cl)
253253
trace_bcache_cache_insert(k);
254254
bch_keylist_push(&op->insert_keys);
255255

256-
n->bi_rw |= REQ_WRITE;
256+
bio_set_op_attrs(n, REQ_OP_WRITE, 0);
257257
bch_submit_bbio(n, op->c, k, 0);
258258
} while (n != bio);
259259

@@ -378,7 +378,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
378378

379379
if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) ||
380380
c->gc_stats.in_use > CUTOFF_CACHE_ADD ||
381-
(bio->bi_rw & REQ_DISCARD))
381+
(bio_op(bio) == REQ_OP_DISCARD))
382382
goto skip;
383383

384384
if (mode == CACHE_MODE_NONE ||
@@ -899,7 +899,7 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
899899
* But check_overlapping drops dirty keys for which io hasn't started,
900900
* so we still want to call it.
901901
*/
902-
if (bio->bi_rw & REQ_DISCARD)
902+
if (bio_op(bio) == REQ_OP_DISCARD)
903903
s->iop.bypass = true;
904904

905905
if (should_writeback(dc, s->orig_bio,
@@ -913,7 +913,7 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
913913
s->iop.bio = s->orig_bio;
914914
bio_get(s->iop.bio);
915915

916-
if (!(bio->bi_rw & REQ_DISCARD) ||
916+
if ((bio_op(bio) != REQ_OP_DISCARD) ||
917917
blk_queue_discard(bdev_get_queue(dc->bdev)))
918918
closure_bio_submit(bio, cl);
919919
} else if (s->iop.writeback) {
@@ -925,10 +925,10 @@ static void cached_dev_write(struct cached_dev *dc, struct search *s)
925925
struct bio *flush = bio_alloc_bioset(GFP_NOIO, 0,
926926
dc->disk.bio_split);
927927

928-
flush->bi_rw = WRITE_FLUSH;
929928
flush->bi_bdev = bio->bi_bdev;
930929
flush->bi_end_io = request_endio;
931930
flush->bi_private = cl;
931+
bio_set_op_attrs(flush, REQ_OP_WRITE, WRITE_FLUSH);
932932

933933
closure_bio_submit(flush, cl);
934934
}
@@ -992,7 +992,7 @@ static blk_qc_t cached_dev_make_request(struct request_queue *q,
992992
cached_dev_read(dc, s);
993993
}
994994
} else {
995-
if ((bio->bi_rw & REQ_DISCARD) &&
995+
if ((bio_op(bio) == REQ_OP_DISCARD) &&
996996
!blk_queue_discard(bdev_get_queue(dc->bdev)))
997997
bio_endio(bio);
998998
else
@@ -1103,7 +1103,7 @@ static blk_qc_t flash_dev_make_request(struct request_queue *q,
11031103
&KEY(d->id, bio->bi_iter.bi_sector, 0),
11041104
&KEY(d->id, bio_end_sector(bio), 0));
11051105

1106-
s->iop.bypass = (bio->bi_rw & REQ_DISCARD) != 0;
1106+
s->iop.bypass = (bio_op(bio) == REQ_OP_DISCARD) != 0;
11071107
s->iop.writeback = true;
11081108
s->iop.bio = bio;
11091109

drivers/md/bcache/super.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ static void __write_super(struct cache_sb *sb, struct bio *bio)
212212
unsigned i;
213213

214214
bio->bi_iter.bi_sector = SB_SECTOR;
215-
bio->bi_rw = REQ_WRITE|REQ_SYNC|REQ_META;
216215
bio->bi_iter.bi_size = SB_SIZE;
216+
bio_set_op_attrs(bio, REQ_OP_WRITE, REQ_SYNC|REQ_META);
217217
bch_bio_map(bio, NULL);
218218

219219
out->offset = cpu_to_le64(sb->offset);
@@ -333,7 +333,7 @@ static void uuid_io_unlock(struct closure *cl)
333333
up(&c->uuid_write_mutex);
334334
}
335335

336-
static void uuid_io(struct cache_set *c, unsigned long rw,
336+
static void uuid_io(struct cache_set *c, int op, unsigned long op_flags,
337337
struct bkey *k, struct closure *parent)
338338
{
339339
struct closure *cl = &c->uuid_write;
@@ -348,21 +348,22 @@ static void uuid_io(struct cache_set *c, unsigned long rw,
348348
for (i = 0; i < KEY_PTRS(k); i++) {
349349
struct bio *bio = bch_bbio_alloc(c);
350350

351-
bio->bi_rw = REQ_SYNC|REQ_META|rw;
351+
bio->bi_rw = REQ_SYNC|REQ_META|op_flags;
352352
bio->bi_iter.bi_size = KEY_SIZE(k) << 9;
353353

354354
bio->bi_end_io = uuid_endio;
355355
bio->bi_private = cl;
356+
bio_set_op_attrs(bio, op, REQ_SYNC|REQ_META|op_flags);
356357
bch_bio_map(bio, c->uuids);
357358

358359
bch_submit_bbio(bio, c, k, i);
359360

360-
if (!(rw & WRITE))
361+
if (op != REQ_OP_WRITE)
361362
break;
362363
}
363364

364365
bch_extent_to_text(buf, sizeof(buf), k);
365-
pr_debug("%s UUIDs at %s", rw & REQ_WRITE ? "wrote" : "read", buf);
366+
pr_debug("%s UUIDs at %s", op == REQ_OP_WRITE ? "wrote" : "read", buf);
366367

367368
for (u = c->uuids; u < c->uuids + c->nr_uuids; u++)
368369
if (!bch_is_zero(u->uuid, 16))
@@ -381,7 +382,7 @@ static char *uuid_read(struct cache_set *c, struct jset *j, struct closure *cl)
381382
return "bad uuid pointer";
382383

383384
bkey_copy(&c->uuid_bucket, k);
384-
uuid_io(c, READ_SYNC, k, cl);
385+
uuid_io(c, REQ_OP_READ, READ_SYNC, k, cl);
385386

386387
if (j->version < BCACHE_JSET_VERSION_UUIDv1) {
387388
struct uuid_entry_v0 *u0 = (void *) c->uuids;
@@ -426,7 +427,7 @@ static int __uuid_write(struct cache_set *c)
426427
return 1;
427428

428429
SET_KEY_SIZE(&k.key, c->sb.bucket_size);
429-
uuid_io(c, REQ_WRITE, &k.key, &cl);
430+
uuid_io(c, REQ_OP_WRITE, 0, &k.key, &cl);
430431
closure_sync(&cl);
431432

432433
bkey_copy(&c->uuid_bucket, &k.key);
@@ -498,7 +499,8 @@ static void prio_endio(struct bio *bio)
498499
closure_put(&ca->prio);
499500
}
500501

501-
static void prio_io(struct cache *ca, uint64_t bucket, unsigned long rw)
502+
static void prio_io(struct cache *ca, uint64_t bucket, int op,
503+
unsigned long op_flags)
502504
{
503505
struct closure *cl = &ca->prio;
504506
struct bio *bio = bch_bbio_alloc(ca->set);
@@ -507,11 +509,11 @@ static void prio_io(struct cache *ca, uint64_t bucket, unsigned long rw)
507509

508510
bio->bi_iter.bi_sector = bucket * ca->sb.bucket_size;
509511
bio->bi_bdev = ca->bdev;
510-
bio->bi_rw = REQ_SYNC|REQ_META|rw;
511512
bio->bi_iter.bi_size = bucket_bytes(ca);
512513

513514
bio->bi_end_io = prio_endio;
514515
bio->bi_private = ca;
516+
bio_set_op_attrs(bio, op, REQ_SYNC|REQ_META|op_flags);
515517
bch_bio_map(bio, ca->disk_buckets);
516518

517519
closure_bio_submit(bio, &ca->prio);
@@ -557,7 +559,7 @@ void bch_prio_write(struct cache *ca)
557559
BUG_ON(bucket == -1);
558560

559561
mutex_unlock(&ca->set->bucket_lock);
560-
prio_io(ca, bucket, REQ_WRITE);
562+
prio_io(ca, bucket, REQ_OP_WRITE, 0);
561563
mutex_lock(&ca->set->bucket_lock);
562564

563565
ca->prio_buckets[i] = bucket;
@@ -599,7 +601,7 @@ static void prio_read(struct cache *ca, uint64_t bucket)
599601
ca->prio_last_buckets[bucket_nr] = bucket;
600602
bucket_nr++;
601603

602-
prio_io(ca, bucket, READ_SYNC);
604+
prio_io(ca, bucket, REQ_OP_READ, READ_SYNC);
603605

604606
if (p->csum != bch_crc64(&p->magic, bucket_bytes(ca) - 8))
605607
pr_warn("bad csum reading priorities");

drivers/md/bcache/writeback.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void write_dirty(struct closure *cl)
182182
struct keybuf_key *w = io->bio.bi_private;
183183

184184
dirty_init(w);
185-
io->bio.bi_rw = WRITE;
185+
bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0);
186186
io->bio.bi_iter.bi_sector = KEY_START(&w->key);
187187
io->bio.bi_bdev = io->dc->bdev;
188188
io->bio.bi_end_io = dirty_endio;
@@ -251,10 +251,10 @@ static void read_dirty(struct cached_dev *dc)
251251
io->dc = dc;
252252

253253
dirty_init(w);
254+
bio_set_op_attrs(&io->bio, REQ_OP_READ, 0);
254255
io->bio.bi_iter.bi_sector = PTR_OFFSET(&w->key, 0);
255256
io->bio.bi_bdev = PTR_CACHE(dc->disk.c,
256257
&w->key, 0)->bdev;
257-
io->bio.bi_rw = READ;
258258
io->bio.bi_end_io = read_dirty_endio;
259259

260260
if (bio_alloc_pages(&io->bio, GFP_KERNEL))

0 commit comments

Comments
 (0)