Drivers: scsi: Derive the FLUSH_TIMEOUT from the basic I/O timeout
PATCH 1/1 Drivers: scsi: Derive the FLUSH_TIMEOUT from the basic I/O timeout
Rather than having a separate constant for specifying the timeout on FLUSH operations, use the basic I/O timeout value that is already configurable on a per target basis to derive the FLUSH timeout. Looking at the current definitions of these timeout values, the FLUSH operation is supposed to have a value that is twice the normal timeout value. This patch preserves this relationship while leveraging the flexibility of specifying the I/O timeout.
I would like to thank Eric Seppanen <[email protected]> and Nicholas A. Bellinger <[email protected]> for their help in resolving this issue.
--- drivers/scsi/sd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +3 -2
@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=2 ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;
@@ -1433,6 +1433,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +unsigned int timeout = sdp->request_queue->rq_timeout;struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))
@@ -1448,7 +1449,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , + &sshdr, timeout *2 ,SD_MAX_RETRIES ,NULL ,REQ_PM );if (res ==0 )break ;
Signature · 1 line
1.7.4.1
Quoted 30 lines · K. Y. Srinivasan
Rather than having a separate constant for specifying the timeout on FLUSH operations, use the basic I/O timeout value that is already configurable on a per target basis to derive the FLUSH timeout. Looking at the current definitions of these timeout values, the FLUSH operation is supposed to have a value that is twice the normal timeout value. This patch preserves this relationship while leveraging the flexibility of specifying the I/O timeout.
I would like to thank Eric Seppanen <[email protected]> and Nicholas A. Bellinger <[email protected]> for their help in resolving this issue.
Signed-off-by K. Y. Srinivasan <[email protected]>--- drivers/scsi/sd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)drivers/scsi/sd.c +1
-1@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=2 ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1436
Quoted 4 lines
drivers/scsi/sd.c +1
-0@@ -1433,6 +1433,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +unsigned int timeout = sdp->request_queue->rq_timeout;
The timeout is signed in the function prototype
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1455
Quoted 12 lines
drivers/scsi/sd.c +1
-1struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,7 +1449,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , + &sshdr, timeout *2 ,SD_MAX_RETRIES ,NULL ,REQ_PM );if (res ==0 )break ;
Not like this, please: you now leave us with a dangling #define whose name makes you think it should be related to flushing and a couple of curious magic constants. It's almost hand crafted to confuse people reading the code.
Please do it like this instead: with a comment explaining what we're doing above the #define and a name that clearly relates to the actions.
James
---
drivers/scsi/sd.c +5 -3
@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=SD_FLUSH_TIMEOUT_MULTIPLIER ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;
@@ -1433,6 +1433,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +const int timeout = sdp->request_queue->rq_timeout + *SD_FLUSH_TIMEOUT_MULTIPLIER ;struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))
@@ -1448,8 +1450,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , -SD_MAX_RETRIES ,NULL ,REQ_PM ); + &sshdr, timeout,SD_MAX_RETRIES , +NULL ,REQ_PM );if (res ==0 )break ; }
drivers/scsi/sd.h +5 -1
@@ -13,7 +13,11 @@*/ #define SD_TIMEOUT (30 * HZ)#define SD_MOD_TIMEOUT (75 * HZ) -#define SD_FLUSH_TIMEOUT (60 * HZ) +/* +* Flush timeout is a multiplier over the standard device timeout which is +* user modifiable via sysfs but initially set to SD_TIMEOUT +*/ +#define SD_FLUSH_TIMEOUT_MULTIPLIER 2#define SD_WRITE_SAME_TIMEOUT (120 * HZ)/*
Quoted 117 lines
-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Friday, October 04, 2013 2:42 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] Drivers: scsi: Derive theFLUSH_TIMEOUTfrom the basic I/O timeoutdrivers/scsi/sd.c static int sd_setup_write_same_cmnd(struct
Quoted 21 lines · K. Y. Srinivasan
Rather than having a separate constant for specifying the timeout on FLUSH operations, use the basic I/O timeout value that is already configurable on a per target basis to derive the FLUSH timeout. Looking at the current definitions of these timeout values, the FLUSH operation is supposed to have a value that is twice the normal timeout value. This patch preserves this relationship while leveraging the flexibility of specifying the I/O timeout.
I would like to thank Eric Seppanen <[email protected]> and Nicholas A. Bellinger <[email protected]> for their help in resolving this issue.
Signed-off-by K. Y. Srinivasan <[email protected]>--- drivers/scsi/sd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)drivers/scsi/sd.c +0
-0@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct
scsi_device*sdp, struct request *rq)drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1436
Quoted 13 lines
drivers/scsi/sd.c +2
-1static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=2 ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;@@ -1433,6 +1433,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +unsigned int timeout = sdp->request_queue->rq_timeout;The timeout is signed in the function prototype
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1455
Quoted 12 lines
drivers/scsi/sd.c +1
-1struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,7 +1449,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , + &sshdr, timeout *2 ,SD_MAX_RETRIES ,NULL ,REQ_PM );if (res ==0 )break ;Not like this, please: you now leave us with a dangling #define whose name makes you think it should be related to flushing and a couple of curious magic constants. It's almost hand crafted to confuse people reading the code.
Please do it like this instead: with a comment explaining what we're doing above the #define and a name that clearly relates to the actions.
James
---
drivers/scsi/sd.c +1
-1@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=SD_FLUSH_TIMEOUT_MULTIPLIER ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ;drivers/scsi/sd.c +4
-2rq->cmd_len =10 ;@@ -1433,6 +1433,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +const int timeout = sdp->request_queue->rq_timeout + *SD_FLUSH_TIMEOUT_MULTIPLIER ;struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,8 +1450,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , -SD_MAX_RETRIES ,NULL ,REQ_PM ); + &sshdr, timeout,SD_MAX_RETRIES , +NULL ,REQ_PM );if (res ==0 )break ; }drivers/scsi/sd.h +0
-0@@ -13,7 +13,11 @@*/ #define SD_TIMEOUT (30 * HZ)
drivers/scsi/sd.h line 23
Quoted 10 lines
drivers/scsi/sd.h +5
-1#define SD_MOD_TIMEOUT (75 * HZ) -#define SD_FLUSH_TIMEOUT (60 * HZ) +/* +* Flush timeout is a multiplier over the standard device timeout which is +* user modifiable via sysfs but initially set to SD_TIMEOUT +*/ +#define SD_FLUSH_TIMEOUT_MULTIPLIER 2#define SD_WRITE_SAME_TIMEOUT (120 * HZ)/*
Thanks James. Given that you have already made the changes you want done (in the Patch above), do you still want me to send you a fixed up patch?
Regards,
K. Y
Quoted 125 lines · KY Srinivasan
Quoted 125 lines
-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Friday, October 04, 2013 2:42 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] Drivers: scsi: Derive theFLUSH_TIMEOUTfrom the basic I/O timeoutdrivers/scsi/sd.c static int sd_setup_write_same_cmnd(struct
Quoted 21 lines · K. Y. Srinivasan
Rather than having a separate constant for specifying the timeout on FLUSH operations, use the basic I/O timeout value that is already configurable on a per target basis to derive the FLUSH timeout. Looking at the current definitions of these timeout values, the FLUSH operation is supposed to have a value that is twice the normal timeout value. This patch preserves this relationship while leveraging the flexibility of specifying the I/O timeout.
I would like to thank Eric Seppanen <[email protected]> and Nicholas A. Bellinger <[email protected]> for their help in resolving this issue.
Signed-off-by K. Y. Srinivasan <[email protected]>--- drivers/scsi/sd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)drivers/scsi/sd.c +0
-0@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct
scsi_device*sdp, struct request *rq)drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1436
Quoted 13 lines
drivers/scsi/sd.c +2
-1static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=2 ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;@@ -1433,6 +1433,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +unsigned int timeout = sdp->request_queue->rq_timeout;The timeout is signed in the function prototype
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1455
Quoted 12 lines
drivers/scsi/sd.c +1
-1struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,7 +1449,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , + &sshdr, timeout *2 ,SD_MAX_RETRIES ,NULL ,REQ_PM );if (res ==0 )break ;Not like this, please: you now leave us with a dangling #define whose name makes you think it should be related to flushing and a couple of curious magic constants. It's almost hand crafted to confuse people reading the code.
Please do it like this instead: with a comment explaining what we're doing above the #define and a name that clearly relates to the actions.
James
---
drivers/scsi/sd.c +1
-1@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct scsi_device *sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=SD_FLUSH_TIMEOUT_MULTIPLIER ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ;drivers/scsi/sd.c +4
-2rq->cmd_len =10 ;@@ -1433,6 +1433,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +const int timeout = sdp->request_queue->rq_timeout + *SD_FLUSH_TIMEOUT_MULTIPLIER ;struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,8 +1450,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , -SD_MAX_RETRIES ,NULL ,REQ_PM ); + &sshdr, timeout,SD_MAX_RETRIES , +NULL ,REQ_PM );if (res ==0 )break ; }drivers/scsi/sd.h +5
-1@@ -13,7 +13,11 @@*/ #define SD_TIMEOUT (30 * HZ)#define SD_MOD_TIMEOUT (75 * HZ) -#define SD_FLUSH_TIMEOUT (60 * HZ) +/* +* Flush timeout is a multiplier over the standard device timeout which is +* user modifiable via sysfs but initially set to SD_TIMEOUT +*/ +#define SD_FLUSH_TIMEOUT_MULTIPLIER 2#define SD_WRITE_SAME_TIMEOUT (120 * HZ)
Quoted 4 lines
drivers/scsi/sd.h line 23
Quoted 1 line
drivers/scsi/sd.h +0
-0/* Thanks James. Given that you have already made the changes you want done (in the Patch above), do you still want me to send you a fixed up patch?
Either way is fine. I just need the patch to be on the mailing list for my workflow (which it is now).
James
Quoted 142 lines
-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Friday, October 04, 2013 3:31 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] Drivers: scsi: Derive theFLUSH_TIMEOUTfrom the basic I/O timeoutQuoted 9 lines · KY Srinivasan
Quoted 9 lines
-----Original Message-----
From: James Bottomley [mailto:[email protected]]
Sent: Friday, October 04, 2013 2:42 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 1/1] Drivers: scsi: Derive theFLUSH_TIMEOUTfrom thebasic
Quoted 7 lines
Quoted 7 lines
I/O timeout
Quoted 4 lines · K. Y. Srinivasan
Rather than having a separate constant for specifying the timeout on FLUSH operations, use the basic I/O timeout value that is already configurable on a per target basis to derive the FLUSH timeout. Looking at the current definitions of these timeout values, the FLUSH operation is supposed to
have
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
a value that is twice the normal timeout value. This patch preserves this relationship while leveraging the flexibility of specifying the I/O timeout.
I would like to thank Eric Seppanen <[email protected]> and Nicholas A. Bellinger <[email protected]> for their help in resolving this issue.
Signed-off-by K. Y. Srinivasan <[email protected]>--- drivers/scsi/sd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)Quoted 8 lines
Quoted 8 lines
drivers/scsi/sd.c static int sd_setup_write_same_cmnd(struct
Quoted 5 lines
drivers/scsi/sd.c +0
-0@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct
scsi_device*sdp, struct request *rq)Quoted 2 lines
drivers/scsi/sd.c +0
-0static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request*rq)
Quoted 37 lines
Quoted 37 lines
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1436
Quoted 11 lines
drivers/scsi/sd.c +2
-1{ - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=2 ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ; rq->cmd_len =10 ;@@ -1433,6 +1433,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +unsigned int timeout = sdp->request_queue->rq_timeout;The timeout is signed in the function prototype
drivers/scsi/sd.c static int sd_sync_cache(struct scsi_disk *sdkp) · line 1455
Quoted 12 lines
drivers/scsi/sd.c +1
-1struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,7 +1449,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , + &sshdr, timeout *2 ,SD_MAX_RETRIES ,NULL ,REQ_PM );if (res ==0 )break ;Not like this, please: you now leave us with a dangling #define whose name makes you think it should be related to flushing and a couple of curious magic constants. It's almost hand crafted to confuse people reading the code.
Please do it like this instead: with a comment explaining what we're doing above the #define and a name that clearly relates to the actions.
James
Quoted 7 lines
drivers/scsi/sd.c static int sd_setup_write_same_cmnd(struct
Quoted 7 lines
---
drivers/scsi/sd.c +0
-0@@ -829,7 +829,7 @@ static int sd_setup_write_same_cmnd(struct
scsi_deviceQuoted 45 lines
Quoted 45 lines
drivers/scsi/sd.c +1
-1*sdp, struct request *rq)static int scsi_setup_flush_cmnd (struct scsi_device *sdp,struct request *rq) { - rq->timeout =SD_FLUSH_TIMEOUT ; + rq->timeout *=SD_FLUSH_TIMEOUT_MULTIPLIER ; rq->retries =SD_MAX_RETRIES ; rq->cmd[0 ] =SYNCHRONIZE_CACHE ;drivers/scsi/sd.c +4
-2rq->cmd_len =10 ;@@ -1433,6 +1433,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp) {int retries, res;struct scsi_device *sdp = sdkp->device; +const int timeout = sdp->request_queue->rq_timeout + *SD_FLUSH_TIMEOUT_MULTIPLIER ;struct scsi_sense_hdr sshdr;if (!scsi_device_online (sdp))@@ -1448,8 +1450,8 @@ static int sd_sync_cache(struct scsi_disk *sdkp)* flush everything. */ res =scsi_execute_req_flags (sdp, cmd,DMA_NONE ,NULL ,0 , - &sshdr,SD_FLUSH_TIMEOUT , -SD_MAX_RETRIES ,NULL ,REQ_PM ); + &sshdr, timeout,SD_MAX_RETRIES , +NULL ,REQ_PM );if (res ==0 )break ; }drivers/scsi/sd.h +5
-1@@ -13,7 +13,11 @@*/ #define SD_TIMEOUT (30 * HZ)#define SD_MOD_TIMEOUT (75 * HZ) -#define SD_FLUSH_TIMEOUT (60 * HZ) +/* +* Flush timeout is a multiplier over the standard device timeout which is +* user modifiable via sysfs but initially set to SD_TIMEOUT +*/ +#define SD_FLUSH_TIMEOUT_MULTIPLIER 2#define SD_WRITE_SAME_TIMEOUT (120 * HZ)
Quoted 8 lines
Quoted 3 lines
drivers/scsi/sd.h line 23
Quoted 1 line
drivers/scsi/sd.h +0
-0/* Thanks James. Given that you have already made the changes you want done
(in the
Quoted 1 line
Patch above), do you still want me to send you a fixed up patch?
Either way is fine. I just need the patch to be on the mailing list for my workflow (which it is now).
In that case, we will go with the patch you have. Thank you for taking the time on this.
Regards,
K. Y
Quoted 3 lines
James