Skip to contentSkip to conversation

convert the remaining mid-layer pieces to scsi_execute_req

PATCH In review James Bottomley 2 participants 3 messages Jun 11, 2005 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 convert the remaining mid-layer pieces to scsi_execute_req

After this, we just have some drivers, all the ULDs and the SPI transport class using scsi_wait_req().

James

drivers/scsi/scsi_ioctl.c +16 -30
@@ -88,25 +88,21 @@ static int ioctl_probe(struct Scsi_Host 
 static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 				  int timeout, int retries)
 {
-	struct scsi_request *sreq;
 	int result;
 	struct scsi_sense_hdr sshdr;
+	char sense[SCSI_SENSE_BUFFERSIZE];
 
 	SCSI_LOG_IOCTL(1, printk("Trying ioctl with scsi command %d\n", *cmd));
 
-	sreq = scsi_allocate_request(sdev, GFP_KERNEL);
-	if (!sreq) {
-		printk(KERN_WARNING "SCSI internal ioctl failed, no memory\n");
-		return -ENOMEM;
-	}
 
-	sreq->sr_data_direction = DMA_NONE;
-        scsi_wait_req(sreq, cmd, NULL, 0, timeout, retries);
+	memset(sense, 0, sizeof(*sense));
+	result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0,
+				  sense, timeout, retries);
 
-	SCSI_LOG_IOCTL(2, printk("Ioctl returned  0x%x\n", sreq->sr_result));
+	SCSI_LOG_IOCTL(2, printk("Ioctl returned  0x%x\n", result));
 
-	if ((driver_byte(sreq->sr_result) & DRIVER_SENSE) &&
-	    (scsi_request_normalize_sense(sreq, &sshdr))) {
+	if ((driver_byte(result) & DRIVER_SENSE) &&
+	    (scsi_normalize_sense(sense, sizeof(*sense), &sshdr))) {
 		switch (sshdr.sense_key) {
 		case ILLEGAL_REQUEST:
 			if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
@@ -125,7 +121,7 @@ static int ioctl_internal_command(struct
 		case UNIT_ATTENTION:
 			if (sdev->removable) {
 				sdev->changed = 1;
-				sreq->sr_result = 0;	/* This is no longer considered an error */
+				result = 0;	/* This is no longer considered an error */
 				break;
 			}
 		default:	/* Fall through for non-removable media */
@@ -135,15 +131,13 @@ static int ioctl_internal_command(struct
 			       sdev->channel,
 			       sdev->id,
 			       sdev->lun,
-			       sreq->sr_result);
-			scsi_print_req_sense("   ", sreq);
+			       result);
+			__scsi_print_sense("   ", sense, sizeof(*sense));
 			break;
 		}
 	}
 
-	result = sreq->sr_result;
 	SCSI_LOG_IOCTL(2, printk("IOCTL Releasing command\n"));
-	scsi_release_request(sreq);
 	return result;
 }
 
