* [PATCH] Correctly release and allocate a new request upon retries
@ 2008-12-08 14:24 Alan D. Brunelle
2008-12-09 14:51 ` Jens Axboe
2008-12-09 23:38 ` FUJITA Tomonori
0 siblings, 2 replies; 3+ messages in thread
From: Alan D. Brunelle @ 2008-12-08 14:24 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org
Cc: Jens Axboe, Mike Anderson, James Bottomley, LKML-scsi
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 0001-Correctly-release-and-allocate-a-new-request-upon-re.patch --]
[-- Type: text/x-diff, Size: 3669 bytes --]
Commands needing to be retried require a complete re-initialization.
The test-unit-ready portion of this patch was causing boots to fail on
my test machine (as in http://lkml.org/lkml/2008/12/5/161). With this
patch in place, the system is booting reliably.
Mike Anderson found the same problem in the hp_hw_start_stop code,
and I applied the same solution in cdrom_read_cdda_bpc.
Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
---
drivers/cdrom/cdrom.c | 16 ++++++++++------
drivers/scsi/device_handler/scsi_dh_hp_sw.c | 12 ++++++++----
2 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index d16b024..7d2e91c 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -2081,10 +2081,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
if (!q)
return -ENXIO;
- rq = blk_get_request(q, READ, GFP_KERNEL);
- if (!rq)
- return -ENOMEM;
-
cdi->last_sense = 0;
while (nframes) {
@@ -2096,9 +2092,17 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
len = nr * CD_FRAMESIZE_RAW;
+ rq = blk_get_request(q, READ, GFP_KERNEL);
+ if (!rq) {
+ ret = -ENOMEM;
+ break;
+ }
+
ret = blk_rq_map_user(q, rq, NULL, ubuf, len, GFP_KERNEL);
- if (ret)
+ if (ret) {
+ blk_put_request(rq);
break;
+ }
rq->cmd[0] = GPCMD_READ_CD;
rq->cmd[1] = 1 << 2;
@@ -2124,6 +2128,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
if (blk_rq_unmap_user(bio))
ret = -EFAULT;
+ blk_put_request(rq);
if (ret)
break;
@@ -2133,7 +2138,6 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
ubuf += len;
}
- blk_put_request(rq);
return ret;
}
diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
index 9aec4ca..f7da753 100644
--- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
+++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
@@ -107,6 +107,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
struct request *req;
int ret;
+retry:
req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
if (!req)
return SCSI_DH_RES_TEMP_UNAVAIL;
@@ -121,7 +122,6 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
req->sense_len = 0;
-retry:
ret = blk_execute_rq(req->q, NULL, req, 1);
if (ret == -EIO) {
if (req->sense_len > 0) {
@@ -136,8 +136,10 @@ retry:
h->path_state = HP_SW_PATH_ACTIVE;
ret = SCSI_DH_OK;
}
- if (ret == SCSI_DH_IMM_RETRY)
+ if (ret == SCSI_DH_IMM_RETRY) {
+ blk_put_request(req);
goto retry;
+ }
if (ret == SCSI_DH_DEV_OFFLINED) {
h->path_state = HP_SW_PATH_PASSIVE;
ret = SCSI_DH_OK;
@@ -200,6 +202,7 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
struct request *req;
int ret, retry;
+retry:
req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
if (!req)
return SCSI_DH_RES_TEMP_UNAVAIL;
@@ -216,7 +219,6 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
req->sense_len = 0;
retry = h->retries;
-retry:
ret = blk_execute_rq(req->q, NULL, req, 1);
if (ret == -EIO) {
if (req->sense_len > 0) {
@@ -231,8 +233,10 @@ retry:
ret = SCSI_DH_OK;
if (ret == SCSI_DH_RETRY) {
- if (--retry)
+ if (--retry) {
+ blk_put_request(req);
goto retry;
+ }
ret = SCSI_DH_IO;
}
--
1.5.6.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Correctly release and allocate a new request upon retries
2008-12-08 14:24 [PATCH] Correctly release and allocate a new request upon retries Alan D. Brunelle
@ 2008-12-09 14:51 ` Jens Axboe
2008-12-09 23:38 ` FUJITA Tomonori
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2008-12-09 14:51 UTC (permalink / raw)
To: Alan D. Brunelle
Cc: linux-kernel@vger.kernel.org, Mike Anderson, James Bottomley,
LKML-scsi
On Mon, Dec 08 2008, Alan D. Brunelle wrote:
> Commands needing to be retried require a complete re-initialization.
>
> The test-unit-ready portion of this patch was causing boots to fail on
> my test machine (as in http://lkml.org/lkml/2008/12/5/161). With this
> patch in place, the system is booting reliably.
>
> Mike Anderson found the same problem in the hp_hw_start_stop code,
> and I applied the same solution in cdrom_read_cdda_bpc.
Thanks Alan, applied for 2.6.28.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Correctly release and allocate a new request upon retries
2008-12-08 14:24 [PATCH] Correctly release and allocate a new request upon retries Alan D. Brunelle
2008-12-09 14:51 ` Jens Axboe
@ 2008-12-09 23:38 ` FUJITA Tomonori
1 sibling, 0 replies; 3+ messages in thread
From: FUJITA Tomonori @ 2008-12-09 23:38 UTC (permalink / raw)
To: Alan.Brunelle
Cc: linux-kernel, jens.axboe, andmike, James.Bottomley, linux-scsi
On Mon, 08 Dec 2008 09:24:05 -0500
"Alan D. Brunelle" <Alan.Brunelle@hp.com> wrote:
> Commands needing to be retried require a complete re-initialization.
>
> The test-unit-ready portion of this patch was causing boots to fail on
> my test machine (as in http://lkml.org/lkml/2008/12/5/161). With this
> patch in place, the system is booting reliably.
>
> Mike Anderson found the same problem in the hp_hw_start_stop code,
> and I applied the same solution in cdrom_read_cdda_bpc.
>
> Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com>
> Cc: Jens Axboe <jens.axboe@oracle.com>
> Cc: Mike Anderson <andmike@linux.vnet.ibm.com>
> ---
> drivers/cdrom/cdrom.c | 16 ++++++++++------
> drivers/scsi/device_handler/scsi_dh_hp_sw.c | 12 ++++++++----
> 2 files changed, 18 insertions(+), 10 deletions(-)
> diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
> index 9aec4ca..f7da753 100644
> --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c
> +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c
> @@ -107,6 +107,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
> struct request *req;
> int ret;
>
> +retry:
> req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
> if (!req)
> return SCSI_DH_RES_TEMP_UNAVAIL;
> @@ -121,7 +122,6 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h)
> memset(req->sense, 0, SCSI_SENSE_BUFFERSIZE);
> req->sense_len = 0;
>
> -retry:
> ret = blk_execute_rq(req->q, NULL, req, 1);
> if (ret == -EIO) {
> if (req->sense_len > 0) {
> @@ -136,8 +136,10 @@ retry:
> h->path_state = HP_SW_PATH_ACTIVE;
> ret = SCSI_DH_OK;
> }
> - if (ret == SCSI_DH_IMM_RETRY)
> + if (ret == SCSI_DH_IMM_RETRY) {
> + blk_put_request(req);
> goto retry;
> + }
> if (ret == SCSI_DH_DEV_OFFLINED) {
> h->path_state = HP_SW_PATH_PASSIVE;
> ret = SCSI_DH_OK;
> @@ -200,6 +202,7 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
> struct request *req;
> int ret, retry;
>
> +retry:
> req = blk_get_request(sdev->request_queue, WRITE, GFP_NOIO);
> if (!req)
> return SCSI_DH_RES_TEMP_UNAVAIL;
> @@ -216,7 +219,6 @@ static int hp_sw_start_stop(struct scsi_device *sdev, struct hp_sw_dh_data *h)
> req->sense_len = 0;
> retry = h->retries;
>
> -retry:
> ret = blk_execute_rq(req->q, NULL, req, 1);
> if (ret == -EIO) {
> if (req->sense_len > 0) {
> @@ -231,8 +233,10 @@ retry:
> ret = SCSI_DH_OK;
>
> if (ret == SCSI_DH_RETRY) {
> - if (--retry)
> + if (--retry) {
> + blk_put_request(req);
> goto retry;
> + }
> ret = SCSI_DH_IO;
> }
Looks like the majority of the usage of
blk_get_request/blk_execute_rq/blk_put_request can be simply replaced
with scsi_execute()? The problem is that scsi_execute doesn't return
all the information about errors?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-09 23:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-08 14:24 [PATCH] Correctly release and allocate a new request upon retries Alan D. Brunelle
2008-12-09 14:51 ` Jens Axboe
2008-12-09 23:38 ` FUJITA Tomonori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox