From 6fea15b01bafce2b30a32e4fcafd747c5665c16b Mon Sep 17 00:00:00 2001 From: Akinori Furuta Date: Wed, 27 Oct 2010 20:39:24 +0900 Subject: [PATCH] SCSI: Take timeout value from sysfs "timeout" attr. To prevent ADATA SSD may hang at FLUSH_CACHE, write value to "timeout" attr greater than 30. --- drivers/scsi/sd.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) mode change 100644 => 100755 drivers/scsi/sd.c diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c old mode 100644 new mode 100755 index ffa0689..ab5db46 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -426,6 +426,7 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) sector_t sector = bio->bi_sector; unsigned int nr_sectors = bio_sectors(bio); unsigned int len; + unsigned int timeout; int ret; struct page *page; @@ -434,7 +435,17 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) nr_sectors >>= 3; } - rq->timeout = SD_TIMEOUT; + /* Copy timeout value from request_queue. i.e. from sysfs timeout. */ + timeout=rq->q->rq_timeout; + if (timeouttimeout=timeout; memset(rq->cmd, 0, rq->cmd_len); @@ -477,7 +488,19 @@ static int scsi_setup_discard_cmnd(struct scsi_device *sdp, struct request *rq) static int scsi_setup_flush_cmnd(struct scsi_device *sdp, struct request *rq) { - rq->timeout = SD_TIMEOUT; + unsigned int timeout; + /* Copy timeout value from request_queue. i.e. from sysfs timeout. */ + timeout=rq->q->rq_timeout; + if (timeouttimeout=timeout; + rq->retries = SD_MAX_RETRIES; rq->cmd[0] = SYNCHRONIZE_CACHE; rq->cmd_len = 10; -- 1.7.2.3