aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/scsi_lib.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-08-10 02:44:47 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:23:37 -0400
commit4aff5e2333c9a1609662f2091f55c3f6fffdad36 (patch)
treeb73d8c2b7c1bdc03d3313c108da7dfc95ee95525 /drivers/scsi/scsi_lib.c
parent77ed74da26f50fa28471571ee7a2251b77526d84 (diff)
[PATCH] Split struct request ->flags into two parts
Right now ->flags is a bit of a mess: some are request types, and others are just modifiers. Clean this up by splitting it into ->cmd_type and ->cmd_flags. This allows introduction of generic Linux block message types, useful for sending generic Linux commands to block devices. Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'drivers/scsi/scsi_lib.c')
-rw-r--r--drivers/scsi/scsi_lib.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index d6743b959a72..71084728eb42 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -82,7 +82,7 @@ static void scsi_unprep_request(struct request *req)
82{ 82{
83 struct scsi_cmnd *cmd = req->special; 83 struct scsi_cmnd *cmd = req->special;
84 84
85 req->flags &= ~REQ_DONTPREP; 85 req->cmd_flags &= ~REQ_DONTPREP;
86 req->special = NULL; 86 req->special = NULL;
87 87
88 scsi_put_command(cmd); 88 scsi_put_command(cmd);
@@ -196,7 +196,8 @@ int scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
196 req->sense_len = 0; 196 req->sense_len = 0;
197 req->retries = retries; 197 req->retries = retries;
198 req->timeout = timeout; 198 req->timeout = timeout;
199 req->flags |= flags | REQ_BLOCK_PC | REQ_SPECIAL | REQ_QUIET; 199 req->cmd_type = REQ_TYPE_BLOCK_PC;
200 req->cmd_flags |= flags | REQ_QUIET | REQ_PREEMPT;
200 201
201 /* 202 /*
202 * head injection *required* here otherwise quiesce won't work 203 * head injection *required* here otherwise quiesce won't work
@@ -397,7 +398,8 @@ int scsi_execute_async(struct scsi_device *sdev, const unsigned char *cmd,
397 req = blk_get_request(sdev->request_queue, write, gfp); 398 req = blk_get_request(sdev->request_queue, write, gfp);
398 if (!req) 399 if (!req)
399 goto free_sense; 400 goto free_sense;
400 req->flags |= REQ_BLOCK_PC | REQ_QUIET; 401 req->cmd_type = REQ_TYPE_BLOCK_PC;
402 req->cmd_flags |= REQ_QUIET;
401 403
402 if (use_sg) 404 if (use_sg)
403 err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp); 405 err = scsi_req_map_sg(req, buffer, use_sg, bufflen, gfp);
@@ -933,7 +935,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
933 break; 935 break;
934 } 936 }
935 } 937 }
936 if (!(req->flags & REQ_QUIET)) { 938 if (!(req->cmd_flags & REQ_QUIET)) {
937 scmd_printk(KERN_INFO, cmd, 939 scmd_printk(KERN_INFO, cmd,
938 "Device not ready: "); 940 "Device not ready: ");
939 scsi_print_sense_hdr("", &sshdr); 941 scsi_print_sense_hdr("", &sshdr);
@@ -941,7 +943,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
941 scsi_end_request(cmd, 0, this_count, 1); 943 scsi_end_request(cmd, 0, this_count, 1);
942 return; 944 return;
943 case VOLUME_OVERFLOW: 945 case VOLUME_OVERFLOW:
944 if (!(req->flags & REQ_QUIET)) { 946 if (!(req->cmd_flags & REQ_QUIET)) {
945 scmd_printk(KERN_INFO, cmd, 947 scmd_printk(KERN_INFO, cmd,
946 "Volume overflow, CDB: "); 948 "Volume overflow, CDB: ");
947 __scsi_print_command(cmd->cmnd); 949 __scsi_print_command(cmd->cmnd);
@@ -963,7 +965,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
963 return; 965 return;
964 } 966 }
965 if (result) { 967 if (result) {
966 if (!(req->flags & REQ_QUIET)) { 968 if (!(req->cmd_flags & REQ_QUIET)) {
967 scmd_printk(KERN_INFO, cmd, 969 scmd_printk(KERN_INFO, cmd,
968 "SCSI error: return code = 0x%08x\n", 970 "SCSI error: return code = 0x%08x\n",
969 result); 971 result);
@@ -995,7 +997,7 @@ static int scsi_init_io(struct scsi_cmnd *cmd)
995 /* 997 /*
996 * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer 998 * if this is a rq->data based REQ_BLOCK_PC, setup for a non-sg xfer
997 */ 999 */
998 if ((req->flags & REQ_BLOCK_PC) && !req->bio) { 1000 if (blk_pc_request(req) && !req->bio) {
999 cmd->request_bufflen = req->data_len; 1001 cmd->request_bufflen = req->data_len;
1000 cmd->request_buffer = req->data; 1002 cmd->request_buffer = req->data;
1001 req->buffer = req->data; 1003 req->buffer = req->data;
@@ -1139,13 +1141,12 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1139 * these two cases differently. We differentiate by looking 1141 * these two cases differently. We differentiate by looking
1140 * at request->cmd, as this tells us the real story. 1142 * at request->cmd, as this tells us the real story.
1141 */ 1143 */
1142 if (req->flags & REQ_SPECIAL && req->special) { 1144 if (blk_special_request(req) && req->special)
1143 cmd = req->special; 1145 cmd = req->special;
1144 } else if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { 1146 else if (blk_pc_request(req) || blk_fs_request(req)) {
1145 1147 if (unlikely(specials_only) && !(req->cmd_flags & REQ_PREEMPT)){
1146 if(unlikely(specials_only) && !(req->flags & REQ_SPECIAL)) { 1148 if (specials_only == SDEV_QUIESCE ||
1147 if(specials_only == SDEV_QUIESCE || 1149 specials_only == SDEV_BLOCK)
1148 specials_only == SDEV_BLOCK)
1149 goto defer; 1150 goto defer;
1150 1151
1151 sdev_printk(KERN_ERR, sdev, 1152 sdev_printk(KERN_ERR, sdev,
@@ -1153,7 +1154,6 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1153 goto kill; 1154 goto kill;
1154 } 1155 }
1155 1156
1156
1157 /* 1157 /*
1158 * Now try and find a command block that we can use. 1158 * Now try and find a command block that we can use.
1159 */ 1159 */
@@ -1184,7 +1184,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1184 * lock. We hope REQ_STARTED prevents anything untoward from 1184 * lock. We hope REQ_STARTED prevents anything untoward from
1185 * happening now. 1185 * happening now.
1186 */ 1186 */
1187 if (req->flags & (REQ_CMD | REQ_BLOCK_PC)) { 1187 if (blk_fs_request(req) || blk_pc_request(req)) {
1188 int ret; 1188 int ret;
1189 1189
1190 /* 1190 /*
@@ -1216,7 +1216,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1216 /* 1216 /*
1217 * Initialize the actual SCSI command for this request. 1217 * Initialize the actual SCSI command for this request.
1218 */ 1218 */
1219 if (req->flags & REQ_BLOCK_PC) { 1219 if (blk_pc_request(req)) {
1220 scsi_setup_blk_pc_cmnd(cmd); 1220 scsi_setup_blk_pc_cmnd(cmd);
1221 } else if (req->rq_disk) { 1221 } else if (req->rq_disk) {
1222 struct scsi_driver *drv; 1222 struct scsi_driver *drv;
@@ -1233,7 +1233,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
1233 /* 1233 /*
1234 * The request is now prepped, no need to come back here 1234 * The request is now prepped, no need to come back here
1235 */ 1235 */
1236 req->flags |= REQ_DONTPREP; 1236 req->cmd_flags |= REQ_DONTPREP;
1237 return BLKPREP_OK; 1237 return BLKPREP_OK;
1238 1238
1239 defer: 1239 defer:
@@ -1454,8 +1454,9 @@ static void scsi_request_fn(struct request_queue *q)
1454 if (unlikely(cmd == NULL)) { 1454 if (unlikely(cmd == NULL)) {
1455 printk(KERN_CRIT "impossible request in %s.\n" 1455 printk(KERN_CRIT "impossible request in %s.\n"
1456 "please mail a stack trace to " 1456 "please mail a stack trace to "
1457 "linux-scsi@vger.kernel.org", 1457 "linux-scsi@vger.kernel.org\n",
1458 __FUNCTION__); 1458 __FUNCTION__);
1459 blk_dump_rq_flags(req, "foo");
1459 BUG(); 1460 BUG();
1460 } 1461 }
1461 spin_lock(shost->host_lock); 1462 spin_lock(shost->host_lock);