From: Tejun Heo <htejun@gmail.com>
To: James.Bottomley@steeleye.com, axboe@suse.de,
Christoph Hellwig <hch@infradead.org>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH scsi-misc-2.6 01/04] scsi: consolidate error handling out of scsi_init_io() into scsi_prep_fn()
Date: Sat, 14 May 2005 22:57:38 +0900 (KST) [thread overview]
Message-ID: <20050514135610.536D5170@htj.dyndns.org> (raw)
In-Reply-To: <20050514135610.81030F26@htj.dyndns.org>
01_scsi_reqfn_consolidate_error_handling.patch
This patch fixes a queue stall bug which occurred when sgtable
allocation failed and device_busy == 0. When scsi_init_io()
returns BLKPREP_DEFER or BLKPREP_KILL, it's supposed to free
resources itself. This patch consolidates defer and kill
handling into scsi_prep_fn().
Note that this patch doesn't consolidate state defer/kill
handlings in scsi_prep_fn() as all state checks will be moved
into scsi_reques_fn() by the following reqfn_reimpl patch.
ret value checking was changed to switch() as in James's
patch. Also, kill: comment is copied from James's patch.
Signed-off-by: Tejun Heo <htejun@gmail.com>
scsi_lib.c | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
Index: scsi-reqfn-export/drivers/scsi/scsi_lib.c
===================================================================
--- scsi-reqfn-export.orig/drivers/scsi/scsi_lib.c 2005-05-14 22:35:18.000000000 +0900
+++ scsi-reqfn-export/drivers/scsi/scsi_lib.c 2005-05-14 22:35:18.000000000 +0900
@@ -977,9 +977,6 @@ static int scsi_init_io(struct scsi_cmnd
printk(KERN_ERR "req nr_sec %lu, cur_nr_sec %u\n", req->nr_sectors,
req->current_nr_sectors);
- /* release the command and kill it */
- scsi_release_buffers(cmd);
- scsi_put_command(cmd);
return BLKPREP_KILL;
}
@@ -1147,18 +1144,24 @@ static int scsi_prep_fn(struct request_q
* required).
*/
ret = scsi_init_io(cmd);
- if (ret) /* BLKPREP_KILL return also releases the command */
- return ret;
+ switch (ret) {
+ case 0:
+ /* Successful initialization. */
+ break;
+ case BLKPREP_DEFER:
+ goto defer;
+ default:
+ /* Unknown return value, fall through. */
+ case BLKPREP_KILL:
+ goto kill;
+ }
/*
* Initialize the actual SCSI command for this request.
*/
drv = *(struct scsi_driver **)req->rq_disk->private_data;
- if (unlikely(!drv->init_command(cmd))) {
- scsi_release_buffers(cmd);
- scsi_put_command(cmd);
- return BLKPREP_KILL;
- }
+ if (unlikely(!drv->init_command(cmd)))
+ goto kill;
}
/*
@@ -1168,12 +1171,25 @@ static int scsi_prep_fn(struct request_q
return BLKPREP_OK;
defer:
- /* If we defer, the elv_next_request() returns NULL, but the
+ /*
+ * If we defer, the elv_next_request() returns NULL, but the
* queue must be restarted, so we plug here if no returning
- * command will automatically do that. */
+ * command will automatically do that.
+ */
if (sdev->device_busy == 0)
blk_plug_device(q);
return BLKPREP_DEFER;
+
+ kill:
+ /*
+ * Here we have to release every resource associated with the
+ * request because this will complete at the request level
+ * (req->end_io), not the scsi command level, so no scsi
+ * routine will get to free the associated resources.
+ */
+ scsi_release_buffers(cmd);
+ scsi_put_command(cmd);
+ return BLKPREP_KILL;
}
/*
next prev parent reply other threads:[~2005-05-14 13:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-14 13:57 [PATCH scsi-misc-2.6 00/04] scsi: scsi_request_fn() reimplementation Tejun Heo
2005-05-14 13:57 ` Tejun Heo [this message]
2005-05-14 13:57 ` [PATCH scsi-misc-2.6 02/04] scsi: move request preps in other places into prep_fn() Tejun Heo
2005-05-14 13:57 ` [PATCH scsi-misc-2.6 03/04] scsi: reimplement scsi_request_fn() Tejun Heo
2005-05-14 13:57 ` [PATCH scsi-misc-2.6 04/04] scsi: remove unnecessary scsi_wait_req_end_io() Tejun Heo
2005-05-14 15:26 ` James Bottomley
2005-05-14 15:47 ` Tejun Heo
2005-05-14 16:19 ` James Bottomley
2005-05-15 1:15 ` Tejun Heo
2005-05-16 16:07 ` James Bottomley
2005-05-16 16:56 ` Tejun Heo
2005-05-15 1:16 ` Tejun Heo
-- strict thread matches above, loose matches on Subject: below --
2005-04-12 10:32 [PATCH scsi-misc-2.6 00/04] scsi: scsi_request_fn() reimplementation Tejun Heo
2005-04-12 10:32 ` [PATCH scsi-misc-2.6 01/04] scsi: consolidate error handling out of scsi_init_io() into scsi_prep_fn() Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050514135610.536D5170@htj.dyndns.org \
--to=htejun@gmail.com \
--cc=James.Bottomley@steeleye.com \
--cc=axboe@suse.de \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®