]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
block: fold cmd_type into the REQ_OP_ space
authorChristoph Hellwig <hch@lst.de>
Tue, 31 Jan 2017 15:57:31 +0000 (16:57 +0100)
committerJens Axboe <axboe@fb.com>
Tue, 31 Jan 2017 21:00:44 +0000 (14:00 -0700)
Instead of keeping two levels of indirection for requests types, fold it
all into the operations.  The little caveat here is that previously
cmd_type only applied to struct request, while the request and bio op
fields were set to plain REQ_OP_READ/WRITE even for passthrough
operations.

Instead this patch adds new REQ_OP_* for SCSI passthrough and driver
private requests, althought it has to add two for each so that we
can communicate the data in/out nature of the request.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
53 files changed:
block/bio.c
block/blk-core.c
block/blk-flush.c
block/blk-map.c
block/blk-mq-debugfs.c
block/bsg.c
block/scsi_ioctl.c
drivers/block/cciss.c
drivers/block/floppy.c
drivers/block/hd.c
drivers/block/mg_disk.c
drivers/block/nbd.c
drivers/block/null_blk.c
drivers/block/osdblk.c
drivers/block/paride/pd.c
drivers/block/pktcdvd.c
drivers/block/ps3disk.c
drivers/block/rbd.c
drivers/block/sx8.c
drivers/block/virtio_blk.c
drivers/block/xen-blkfront.c
drivers/block/xsysace.c
drivers/cdrom/cdrom.c
drivers/cdrom/gdrom.c
drivers/ide/ide-atapi.c
drivers/ide/ide-cd.c
drivers/ide/ide-cd_ioctl.c
drivers/ide/ide-devsets.c
drivers/ide/ide-disk.c
drivers/ide/ide-eh.c
drivers/ide/ide-floppy.c
drivers/ide/ide-io.c
drivers/ide/ide-ioctls.c
drivers/ide/ide-park.c
drivers/ide/ide-pm.c
drivers/ide/ide-tape.c
drivers/ide/ide-taskfile.c
drivers/mtd/mtd_blkdevs.c
drivers/mtd/ubi/block.c
drivers/nvme/host/core.c
drivers/nvme/host/rdma.c
drivers/scsi/osd/osd_initiator.c
drivers/scsi/osst.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_lib.c
drivers/scsi/sg.c
drivers/scsi/sr.c
drivers/scsi/st.c
drivers/target/target_core_pscsi.c
fs/nfsd/blocklayout.c
include/linux/blk_types.h
include/linux/blkdev.h
include/linux/ide.h

index 2b375020fc49bab0bfcabda4fc3d16118b5f1512..9a2dd7145e83b3a1d2dab269113a8dbbd6bbdc5c 100644 (file)
@@ -1227,9 +1227,6 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
        if (!bio)
                goto out_bmd;
 
