Re: [PATCH 1/1] scsi: Add EH Start Unit retry

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2007-03-29 at 15:25 -0500, Brian King wrote:
> -		int rtn;
> +		int retry_cnt = 1, rtn;
>  
> +retry_stu:
>  		rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
>  					START_UNIT_TIMEOUT, 0);
> -		if (rtn == SUCCESS)
> +
> +		switch (rtn) {
> +		case SUCCESS:
>  			return 0;
> +		case NEEDS_RETRY:
> +			if (retry_cnt--)
> +				goto retry_stu;
> +			/*FALLTHRU*/
> +		default:
> +			return 1;
> +		}

This is pretty much an open coded for loop ... how about just doing a
for loop as attached below?

The two advantages to this are:

     1. it's cleaner and more readable
     2. the compiler knows how to optimize it better

James

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 7a1a1bb..28a266c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -932,10 +932,12 @@ static int scsi_eh_try_stu(struct scsi_cmnd *scmd)
 	static unsigned char stu_command[6] = {START_STOP, 0, 0, 0, 1, 0};
 
 	if (scmd->device->allow_restart) {
-		int rtn;
+		int i, rtn = NEEDS_RETRY;
+
+		for (i = 0; rtn == NEEDS_RETRY && i < 2; i++)
+			rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
+						START_UNIT_TIMEOUT, 0);
 
-		rtn = scsi_send_eh_cmnd(scmd, stu_command, 6,
-					START_UNIT_TIMEOUT, 0);
 		if (rtn == SUCCESS)
 			return 0;
 	}


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux