block, drivers, cgroup: use op_is_write helper instead of checking for REQ_WRITE
authorMike Christie <mchristi@redhat.com>
Sun, 5 Jun 2016 19:31:45 +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 patch converts the drivers and cgroup to use the
op_is_write helper. This should just cover the simple
cases. I did dm, md and bcache in their own patches
because they were more involved.

Signed-off-by: Mike Christie <mchristi@redhat.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
block/blk-core.c
block/blk-merge.c
drivers/ata/libata-scsi.c
drivers/block/loop.c
drivers/block/umem.c
drivers/scsi/osd/osd_initiator.c
include/linux/blk-cgroup.h

index e953407895924901533d925d53ab18af61872a23..e8e5865a53e2cccac58eec29ca6b1007ad643fa9 100644 (file)
@@ -2115,7 +2115,7 @@ blk_qc_t submit_bio(struct bio *bio)
                else
                        count = bio_sectors(bio);
 
-               if (bio->bi_rw & WRITE) {
+               if (op_is_write(bio_op(bio))) {
                        count_vm_events(PGPGOUT, count);
                } else {
                        task_io_account_read(bio->bi_iter.bi_size);
@@ -2126,7 +2126,7 @@ blk_qc_t submit_bio(struct bio *bio)
                        char b[BDEVNAME_SIZE];
                        printk(KERN_DEBUG "%s(%d): %s block %Lu on %s (%u sectors)\n",
                        current->comm, task_pid_nr(current),
-                               (bio->bi_rw & WRITE) ? "WRITE" : "READ",
+                               op_is_write(bio_op(bio)) ? "WRITE" : "READ",
                                (unsigned long long)bio->bi_iter.bi_sector,
                                bdevname(bio->bi_bdev, b),
                                count);
index 261353166dcf33a042ea4466ecae044388dddc98..b198070c5bc4914f34b5d6bd0609e8c251aa4964 100644 (file)
@@ -439,7 +439,7 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
        }
 
        if (q->dma_drain_size && q->dma_drain_needed(rq)) {
-               if (rq->cmd_flags & REQ_WRITE)
+               if (op_is_write(req_op(rq)))
                        memset(q->dma_drain_buffer, 0, q->dma_drain_size);
 
                sg_unmark_end(sg);
index bfec66fb26e27a2c9d7ecbb42549027ac1578d5e..4c6eb22cc85df05bc1245cc6dc7175f5c38503b2 100644 (file)
@@ -1190,7 +1190,7 @@ static int atapi_drain_needed(struct request *rq)
        if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC))
                return 0;
 
-       if (!blk_rq_bytes(rq) || (rq->cmd_flags & REQ_WRITE))
+       if (!blk_rq_bytes(rq) || op_is_write(req_op(rq)))
                return 0;
 
        return atapi_cmd_type(rq->cmd[0]) == ATAPI_MISC;
index 1fa8cc235977f404bc995d73659714fbccad7066..e9f1701af7cb3a9965b6ce32ae73c932757e361f 100644 (file)
@@ -447,7 +447,7 @@ static int lo_req_flush(struct loop_device *lo, struct request *rq)
 
 static inline void handle_partial_read(struct loop_cmd *cmd, long bytes)
 {
-       if (bytes < 0 || (cmd->rq->cmd_flags & REQ_WRITE))
+       if (bytes < 0 || op_is_write(req_op(cmd->rq)))
                return;
 
        if (unlikely(bytes < blk_rq_bytes(cmd->rq))) {
@@ -541,7 +541,7 @@ static int do_req_filebacked(struct loop_device *lo, struct request *rq)
 
        pos = ((loff_t) blk_rq_pos(rq) << 9) + lo->lo_offset;
 
-       if (rq->cmd_flags & REQ_WRITE) {
+       if (op_is_write(req_op(rq))) {
                if (rq->cmd_flags & REQ_FLUSH)
                        ret = lo_req_flush(lo, rq);
                else if (rq->cmd_flags & REQ_DISCARD)
@@ -1672,7 +1672,7 @@ static int loop_queue_rq(struct blk_mq_hw_ctx *hctx,
 
 static void loop_handle_cmd(struct loop_cmd *cmd)
 {
-       const bool write = cmd->rq->cmd_flags & REQ_WRITE;
+       const bool write = op_is_write(req_op(cmd->rq));
        struct loop_device *lo = cmd->rq->q->queuedata;
        int ret = 0;
 
index 7939b9f8744135d137e222c6593cc0a96b94c18a..4b3ba74e9d22f3ec90ad4d8b39cdb0fcfac2ab83 100644 (file)
@@ -462,7 +462,7 @@ static void process_page(unsigned long data)
                                le32_to_cpu(desc->local_addr)>>9,
                                le32_to_cpu(desc->transfer_size));
                        dump_dmastat(card, control);
-               } else if ((bio->bi_rw & REQ_WRITE) &&
+               } else if (op_is_write(bio_op(bio)) &&
                           le32_to_cpu(desc->local_addr) >> 9 ==
                                card->init_size) {
                        card->init_size += le32_to_cpu(desc->transfer_size) >> 9;
index 3b11aad0375226d2afed99157546abe98200c972..14ed39b32bfc4cfda501585e932df11a9dab5d49 100644 (file)
@@ -824,7 +824,7 @@ void osd_req_write(struct osd_request *or,
 {
        _osd_req_encode_common(or, OSD_ACT_WRITE, obj, offset, len);
        WARN_ON(or->out.bio || or->out.total_bytes);
-       WARN_ON(0 == (bio->bi_rw & REQ_WRITE));
+       WARN_ON(!op_is_write(bio_op(bio)));
        or->out.bio = bio;
        or->out.total_bytes = len;
 }
@@ -875,7 +875,7 @@ void osd_req_read(struct osd_request *or,
 {
        _osd_req_encode_common(or, OSD_ACT_READ, obj, offset, len);
        WARN_ON(or->in.bio || or->in.total_bytes);
-       WARN_ON(bio->bi_rw & REQ_WRITE);
+       WARN_ON(op_is_write(bio_op(bio)));
        or->in.bio = bio;
        or->in.total_bytes = len;
 }
index c02e669945e9279bceb796eb9a1adb938ebf863b..04f9c8d640603ad053b1968ec7fc97f6be07af9a 100644 (file)
@@ -601,7 +601,7 @@ static inline void blkg_rwstat_add(struct blkg_rwstat *rwstat,
 {
        struct percpu_counter *cnt;
 
-       if (rw & REQ_WRITE)
+       if (op_is_write(rw))
                cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_WRITE];
        else
                cnt = &rwstat->cpu_cnt[BLKG_RWSTAT_READ];