[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <80a69f59-08b6-73c2-5ee6-848149005701@acm.org>
Date: Fri, 15 May 2020 20:19:11 -0700
From: Bart Van Assche <bvanassche@....org>
To: Avri Altman <avri.altman@....com>,
"James E . J . Bottomley" <jejb@...ux.vnet.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: alim.akhtar@...sung.com, asutoshd@...eaurora.org,
Zang Leigang <zangleigang@...ilicon.com>,
Avi Shchislowski <avi.shchislowski@....com>,
Bean Huo <beanhuo@...ron.com>, cang@...eaurora.org,
stanley.chu@...iatek.com,
MOHAMMED RAFIQ KAMAL BASHA <md.rafiq@...sung.com>,
Sang-yoon Oh <sangyoon.oh@...sung.com>,
yongmyung lee <ymhungry.lee@...sung.com>,
Jinyoung CHOI <j-young.choi@...sung.com>
Subject: Re: [RFC PATCH 11/13] scsi: Allow device handler set their own CDB
On 2020-05-15 03:30, Avri Altman wrote:
> Allow scsi device handler handle their own CDB and ship it down the
> stream of scsi passthrough command setup flow, without any further
> interventions.
>
> This is useful for setting DRV-OP that implements vendor commands via
> the scsi device handlers framework.
>
> Signed-off-by: Avri Altman <avri.altman@....com>
> ---
> drivers/scsi/scsi_lib.c | 5 +++--
> drivers/scsi/sd.c | 9 +++++++++
> 2 files changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
> index 6b6dd40..4e98714 100644
> --- a/drivers/scsi/scsi_lib.c
> +++ b/drivers/scsi/scsi_lib.c
> @@ -1148,14 +1148,15 @@ static blk_status_t scsi_setup_fs_cmnd(struct scsi_device *sdev,
> {
> struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
>
> + cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
> + memset(cmd->cmnd, 0, BLK_MAX_CDB);
> +
> if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
> blk_status_t ret = sdev->handler->prep_fn(sdev, req);
> if (ret != BLK_STS_OK)
> return ret;
> }
>
> - cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
> - memset(cmd->cmnd, 0, BLK_MAX_CDB);
> return scsi_cmd_to_driver(cmd)->init_command(cmd);
> }
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index a793cb0..246bef8 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -1221,6 +1221,14 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd)
> } else if (sdp->use_16_for_rw || (nr_blocks > 0xffff)) {
> ret = sd_setup_rw16_cmnd(cmd, write, lba, nr_blocks,
> protect | fua);
> + } else if (unlikely(sdp->handler && blk_rq_is_private(rq))) {
> + /*
> + * scsi device handler that implements vendor commands -
> + * the command was already constructed in the device handler's
> + * prep_fn, so no need to do anything here
> + */
> + rq->cmd_flags = REQ_OP_READ;
> + ret = BLK_STS_OK;
> } else if ((nr_blocks > 0xff) || (lba > 0x1fffff) ||
> sdp->use_10_for_rw || protect) {
> ret = sd_setup_rw10_cmnd(cmd, write, lba, nr_blocks,
> @@ -1285,6 +1293,7 @@ static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
> return sd_setup_write_same_cmnd(cmd);
> case REQ_OP_FLUSH:
> return sd_setup_flush_cmnd(cmd);
> + case REQ_OP_DRV_IN:
> case REQ_OP_READ:
> case REQ_OP_WRITE:
> return sd_setup_read_write_cmnd(cmd);
The above looks weird to me. My understanding is that
scsi_setup_fs_cmnd() is intended for operations like REQ_OP_READ,
REQ_OP_WRITE and REQ_OP_DISCARD. I don't think that it is appropriate to
pass REQ_OP_DRV_IN requests to scsi_setup_fs_cmnd() and/or
sd_init_command().
Thanks,
Bart.
Powered by blists - more mailing lists