-       if (iter->type & WRITE)
-               bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
-
        ret = 0;
 
        if (map_data) {
@@ -1394,12 +1391,6 @@ struct bio *bio_map_user_iov(struct request_queue *q,
 
        kfree(pages);
 
-       /*
-        * set data direction, and check if mapped pages need bouncing
-        */
-       if (iter->type & WRITE)
-               bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
-
        bio_set_flag(bio, BIO_USER_MAPPED);
 
        /*
@@ -1590,7 +1581,6 @@ struct bio *bio_copy_kern(struct request_queue *q, void *data, unsigned int len,
                bio->bi_private = data;
        } else {
                bio->bi_end_io = bio_copy_kern_endio;
-               bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
        }
 
        return bio;
index 44431086e4e7f1e0b815d28f7dec4cd7610ce485..3266daaa343f3ef4fa21aa474c13129d2f20eafc 100644 (file)
@@ -158,8 +158,8 @@ static void req_bio_endio(struct request *rq, struct bio *bio,
 
 void blk_dump_rq_flags(struct request *rq, char *msg)
 {
-       printk(KERN_INFO "%s: dev %s: type=%x, flags=%llx\n", msg,
-               rq->rq_disk ? rq->rq_disk->disk_name : "?", rq->cmd_type,
+       printk(KERN_INFO "%s: dev %s: flags=%llx\n", msg,
+               rq->rq_disk ? rq->rq_disk->disk_name : "?",
                (unsigned long long) rq->cmd_flags);
 
        printk(KERN_INFO "  sector %llu, nr/cnr %u/%u\n",
@@ -1593,7 +1593,6 @@ out:
 
 void init_request_from_bio(struct request *req, struct bio *bio)
 {
-       req->cmd_type = REQ_TYPE_FS;
        if (bio->bi_opf & REQ_RAHEAD)
                req->cmd_flags |= REQ_FAILFAST_MASK;
 
@@ -2983,7 +2982,6 @@ EXPORT_SYMBOL_GPL(blk_rq_unprep_clone);
 static void __blk_rq_prep_clone(struct request *dst, struct request *src)
 {
        dst->cpu = src->cpu;
-       dst->cmd_type = src->cmd_type;
        dst->__sector = blk_rq_pos(src);
        dst->__data_len = blk_rq_bytes(src);
        dst->nr_phys_segments = src->nr_phys_segments;
index 0a0358e48b7671f2abc99b834141d3ac53cc2175..9681625792343580171db4c507f43220e48d93b0 100644 (file)
@@ -327,7 +327,6 @@ static bool blk_kick_flush(struct request_queue *q, struct blk_flush_queue *fq)
                blk_mq_tag_set_rq(hctx, first_rq->tag, flush_rq);
        }
 
-       flush_rq->cmd_type = REQ_TYPE_FS;
        flush_rq->cmd_flags = REQ_OP_FLUSH | REQ_PREFLUSH;
        flush_rq->rq_flags |= RQF_FLUSH_SEQ;
        flush_rq->rq_disk = first_rq->rq_disk;
index 0acb6640ead708ef8450a32cb7ff6b0aee350515..2f18c2a0be1b22680472972c03f93b598dc7cb12 100644 (file)
@@ -16,8 +16,6 @@
 int blk_rq_append_bio(struct request *rq, struct bio *bio)
 {
        if (!rq->bio) {
-               rq->cmd_flags &= REQ_OP_MASK;
-               rq->cmd_flags |= (bio->bi_opf & REQ_OP_MASK);
                blk_rq_bio_prep(rq->q, rq, bio);
        } else {
                if (!ll_back_merge_fn(rq->q, rq, bio))
@@ -62,6 +60,9 @@ static int __blk_rq_map_user_iov(struct request *rq,
        if (IS_ERR(bio))
                return PTR_ERR(bio);
 
+       bio->bi_opf &= ~REQ_OP_MASK;
+       bio->bi_opf |= req_op(rq);
+
        if (map_data && map_data->null_mapped)
                bio_set_flag(bio, BIO_NULL_MAPPED);
 
@@ -90,7 +91,7 @@ static int __blk_rq_map_user_iov(struct request *rq,
 }
 
 /**
- * blk_rq_map_user_iov - map user data to a request, for REQ_TYPE_BLOCK_PC usage
+ * blk_rq_map_user_iov - map user data to a request, for passthrough requests
  * @q:         request queue where request should be inserted
  * @rq:                request to map data to
  * @map_data:   pointer to the rq_map_data holding pages (if necessary)
@@ -199,7 +200,7 @@ int blk_rq_unmap_user(struct bio *bio)
 EXPORT_SYMBOL(blk_rq_unmap_user);
 
 /**
- * blk_rq_map_kern - map kernel data to a request, for REQ_TYPE_BLOCK_PC usage
+ * blk_rq_map_kern - map kernel data to a request, for passthrough requests
  * @q:         request queue where request should be inserted
  * @rq:                request to fill
  * @kbuf:      the kernel buffer
@@ -234,8 +235,8 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
        if (IS_ERR(bio))
                return PTR_ERR(bio);
 
-       if (!reading)
-               bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
+       bio->bi_opf &= ~REQ_OP_MASK;
+       bio->bi_opf |= req_op(rq);
 
        if (do_copy)
                rq->rq_flags |= RQF_COPY_USER;
index 5cd2b435a9f5c7224746e4bbfb7bb4ebb469e74d..1e2a4a2ff62349b3e29c30d09b11d93be3907847 100644 (file)
@@ -88,8 +88,8 @@ static int blk_mq_debugfs_rq_show(struct seq_file *m, void *v)
 {
        struct request *rq = list_entry_rq(v);
 
-       seq_printf(m, "%p {.cmd_type=%u, .cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n",
-                  rq, rq->cmd_type, rq->cmd_flags, (unsigned int)rq->rq_flags,
+       seq_printf(m, "%p {.cmd_flags=0x%x, .rq_flags=0x%x, .tag=%d, .internal_tag=%d}\n",
+                  rq, rq->cmd_flags, (unsigned int)rq->rq_flags,
                   rq->tag, rq->internal_tag);
        return 0;
 }
index e34c3320956cb16040a89518d9bf38c85e1ce17e..a9a8b8e0446f4434616a4f4d7f5513bd3a8936c9 100644 (file)
@@ -177,7 +177,7 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
  * Check if sg_io_v4 from user is allowed and valid
  */
 static int
-bsg_validate_sgv4_hdr(struct sg_io_v4 *hdr, int *rw)
+bsg_validate_sgv4_hdr(struct sg_io_v4 *hdr, int *op)
 {
        int ret = 0;
 
@@ -198,7 +198,7 @@ bsg_validate_sgv4_hdr(struct sg_io_v4 *hdr, int *rw)
                ret = -EINVAL;
        }
 
-       *rw = hdr->dout_xfer_len ? WRITE : READ;
+       *op = hdr->dout_xfer_len ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN;
        return ret;
 }
 
@@ -210,8 +210,8 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
 {
        struct request_queue *q = bd->queue;
        struct request *rq, *next_rq = NULL;
-       int ret, rw;
-       unsigned int dxfer_len;
+       int ret;
+       unsigned int op, dxfer_len;
        void __user *dxferp = NULL;
        struct bsg_class_device *bcd = &q->bsg_dev;
 
@@ -226,14 +226,14 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
                hdr->dout_xfer_len, (unsigned long long) hdr->din_xferp,
                hdr->din_xfer_len);
 
-       ret = bsg_validate_sgv4_hdr(hdr, &rw);
+       ret = bsg_validate_sgv4_hdr(hdr, &op);
        if (ret)
                return ERR_PTR(ret);
 
        /*
         * map scatter-gather elements separately and string them to request
         */
-       rq = blk_get_request(q, rw, GFP_KERNEL);
+       rq = blk_get_request(q, op, GFP_KERNEL);
        if (IS_ERR(rq))
                return rq;
        scsi_req_init(rq);
@@ -242,20 +242,19 @@ bsg_map_hdr(struct bsg_device *bd, struct sg_io_v4 *hdr, fmode_t has_write_perm)
        if (ret)
                goto out;
 
-       if (rw == WRITE && hdr->din_xfer_len) {
+       if (op == REQ_OP_SCSI_OUT && hdr->din_xfer_len) {
                if (!test_bit(QUEUE_FLAG_BIDI, &q->queue_flags)) {
                        ret = -EOPNOTSUPP;
                        goto out;
                }
 
-               next_rq = blk_get_request(q, READ, GFP_KERNEL);
+               next_rq = blk_get_request(q, REQ_OP_SCSI_IN, GFP_KERNEL);
                if (IS_ERR(next_rq)) {
                        ret = PTR_ERR(next_rq);
                        next_rq = NULL;
                        goto out;
                }
                rq->next_rq = next_rq;
-               next_rq->cmd_type = rq->cmd_type;
 
                dxferp = (void __user *)(unsigned long)hdr->din_xferp;
                ret =  blk_rq_map_user(q, next_rq, NULL, dxferp,
index 7edf44f25e082da4f5e7522efec8539bbcd8c682..2a2fc768b27ad81583424252f13b89303269b755 100644 (file)
@@ -321,7 +321,8 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk,
                at_head = 1;
 
        ret = -ENOMEM;
-       rq = blk_get_request(q, writing ? WRITE : READ, GFP_KERNEL);
+       rq = blk_get_request(q, writing ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
+                       GFP_KERNEL);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
        req = scsi_req(rq);
@@ -448,7 +449,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
 
        }
 
-       rq = blk_get_request(q, in_len ? WRITE : READ, __GFP_RECLAIM);
+       rq = blk_get_request(q, in_len ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
+                       __GFP_RECLAIM);
        if (IS_ERR(rq)) {
                err = PTR_ERR(rq);
                goto error_free_buffer;
@@ -537,7 +539,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
        struct request *rq;
        int err;
 
-       rq = blk_get_request(q, WRITE, __GFP_RECLAIM);
+       rq = blk_get_request(q, REQ_OP_SCSI_OUT, __GFP_RECLAIM);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
        scsi_req_init(rq);
@@ -745,7 +747,6 @@ void scsi_req_init(struct request *rq)
 {
        struct scsi_request *req = scsi_req(rq);
 
-       rq->cmd_type = REQ_TYPE_BLOCK_PC;
        memset(req->__cmd, 0, sizeof(req->__cmd));
        req->cmd = req->__cmd;
        req->cmd_len = BLK_MAX_CDB;
index 53dc2971a3bac7dfb3ea9f1e6264da34679ca0e4..f21c2f0c5ccd5d25445f4e5eee03938b9b16dcf9 100644 (file)
@@ -3394,7 +3394,9 @@ static void do_cciss_request(struct request_queue *q)
                c->Header.SGList = h->max_cmd_sgentries;
        set_performant_mode(h, c);
 
-       if (likely(creq->cmd_type == REQ_TYPE_FS)) {
+       switch (req_op(creq)) {
+       case REQ_OP_READ:
+       case REQ_OP_WRITE:
                if(h->cciss_read == CCISS_READ_10) {
                        c->Request.CDB[1] = 0;
                        c->Request.CDB[2] = (start_blk >> 24) & 0xff; /* MSB */
@@ -3424,13 +3426,16 @@ static void do_cciss_request(struct request_queue *q)
                        c->Request.CDB[13]= blk_rq_sectors(creq) & 0xff;
                        c->Request.CDB[14] = c->Request.CDB[15] = 0;
                }
-       } else if (creq->cmd_type == REQ_TYPE_BLOCK_PC) {
+               break;
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
                c->Request.CDBLen = scsi_req(creq)->cmd_len;
                memcpy(c->Request.CDB, scsi_req(creq)->cmd, BLK_MAX_CDB);
                scsi_req(creq)->sense = c->err_info->SenseInfo;
-       } else {
+               break;
+       default:
                dev_warn(&h->pdev->dev, "bad request type %d\n",
-                       creq->cmd_type);
+                       creq->cmd_flags);
                BUG();
        }
 
index 184887af4b9fbbb365480a6e275544c501ae2b5a..45b4384f650ccedeed20c2b4718fa1be49b87b06 100644 (file)
@@ -2900,8 +2900,8 @@ static void do_fd_request(struct request_queue *q)
                return;
 
        if (WARN(atomic_read(&usage_count) == 0,
-                "warning: usage count=0, current_req=%p sect=%ld type=%x flags=%llx\n",
-                current_req, (long)blk_rq_pos(current_req), current_req->cmd_type,
+                "warning: usage count=0, current_req=%p sect=%ld flags=%llx\n",
+                current_req, (long)blk_rq_pos(current_req),
                 (unsigned long long) current_req->cmd_flags))
                return;
 
index a9b48ed7a3cd258c1314b23aa77502c9a4fbbfc1..6043648da1e85581135e16169210219aecbd5285 100644 (file)
@@ -626,30 +626,29 @@ repeat:
                req_data_dir(req) == READ ? "read" : "writ",
                cyl, head, sec, nsect, bio_data(req->bio));
 #endif
-       if (req->cmd_type == REQ_TYPE_FS) {
-               switch (rq_data_dir(req)) {
-               case READ:
-                       hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_READ,
-                               &read_intr);
-                       if (reset)
-                               goto repeat;
-                       break;
-               case WRITE:
-                       hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_WRITE,
-                               &write_intr);
-                       if (reset)
-                               goto repeat;
-                       if (wait_DRQ()) {
-                               bad_rw_intr();
-                               goto repeat;
-                       }
-                       outsw(HD_DATA, bio_data(req->bio), 256);
-                       break;
-               default:
-                       printk("unknown hd-command\n");
-                       hd_end_request_cur(-EIO);
-                       break;
+
+       switch (req_op(req)) {
+       case REQ_OP_READ:
+               hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_READ,
+                       &read_intr);
+               if (reset)
+                       goto repeat;
+               break;
+       case REQ_OP_WRITE:
+               hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_WRITE,
+                       &write_intr);
+               if (reset)
+                       goto repeat;
+               if (wait_DRQ()) {
+                       bad_rw_intr();
+                       goto repeat;
                }
+               outsw(HD_DATA, bio_data(req->bio), 256);
+               break;
+       default:
+               printk("unknown hd-command\n");
+               hd_end_request_cur(-EIO);
+               break;
        }
 }
 
index e937fcf717690fa5a6ec2d4e7915908fbe001836..286f276f586e4674e323dafd3a1a60ababcc9088 100644 (file)
@@ -670,15 +670,17 @@ static void mg_request_poll(struct request_queue *q)
                                break;
                }
 
-               if (unlikely(host->req->cmd_type != REQ_TYPE_FS)) {
-                       mg_end_request_cur(host, -EIO);
-                       continue;
-               }
-
-               if (rq_data_dir(host->req) == READ)
+               switch (req_op(host->req)) {
+               case REQ_OP_READ:
                        mg_read(host->req);
-               else
+                       break;
+               case REQ_OP_WRITE:
                        mg_write(host->req);
+                       break;
+               default:
+                       mg_end_request_cur(host, -EIO);
+                       break;
+               }
        }
 }
 
@@ -687,13 +689,15 @@ static unsigned int mg_issue_req(struct request *req,
                unsigned int sect_num,
                unsigned int sect_cnt)
 {
-       if (rq_data_dir(req) == READ) {
+       switch (req_op(host->req)) {
+       case REQ_OP_READ:
                if (mg_out(host, sect_num, sect_cnt, MG_CMD_RD, &mg_read_intr)
                                != MG_ERR_NONE) {
                        mg_bad_rw_intr(host);
                        return host->error;
                }
-       } else {
+               break;
+       case REQ_OP_WRITE:
                /* TODO : handler */
                outb(ATA_NIEN, (unsigned long)host->dev_base + MG_REG_DRV_CTRL);
                if (mg_out(host, sect_num, sect_cnt, MG_CMD_WR, &mg_write_intr)
@@ -712,6 +716,10 @@ static unsigned int mg_issue_req(struct request *req,
                mod_timer(&host->timer, jiffies + 3 * HZ);
                outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
                                MG_REG_COMMAND);
+               break;
+       default:
+               mg_end_request_cur(host, -EIO);
+               break;
        }
        return MG_ERR_NONE;
 }
@@ -753,11 +761,6 @@ static void mg_request(struct request_queue *q)
                        continue;
                }
 
-               if (unlikely(req->cmd_type != REQ_TYPE_FS)) {
-                       mg_end_request_cur(host, -EIO);
-                       continue;
-               }
-
                if (!mg_issue_req(req, host, sect_num, sect_cnt))
                        return;
        }
