From: Boaz Harrosh <bharrosh@panasas.com>
To: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Kai.Makisara@kolumbus.fi, James.Bottomley@HansenPartnership.com,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 02/11] st: add st_scsi_kern_execute helper function
Date: Sun, 30 Nov 2008 14:10:56 +0200 [thread overview]
Message-ID: <493282D0.6020006@panasas.com> (raw)
In-Reply-To: <1228032485-10328-3-git-send-email-fujita.tomonori@lab.ntt.co.jp>
FUJITA Tomonori wrote:
> st_scsi_kern_execute is a helper function to perform SCSI commands
> synchronously. It supports data transfer with a liner in-kernel buffer
> (not scatter gather). st_scsi_kern_execute internally uses
> blk_get_request, blk_rq_map_kern, and blk_execute_rq.
>
> The majority of st_do_scsi can be replaced with
> st_scsi_kern_execute. This is a preparation for rewriting st_do_scsi
> to remove obsolete scsi_execute_async().
>
> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> ---
> drivers/scsi/st.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 49 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
> index 878493d..6179940 100644
> --- a/drivers/scsi/st.c
> +++ b/drivers/scsi/st.c
> @@ -533,6 +533,55 @@ st_do_scsi(struct st_request * SRpnt, struct scsi_tape * STp, unsigned char *cmd
> return SRpnt;
> }
>
> +static int st_scsi_kern_execute(struct st_request *streq,
> + const unsigned char *cmd, int data_direction,
> + void *buffer, unsigned bufflen, int timeout,
> + int retries)
> +{
> + struct scsi_tape *stp = streq->stp;
> + struct request *req;
> + int write = (data_direction == DMA_TO_DEVICE);
> + int ret = 0;
> +
> + /* st_do_scsi returns -EBUSY in case of OOM */
> + req = blk_get_request(stp->device->request_queue, write, GFP_KERNEL);
> + if (!req)
> + return -EBUSY;
> +
> + if (bufflen) {
> + ret = blk_rq_map_kern(stp->device->request_queue, req,
> + buffer, bufflen, GFP_KERNEL);
> + if (ret)
> + goto out;
> + }
> +
> + req->cmd_type = REQ_TYPE_BLOCK_PC;
> + req->cmd_flags |= REQ_QUIET;
> +
> + req->cmd_len = COMMAND_SIZE(cmd[0]);
> + memcpy(req->cmd, cmd, req->cmd_len);
> +
> + req->sense = streq->sense;
> + req->sense_len = 0;
> +
> + req->timeout = timeout;
> + req->retries = retries;
> +
> + stp->buffer->cmdstat.have_sense = 0;
> + memcpy(streq->cmd, cmd, sizeof(streq->cmd));
> +
> + blk_execute_rq(req->q, NULL, req, 1);
> +
> + stp->buffer->cmdstat.midlevel_result = streq->result = req->errors;
> + stp->buffer->cmdstat.residual = req->data_len;
> +
TOMO Hi.
would you say that the only reason we cannot use scsi_execute inside st_scsi_kern_execute
is because we don't have residual count returned from scsi_execute ?
> + stp->buffer->syscall_result = st_chk_result(stp, streq);
> +
> +out:
> + blk_put_request(req);
> +
> + return ret;
> +}
>
> /* Handle the write-behind checking (waits for completion). Returns -ENOSPC if
> write has been correct but EOM early warning reached, -EIO if write ended in
The reason I'm asking is because I needed the same from scsi_execute in the passed.
Boaz
next prev parent reply other threads:[~2008-11-30 12:11 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-30 8:07 [PATCH 00/11] st: remove scsi_execute_async usage (the first half) FUJITA Tomonori
2008-11-30 8:07 ` [PATCH 01/11] st: move st_request initialization to st_allocate_request form st_do_scsi FUJITA Tomonori
2008-11-30 8:07 ` [PATCH 02/11] st: add st_scsi_kern_execute helper function FUJITA Tomonori
2008-11-30 8:07 ` [PATCH 03/11] st: convert test_ready to use st_scsi_kern_execute FUJITA Tomonori
2008-11-30 8:07 ` [PATCH 04/11] st: convert set_location " FUJITA Tomonori
2008-11-30 8:07 ` [PATCH 05/11] st: convert do_load_unload " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 06/11] st: convert cross_eof " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 07/11] st: convert st_flush " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 08/11] st: convert check_tape " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 09/11] st: convert read_mode_page " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 10/11] st: convert write_mode_page " FUJITA Tomonori
2008-11-30 8:08 ` [PATCH 11/11] st: convert get_location " FUJITA Tomonori
2008-11-30 12:12 ` [PATCH 09/11] st: convert read_mode_page " Boaz Harrosh
2008-12-01 8:21 ` FUJITA Tomonori
2008-11-30 12:10 ` Boaz Harrosh [this message]
2008-12-01 8:15 ` [PATCH 02/11] st: add st_scsi_kern_execute helper function FUJITA Tomonori
2008-12-01 15:19 ` [PATCH 00/11] st: remove scsi_execute_async usage (the first half) Vladislav Bolkhovitin
2008-12-01 15:36 ` Boaz Harrosh
2008-12-01 18:17 ` Vladislav Bolkhovitin
2008-12-02 7:52 ` Boaz Harrosh
2008-12-02 19:08 ` Kai Makisara
2008-12-03 0:27 ` FUJITA Tomonori
2008-12-03 19:40 ` Kai Makisara
2008-12-04 5:53 ` FUJITA Tomonori
2008-12-04 20:23 ` Kai Makisara
2008-12-05 6:25 ` FUJITA Tomonori
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=493282D0.6020006@panasas.com \
--to=bharrosh@panasas.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Kai.Makisara@kolumbus.fi \
--cc=fujita.tomonori@lab.ntt.co.jp \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.