Skip to contentSkip to conversation

make all scsi REQ_PC use the same setup and completion paths.

PATCH In review Mike Christie 1 participant 1 message Nov 8, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 10/10 make all scsi REQ_PC use the same setup and completion paths.

This is more of RFC and so I made it the last patch incase it is not correct.

scsi_prep_fn's REQ_PC code does the same setup and completion as sd and st's init_command. sr's does almost the same thing except the init_command tests cd->device->changed and fails the commands if changed is set. And sr's intr command clears the scsi_cmnd->result for RECOVERED_ERROR. If not for those two cases, sr, sd and st could all use the same setup and completion code paths for REQ_PC commands. I was not sure if sr's code was mistake or maybe not needed since the caller can check these things (but maybe userspace apps rely on this behavior now). If that sr code can go for REQ_PC commands this patch brings all those paths together.

drivers/scsi/scsi_lib.c +1 -1
index c06e1e4..99cb09f 100644
@@ -1377,7 +1377,7 @@ static int scsi_prep_fn(struct request_q
 		/*
 		 * Initialize the actual SCSI command for this request.
 		 */
-		if (req->rq_disk) {
+		if (!blk_pc_request(req) && req->rq_disk) {
 			drv = *(struct scsi_driver **)req->rq_disk->private_data;
 			if (unlikely(!drv->init_command(cmd))) {
 				scsi_release_buffers(cmd);
drivers/scsi/sd.c +4 -42

70 lines not on this page · raw message

drivers/scsi/sr.c +2 -30
index bbcf428..f741c0d 100644
@@ -295,7 +295,7 @@ static void rw_intr(struct scsi_cmnd * S
 
 static int sr_init_command(struct scsi_cmnd * SCpnt)
 {
-	int block=0, this_count, s_size, timeout = SR_TIMEOUT;
+	int block=0, this_count, s_size;
 	struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
 
 	SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %s, block = %d\n",
@@ -316,33 +316,6 @@ static int sr_init_command(struct scsi_c
 		return 0;
 	}
 
-	/*
-	 * these are already setup, just copy cdb basically
-	 */
-	if (SCpnt->request->flags & REQ_BLOCK_PC) {
-		struct request *rq = SCpnt->request;
-
-		if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
-			return 0;
-
-		memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
-		SCpnt->cmd_len = rq->cmd_len;
-		if (!rq->data_len)
-			SCpnt->sc_data_direction = DMA_NONE;
-		else if (rq_data_dir(rq) == WRITE)
-			SCpnt->sc_data_direction = DMA_TO_DEVICE;
-		else
-			SCpnt->sc_data_direction = DMA_FROM_DEVICE;
-
-		this_count = rq->data_len;
-		if (rq->timeout)
-			timeout = rq->timeout;
-
-		SCpnt->allowed = rq->retries;
-		SCpnt->transfersize = rq->data_len;
-		goto queue;
-	}
-
 	if (!(SCpnt->request->flags & REQ_CMD)) {
 		blk_dump_rq_flags(SCpnt->request, "sr unsup command");
 		return 0;
@@ -437,8 +410,7 @@ static int sr_init_command(struct scsi_c
 	SCpnt->transfersize = cd->device->sector_size;
 	SCpnt->underflow = this_count << 9;
 	SCpnt->allowed = MAX_RETRIES;
-queue:
-	SCpnt->timeout_per_command = timeout;
+	SCpnt->timeout_per_command = SR_TIMEOUT;
 
 	/*
 	 * This is the completion routine we use.  This is matched in terms
drivers/scsi/st.c +0 -43

61 lines not on this page · raw message