index 8bce1c7c18d523e6466e44fcf16887cc15d41acf..58296e4427b018e821baf5e4aea54fd5954f6f12 100644 (file)
@@ -271,17 +271,22 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
        u32 type;
        u32 tag = blk_mq_unique_tag(req);
 
-       if (req->cmd_type != REQ_TYPE_FS)
-               return -EIO;
-
-       if (req_op(req) == REQ_OP_DISCARD)
+       switch (req_op(req)) {
+       case REQ_OP_DISCARD:
                type = NBD_CMD_TRIM;
-       else if (req_op(req) == REQ_OP_FLUSH)
+               break;
+       case REQ_OP_FLUSH:
                type = NBD_CMD_FLUSH;
-       else if (rq_data_dir(req) == WRITE)
+               break;
+       case REQ_OP_WRITE:
                type = NBD_CMD_WRITE;
-       else
+               break;
+       case REQ_OP_READ:
                type = NBD_CMD_READ;
+               break;
+       default:
+               return -EIO;
+       }
 
        if (rq_data_dir(req) == WRITE &&
            (nbd->flags & NBD_FLAG_READ_ONLY)) {
index c0e14e54909b41b8f8e2f916be0d1169464ff643..4335b84a565b92abc6215083ddcd69d7fa5b3bce 100644 (file)
@@ -431,11 +431,11 @@ static int null_lnvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)
        struct request *rq;
        struct bio *bio = rqd->bio;
 
-       rq = blk_mq_alloc_request(q, bio_data_dir(bio), 0);
+       rq = blk_mq_alloc_request(q,
+               op_is_write(bio_op(bio)) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, 0);
        if (IS_ERR(rq))
                return -ENOMEM;
 
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        rq->__sector = bio->bi_iter.bi_sector;
        rq->ioprio = bio_prio(bio);
 
index 92900f5f0b4725ebc1d1edbf3da30138a3e2979b..8127b8201a011a2b26d9b2665ae11233e5799179 100644 (file)
@@ -308,12 +308,6 @@ static void osdblk_rq_fn(struct request_queue *q)
                if (!rq)
                        break;
 
-               /* filter out block requests we don't understand */
-               if (rq->cmd_type != REQ_TYPE_FS) {
-                       blk_end_request_all(rq, 0);
-                       continue;
-               }
-
                /* deduce our operation (read, write, flush) */
                /* I wish the block layer simplified cmd_type/cmd_flags/cmd[]
                 * into a clearly defined set of RPC commands:
index c3ed2fc72daae449f354867cb50e3eb111ec9c75..644ba0888bd41bb5e54f4ab58345b6af9519e0c2 100644 (file)
@@ -439,18 +439,16 @@ static int pd_retries = 0;        /* i/o error retry count */
 static int pd_block;           /* address of next requested block */
 static int pd_count;           /* number of blocks still to do */
 static int pd_run;             /* sectors in current cluster */
