block/scsi: Allow request and error handling timeouts to be specified
Subsystems (2)
PATCH 1/1 block/scsi: Allow request and error handling timeouts to be specified
Export rq_timeout in sysfs for block devices since it is a request_queue property. Until now it has only been possible to explicitly set this for SCSI class devices.
Also introduce eh_timeout which can be used for error handling purposes. This was previously hardcoded to 10 seconds in the SCSI error handling code. However, for some fast-fail scenarios it is necessary to be able to tune this as it can take several iterations (bus device, target, bus, controller) before we give up.
Signed-off-by Martin K. Petersen <[email protected]>
Documentation/ABI/testing/sysfs-block +23 -0
@@ -129,6 +129,29 @@ Description: throughput is desired. If no optimal I/O size is reported this file contains 0. +What: /sys/block/<disk>/queue/rq_timeout_secs +Date: June 2012 +Contact: Martin K. Petersen <[email protected]> +Description: + This is the timeout in seconds for regular filesystem + I/O requests. If the disk device has not completed the + request in this many seconds the kernel will fail the + I/O and initiate the subsystem-specific error handling + process. + +What: /sys/block/<disk>/queue/eh_timeout_secs +Date: June 2012 +Contact: Martin K. Petersen <[email protected]> +Description: + If a device has timed out while processing regular + filesystem I/O the kernel will attempt to bring the + device back online. This typically involves an + escalating set of approaches (device reset, bus reset, + controller reset). eh_timeout_secs describes how many + seconds should be spent waiting for response after each + recovery attempt before moving on to the next step in + the error handling process. + What: /sys/block/<disk>/queue/nomerges Date: January 2010 Contact:
block/blk-settings.c +6 -0
@@ -87,6 +87,12 @@ void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout) }EXPORT_SYMBOL_GPL (blk_queue_rq_timeout); +void blk_queue_eh_timeout (struct request_queue *q,unsigned int timeout) +{ + q->eh_timeout = timeout; +} +EXPORT_SYMBOL_GPL (blk_queue_eh_timeout); +void blk_queue_rq_timed_out (struct request_queue *q,rq_timed_out_fn *fn) { q->rq_timed_out_fn = fn;
block/blk-sysfs.c +50 -0
68 lines not on this page · raw message
drivers/scsi/scsi_error.c +6 -5
@@ -42,8 +42,6 @@#include <trace/events/scsi.h> -#define SENSE_TIMEOUT (10*HZ) -/* * These should *probably* be handled by the host itself. * Since it is allowed to sleep, it probably should.
@@ -852,7 +850,8 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,*/ static int scsi_request_sense (struct scsi_cmnd *scmd) { -return scsi_send_eh_cmnd (scmd,NULL ,0 ,SENSE_TIMEOUT , ~0 ); +return scsi_send_eh_cmnd (scmd,NULL ,0 , + scmd->device->request_queue->eh_timeout, ~0 ); }/**
@@ -953,7 +952,8 @@ static int scsi_eh_tur(struct scsi_cmnd *scmd)int retry_cnt =1 , rtn; retry_tur: - rtn =scsi_send_eh_cmnd (scmd, tur_command,6 ,SENSE_TIMEOUT ,0 ); + rtn =scsi_send_eh_cmnd (scmd, tur_command,6 , + scmd->device->request_queue->eh_timeout,0 );SCSI_LOG_ERROR_RECOVERY (3 ,printk ("%s: scmd %p rtn %x\n" , __func__, scmd, rtn));
@@ -1065,12 +1065,13 @@ static int scsi_eh_abort_cmds(struct list_head *work_q,static int scsi_eh_try_stu (struct scsi_cmnd *scmd) {static unsigned char stu_command[6 ] = {START_STOP ,0 ,0 ,0 ,1 ,0 }; +unsigned int tmo = scmd->device->request_queue->rq_timeout;if (scmd->device->allow_restart) {int i, rtn =NEEDS_RETRY ;for (i =0 ; rtn ==NEEDS_RETRY && i <2 ; i++) - rtn =scsi_send_eh_cmnd (scmd, stu_command,6 , scmd->device->request_queue->rq_timeout,0 ); + rtn =scsi_send_eh_cmnd (scmd, stu_command,6 , tmo,0 );if (rtn ==SUCCESS )return 0 ;
drivers/scsi/scsi_lib.c +3 -0
@@ -1696,6 +1696,9 @@ struct request_queue *__scsi_alloc_queue(struct Scsi_Host *shost,*/ blk_queue_dma_alignment (q,0x03 ); +blk_queue_rq_timeout (q,SCSI_DEFAULT_RQ_TIMEOUT ); +blk_queue_eh_timeout (q,SCSI_DEFAULT_EH_TIMEOUT ); +return q; }EXPORT_SYMBOL (__scsi_alloc_queue);
include/linux/blkdev.h +2 -0
@@ -379,6 +379,7 @@ struct request_queue {unsigned int in_flight[2 ];unsigned int rq_timeout; +unsigned int eh_timeout;struct timer_list timeout;struct list_head timeout_list;
@@ -889,6 +890,7 @@ extern void blk_queue_update_dma_alignment(struct request_queue *, int);extern void blk_queue_softirq_done (struct request_queue *,softirq_done_fn *);extern void blk_queue_rq_timed_out (struct request_queue *,rq_timed_out_fn *);extern void blk_queue_rq_timeout (struct request_queue *,unsigned int ); +extern void blk_queue_eh_timeout (struct request_queue *,unsigned int );extern void blk_queue_flush (struct request_queue *q,unsigned int flush);extern void blk_queue_flush_queueable (struct request_queue *q,bool queueable);extern struct backing_dev_info *blk_get_backing_dev_info (struct block_device *bdev);
include/scsi/scsi.h +6 -0
@@ -10,9 +10,15 @@#include <linux/types.h> #include <linux/scatterlist.h> +#include <linux/kernel.h> struct scsi_cmnd ; +enum scsi_timeouts { +SCSI_DEFAULT_RQ_TIMEOUT =30 *HZ , +SCSI_DEFAULT_EH_TIMEOUT =10 *HZ , +}; +/* * The maximum number of SG segments that we will put inside a * scatterlist (unless chaining is used). Should ideally fit inside a