bcache: use op_is_write instead of checking for REQ_WRITE
authorMike Christie <mchristi@redhat.com>
Sun, 5 Jun 2016 19:31:47 +0000 (14:31 -0500)
committerJens Axboe <axboe@fb.com>
Tue, 7 Jun 2016 19:41:38 +0000 (13:41 -0600)
We currently set REQ_WRITE/WRITE for all non READ IOs
like discard, flush, writesame, etc. In the next patches where we
no longer set up the op as a bitmap, we will not be able to
detect a operation direction like writesame by testing if REQ_WRITE is
set.

This has bcache use the op_is_write helper which will do the right
thing.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/md/bcache/io.c
drivers/md/bcache/request.c

index 86a0bb87124e3849df567a49d0de6afbfe1a7175..fd885cc2afad4a5caae3042f73c6d862db2e3bf1 100644 (file)
@@ -111,7 +111,7 @@ void bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
        struct bbio *b = container_of(bio, struct bbio, bio);
        struct cache *ca = PTR_CACHE(c, &b->key, 0);
 
-       unsigned threshold = bio->bi_rw & REQ_WRITE
+       unsigned threshold = op_is_write(bio_op(bio))
                ? c->congested_write_threshold_us
                : c->congested_read_threshold_us;
 
index 25fa8445bb2422ba29f745aa2c0b68e37b3ec326..6b85a23ec92a926f7c9cd202a8784e31c2c9fc0c 100644 (file)
@@ -383,7 +383,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
 
        if (mode == CACHE_MODE_NONE ||
            (mode == CACHE_MODE_WRITEAROUND &&
-            (bio->bi_rw & REQ_WRITE)))
+            op_is_write(bio_op(bio))))
                goto skip;
 
        if (bio->bi_iter.bi_sector & (c->sb.block_size - 1) ||
@@ -404,7 +404,7 @@ static bool check_should_bypass(struct cached_dev *dc, struct bio *bio)
 
        if (!congested &&
            mode == CACHE_MODE_WRITEBACK &&
-           (bio->bi_rw & REQ_WRITE) &&
+           op_is_write(bio_op(bio)) &&
            (bio->bi_rw & REQ_SYNC))
                goto rescale;
 
@@ -657,7 +657,7 @@ static inline struct search *search_alloc(struct bio *bio,
        s->cache_miss           = NULL;
        s->d                    = d;
        s->recoverable          = 1;
-       s->write                = (bio->bi_rw & REQ_WRITE) != 0;
+       s->write                = op_is_write(bio_op(bio));
        s->read_dirty_data      = 0;
        s->start_time           = jiffies;