@@ -208,8 +202,8 @@ int scsi_ioctl_send_command(struct scsi_
 {
 	char *buf;
 	unsigned char cmd[MAX_COMMAND_SIZE];
+	unsigned char sense[SCSI_SENSE_BUFFERSIZE];
 	char __user *cmd_in;
-	struct scsi_request *sreq;
 	unsigned char opcode;
 	unsigned int inlen, outlen, cmdlen;
 	unsigned int needed, buf_needed;
@@ -321,31 +315,23 @@ int scsi_ioctl_send_command(struct scsi_
 		break;
 	}
 
-	sreq = scsi_allocate_request(sdev, GFP_KERNEL);
-        if (!sreq) {
-                result = -EINTR;
-                goto error;
-        }
-
-	sreq->sr_data_direction = data_direction;
-        scsi_wait_req(sreq, cmd, buf, needed, timeout, retries);
-
+	result = scsi_execute_req(sdev, cmd, data_direction, buf, needed,
+				  sense, timeout, retries);
+				  
 	/* 
 	 * If there was an error condition, pass the info back to the user. 
 	 */
-	result = sreq->sr_result;
 	if (result) {
-		int sb_len = sizeof(sreq->sr_sense_buffer);
+		int sb_len = sizeof(*sense);
 
 		sb_len = (sb_len > OMAX_SB_LEN) ? OMAX_SB_LEN : sb_len;
-		if (copy_to_user(cmd_in, sreq->sr_sense_buffer, sb_len))
+		if (copy_to_user(cmd_in, sense, sb_len))
 			result = -EFAULT;
 	} else {
 		if (copy_to_user(cmd_in, buf, outlen))
 			result = -EFAULT;
 	}	
 
-	scsi_release_request(sreq);
 error:
 	kfree(buf);
 	return result;
drivers/scsi/scsi_lib.c +33 -61

175 lines not on this page · raw message

drivers/scsi/sd.c +3 -2
@@ -1302,8 +1302,9 @@ static inline int
 sd_do_mode_sense(struct scsi_request *SRpnt, int dbd, int modepage,
 		 unsigned char *buffer, int len, struct scsi_mode_data *data)
 {
-	return __scsi_mode_sense(SRpnt, dbd, modepage, buffer, len,
-				 SD_TIMEOUT, SD_MAX_RETRIES, data);
+	return scsi_mode_sense(SRpnt->sr_device, dbd, modepage, buffer, len,
+			       SD_TIMEOUT, SD_MAX_RETRIES, data,
+			       SRpnt->sr_sense_buffer);
 }
 
 /*
drivers/scsi/sr.c +1 -1
@@ -817,7 +817,7 @@ static void get_capabilities(struct scsi
 
 	/* ask for mode page 0x2a */
 	rc = scsi_mode_sense(cd->device, 0, 0x2a, buffer, 128,
-			     SR_TIMEOUT, 3, &data);
+			     SR_TIMEOUT, 3, &data, NULL);
 
 	if (!scsi_status_is_good(rc)) {
 		/* failed, drive doesn't have capabilities mode page */
include/scsi/scsi_device.h +10 -2
@@ -8,8 +8,15 @@
 
 struct request_queue;
 struct scsi_cmnd;
-struct scsi_mode_data;
 
+struct scsi_mode_data {
+	__u32	length;
+	__u16	block_descriptor_length;
+	__u8	medium_type;
+	__u8	device_specific;
+	__u8	header_length;
+	__u8	longlba:1;
+};
 
 /*
  * sdev state: If you alter this, you also need to alter scsi_sysfs.c
@@ -228,7 +235,8 @@ extern int scsi_set_medium_removal(struc
 
 extern int scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,
 			   unsigned char *buffer, int len, int timeout,
-			   int retries, struct scsi_mode_data *data);
+			   int retries, struct scsi_mode_data *data,
+			   char *sense);
 extern int scsi_test_unit_ready(struct scsi_device *sdev, int timeout,
 				int retries);
 extern int scsi_device_set_state(struct scsi_device *sdev,
include/scsi/scsi_request.h +0 -15
@@ -58,19 +58,4 @@ extern int scsi_execute_req(struct scsi_
 			    int data_direction, void *buffer, unsigned bufflen,
 			    unsigned char *sense, int timeout, int retries);
 
-struct scsi_mode_data {
-	__u32	length;
-	__u16	block_descriptor_length;
-	__u8	medium_type;
-	__u8	device_specific;
-	__u8	header_length;
-	__u8	longlba:1;
-};
-
-extern int __scsi_mode_sense(struct scsi_request *SRpnt, int dbd,
-			     int modepage, unsigned char *buffer, int len,
-			     int timeout, int retries,
-			     struct scsi_mode_data *data);
-
-
 #endif /* _SCSI_SCSI_REQUEST_H */
#1 lore raw
Quoted 8 lines · James Bottomley

After this, we just have some drivers, all the ULDs and the SPI transport class using scsi_wait_req().

James

drivers/scsi/scsi_ioctl.c static int ioctl_probe(struct Scsi_Host · line 93

Quoted 7 lines
drivers/scsi/scsi_ioctl.c +1 -1
@@ -88,25 +88,21 @@ static int ioctl_probe(struct Scsi_Host 
 static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 				  int timeout, int retries)
 {
-	struct scsi_request *sreq;
 	int result;
 	struct scsi_sense_hdr sshdr;
+	char sense[SCSI_SENSE_BUFFERSIZE];

What is the average stack size at this call depth?

Jeff

#2 lore raw
Quoted 6 lines · Jeff Garzik
Quoted 5 lines · James Bottomley

After this, we just have some drivers, all the ULDs and the SPI transport class using scsi_wait_req().

James

Quoted 12 lines

drivers/scsi/scsi_ioctl.c static int ioctl_probe(struct Scsi_Host · line 93

Quoted 10 lines
drivers/scsi/scsi_ioctl.c +1 -1
@@ -88,25 +88,21 @@ static int ioctl_probe(struct Scsi_Host 
 static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 				  int timeout, int retries)
 {
-	struct scsi_request *sreq;
 	int result;
 	struct scsi_sense_hdr sshdr;
+	char sense[SCSI_SENSE_BUFFERSIZE];

What is the average stack size at this call depth?

Erm, well that's architecture dependent, as I'm sure you know.

On parisc64, none of the prior callers really goes over a stack frame, so it's 128*depth.

James