-static int pd_cmd;             /* current command READ/WRITE */
 static char *pd_buf;           /* buffer for request in progress */
 
 static enum action do_pd_io_start(void)
 {
-       if (pd_req->cmd_type == REQ_TYPE_DRV_PRIV) {
+       switch (req_op(pd_req)) {
+       case REQ_OP_DRV_IN:
                phase = pd_special;
                return pd_special();
-       }
-
-       pd_cmd = rq_data_dir(pd_req);
-       if (pd_cmd == READ || pd_cmd == WRITE) {
+       case REQ_OP_READ:
+       case REQ_OP_WRITE:
                pd_block = blk_rq_pos(pd_req);
                pd_count = blk_rq_cur_sectors(pd_req);
                if (pd_block + pd_count > get_capacity(pd_req->rq_disk))
@@ -458,7 +456,7 @@ static enum action do_pd_io_start(void)
                pd_run = blk_rq_sectors(pd_req);
                pd_buf = bio_data(pd_req->bio);
                pd_retries = 0;
-               if (pd_cmd == READ)
+               if (req_op(pd_req) == REQ_OP_READ)
                        return do_pd_read_start();
                else
                        return do_pd_write_start();
@@ -723,11 +721,10 @@ static int pd_special_command(struct pd_unit *disk,
        struct request *rq;
        int err = 0;
 
-       rq = blk_get_request(disk->gd->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(disk->gd->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
 
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        rq->special = func;
 
        err = blk_execute_rq(disk->gd->queue, disk->gd, rq, 0);
index 918a92ccd0c0596c8dae024c238dff091d253b84..f4bd95943dc25ddd98d3b4d5b9919161854bddfd 100644 (file)
@@ -704,7 +704,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
        int ret = 0;
 
        rq = blk_get_request(q, (cgc->data_direction == CGC_DATA_WRITE) ?
-                            WRITE : READ, __GFP_RECLAIM);
+                            REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM);
        if (IS_ERR(rq))
                return PTR_ERR(rq);
        scsi_req_init(rq);
index 76f33c84ce3dfb2eb6228d7bc5afdecb284e6ba9..a809e3e9feb8b885af9cd439de909c7e2e27f220 100644 (file)
@@ -196,16 +196,19 @@ static void ps3disk_do_request(struct ps3_storage_device *dev,
        dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
 
        while ((req = blk_fetch_request(q))) {
-               if (req_op(req) == REQ_OP_FLUSH) {
+               switch (req_op(req)) {
+               case REQ_OP_FLUSH:
                        if (ps3disk_submit_flush_request(dev, req))
-                               break;
-               } else if (req->cmd_type == REQ_TYPE_FS) {
+                               return;
+                       break;
+               case REQ_OP_READ:
+               case REQ_OP_WRITE:
                        if (ps3disk_submit_request_sg(dev, req))
-                               break;
-               } else {
+                               return;
+                       break;
+               default:
                        blk_dump_rq_flags(req, DEVICE_NAME " bad request");
                        __blk_end_request_all(req, -EIO);
-                       continue;
                }
        }
 }
index 36d2b9f4e83654637925d57fce5a4fc8cd0f009e..4d78cf605b21628de4b69a631849e621fa9f5151 100644 (file)
@@ -4099,19 +4099,21 @@ static void rbd_queue_workfn(struct work_struct *work)
        bool must_be_locked;
        int result;
 
-       if (rq->cmd_type != REQ_TYPE_FS) {
-               dout("%s: non-fs request type %d\n", __func__,
-                       (int) rq->cmd_type);
-               result = -EIO;
-               goto err;
-       }
-
-       if (req_op(rq) == REQ_OP_DISCARD)
+       switch (req_op(rq)) {
+       case REQ_OP_DISCARD:
                op_type = OBJ_OP_DISCARD;
-       else if (req_op(rq) == REQ_OP_WRITE)
+               break;
+       case REQ_OP_WRITE:
                op_type = OBJ_OP_WRITE;
-       else
+               break;
+       case REQ_OP_READ:
                op_type = OBJ_OP_READ;
+               break;
+       default:
+               dout("%s: non-fs request type %d\n", __func__, req_op(rq));
+               result = -EIO;
+               goto err;
+       }
 
        /* Ignore/skip any zero-length requests */
 
index 0e93ad7b851160540b25c068e5314f107dad2964..c8e072caf56ffcd9678b850ffab9886f6ac9b5c6 100644 (file)
@@ -567,7 +567,7 @@ static struct carm_request *carm_get_special(struct carm_host *host)
        if (!crq)
                return NULL;
 
-       rq = blk_get_request(host->oob_q, WRITE /* bogus */, GFP_KERNEL);
+       rq = blk_get_request(host->oob_q, REQ_OP_DRV_OUT, GFP_KERNEL);
        if (IS_ERR(rq)) {
                spin_lock_irqsave(&host->lock, flags);
                carm_put_request(host, crq);
@@ -620,7 +620,6 @@ static int carm_array_info (struct carm_host *host, unsigned int array_idx)
        spin_unlock_irq(&host->lock);
 
        DPRINTK("blk_execute_rq_nowait, tag == %u\n", idx);
-       crq->rq->cmd_type = REQ_TYPE_DRV_PRIV;
        crq->rq->special = crq;
        blk_execute_rq_nowait(host->oob_q, NULL, crq->rq, true, NULL);
 
@@ -661,7 +660,6 @@ static int carm_send_special (struct carm_host *host, carm_sspc_t func)
        crq->msg_bucket = (u32) rc;
 
        DPRINTK("blk_execute_rq_nowait, tag == %u\n", idx);
-       crq->rq->cmd_type = REQ_TYPE_DRV_PRIV;
        crq->rq->special = crq;
        blk_execute_rq_nowait(host->oob_q, NULL, crq->rq, true, NULL);
 
index d9491bdd3ad36df15404a1548253c11c83c02d6f..a363170e45b182aa0016fef00dee1a6b37e5cb65 100644 (file)
@@ -175,11 +175,12 @@ static inline void virtblk_request_done(struct request *req)
        struct virtblk_req *vbr = blk_mq_rq_to_pdu(req);
        int error = virtblk_result(vbr);
 
-       switch (req->cmd_type) {
-       case REQ_TYPE_BLOCK_PC:
+       switch (req_op(req)) {
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
                virtblk_scsi_reques_done(req);
                break;
-       case REQ_TYPE_DRV_PRIV:
+       case REQ_OP_DRV_IN:
                req->errors = (error != 0);
                break;
        }
@@ -226,36 +227,35 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
        int qid = hctx->queue_num;
        int err;
        bool notify = false;
+       u32 type;
 
        BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
 
-       if (req_op(req) == REQ_OP_FLUSH) {
-               vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_FLUSH);
-               vbr->out_hdr.sector = 0;
-               vbr->out_hdr.ioprio = cpu_to_virtio32(vblk->vdev, req_get_ioprio(req));
-       } else {
-               switch (req->cmd_type) {
-               case REQ_TYPE_FS:
-                       vbr->out_hdr.type = 0;
-                       vbr->out_hdr.sector = cpu_to_virtio64(vblk->vdev, blk_rq_pos(req));
-                       vbr->out_hdr.ioprio = cpu_to_virtio32(vblk->vdev, req_get_ioprio(req));
-                       break;
-               case REQ_TYPE_BLOCK_PC:
-                       vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_SCSI_CMD);
-                       vbr->out_hdr.sector = 0;
-                       vbr->out_hdr.ioprio = cpu_to_virtio32(vblk->vdev, req_get_ioprio(req));
-                       break;
-               case REQ_TYPE_DRV_PRIV:
-                       vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, VIRTIO_BLK_T_GET_ID);
-                       vbr->out_hdr.sector = 0;
-                       vbr->out_hdr.ioprio = cpu_to_virtio32(vblk->vdev, req_get_ioprio(req));
-                       break;
-               default:
-                       /* We don't put anything else in the queue. */
-                       BUG();
-               }
+       switch (req_op(req)) {
+       case REQ_OP_READ:
+       case REQ_OP_WRITE:
+               type = 0;
+               break;
+       case REQ_OP_FLUSH:
+               type = VIRTIO_BLK_T_FLUSH;
+               break;
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
+               type = VIRTIO_BLK_T_SCSI_CMD;
+               break;
+       case REQ_OP_DRV_IN:
+               type = VIRTIO_BLK_T_GET_ID;
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               return BLK_MQ_RQ_QUEUE_ERROR;
        }
 
+       vbr->out_hdr.type = cpu_to_virtio32(vblk->vdev, type);
+       vbr->out_hdr.sector = type ?
+               0 : cpu_to_virtio64(vblk->vdev, blk_rq_pos(req));
+       vbr->out_hdr.ioprio = cpu_to_virtio32(vblk->vdev, req_get_ioprio(req));
+
        blk_mq_start_request(req);
 
        num = blk_rq_map_sg(hctx->queue, req, vbr->sg);
@@ -267,7 +267,7 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx,
        }
 
        spin_lock_irqsave(&vblk->vqs[qid].lock, flags);
-       if (req->cmd_type == REQ_TYPE_BLOCK_PC)
+       if (req_op(req) == REQ_OP_SCSI_IN || req_op(req) == REQ_OP_SCSI_OUT)
                err = virtblk_add_req_scsi(vblk->vqs[qid].vq, vbr, vbr->sg, num);
        else
                err = virtblk_add_req(vblk->vqs[qid].vq, vbr, vbr->sg, num);
@@ -300,10 +300,9 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
        struct request *req;
        int err;
 
-       req = blk_get_request(q, READ, GFP_KERNEL);
+       req = blk_get_request(q, REQ_OP_DRV_IN, GFP_KERNEL);
        if (IS_ERR(req))
                return PTR_ERR(req);
-       req->cmd_type = REQ_TYPE_DRV_PRIV;
 
        err = blk_rq_map_kern(q, req, id_str, VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
        if (err)
index b2bdfa81f9297cd588ffcb1168f7db1cd5a48228..9a8cb226cb3a7fc4c8d6cbe6606c0be037f81369 100644 (file)
@@ -865,7 +865,7 @@ static inline void flush_requests(struct blkfront_ring_info *rinfo)
 static inline bool blkif_request_flush_invalid(struct request *req,
                                               struct blkfront_info *info)
 {
-       return ((req->cmd_type != REQ_TYPE_FS) ||
+       return (blk_rq_is_passthrough(req) ||
                ((req_op(req) == REQ_OP_FLUSH) &&
                 !info->feature_flush) ||
                ((req->cmd_flags & REQ_FUA) &&
index c4328d9d9981ed18c8d5c5decc5af9efe00338ee..757dce2147e005a4b2bcb16881a19e226ab75743 100644 (file)
@@ -468,7 +468,7 @@ static struct request *ace_get_next_request(struct request_queue *q)
        struct request *req;
 
        while ((req = blk_peek_request(q)) != NULL) {
-               if (req->cmd_type == REQ_TYPE_FS)
+               if (!blk_rq_is_passthrough(req))
                        break;
                blk_start_request(req);
                __blk_end_request_all(req, -EIO);
index 36f5237a8a6900d96846fc3d3d605399c390fcc9..8f496b4f3dd1a7b8d083464ae77cef4c55421141 100644 (file)
@@ -2191,7 +2191,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
 
                len = nr * CD_FRAMESIZE_RAW;
 
-               rq = blk_get_request(q, READ, GFP_KERNEL);
+               rq = blk_get_request(q, REQ_OP_SCSI_IN, GFP_KERNEL);
                if (IS_ERR(rq)) {
                        ret = PTR_ERR(rq);
                        break;
index 584bc3126403d58955a915db2117fcd1d16de5a2..b6f1a5d95bc5ab414d590d6379457e9e4ffe0877 100644 (file)
@@ -659,23 +659,24 @@ static void gdrom_request(struct request_queue *rq)
        struct request *req;
 
        while ((req = blk_fetch_request(rq)) != NULL) {
-               if (req->cmd_type != REQ_TYPE_FS) {
-                       printk(KERN_DEBUG "gdrom: Non-fs request ignored\n");
-                       __blk_end_request_all(req, -EIO);
-                       continue;
-               }
-               if (rq_data_dir(req) != READ) {
+               switch (req_op(req)) {
+               case REQ_OP_READ:
+                       /*
+                        * Add to list of deferred work and then schedule
+                        * workqueue.
+                        */
+                       list_add_tail(&req->queuelist, &gdrom_deferred);
+                       schedule_work(&work);
+                       break;
+               case REQ_OP_WRITE:
                        pr_notice("Read only device - write request ignored\n");
                        __blk_end_request_all(req, -EIO);
-                       continue;
+                       break;
+               default:
+                       printk(KERN_DEBUG "gdrom: Non-fs request ignored\n");
+                       __blk_end_request_all(req, -EIO);
+                       break;
                }
-
-               /*
-                * Add to list of deferred work and then schedule
-                * workqueue.
-                */
-               list_add_tail(&req->queuelist, &gdrom_deferred);
-               schedule_work(&work);
        }
 }
 
index a8c650e8c92ef65760c2c06d5e89149cc2df0dc0..feb30061123bc07c14b7d1ae0b5b7ce19d533790 100644 (file)
@@ -92,9 +92,8 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
        struct request *rq;
        int error;
 
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        rq->special = (char *)pc;
 
@@ -212,7 +211,7 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq)
        }
 
        sense_rq->rq_disk = rq->rq_disk;
-       sense_rq->cmd_type = REQ_TYPE_DRV_PRIV;
+       sense_rq->cmd_flags = REQ_OP_DRV_IN;
        ide_req(sense_rq)->type = ATA_PRIV_SENSE;
        sense_rq->rq_flags |= RQF_PREEMPT;
 
@@ -312,19 +311,21 @@ EXPORT_SYMBOL_GPL(ide_cd_expiry);
 
 int ide_cd_get_xferlen(struct request *rq)
 {
-       switch (rq->cmd_type) {
-       case REQ_TYPE_FS:
+       switch (req_op(rq)) {
+       default:
                return 32768;
-       case REQ_TYPE_BLOCK_PC:
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
                return blk_rq_bytes(rq);
-       case REQ_TYPE_DRV_PRIV:
+       case REQ_OP_DRV_IN:
+       case REQ_OP_DRV_OUT:
                switch (ide_req(rq)->type) {
                case ATA_PRIV_PC:
                case ATA_PRIV_SENSE:
                        return blk_rq_bytes(rq);
+               default:
+                       return 0;
                }
-       default:
-               return 0;
        }
 }
 EXPORT_SYMBOL_GPL(ide_cd_get_xferlen);
@@ -491,7 +492,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
                        error = 0;
                } else {
 
-                       if (rq->cmd_type != REQ_TYPE_FS && uptodate <= 0) {
+                       if (blk_rq_is_passthrough(rq) && uptodate <= 0) {
                                if (rq->errors == 0)
                                        rq->errors = -EIO;
                        }
index 207af7816544ee765b777917f38882ac1a8c11f9..dc039d150357ad3e518cc868ece780a85d7eba5b 100644 (file)
@@ -176,7 +176,7 @@ static void cdrom_analyze_sense_data(ide_drive_t *drive,
                        if (!sense->valid)
                                break;
                        if (failed_command == NULL ||
-                           failed_command->cmd_type != REQ_TYPE_FS)
+                           blk_rq_is_passthrough(failed_command))
                                break;
                        sector = (sense->information[0] << 24) |
                                 (sense->information[1] << 16) |
@@ -293,7 +293,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
        }
 
        /* if we have an error, pass CHECK_CONDITION as the SCSI status byte */
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC && !rq->errors)
+       if (blk_rq_is_scsi(rq) && !rq->errors)
                rq->errors = SAM_STAT_CHECK_CONDITION;
 
        if (blk_noretry_request(rq))
@@ -301,13 +301,13 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
 
        switch (sense_key) {
        case NOT_READY:
-               if (rq->cmd_type == REQ_TYPE_FS && rq_data_dir(rq) == WRITE) {
+               if (req_op(rq) == REQ_OP_WRITE) {
                        if (ide_cd_breathe(drive, rq))
                                return 1;
                } else {
                        cdrom_saw_media_change(drive);
 
-                       if (rq->cmd_type == REQ_TYPE_FS &&
+                       if (!blk_rq_is_passthrough(rq) &&
                            !(rq->rq_flags & RQF_QUIET))
                                printk(KERN_ERR PFX "%s: tray open\n",
                                        drive->name);
@@ -317,7 +317,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
        case UNIT_ATTENTION:
                cdrom_saw_media_change(drive);
 
-               if (rq->cmd_type != REQ_TYPE_FS)
+               if (blk_rq_is_passthrough(rq))
                        return 0;
 
                /*
@@ -365,7 +365,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
                do_end_request = 1;
                break;
        default:
-               if (rq->cmd_type != REQ_TYPE_FS)
+               if (blk_rq_is_passthrough(rq))
                        break;
                if (err & ~ATA_ABORTED) {
                        /* go to the default handler for other errors */
@@ -376,7 +376,7 @@ static int cdrom_decode_status(ide_drive_t *drive, u8 stat)
                        do_end_request = 1;
        }
 
-       if (rq->cmd_type != REQ_TYPE_FS) {
+       if (blk_rq_is_passthrough(rq)) {
                rq->rq_flags |= RQF_FAILED;
                do_end_request = 1;
        }
@@ -435,10 +435,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
                int error;
                bool delay = false;
 
-               rq = blk_get_request(drive->queue, write, __GFP_RECLAIM);
+               rq = blk_get_request(drive->queue,
+                       write ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,  __GFP_RECLAIM);
                scsi_req_init(rq);
                memcpy(scsi_req(rq)->cmd, cmd, BLK_MAX_CDB);
-               rq->cmd_type = REQ_TYPE_DRV_PRIV;
                ide_req(rq)->type = ATA_PRIV_PC;
                rq->rq_flags |= rq_flags;
                rq->timeout = timeout;
@@ -564,7 +564,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
        ide_read_bcount_and_ireason(drive, &len, &ireason);
 
-       thislen = (rq->cmd_type == REQ_TYPE_FS) ? len : cmd->nleft;
+       thislen = !blk_rq_is_passthrough(rq) ? len : cmd->nleft;
        if (thislen > len)
                thislen = len;
 
@@ -573,7 +573,8 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
        /* If DRQ is clear, the command has completed. */
        if ((stat & ATA_DRQ) == 0) {
-               if (rq->cmd_type == REQ_TYPE_FS) {
+               switch (req_op(rq)) {
+               default:
                        /*
                         * If we're not done reading/writing, complain.
                         * Otherwise, complete the command normally.
@@ -587,7 +588,9 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
                                        rq->rq_flags |= RQF_FAILED;
                                uptodate = 0;
                        }
-               } else if (rq->cmd_type != REQ_TYPE_BLOCK_PC) {
+                       goto out_end;
+               case REQ_OP_DRV_IN:
+               case REQ_OP_DRV_OUT:
                        ide_cd_request_sense_fixup(drive, cmd);
 
                        uptodate = cmd->nleft ? 0 : 1;
@@ -603,8 +606,11 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
                        if (!uptodate)
                                rq->rq_flags |= RQF_FAILED;
+                       goto out_end;
+               case REQ_OP_SCSI_IN:
+               case REQ_OP_SCSI_OUT:
+                       goto out_end;
                }
-               goto out_end;
        }
 
        rc = ide_check_ireason(drive, rq, len, ireason, write);
@@ -636,7 +642,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
 
        /* pad, if necessary */
        if (len > 0) {
-               if (rq->cmd_type != REQ_TYPE_FS || write == 0)
+               if (blk_rq_is_passthrough(rq) || write == 0)
                        ide_pad_transfer(drive, write, len);
                else {
                        printk(KERN_ERR PFX "%s: confused, missing data\n",
@@ -645,12 +651,18 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
                }
        }
 
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC) {
+       switch (req_op(rq)) {
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
                timeout = rq->timeout;
-       } else {
+               break;
+       case REQ_OP_DRV_IN:
+       case REQ_OP_DRV_OUT:
+               expiry = ide_cd_expiry;
+               /*FALLTHRU*/
+       default:
                timeout = ATAPI_WAIT_PC;
-               if (rq->cmd_type != REQ_TYPE_FS)
-                       expiry = ide_cd_expiry;
+               break;
        }
 
        hwif->expiry = expiry;
@@ -658,7 +670,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive)
        return ide_started;
 
 out_end:
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC && rc == 0) {
+       if (blk_rq_is_scsi(rq) && rc == 0) {
                scsi_req(rq)->resid_len = 0;
                blk_end_request_all(rq, 0);
                hwif->rq = NULL;
@@ -666,7 +678,7 @@ out_end:
                if (sense && uptodate)
                        ide_cd_complete_failed_rq(drive, rq);
 
-               if (rq->cmd_type == REQ_TYPE_FS) {
+               if (!blk_rq_is_passthrough(rq)) {
                        if (cmd->nleft == 0)
                                uptodate = 1;
                } else {
@@ -679,7 +691,7 @@ out_end:
                                return ide_stopped;
 
                /* make sure it's fully ended */
-               if (rq->cmd_type != REQ_TYPE_FS) {
+               if (blk_rq_is_passthrough(rq)) {
                        scsi_req(rq)->resid_len -= cmd->nbytes - cmd->nleft;
                        if (uptodate == 0 && (cmd->tf_flags & IDE_TFLAG_WRITE))
                                scsi_req(rq)->resid_len += cmd->last_xfer_len;
@@ -739,7 +751,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
        ide_debug_log(IDE_DBG_PC, "rq->cmd[0]: 0x%x, rq->cmd_type: 0x%x",
                                  rq->cmd[0], rq->cmd_type);
 
-       if (rq->cmd_type == REQ_TYPE_BLOCK_PC)
+       if (blk_rq_is_scsi(rq))
                rq->rq_flags |= RQF_QUIET;
        else
                rq->rq_flags &= ~RQF_FAILED;
@@ -781,18 +793,20 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
        if (drive->debug_mask & IDE_DBG_RQ)
                blk_dump_rq_flags(rq, "ide_cd_do_request");
 
-       switch (rq->cmd_type) {
-       case REQ_TYPE_FS:
+       switch (req_op(rq)) {
+       default:
                if (cdrom_start_rw(drive, rq) == ide_stopped)
                        goto out_end;
                break;
-       case REQ_TYPE_BLOCK_PC:
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
        handle_pc:
                if (!rq->timeout)
                        rq->timeout = ATAPI_WAIT_PC;
                cdrom_do_block_pc(drive, rq);
                break;
-       case REQ_TYPE_DRV_PRIV:
+       case REQ_OP_DRV_IN:
+       case REQ_OP_DRV_OUT:
                switch (ide_req(rq)->type) {
                case ATA_PRIV_MISC:
                        /* right now this can only be a reset... */
@@ -801,9 +815,9 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
                case ATA_PRIV_SENSE:
                case ATA_PRIV_PC:
                        goto handle_pc;
+               default:
+                       BUG();
                }
-       default:
-               BUG();
        }
 
        /* prepare sense request for this command */
@@ -816,7 +830,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
 
        cmd.rq = rq;
 
-       if (rq->cmd_type == REQ_TYPE_FS || blk_rq_bytes(rq)) {
+       if (!blk_rq_is_passthrough(rq) || blk_rq_bytes(rq)) {
                ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
                ide_map_sg(drive, &cmd);
        }
@@ -1373,9 +1387,9 @@ static int ide_cdrom_prep_pc(struct request *rq)
 
 static int ide_cdrom_prep_fn(struct request_queue *q, struct request *rq)
 {
-       if (rq->cmd_type == REQ_TYPE_FS)
+       if (!blk_rq_is_passthrough(rq))
                return ide_cdrom_prep_fs(q, rq);
-       else if (rq->cmd_type == REQ_TYPE_BLOCK_PC)
+       else if (blk_rq_is_scsi(rq))
                return ide_cdrom_prep_pc(rq);
 
        return 0;
index 3f03eed0ff788f44115ece617642c80497b87f57..9fcefbc8425e748cf27b4967f2a16fcc67605965 100644 (file)
@@ -303,9 +303,8 @@ int ide_cdrom_reset(struct cdrom_device_info *cdi)
        struct request *rq;
        int ret;
 
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        rq->rq_flags = RQF_QUIET;
        ret = blk_execute_rq(drive->queue, cd->disk, rq, 0);
index c040b9de2b4e46f1007fb50311b7e59713bde4a4..a45dda5386e4403206ee73a18b8bb8b16b012e65 100644 (file)
@@ -165,9 +165,8 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting,
        if (!(setting->flags & DS_SYNC))
                return setting->set(drive, arg);
 
-       rq = blk_get_request(q, READ, __GFP_RECLAIM);
+       rq = blk_get_request(q, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        scsi_req(rq)->cmd_len = 5;
        scsi_req(rq)->cmd[0] = REQ_DEVSET_EXEC;
index 69cf71729841abdec28f37de91beffbc2836ae62..186159715b71c6fd7a01eb11bc92239487c4dc7e 100644 (file)
@@ -184,7 +184,7 @@ static ide_startstop_t ide_do_rw_disk(ide_drive_t *drive, struct request *rq,
        ide_hwif_t *hwif = drive->hwif;
 
        BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED);
-       BUG_ON(rq->cmd_type != REQ_TYPE_FS);
+       BUG_ON(blk_rq_is_passthrough(rq));
 
        ledtrig_disk_activity();
 
@@ -452,8 +452,8 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
        cmd->valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE;
        cmd->tf_flags = IDE_TFLAG_DYN;
        cmd->protocol = ATA_PROT_NODATA;
-
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
+       rq->cmd_flags &= ~REQ_OP_MASK;
+       rq->cmd_flags |= REQ_OP_DRV_OUT;
        ide_req(rq)->type = ATA_PRIV_TASKFILE;
        rq->special = cmd;
        cmd->rq = rq;
@@ -478,9 +478,8 @@ static int set_multcount(ide_drive_t *drive, int arg)
        if (drive->special_flags & IDE_SFLAG_SET_MULTMODE)
                return -EBUSY;
 
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_TASKFILE;
 
        drive->mult_req = arg;
index 1e4b1476e55926b9033201a9064826577758934f..cf3af68403689a62f9c237d7d1ced636a1aca6b5 100644 (file)
@@ -123,7 +123,7 @@ ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
                return ide_stopped;
 
        /* retry only "normal" I/O: */
-       if (rq->cmd_type != REQ_TYPE_FS) {
+       if (blk_rq_is_passthrough(rq)) {
                if (ata_taskfile_request(rq)) {
                        struct ide_cmd *cmd = rq->special;
 
index 24c6d363b3a4cadc204a3c1f96f3a0e4d5b9e702..a69e8013f1dff9ff0e8b63fea7cee0ca3767a23f 100644 (file)
@@ -72,7 +72,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
                drive->failed_pc = NULL;
 
        if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
-           rq->cmd_type == REQ_TYPE_BLOCK_PC)
+           (req_op(rq) == REQ_OP_SCSI_IN || req_op(rq) == REQ_OP_SCSI_OUT))
                uptodate = 1; /* FIXME */
        else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
 
@@ -254,8 +254,8 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
                        goto out_end;
        }
 
-       switch (rq->cmd_type) {
-       case REQ_TYPE_FS:
+       switch (req_op(rq)) {
+       default:
                if (((long)blk_rq_pos(rq) % floppy->bs_factor) ||
                    (blk_rq_sectors(rq) % floppy->bs_factor)) {
                        printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
@@ -265,11 +265,13 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
                pc = &floppy->queued_pc;
                idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
                break;
-       case REQ_TYPE_BLOCK_PC:
+       case REQ_OP_SCSI_IN:
+       case REQ_OP_SCSI_OUT:
                pc = &floppy->queued_pc;
                idefloppy_blockpc_cmd(floppy, pc, rq);
                break;
-       case REQ_TYPE_DRV_PRIV:
+       case REQ_OP_DRV_IN:
+       case REQ_OP_DRV_OUT:
                switch (ide_req(rq)->type) {
                case ATA_PRIV_MISC:
                case ATA_PRIV_SENSE:
@@ -278,9 +280,6 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
                default:
                        BUG();
                }
-               break;
-       default:
-               BUG();
        }
 
        ide_prep_sense(drive, rq);
@@ -292,7 +291,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
 
        cmd.rq = rq;
 
-       if (rq->cmd_type == REQ_TYPE_FS || blk_rq_bytes(rq)) {
+       if (!blk_rq_is_passthrough(rq) || blk_rq_bytes(rq)) {
                ide_init_sg_cmd(&cmd, blk_rq_bytes(rq));
                ide_map_sg(drive, &cmd);
        }
@@ -302,7 +301,7 @@ static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
        return ide_floppy_issue_pc(drive, &cmd, pc);
 out_end:
        drive->failed_pc = NULL;
-       if (rq->cmd_type != REQ_TYPE_FS && rq->errors == 0)
+       if (blk_rq_is_passthrough(rq) && rq->errors == 0)
                rq->errors = -EIO;
        ide_complete_rq(drive, -EIO, blk_rq_bytes(rq));
        return ide_stopped;
index 6735c92b8da7d6d7c7d603445fb70f33a39c312e..043b1fb963cb89982029dddad977c386f8e6bfde 100644 (file)
@@ -145,7 +145,7 @@ void ide_kill_rq(ide_drive_t *drive, struct request *rq)
        } else {
                if (media == ide_tape)
                        rq->errors = IDE_DRV_ERROR_GENERAL;
-               else if (rq->cmd_type != REQ_TYPE_FS && rq->errors == 0)
+               else if (blk_rq_is_passthrough(rq) && rq->errors == 0)
                        rq->errors = -EIO;
        }
 
index fc19e842deefb2e55429a793977bd8db6bfea6fa..248a3e0ceb468bdb57e896425a642375e77355be 100644 (file)
@@ -125,9 +125,8 @@ static int ide_cmd_ioctl(ide_drive_t *drive, unsigned long arg)
        if (NULL == (void *) arg) {
                struct request *rq;
 
-               rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+               rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
                scsi_req_init(rq);
-               rq->cmd_type = REQ_TYPE_DRV_PRIV;
                ide_req(rq)->type = ATA_PRIV_TASKFILE;
                err = blk_execute_rq(drive->queue, NULL, rq, 0);
                blk_put_request(rq);
@@ -223,9 +222,8 @@ static int generic_drive_reset(ide_drive_t *drive)
        struct request *rq;
        int ret = 0;
 
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        scsi_req(rq)->cmd_len = 1;
        scsi_req(rq)->cmd[0] = REQ_DRIVE_RESET;
index fc3c944ca4be2a8ff9e4b1bcaa9bbf34c7805a49..101aed9a61ca319439d825c6e433a53175e0ed64 100644 (file)
@@ -31,11 +31,10 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
        }
        spin_unlock_irq(&hwif->lock);
 
-       rq = blk_get_request(q, READ, __GFP_RECLAIM);
+       rq = blk_get_request(q, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
        scsi_req(rq)->cmd[0] = REQ_PARK_HEADS;
        scsi_req(rq)->cmd_len = 1;
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        rq->special = &timeout;
        rc = blk_execute_rq(q, NULL, rq, 1);
@@ -47,14 +46,13 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
         * Make sure that *some* command is sent to the drive after the
         * timeout has expired, so power management will be reenabled.
         */
-       rq = blk_get_request(q, READ, GFP_NOWAIT);
+       rq = blk_get_request(q, REQ_OP_DRV_IN, GFP_NOWAIT);
        scsi_req_init(rq);
        if (IS_ERR(rq))
                goto out;
 
        scsi_req(rq)->cmd[0] = REQ_UNPARK_HEADS;
        scsi_req(rq)->cmd_len = 1;
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        elv_add_request(q, rq, ELEVATOR_INSERT_FRONT);
 
index 0c1296815dfad25be614f377933fc4f580b7325e..ec951be4b0c8ab0950ca31dbeb070520c925230e 100644 (file)
@@ -18,9 +18,8 @@ int generic_ide_suspend(struct device *dev, pm_message_t mesg)
        }
 
        memset(&rqpm, 0, sizeof(rqpm));
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_PM_SUSPEND;
        rq->special = &rqpm;
        rqpm.pm_step = IDE_PM_START_SUSPEND;
@@ -90,9 +89,8 @@ int generic_ide_resume(struct device *dev)
        }
 
        memset(&rqpm, 0, sizeof(rqpm));
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_PM_RESUME;
        rq->rq_flags |= RQF_PREEMPT;
        rq->special = &rqpm;
@@ -244,12 +242,12 @@ void ide_check_pm_state(ide_drive_t *drive, struct request *rq)
 {
        struct ide_pm_state *pm = rq->special;
 
-       if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
+       if (blk_rq_is_private(rq) &&
            ide_req(rq)->type == ATA_PRIV_PM_SUSPEND &&
            pm->pm_step == IDE_PM_START_SUSPEND)
                /* Mark drive blocked when starting the suspend sequence. */
                drive->dev_flags |= IDE_DFLAG_BLOCKED;
-       else if (rq->cmd_type == REQ_TYPE_DRV_PRIV &&
+       else if (blk_rq_is_private(rq) &&
                 ide_req(rq)->type == ATA_PRIV_PM_RESUME &&
                 pm->pm_step == IDE_PM_START_RESUME) {
                /*
index 37c7beabaacc55ba02ed66b68c7e0e8109508b08..3c1b7974d66de7657d357943646293de7c10efff 100644 (file)
@@ -577,7 +577,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive,
                      req->cmd[0], (unsigned long long)blk_rq_pos(rq),
                      blk_rq_sectors(rq));
 
-       BUG_ON(rq->cmd_type != REQ_TYPE_DRV_PRIV);
+       BUG_ON(!blk_rq_is_private(rq));
        BUG_ON(ide_req(rq)->type != ATA_PRIV_MISC &&
               ide_req(rq)->type != ATA_PRIV_SENSE);
 
@@ -854,9 +854,8 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int size)
        BUG_ON(cmd != REQ_IDETAPE_READ && cmd != REQ_IDETAPE_WRITE);
        BUG_ON(size < 0 || size % tape->blk_size);
 
-       rq = blk_get_request(drive->queue, READ, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_MISC;
        scsi_req(rq)->cmd[13] = cmd;
        rq->rq_disk = tape->disk;
index 9ccc1d57339310b3cac3b6cf2eff87f51776b361..247b9faccce171d607b275e4849dc28d9c8d1f23 100644 (file)
@@ -428,11 +428,11 @@ int ide_raw_taskfile(ide_drive_t *drive, struct ide_cmd *cmd, u8 *buf,
 {
        struct request *rq;
        int error;
-       int rw = !(cmd->tf_flags & IDE_TFLAG_WRITE) ? READ : WRITE;
 
-       rq = blk_get_request(drive->queue, rw, __GFP_RECLAIM);
+       rq = blk_get_request(drive->queue,
+               (cmd->tf_flags & IDE_TFLAG_WRITE) ?
+                       REQ_OP_DRV_OUT : REQ_OP_DRV_IN, __GFP_RECLAIM);
        scsi_req_init(rq);
-       rq->cmd_type = REQ_TYPE_DRV_PRIV;
        ide_req(rq)->type = ATA_PRIV_TASKFILE;
 
        /*
index df8a5ef334c0a42e78cfd6e382d413916bd6f2a6..6b8d5cd7dbf6bdc3442c1d44ae136a3c6f885aff 100644 (file)
@@ -84,9 +84,6 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
        nsect = blk_rq_cur_bytes(req) >> tr->blkshift;
        buf = bio_data(req->bio);
 
-       if (req->cmd_type != REQ_TYPE_FS)
-               return -EIO;
-
        if (req_op(req) == REQ_OP_FLUSH)
                return tr->flush(dev);
 
@@ -94,16 +91,16 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
            get_capacity(req->rq_disk))
                return -EIO;
 
-       if (req_op(req) == REQ_OP_DISCARD)
+       switch (req_op(req)) {
+       case REQ_OP_DISCARD:
                return tr->discard(dev, block, nsect);
-
-       if (rq_data_dir(req) == READ) {
+       case REQ_OP_READ:
                for (; nsect > 0; nsect--, block++, buf += tr->blksize)
                        if (tr->readsect(dev, block, buf))
                                return -EIO;
                rq_flush_dcache_pages(req);
                return 0;
-       } else {
+       case REQ_OP_WRITE:
                if (!tr->writesect)
                        return -EIO;
 
@@ -112,6 +109,8 @@ static int do_blktrans_request(struct mtd_blktrans_ops *tr,
                        if (tr->writesect(dev, block, buf))
                                return -EIO;
                return 0;
+       default:
+               return -EIO;
        }
 }
 
index d1e6931c132f79a5a7a57557c75644170c6ee4a6..c80869e60909c91f66ea4a1bb532bd18368e724d 100644 (file)
@@ -323,16 +323,15 @@ static int ubiblock_queue_rq(struct blk_mq_hw_ctx *hctx,
        struct ubiblock *dev = hctx->queue->queuedata;
        struct ubiblock_pdu *pdu = blk_mq_rq_to_pdu(req);
 
-       if (req->cmd_type != REQ_TYPE_FS)
+       switch (req_op(req)) {
+       case REQ_OP_READ:
+               ubi_sgl_init(&pdu->usgl);
+               queue_work(dev->wq, &pdu->work);
+               return BLK_MQ_RQ_QUEUE_OK;
+       default:
                return BLK_MQ_RQ_QUEUE_ERROR;
+       }
 
-       if (rq_data_dir(req) != READ)
-               return BLK_MQ_RQ_QUEUE_ERROR; /* Write not implemented */
-
-       ubi_sgl_init(&pdu->usgl);
-       queue_work(dev->wq, &pdu->work);
-
-       return BLK_MQ_RQ_QUEUE_OK;
 }
 
 static int ubiblock_init_request(void *data, struct request *req,
index 8a3c3e32a704b3e359a78ed06e95c6e977f322bc..1640a5c8abbb599e6cc87a61a75f79f1ebeec730 100644 (file)
@@ -208,18 +208,18 @@ EXPORT_SYMBOL_GPL(nvme_requeue_req);
 struct request *nvme_alloc_request(struct request_queue *q,
                struct nvme_command *cmd, unsigned int flags, int qid)
 {
+       unsigned op = nvme_is_write(cmd) ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
        struct request *req;
 
        if (qid == NVME_QID_ANY) {
-               req = blk_mq_alloc_request(q, nvme_is_write(cmd), flags);
+               req = blk_mq_alloc_request(q, op, flags);
        } else {
-               req = blk_mq_alloc_request_hctx(q, nvme_is_write(cmd), flags,
+               req = blk_mq_alloc_request_hctx(q, op, flags,
                                qid ? qid - 1 : 0);
        }
        if (IS_ERR(req))
                return req;
 
-       req->cmd_type = REQ_TYPE_DRV_PRIV;
        req->cmd_flags |= REQ_FAILFAST_DRIVER;
        nvme_req(req)->cmd = cmd;
 
@@ -309,17 +309,27 @@ int nvme_setup_cmd(struct nvme_ns *ns, struct request *req,
 {
        int ret = BLK_MQ_RQ_QUEUE_OK;
 
-       if (req->cmd_type == REQ_TYPE_DRV_PRIV)
+       switch (req_op(req)) {
+       case REQ_OP_DRV_IN:
+       case REQ_OP_DRV_OUT:
                memcpy(cmd, nvme_req(req)->cmd, sizeof(*cmd));
-       else if (req_op(req) == REQ_OP_FLUSH)
+               break;
+       case REQ_OP_FLUSH:
                nvme_setup_flush(ns, cmd);
-       else if (req_op(req) == REQ_OP_DISCARD)
+               break;
+       case REQ_OP_DISCARD:
                ret = nvme_setup_discard(ns, req, cmd);
-       else
+               break;
+       case REQ_OP_READ:
+       case REQ_OP_WRITE:
                nvme_setup_rw(ns, req, cmd);
+               break;
+       default:
+               WARN_ON_ONCE(1);
+               return BLK_MQ_RQ_QUEUE_ERROR;
+       }
 
        cmd->common.command_id = req->tag;
-
        return ret;
 }
 EXPORT_SYMBOL_GPL(nvme_setup_cmd);
index ecc79b2fcfafe5845a49f33e8e1f1a51e39d3b0e..a75e95d42b3febf5edba65c4ba7ed5181aa08c20 100644 (file)
@@ -1471,7 +1471,7 @@ static int nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
        ib_dma_sync_single_for_device(dev, sqe->dma,
                        sizeof(struct nvme_command), DMA_TO_DEVICE);
 
-       if (rq->cmd_type == REQ_TYPE_FS && req_op(rq) == REQ_OP_FLUSH)
+       if (req_op(rq) == REQ_OP_FLUSH)
                flush = true;
        ret = nvme_rdma_post_send(queue, sqe, req->sge, req->num_sge,
                        req->mr->need_inval ? &req->reg_wr.wr : NULL, flush);
index fcb040eebf47dda3902cdeb3edbe7736845fd04e..30b905080c61412a3e8e1234157e687594e0a041 100644 (file)
@@ -1565,7 +1565,8 @@ static struct request *_make_request(struct request_queue *q, bool has_write,
        struct bio *bio = oii->bio;
        int ret;
 
-       req = blk_get_request(q, has_write ? WRITE : READ, flags);
+       req = blk_get_request(q, has_write ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
+                       flags);
        if (IS_ERR(req))
                return req;
        scsi_req_init(req);
index d314aa5c71cf3b9b99ee2b3cf53a7079d5617505..451de6c5e3c9942b3a8094bd705fbd234b094f91 100644 (file)
@@ -367,7 +367,8 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,
        int err = 0;
        int write = (data_direction == DMA_TO_DEVICE);
 
-       req = blk_get_request(SRpnt->stp->device->request_queue, write, GFP_KERNEL);
+       req = blk_get_request(SRpnt->stp->device->request_queue,
+                       write ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, GFP_KERNEL);
        if (IS_ERR(req))
                return DRIVER_ERROR << 24;
 
index b4ce7bb5d2a9edc66ae7f3fe7ca862f41cb80da1..9e82fa5715bc917bba8f49c7a603b8aea69e8871 100644 (file)
@@ -1974,7 +1974,7 @@ static void scsi_eh_lock_door(struct scsi_device *sdev)
         * blk_get_request with GFP_KERNEL (__GFP_RECLAIM) sleeps until a
         * request becomes available
         */
-       req = blk_get_request(sdev->request_queue, READ, GFP_KERNEL);
+       req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, GFP_KERNEL);
        if (IS_ERR(req))
                return;
        rq = scsi_req(req);
index 31629a7b728dd9ea6e0cf897bb729bcd94502ba1..90f65c8f487aa3594655e4e43e06723b1344754b 100644 (file)
@@ -219,11 +219,12 @@ static int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
                 req_flags_t rq_flags, int *resid)
 {
        struct request *req;
-       int write = (data_direction == DMA_TO_DEVICE);
        struct scsi_request *rq;
        int ret = DRIVER_ERROR << 24;
 
-       req = blk_get_request(sdev->request_queue, write, __GFP_RECLAIM);
+       req = blk_get_request(sdev->request_queue,
+                       data_direction == DMA_TO_DEVICE ?
+                       REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, __GFP_RECLAIM);
        if (IS_ERR(req))
                return ret;
        rq = scsi_req(req);
@@ -839,8 +840,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                }
        } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) {
                /*
-                * Certain non BLOCK_PC requests are commands that don't
-                * actually transfer anything (FLUSH), so cannot use
+                * Flush commands do not transfers any data, and thus cannot use
                 * good_bytes != blk_rq_bytes(req) as the signal for an error.
                 * This sets the error explicitly for the problem case.
                 */
@@ -859,8 +859,8 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                blk_rq_sectors(req), good_bytes));
 
        /*
-        * Recovered errors need reporting, but they're always treated
-        * as success, so fiddle the result code here.  For BLOCK_PC
+        * Recovered errors need reporting, but they're always treated as
+        * success, so fiddle the result code here.  For passthrough requests
         * we already took a copy of the original into rq->errors which
         * is what gets returned to the user
         */
@@ -874,7 +874,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
                else if (!(req->rq_flags & RQF_QUIET))
                        scsi_print_sense(cmd);
                result = 0;
-               /* BLOCK_PC may have set error */
+               /* for passthrough error may be set */
                error = 0;
        }
 
@@ -1179,12 +1179,12 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
        spin_unlock_irqrestore(&dev->list_lock, flags);
 }
 
-static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
+static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req)
 {
        struct scsi_cmnd *cmd = req->special;
 
        /*
-        * BLOCK_PC requests may transfer data, in which case they must
+        * Passthrough requests may transfer data, in which case they must
         * a bio attached to them.  Or they might contain a SCSI command
         * that does not transfer data, in which case they may optionally
         * submit a request without an attached bio.
@@ -1207,7 +1207,7 @@ static int scsi_setup_blk_pc_cmnd(struct scsi_device *sdev, struct request *req)
 }
 
 /*
- * Setup a REQ_TYPE_FS command.  These are simple request from filesystems
+ * Setup a normal block command.  These are simple request from filesystems
  * that still need to be translated to SCSI CDBs from the ULD.
  */
 static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
@@ -1236,14 +1236,10 @@ static int scsi_setup_cmnd(struct scsi_device *sdev, struct request *req)
        else
                cmd->sc_data_direction = DMA_FROM_DEVICE;
 
-       switch (req->cmd_type) {
-       case REQ_TYPE_FS:
+       if (blk_rq_is_scsi(req))
+               return scsi_setup_scsi_cmnd(sdev, req);
+       else
                return scsi_setup_fs_cmnd(sdev, req);
-       case REQ_TYPE_BLOCK_PC:
-               return scsi_setup_blk_pc_cmnd(sdev, req);
-       default:
-               return BLKPREP_KILL;
-       }
 }
 
 static int
index 226a8def7a8bb2173224a56f1742bc4f9ffc4123..e0e308b7e01aac52c32694eb574e647888ae1baa 100644 (file)
@@ -1698,7 +1698,8 @@ sg_start_req(Sg_request *srp, unsigned char *cmd)
         * With scsi-mq disabled, blk_get_request() with GFP_KERNEL usually
         * does not sleep except under memory pressure.
         */
-       rq = blk_get_request(q, rw, GFP_KERNEL);
+       rq = blk_get_request(q, hp->dxfer_direction == SG_DXFER_TO_DEV ?
+                       REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, GFP_KERNEL);
        if (IS_ERR(rq)) {
                kfree(long_cmdp);
                return PTR_ERR(rq);
index 94352e4df831be803c3ef6a76cf7f6177750f29c..2e1d910092d88079314bf315225e5c33d57a066f 100644 (file)
@@ -437,14 +437,17 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
                goto out;
        }
 
-       if (rq_data_dir(rq) == WRITE) {
+       switch (req_op(rq)) {
+       case REQ_OP_WRITE:
                if (!cd->writeable)
                        goto out;
                SCpnt->cmnd[0] = WRITE_10;
                cd->cdi.media_written = 1;
-       } else if (rq_data_dir(rq) == READ) {
+               break;
+       case REQ_OP_READ:
                SCpnt->cmnd[0] = READ_10;
-       } else {
+               break;
+       default:
                blk_dump_rq_flags(rq, "Unknown sr command");
                goto out;
        }
index 4af900100a24bc920540012839bd44c404de4359..81212d4bd9bf2d5e5982ca2f4359ea12b712dced 100644 (file)
@@ -541,11 +541,11 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
        struct scsi_request *rq;
        struct rq_map_data *mdata = &SRpnt->stp->buffer->map_data;
        int err = 0;
-       int write = (data_direction == DMA_TO_DEVICE);
        struct scsi_tape *STp = SRpnt->stp;
 
-       req = blk_get_request(SRpnt->stp->device->request_queue, write,
-                             GFP_KERNEL);
+       req = blk_get_request(SRpnt->stp->device->request_queue,
+                       data_direction == DMA_TO_DEVICE ?
+                       REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, GFP_KERNEL);
        if (IS_ERR(req))
                return DRIVER_ERROR << 24;
        rq = scsi_req(req);
index e52f4e1a4675a8e0740bec26544aecf5e6259061..a8f8e53f2f574852de573a08a86ad1c25b4cf332 100644 (file)
@@ -1005,7 +1005,8 @@ pscsi_execute_cmd(struct se_cmd *cmd)
                scsi_command_size(cmd->t_task_cdb));
 
        req = blk_get_request(pdv->pdv_sd->request_queue,
-                       (cmd->data_direction == DMA_TO_DEVICE),
+                       cmd->data_direction == DMA_TO_DEVICE ?
+                       REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
                        GFP_KERNEL);
        if (IS_ERR(req)) {
                pr_err("PSCSI: blk_get_request() failed\n");
index 930d98caab5b5b3370769c3772be642300530fed..a06115e3161244f37f549b3d83629a620d0a2019 100644 (file)
@@ -223,7 +223,7 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
        if (!buf)
                return -ENOMEM;
 
-       rq = blk_get_request(q, READ, GFP_KERNEL);
+       rq = blk_get_request(q, REQ_OP_SCSI_IN, GFP_KERNEL);
        if (IS_ERR(rq)) {
                error = -ENOMEM;
                goto out_free_buf;
index 37c9a43c5e789f93dece3f3b6b85bf880aa2119b..d703acb55d0f0d196296ef4d82f4e97a5efd9c3a 100644 (file)
@@ -162,6 +162,13 @@ enum req_opf {
        /* write the zero filled sector many times */
        REQ_OP_WRITE_ZEROES     = 8,
 
+       /* SCSI passthrough using struct scsi_request */
+       REQ_OP_SCSI_IN          = 32,
+       REQ_OP_SCSI_OUT         = 33,
+       /* Driver private requests */
+       REQ_OP_DRV_IN           = 34,
+       REQ_OP_DRV_OUT          = 35,
+
        REQ_OP_LAST,
 };
 
index 7121be0815178149939ea0d164c4cac5b4ff7d8a..1e947e725528edf4d8fc0536633597b85d430460 100644 (file)
@@ -70,15 +70,6 @@ struct request_list {
        unsigned int            flags;
 };
 
-/*
- * request command types
- */
-enum rq_cmd_type_bits {
-       REQ_TYPE_FS             = 1,    /* fs request */
-       REQ_TYPE_BLOCK_PC,              /* scsi command */
-       REQ_TYPE_DRV_PRIV,              /* driver defined types from here */
-};
-
 /*
  * request flags */
 typedef __u32 __bitwise req_flags_t;
@@ -145,7 +136,6 @@ struct request {
        struct blk_mq_ctx *mq_ctx;
 
        int cpu;
-       unsigned cmd_type;
        unsigned int cmd_flags;         /* op and common flags */
        req_flags_t rq_flags;
        unsigned long atomic_flags;
@@ -242,9 +232,19 @@ struct request {
        struct request *next_rq;
 };
 
+static inline bool blk_rq_is_scsi(struct request *rq)
+{
+       return req_op(rq) == REQ_OP_SCSI_IN || req_op(rq) == REQ_OP_SCSI_OUT;
+}
+
+static inline bool blk_rq_is_private(struct request *rq)
+{
+       return req_op(rq) == REQ_OP_DRV_IN || req_op(rq) == REQ_OP_DRV_OUT;
+}
+
 static inline bool blk_rq_is_passthrough(struct request *rq)
 {
-       return rq->cmd_type != REQ_TYPE_FS;
+       return blk_rq_is_scsi(rq) || blk_rq_is_private(rq);
 }
 
 static inline unsigned short req_get_ioprio(struct request *req)
index 5cc6caa94cac0230236de84af27f46ecd750b2e2..2f51c1724b5af647423770dfadafaa7a8837b600 100644 (file)
@@ -63,31 +63,27 @@ static inline struct ide_request *ide_req(struct request *rq)
 
 static inline bool ata_misc_request(struct request *rq)
 {
-       return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
-               ide_req(rq)->type == ATA_PRIV_MISC;
+       return blk_rq_is_private(rq) && ide_req(rq)->type == ATA_PRIV_MISC;
 }
 
 static inline bool ata_taskfile_request(struct request *rq)
 {
-       return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
-               ide_req(rq)->type == ATA_PRIV_TASKFILE;
+       return blk_rq_is_private(rq) && ide_req(rq)->type == ATA_PRIV_TASKFILE;
 }
 
 static inline bool ata_pc_request(struct request *rq)
 {
-       return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
-               ide_req(rq)->type == ATA_PRIV_PC;
+       return blk_rq_is_private(rq) && ide_req(rq)->type == ATA_PRIV_PC;
 }
 
 static inline bool ata_sense_request(struct request *rq)
 {
-       return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
-               ide_req(rq)->type == ATA_PRIV_SENSE;
+       return blk_rq_is_private(rq) && ide_req(rq)->type == ATA_PRIV_SENSE;
 }
 
 static inline bool ata_pm_request(struct request *rq)
 {
-       return rq->cmd_type == REQ_TYPE_DRV_PRIV &&
+       return blk_rq_is_private(rq) &&
                (ide_req(rq)->type == ATA_PRIV_PM_SUSPEND ||
                 ide_req(rq)->type == ATA_PRIV_PM_RESUME);
 }