public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: Mike Christie <michael.christie@oracle.com>,
	bvanassche@acm.org, mwilck@suse.com, hch@lst.de,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	james.bottomley@hansenpartnership.com
Subject: Re: [PATCH v2 01/15] scsi: Add struct for args to execution functions
Date: Fri, 9 Dec 2022 10:40:35 +0000	[thread overview]
Message-ID: <0e69ddee-4967-ee07-b959-91d7de7b212e@oracle.com> (raw)
In-Reply-To: <20221209061325.705999-2-michael.christie@oracle.com>

On 09/12/2022 06:13, Mike Christie wrote:
> Subject:
> [PATCH v2 01/15] scsi: Add struct for args to execution functions
> From:
> Mike Christie <michael.christie@oracle.com>
> Date:
> 09/12/2022, 06:13
> 
> To:
> john.g.garry@oracle.com, bvanassche@acm.org, mwilck@suse.com, 
> hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, 
> james.bottomley@hansenpartnership.com
> CC:
> Mike Christie <michael.christie@oracle.com>

Generally I think that this looks ok, but I have a bit of a niggle about 
the sense_len argument, below.

> 
> 
> This begins to move the SCSI execution functions to use a struct for
> passing in optional args. This patch adds the new struct, temporarily
> converts scsi_execute and scsi_execute_req and add two helpers:
> 1. scsi_execute_args which takes the scsi_exec_args struct.
> 2. scsi_execute_cmd does not support the scsi_exec_args struct.
> 
> The next patches will convert scsi_execute and scsi_execute_req users to
> the new helpers then remove scsi_execute and scsi_execute_req.
> 
> Signed-off-by: Mike Christie<michael.christie@oracle.com>
> ---

...

>   
>   	/*
>   	 * head injection*required*  here otherwise quiesce won't work
> @@ -249,13 +238,14 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
>   	if (unlikely(scmd->resid_len > 0 && scmd->resid_len <= bufflen))
>   		memset(buffer + bufflen - scmd->resid_len, 0, scmd->resid_len);
>   
> -	if (resid)
> -		*resid = scmd->resid_len;
> -	if (sense && scmd->sense_len)
> -		memcpy(sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
> -	if (sshdr)
> -		scsi_normalize_sense(scmd->sense_buffer, scmd->sense_len,
> -				     sshdr);
> +	if (args.resid)
> +		*args.resid = scmd->resid_len;
> +	if (args.sense && scmd->sense_len)

I am not sure that you require the sense_len check as you effectively 
have that same check in scsi_execute_args(), which is the only caller 
which would have args.sense set. But I suppose __scsi_execute() is still 
a public API (so should still check); but, by that same token, we have 
no sanity check for args.sense_len value here then. Is it possible to 
make __scsi_execute() non-public or move/add the check for proper 
sense_len here? I'm being extra cautious about this, I suppose.

> +		memcpy(args.sense, scmd->sense_buffer, SCSI_SENSE_BUFFERSIZE);
> +	if (args.sshdr)
> +		scsi_normalize_sense(scmd->sense_buffer,
> +				     scmd->sense_len, args.sshdr);
> +
>   	ret = scmd->result;
>    out:
>   	blk_mq_free_request(req);
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index 3642b8e3928b..eb960aa73b3b 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h

...

> +
> +#define scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, timeout,	\
> +			 retries)					\
> +({									\
> +	struct scsi_exec_args exec_args = {};				\

nit: I think that this can be static const, but no biggie

> +									\
> +	__scsi_execute(sdev, cmd, opf, buffer, bufflen, timeout,	\
> +		       retries, exec_args);				\
> +})
> +

  reply	other threads:[~2022-12-09 10:40 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-09  6:13 [PATCH v2 00/15] scsi: Add struct for args to execution functions Mike Christie
2022-12-09  6:13 ` [PATCH v2 01/15] " Mike Christie
2022-12-09 10:40   ` John Garry [this message]
2022-12-09 17:15     ` Mike Christie
2022-12-09 18:37       ` Mike Christie
2022-12-09 18:47         ` Bart Van Assche
2022-12-12 16:17           ` John Garry
2022-12-12 17:03             ` Mike Christie
2022-12-12 19:45   ` Bart Van Assche
2022-12-12 21:17     ` Mike Christie
2022-12-09  6:13 ` [PATCH v2 02/15] scsi: libata: Convert to scsi_execute_args Mike Christie
2022-12-09  9:55   ` John Garry
2022-12-12  5:11   ` Damien Le Moal
2022-12-09  6:13 ` [PATCH v2 03/15] hwmon: drivetemp: Convert to scsi_execute_cmd Mike Christie
2022-12-09  9:56   ` John Garry
2022-12-12 20:58   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 04/15] scsi: ch: Convert to scsi_execute_args Mike Christie
2022-12-09  9:57   ` John Garry
2022-12-09 17:20   ` kernel test robot
2022-12-12 19:46   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 05/15] scsi: scsi_dh: " Mike Christie
2022-12-09 10:03   ` John Garry
2022-12-09 18:21   ` kernel test robot
2022-12-09 19:11   ` kernel test robot
2022-12-12 21:00   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 06/15] scsi: core: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:05   ` John Garry
2022-12-12 21:04   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 07/15] scsi: spi: Convert to scsi_execute_args Mike Christie
2022-12-09 10:10   ` John Garry
2022-12-12 21:16     ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 08/15] scsi: sd: " Mike Christie
2022-12-09 10:12   ` John Garry
2022-12-12 21:16     ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 09/15] scsi: zbc: " Mike Christie
2022-12-09 10:13   ` John Garry
2022-12-12 21:17   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 10/15] scsi: ses: " Mike Christie
2022-12-09 10:14   ` John Garry
2022-12-12 21:17   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 11/15] scsi: sr: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:20   ` John Garry
2022-12-12 21:18   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 12/15] scsi: virtio_scsi: Convert to scsi_execute_cmd Mike Christie
2022-12-09 10:21   ` John Garry
2022-12-12 21:29   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 13/15] scsi: target_core_pscsi: " Mike Christie
2022-12-09 10:22   ` John Garry
2022-12-12 21:30   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 14/15] scsi: cxlflash: Convert to scsi_execute_args/cmd Mike Christie
2022-12-09 10:23   ` John Garry
2022-12-12 21:30   ` Bart Van Assche
2022-12-09  6:13 ` [PATCH v2 15/15] scsi: Remove scsi_execute_req/scsi_execute functions Mike Christie
2022-12-09 10:23   ` John Garry
2022-12-12 21:31   ` Bart Van Assche

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=0e69ddee-4967-ee07-b959-91d7de7b212e@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=bvanassche@acm.org \
    --cc=hch@lst.de \
    --cc=james.bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=mwilck@suse.com \
    /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