summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-01-31 10:57:29 -0500
committerJens Axboe <axboe@fb.com>2017-01-31 16:00:34 -0500
commit57292b58ddb58689e8c3b4c6eadbef10d9ca44dd (patch)
treedd6e5af538b2f2684d2090781f668c7099a0455e
parent09fc54ccc42744669e748434af5c2f8adcad900f (diff)
block: introduce blk_rq_is_passthrough
This can be used to check for fs vs non-fs requests and basically removes all knowledge of BLOCK_PC specific from the block layer, as well as preparing for removing the cmd_type field in struct request. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r--block/blk-core.c8
-rw-r--r--block/blk-exec.c2
-rw-r--r--block/blk.h2
-rw-r--r--block/elevator.c4
-rw-r--r--block/mq-deadline.c2
-rw-r--r--drivers/ata/libata-scsi.c2
-rw-r--r--drivers/block/cciss.c36
-rw-r--r--drivers/nvme/host/fc.c2
-rw-r--r--drivers/nvme/host/pci.c4
-rw-r--r--drivers/nvme/host/rdma.c4
-rw-r--r--drivers/nvme/target/loop.c2
-rw-r--r--drivers/scsi/hpsa.c4
-rw-r--r--drivers/scsi/scsi.c2
-rw-r--r--drivers/scsi/scsi_error.c4
-rw-r--r--drivers/scsi/scsi_lib.c6
-rw-r--r--drivers/scsi/smartpqi/smartpqi_init.c2
-rw-r--r--drivers/scsi/sun3_scsi.c2
-rw-r--r--include/linux/blkdev.h16
-rw-r--r--include/linux/blktrace_api.h4
-rw-r--r--include/scsi/scsi_cmnd.h2
-rw-r--r--kernel/trace/blktrace.c2
21 files changed, 59 insertions, 53 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 95829523cded..44431086e4e7 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2506,10 +2506,10 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
2506 * TODO: tj: This is too subtle. It would be better to let 2506 * TODO: tj: This is too subtle. It would be better to let
2507 * low level drivers do what they see fit. 2507 * low level drivers do what they see fit.
2508 */ 2508 */
2509 if (req->cmd_type == REQ_TYPE_FS) 2509 if (!blk_rq_is_passthrough(req))
2510 req->errors = 0; 2510 req->errors = 0;
2511 2511
2512 if (error && req->cmd_type == REQ_TYPE_FS && 2512 if (error && !blk_rq_is_passthrough(req) &&
2513 !(req->rq_flags & RQF_QUIET)) { 2513 !(req->rq_flags & RQF_QUIET)) {
2514 char *error_type; 2514 char *error_type;
2515 2515
@@ -2581,7 +2581,7 @@ bool blk_update_request(struct request *req, int error, unsigned int nr_bytes)
2581 req->__data_len -= total_bytes; 2581 req->__data_len -= total_bytes;
2582 2582
2583 /* update sector only for requests with clear definition of sector */ 2583 /* update sector only for requests with clear definition of sector */
2584 if (req->cmd_type == REQ_TYPE_FS) 2584 if (!blk_rq_is_passthrough(req))
2585 req->__sector += total_bytes >> 9; 2585 req->__sector += total_bytes >> 9;
2586 2586
2587 /* mixed attributes always follow the first bio */ 2587 /* mixed attributes always follow the first bio */
@@ -2659,7 +2659,7 @@ void blk_finish_request(struct request *req, int error)
2659 2659
2660 BUG_ON(blk_queued_rq(req)); 2660 BUG_ON(blk_queued_rq(req));
2661 2661
2662 if (unlikely(laptop_mode) && req->cmd_type == REQ_TYPE_FS) 2662 if (unlikely(laptop_mode) && !blk_rq_is_passthrough(req))
2663 laptop_io_completion(&req->q->backing_dev_info); 2663 laptop_io_completion(&req->q->backing_dev_info);
2664 2664
2665 blk_delete_timer(req); 2665 blk_delete_timer(req);
diff --git a/block/blk-exec.c b/block/blk-exec.c
index ed51800f4b44..8cd0e9bc8dc8 100644
--- a/block/blk-exec.c
+++ b/block/blk-exec.c
@@ -51,7 +51,7 @@ void blk_execute_rq_nowait(struct request_queue *q, struct gendisk *bd_disk,
51 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK; 51 int where = at_head ? ELEVATOR_INSERT_FRONT : ELEVATOR_INSERT_BACK;
52 52
53 WARN_ON(irqs_disabled()); 53 WARN_ON(irqs_disabled());
54 WARN_ON(rq->cmd_type == REQ_TYPE_FS); 54 WARN_ON(!blk_rq_is_passthrough(rq));
55 55
56 rq->rq_disk = bd_disk; 56 rq->rq_disk = bd_disk;
57 rq->end_io = done; 57 rq->end_io = done;
diff --git a/block/blk.h b/block/blk.h
index 9a716b5925a4..c1bd4bf9e645 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -249,7 +249,7 @@ static inline int blk_do_io_stat(struct request *rq)
249{ 249{
250 return rq->rq_disk && 250 return rq->rq_disk &&
251 (rq->rq_flags & RQF_IO_STAT) && 251 (rq->rq_flags & RQF_IO_STAT) &&
252 (rq->cmd_type == REQ_TYPE_FS); 252 !blk_rq_is_passthrough(rq);
253} 253}
254 254
255/* 255/*
diff --git a/block/elevator.c b/block/elevator.c
index ef7f59469acc..dba9be891a6b 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -634,7 +634,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)
634 634
635 if (rq->rq_flags & RQF_SOFTBARRIER) { 635 if (rq->rq_flags & RQF_SOFTBARRIER) {
636 /* barriers are scheduling boundary, update end_sector */ 636 /* barriers are scheduling boundary, update end_sector */
637 if (rq->cmd_type == REQ_TYPE_FS) { 637 if (!blk_rq_is_passthrough(rq)) {
638 q->end_sector = rq_end_sector(rq); 638 q->end_sector = rq_end_sector(rq);
639 q->boundary_rq = rq; 639 q->boundary_rq = rq;
640 } 640 }
@@ -676,7 +676,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where)
676 if (elv_attempt_insert_merge(q, rq)) 676 if (elv_attempt_insert_merge(q, rq))
677 break; 677 break;
678 case ELEVATOR_INSERT_SORT: 678 case ELEVATOR_INSERT_SORT:
679 BUG_ON(rq->cmd_type != REQ_TYPE_FS); 679 BUG_ON(blk_rq_is_passthrough(rq));
680 rq->rq_flags |= RQF_SORTED; 680 rq->rq_flags |= RQF_SORTED;
681 q->nr_sorted++; 681 q->nr_sorted++;
682 if (rq_mergeable(rq)) { 682 if (rq_mergeable(rq)) {
diff --git a/block/mq-deadline.c b/block/mq-deadline.c
index d93ec713fa62..49583536698c 100644
--- a/block/mq-deadline.c
+++ b/block/mq-deadline.c
@@ -398,7 +398,7 @@ static void dd_insert_request(struct blk_mq_hw_ctx *hctx, struct request *rq,
398 if (blk_mq_sched_bypass_insert(hctx, rq)) 398 if (blk_mq_sched_bypass_insert(hctx, rq))
399 return; 399 return;
400 400
401 if (at_head || rq->cmd_type != REQ_TYPE_FS) { 401 if (at_head || blk_rq_is_passthrough(rq)) {
402 if (at_head) 402 if (at_head)
403 list_add(&rq->queuelist, &dd->dispatch); 403 list_add(&rq->queuelist, &dd->dispatch);
404 else 404 else
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 6abd73975f87..c771d4c341ea 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -1265,7 +1265,7 @@ static void ata_scsi_sdev_config(struct scsi_device *sdev)
1265 */ 1265 */
1266static int atapi_drain_needed(struct request *rq) 1266static int atapi_drain_needed(struct request *rq)
1267{ 1267{
1268 if (likely(rq->cmd_type != REQ_TYPE_BLOCK_PC)) 1268 if (likely(!blk_rq_is_passthrough(rq)))
1269 return 0; 1269 return 0;
1270 1270
1271 if (!blk_rq_bytes(rq) || op_is_write(req_op(rq))) 1271 if (!blk_rq_bytes(rq) || op_is_write(req_op(rq)))
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b93bb73b49d2..53dc2971a3ba 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1854,7 +1854,7 @@ static void cciss_softirq_done(struct request *rq)
1854 dev_dbg(&h->pdev->dev, "Done with %p\n", rq); 1854 dev_dbg(&h->pdev->dev, "Done with %p\n", rq);
1855 1855
1856 /* set the residual count for pc requests */ 1856 /* set the residual count for pc requests */
1857 if (rq->cmd_type == REQ_TYPE_BLOCK_PC) 1857 if (blk_rq_is_passthrough(rq))
1858 scsi_req(rq)->resid_len = c->err_info->ResidualCnt; 1858 scsi_req(rq)->resid_len = c->err_info->ResidualCnt;
1859 1859
1860 blk_end_request_all(rq, (rq->errors == 0) ? 0 : -EIO); 1860 blk_end_request_all(rq, (rq->errors == 0) ? 0 : -EIO);
@@ -3083,7 +3083,7 @@ static inline int evaluate_target_status(ctlr_info_t *h,
3083 driver_byte = DRIVER_OK; 3083 driver_byte = DRIVER_OK;
3084 msg_byte = cmd->err_info->CommandStatus; /* correct? seems too device specific */ 3084 msg_byte = cmd->err_info->CommandStatus; /* correct? seems too device specific */
3085 3085
3086 if (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) 3086 if (blk_rq_is_passthrough(cmd->rq))
3087 host_byte = DID_PASSTHROUGH; 3087 host_byte = DID_PASSTHROUGH;
3088 else 3088 else
3089 host_byte = DID_OK; 3089 host_byte = DID_OK;
@@ -3092,7 +3092,7 @@ static inline int evaluate_target_status(ctlr_info_t *h,
3092 host_byte, driver_byte); 3092 host_byte, driver_byte);
3093 3093
3094 if (cmd->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) { 3094 if (cmd->err_info->ScsiStatus != SAM_STAT_CHECK_CONDITION) {
3095 if (cmd->rq->cmd_type != REQ_TYPE_BLOCK_PC) 3095 if (!blk_rq_is_passthrough(cmd->rq))
3096 dev_warn(&h->pdev->dev, "cmd %p " 3096 dev_warn(&h->pdev->dev, "cmd %p "
3097 "has SCSI Status 0x%x\n", 3097 "has SCSI Status 0x%x\n",
3098 cmd, cmd->err_info->ScsiStatus); 3098 cmd, cmd->err_info->ScsiStatus);
@@ -3103,16 +3103,16 @@ static inline int evaluate_target_status(ctlr_info_t *h,
3103 sense_key = 0xf & cmd->err_info->SenseInfo[2]; 3103 sense_key = 0xf & cmd->err_info->SenseInfo[2];
3104 /* no status or recovered error */ 3104 /* no status or recovered error */
3105 if (((sense_key == 0x0) || (sense_key == 0x1)) && 3105 if (((sense_key == 0x0) || (sense_key == 0x1)) &&
3106 (cmd->rq->cmd_type != REQ_TYPE_BLOCK_PC)) 3106 !blk_rq_is_passthrough(cmd->rq))
3107 error_value = 0; 3107 error_value = 0;
3108 3108
3109 if (check_for_unit_attention(h, cmd)) { 3109 if (check_for_unit_attention(h, cmd)) {
3110 *retry_cmd = !(cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC); 3110 *retry_cmd = !blk_rq_is_passthrough(cmd->rq);
3111 return 0; 3111 return 0;
3112 } 3112 }
3113 3113
3114 /* Not SG_IO or similar? */ 3114 /* Not SG_IO or similar? */
3115 if (cmd->rq->cmd_type != REQ_TYPE_BLOCK_PC) { 3115 if (!blk_rq_is_passthrough(cmd->rq)) {
3116 if (error_value != 0) 3116 if (error_value != 0)
3117 dev_warn(&h->pdev->dev, "cmd %p has CHECK CONDITION" 3117 dev_warn(&h->pdev->dev, "cmd %p has CHECK CONDITION"
3118 " sense key = 0x%x\n", cmd, sense_key); 3118 " sense key = 0x%x\n", cmd, sense_key);
@@ -3146,14 +3146,14 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3146 rq->errors = evaluate_target_status(h, cmd, &retry_cmd); 3146 rq->errors = evaluate_target_status(h, cmd, &retry_cmd);
3147 break; 3147 break;
3148 case CMD_DATA_UNDERRUN: 3148 case CMD_DATA_UNDERRUN:
3149 if (cmd->rq->cmd_type == REQ_TYPE_FS) { 3149 if (!blk_rq_is_passthrough(cmd->rq)) {
3150 dev_warn(&h->pdev->dev, "cmd %p has" 3150 dev_warn(&h->pdev->dev, "cmd %p has"
3151 " completed with data underrun " 3151 " completed with data underrun "
3152 "reported\n", cmd); 3152 "reported\n", cmd);
3153 } 3153 }
3154 break; 3154 break;
3155 case CMD_DATA_OVERRUN: 3155 case CMD_DATA_OVERRUN:
3156 if (cmd->rq->cmd_type == REQ_TYPE_FS) 3156 if (!blk_rq_is_passthrough(cmd->rq))
3157 dev_warn(&h->pdev->dev, "cciss: cmd %p has" 3157 dev_warn(&h->pdev->dev, "cciss: cmd %p has"
3158 " completed with data overrun " 3158 " completed with data overrun "
3159 "reported\n", cmd); 3159 "reported\n", cmd);
@@ -3163,7 +3163,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3163 "reported invalid\n", cmd); 3163 "reported invalid\n", cmd);
3164 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3164 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3165 cmd->err_info->CommandStatus, DRIVER_OK, 3165 cmd->err_info->CommandStatus, DRIVER_OK,
3166 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3166 blk_rq_is_passthrough(cmd->rq) ?
3167 DID_PASSTHROUGH : DID_ERROR); 3167 DID_PASSTHROUGH : DID_ERROR);
3168 break; 3168 break;
3169 case CMD_PROTOCOL_ERR: 3169 case CMD_PROTOCOL_ERR:
@@ -3171,7 +3171,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3171 "protocol error\n", cmd); 3171 "protocol error\n", cmd);
3172 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3172 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3173 cmd->err_info->CommandStatus, DRIVER_OK, 3173 cmd->err_info->CommandStatus, DRIVER_OK,
3174 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3174 blk_rq_is_passthrough(cmd->rq) ?
3175 DID_PASSTHROUGH : DID_ERROR); 3175 DID_PASSTHROUGH : DID_ERROR);
3176 break; 3176 break;
3177 case CMD_HARDWARE_ERR: 3177 case CMD_HARDWARE_ERR:
@@ -3179,7 +3179,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3179 " hardware error\n", cmd); 3179 " hardware error\n", cmd);
3180 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3180 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3181 cmd->err_info->CommandStatus, DRIVER_OK, 3181 cmd->err_info->CommandStatus, DRIVER_OK,
3182 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3182 blk_rq_is_passthrough(cmd->rq) ?
3183 DID_PASSTHROUGH : DID_ERROR); 3183 DID_PASSTHROUGH : DID_ERROR);
3184 break; 3184 break;
3185 case CMD_CONNECTION_LOST: 3185 case CMD_CONNECTION_LOST:
@@ -3187,7 +3187,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3187 "connection lost\n", cmd); 3187 "connection lost\n", cmd);
3188 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3188 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3189 cmd->err_info->CommandStatus, DRIVER_OK, 3189 cmd->err_info->CommandStatus, DRIVER_OK,
3190 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3190 blk_rq_is_passthrough(cmd->rq) ?
3191 DID_PASSTHROUGH : DID_ERROR); 3191 DID_PASSTHROUGH : DID_ERROR);
3192 break; 3192 break;
3193 case CMD_ABORTED: 3193 case CMD_ABORTED:
@@ -3195,7 +3195,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3195 "aborted\n", cmd); 3195 "aborted\n", cmd);
3196 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3196 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3197 cmd->err_info->CommandStatus, DRIVER_OK, 3197 cmd->err_info->CommandStatus, DRIVER_OK,
3198 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3198 blk_rq_is_passthrough(cmd->rq) ?
3199 DID_PASSTHROUGH : DID_ABORT); 3199 DID_PASSTHROUGH : DID_ABORT);
3200 break; 3200 break;
3201 case CMD_ABORT_FAILED: 3201 case CMD_ABORT_FAILED:
@@ -3203,7 +3203,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3203 "abort failed\n", cmd); 3203 "abort failed\n", cmd);
3204 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3204 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3205 cmd->err_info->CommandStatus, DRIVER_OK, 3205 cmd->err_info->CommandStatus, DRIVER_OK,
3206 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3206 blk_rq_is_passthrough(cmd->rq) ?
3207 DID_PASSTHROUGH : DID_ERROR); 3207 DID_PASSTHROUGH : DID_ERROR);
3208 break; 3208 break;
3209 case CMD_UNSOLICITED_ABORT: 3209 case CMD_UNSOLICITED_ABORT:
@@ -3218,21 +3218,21 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3218 "%p retried too many times\n", cmd); 3218 "%p retried too many times\n", cmd);
3219 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3219 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3220 cmd->err_info->CommandStatus, DRIVER_OK, 3220 cmd->err_info->CommandStatus, DRIVER_OK,
3221 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3221 blk_rq_is_passthrough(cmd->rq) ?
3222 DID_PASSTHROUGH : DID_ABORT); 3222 DID_PASSTHROUGH : DID_ABORT);
3223 break; 3223 break;
3224 case CMD_TIMEOUT: 3224 case CMD_TIMEOUT:
3225 dev_warn(&h->pdev->dev, "cmd %p timedout\n", cmd); 3225 dev_warn(&h->pdev->dev, "cmd %p timedout\n", cmd);
3226 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3226 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3227 cmd->err_info->CommandStatus, DRIVER_OK, 3227 cmd->err_info->CommandStatus, DRIVER_OK,
3228 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3228 blk_rq_is_passthrough(cmd->rq) ?
3229 DID_PASSTHROUGH : DID_ERROR); 3229 DID_PASSTHROUGH : DID_ERROR);
3230 break; 3230 break;
3231 case CMD_UNABORTABLE: 3231 case CMD_UNABORTABLE:
3232 dev_warn(&h->pdev->dev, "cmd %p unabortable\n", cmd); 3232 dev_warn(&h->pdev->dev, "cmd %p unabortable\n", cmd);
3233 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3233 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3234 cmd->err_info->CommandStatus, DRIVER_OK, 3234 cmd->err_info->CommandStatus, DRIVER_OK,
3235 cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC ? 3235 blk_rq_is_passthrough(cmd->rq) ?
3236 DID_PASSTHROUGH : DID_ERROR); 3236 DID_PASSTHROUGH : DID_ERROR);
3237 break; 3237 break;
3238 default: 3238 default:
@@ -3241,7 +3241,7 @@ static inline void complete_command(ctlr_info_t *h, CommandList_struct *cmd,
3241 cmd->err_info->CommandStatus); 3241 cmd->err_info->CommandStatus);
3242 rq->errors = make_status_bytes(SAM_STAT_GOOD, 3242 rq->errors = make_status_bytes(SAM_STAT_GOOD,
3243 cmd->err_info->CommandStatus, DRIVER_OK, 3243 cmd->err_info->CommandStatus, DRIVER_OK,
3244 (cmd->rq->cmd_type == REQ_TYPE_BLOCK_PC) ? 3244 blk_rq_is_passthrough(cmd->rq) ?
3245 DID_PASSTHROUGH : DID_ERROR); 3245 DID_PASSTHROUGH : DID_ERROR);
3246 } 3246 }
3247 3247
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index fcc9dcfdf675..40c979b777b8 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -1937,7 +1937,7 @@ nvme_fc_complete_rq(struct request *rq)
1937 return; 1937 return;
1938 } 1938 }
1939 1939
1940 if (rq->cmd_type == REQ_TYPE_DRV_PRIV) 1940 if (blk_rq_is_passthrough(rq))
1941 error = rq->errors; 1941 error = rq->errors;
1942 else 1942 else
1943 error = nvme_error_status(rq->errors); 1943 error = nvme_error_status(rq->errors);
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 7103bce4ba4f..f29365b8c9be 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -588,7 +588,7 @@ static int nvme_queue_rq(struct blk_mq_hw_ctx *hctx,
588 */ 588 */
589 if (ns && ns->ms && !blk_integrity_rq(req)) { 589 if (ns && ns->ms && !blk_integrity_rq(req)) {
590 if (!(ns->pi_type && ns->ms == 8) && 590 if (!(ns->pi_type && ns->ms == 8) &&
591 req->cmd_type != REQ_TYPE_DRV_PRIV) { 591 !blk_rq_is_passthrough(req)) {
592 blk_mq_end_request(req, -EFAULT); 592 blk_mq_end_request(req, -EFAULT);
593 return BLK_MQ_RQ_QUEUE_OK; 593 return BLK_MQ_RQ_QUEUE_OK;
594 } 594 }
@@ -645,7 +645,7 @@ static void nvme_complete_rq(struct request *req)
645 return; 645 return;
646 } 646 }
647 647
648 if (req->cmd_type == REQ_TYPE_DRV_PRIV) 648 if (blk_rq_is_passthrough(req))
649 error = req->errors; 649 error = req->errors;
650 else 650 else
651 error = nvme_error_status(req->errors); 651 error = nvme_error_status(req->errors);
diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c
index 557f29b1f1bb..ecc79b2fcfaf 100644
--- a/drivers/nvme/host/rdma.c
+++ b/drivers/nvme/host/rdma.c
@@ -1423,7 +1423,7 @@ static inline bool nvme_rdma_queue_is_ready(struct nvme_rdma_queue *queue,
1423 if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) { 1423 if (unlikely(!test_bit(NVME_RDMA_Q_LIVE, &queue->flags))) {
1424 struct nvme_command *cmd = nvme_req(rq)->cmd; 1424 struct nvme_command *cmd = nvme_req(rq)->cmd;
1425 1425
1426 if (rq->cmd_type != REQ_TYPE_DRV_PRIV || 1426 if (!blk_rq_is_passthrough(rq) ||
1427 cmd->common.opcode != nvme_fabrics_command || 1427 cmd->common.opcode != nvme_fabrics_command ||
1428 cmd->fabrics.fctype != nvme_fabrics_type_connect) 1428 cmd->fabrics.fctype != nvme_fabrics_type_connect)
1429 return false; 1429 return false;
@@ -1522,7 +1522,7 @@ static void nvme_rdma_complete_rq(struct request *rq)
1522 return; 1522 return;
1523 } 1523 }
1524 1524
1525 if (rq->cmd_type == REQ_TYPE_DRV_PRIV) 1525 if (blk_rq_is_passthrough(rq))
1526 error = rq->errors; 1526 error = rq->errors;
1527 else 1527 else
1528 error = nvme_error_status(rq->errors); 1528 error = nvme_error_status(rq->errors);
diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c
index 9aaa70071ae5..f3862e38f574 100644
--- a/drivers/nvme/target/loop.c
+++ b/drivers/nvme/target/loop.c
@@ -104,7 +104,7 @@ static void nvme_loop_complete_rq(struct request *req)
104 return; 104 return;
105 } 105 }
106 106
107 if (req->cmd_type == REQ_TYPE_DRV_PRIV) 107 if (blk_rq_is_passthrough(req))
108 error = req->errors; 108 error = req->errors;
109 else 109 else
110 error = nvme_error_status(req->errors); 110 error = nvme_error_status(req->errors);
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index cbc0c5fe5a60..c611412a8de9 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -5539,8 +5539,8 @@ static int hpsa_scsi_queue_command(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
5539 * Retries always go down the normal I/O path. 5539 * Retries always go down the normal I/O path.
5540 */ 5540 */
5541 if (likely(cmd->retries == 0 && 5541 if (likely(cmd->retries == 0 &&
5542 cmd->request->cmd_type == REQ_TYPE_FS && 5542 !blk_rq_is_passthrough(cmd->request) &&
5543 h->acciopath_status)) { 5543 h->acciopath_status)) {
5544 rc = hpsa_ioaccel_submit(h, c, cmd, scsi3addr); 5544 rc = hpsa_ioaccel_submit(h, c, cmd, scsi3addr);
5545 if (rc == 0) 5545 if (rc == 0)
5546 return 0; 5546 return 0;
diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index 3d8d2153b448..7bfbcfa7af40 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -238,7 +238,7 @@ void scsi_finish_command(struct scsi_cmnd *cmd)
238 "(result %x)\n", cmd->result)); 238 "(result %x)\n", cmd->result));
239 239
240 good_bytes = scsi_bufflen(cmd); 240 good_bytes = scsi_bufflen(cmd);
241 if (cmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { 241 if (!blk_rq_is_passthrough(cmd->request)) {
242 int old_good_bytes = good_bytes; 242 int old_good_bytes = good_bytes;
243 drv = scsi_cmd_to_driver(cmd); 243 drv = scsi_cmd_to_driver(cmd);
244 if (drv->done) 244 if (drv->done)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 4b40f746d534..b4ce7bb5d2a9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1106,7 +1106,7 @@ static int scsi_request_sense(struct scsi_cmnd *scmd)
1106 1106
1107static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn) 1107static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn)
1108{ 1108{
1109 if (scmd->request->cmd_type != REQ_TYPE_BLOCK_PC) { 1109 if (!blk_rq_is_passthrough(scmd->request)) {
1110 struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd); 1110 struct scsi_driver *sdrv = scsi_cmd_to_driver(scmd);
1111 if (sdrv->eh_action) 1111 if (sdrv->eh_action)
1112 rtn = sdrv->eh_action(scmd, rtn); 1112 rtn = sdrv->eh_action(scmd, rtn);
@@ -1746,7 +1746,7 @@ check_type:
1746 * the check condition was retryable. 1746 * the check condition was retryable.
1747 */ 1747 */
1748 if (scmd->request->cmd_flags & REQ_FAILFAST_DEV || 1748 if (scmd->request->cmd_flags & REQ_FAILFAST_DEV ||
1749 scmd->request->cmd_type == REQ_TYPE_BLOCK_PC) 1749 blk_rq_is_passthrough(scmd->request))
1750 return 1; 1750 return 1;
1751 else 1751 else
1752 return 0; 1752 return 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8188e5c71f75..31629a7b728d 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -582,7 +582,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
582 582
583static void scsi_uninit_cmd(struct scsi_cmnd *cmd) 583static void scsi_uninit_cmd(struct scsi_cmnd *cmd)
584{ 584{
585 if (cmd->request->cmd_type == REQ_TYPE_FS) { 585 if (!blk_rq_is_passthrough(cmd->request)) {
586 struct scsi_driver *drv = scsi_cmd_to_driver(cmd); 586 struct scsi_driver *drv = scsi_cmd_to_driver(cmd);
587 587
588 if (drv->uninit_command) 588 if (drv->uninit_command)
@@ -806,7 +806,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
806 sense_deferred = scsi_sense_is_deferred(&sshdr); 806 sense_deferred = scsi_sense_is_deferred(&sshdr);
807 } 807 }
808 808
809 if (req->cmd_type == REQ_TYPE_BLOCK_PC) { /* SG_IO ioctl from block level */ 809 if (blk_rq_is_passthrough(req)) {
810 if (result) { 810 if (result) {
811 if (sense_valid) { 811 if (sense_valid) {
812 /* 812 /*
@@ -847,7 +847,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
847 error = __scsi_error_from_host_byte(cmd, result); 847 error = __scsi_error_from_host_byte(cmd, result);
848 } 848 }
849 849
850 /* no bidi support for !REQ_TYPE_BLOCK_PC yet */ 850 /* no bidi support for !blk_rq_is_passthrough yet */
851 BUG_ON(blk_bidi_rq(req)); 851 BUG_ON(blk_bidi_rq(req));
852 852
853 /* 853 /*
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 8702d9cf8040..11c0dfb3dfa3 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -4499,7 +4499,7 @@ static int pqi_scsi_queue_command(struct Scsi_Host *shost,
4499 if (pqi_is_logical_device(device)) { 4499 if (pqi_is_logical_device(device)) {
4500 raid_bypassed = false; 4500 raid_bypassed = false;
4501 if (device->offload_enabled && 4501 if (device->offload_enabled &&
4502 scmd->request->cmd_type == REQ_TYPE_FS) { 4502 !blk_rq_is_passthrough(scmd->request)) {
4503 rc = pqi_raid_bypass_submit_scsi_cmd(ctrl_info, device, 4503 rc = pqi_raid_bypass_submit_scsi_cmd(ctrl_info, device,
4504 scmd, queue_group); 4504 scmd, queue_group);
4505 if (rc == 0 || 4505 if (rc == 0 ||
diff --git a/drivers/scsi/sun3_scsi.c b/drivers/scsi/sun3_scsi.c
index 88db6992420e..bcf7d05d1aab 100644
--- a/drivers/scsi/sun3_scsi.c
+++ b/drivers/scsi/sun3_scsi.c
@@ -260,7 +260,7 @@ static int sun3scsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
260{ 260{
261 int wanted_len = cmd->SCp.this_residual; 261 int wanted_len = cmd->SCp.this_residual;
262 262
263 if (wanted_len < DMA_MIN_SIZE || cmd->request->cmd_type != REQ_TYPE_FS) 263 if (wanted_len < DMA_MIN_SIZE || blk_rq_is_passthrough(cmd->request))
264 return 0; 264 return 0;
265 265
266 return wanted_len; 266 return wanted_len;
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e4c5f284fe2d..7121be081517 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -242,6 +242,11 @@ struct request {
242 struct request *next_rq; 242 struct request *next_rq;
243}; 243};
244 244
245static inline bool blk_rq_is_passthrough(struct request *rq)
246{
247 return rq->cmd_type != REQ_TYPE_FS;
248}
249
245static inline unsigned short req_get_ioprio(struct request *req) 250static inline unsigned short req_get_ioprio(struct request *req)
246{ 251{
247 return req->ioprio; 252 return req->ioprio;
@@ -698,9 +703,10 @@ static inline void queue_flag_clear(unsigned int flag, struct request_queue *q)
698 ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ 703 ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
699 REQ_FAILFAST_DRIVER)) 704 REQ_FAILFAST_DRIVER))
700 705
701#define blk_account_rq(rq) \ 706static inline bool blk_account_rq(struct request *rq)
702 (((rq)->rq_flags & RQF_STARTED) && \ 707{
703 ((rq)->cmd_type == REQ_TYPE_FS)) 708 return (rq->rq_flags & RQF_STARTED) && !blk_rq_is_passthrough(rq);
709}
704 710
705#define blk_rq_cpu_valid(rq) ((rq)->cpu != -1) 711#define blk_rq_cpu_valid(rq) ((rq)->cpu != -1)
706#define blk_bidi_rq(rq) ((rq)->next_rq != NULL) 712#define blk_bidi_rq(rq) ((rq)->next_rq != NULL)
@@ -775,7 +781,7 @@ static inline void blk_clear_rl_full(struct request_list *rl, bool sync)
775 781
776static inline bool rq_mergeable(struct request *rq) 782static inline bool rq_mergeable(struct request *rq)
777{ 783{
778 if (rq->cmd_type != REQ_TYPE_FS) 784 if (blk_rq_is_passthrough(rq))
779 return false; 785 return false;
780 786
781 if (req_op(rq) == REQ_OP_FLUSH) 787 if (req_op(rq) == REQ_OP_FLUSH)
@@ -1049,7 +1055,7 @@ static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
1049{ 1055{
1050 struct request_queue *q = rq->q; 1056 struct request_queue *q = rq->q;
1051 1057
1052 if (unlikely(rq->cmd_type != REQ_TYPE_FS)) 1058 if (blk_rq_is_passthrough(rq))
1053 return q->limits.max_hw_sectors; 1059 return q->limits.max_hw_sectors;
1054 1060
1055 if (!q->limits.chunk_sectors || 1061 if (!q->limits.chunk_sectors ||
diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index a143a67a6f33..341f9418bd68 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -114,12 +114,12 @@ extern void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes);
114 114
115static inline sector_t blk_rq_trace_sector(struct request *rq) 115static inline sector_t blk_rq_trace_sector(struct request *rq)
116{ 116{
117 return (rq->cmd_type != REQ_TYPE_FS) ? 0 : blk_rq_pos(rq); 117 return blk_rq_is_passthrough(rq) ? 0 : blk_rq_pos(rq);
118} 118}
119 119
120static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq) 120static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq)
121{ 121{
122 return (rq->cmd_type != REQ_TYPE_FS) ? 0 : blk_rq_sectors(rq); 122 return blk_rq_is_passthrough(rq) ? 0 : blk_rq_sectors(rq);
123} 123}
124 124
125#endif 125#endif
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index f708f1acfc50..b379f93a2c48 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -151,7 +151,7 @@ static inline void *scsi_cmd_priv(struct scsi_cmnd *cmd)
151 return cmd + 1; 151 return cmd + 1;
152} 152}
153 153
154/* make sure not to use it with REQ_TYPE_BLOCK_PC commands */ 154/* make sure not to use it with passthrough commands */
155static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd) 155static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
156{ 156{
157 return *(struct scsi_driver **)cmd->request->rq_disk->private_data; 157 return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 512b34703ac3..e33050e3ea1c 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -712,7 +712,7 @@ static void blk_add_trace_rq(struct request_queue *q, struct request *rq,
712 if (likely(!bt)) 712 if (likely(!bt))
713 return; 713 return;
714 714
715 if (rq->cmd_type != REQ_TYPE_FS) 715 if (blk_rq_is_passthrough(rq))
716 what |= BLK_TC_ACT(BLK_TC_PC); 716 what |= BLK_TC_ACT(BLK_TC_PC);
717 else 717 else
718 what |= BLK_TC_ACT(BLK_TC_FS); 718 what |= BLK_TC_ACT(BLK_TC_FS);