From: Hannes Reinecke <hare@suse.de>
To: Damien Le Moal <damien.lemoal@wdc.com>,
linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>,
dm-devel@redhat.com, Mike Snitzer <snitzer@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>,
Matias Bjorling <matias.bjorling@wdc.com>
Subject: Re: [PATCH v3 03/11] scsi: sd_zbc: Fix sd_zbc_check_zones() error checks
Date: Fri, 12 Oct 2018 09:35:41 +0200 [thread overview]
Message-ID: <e45aba21-baf3-caab-de83-0c36925ebfdb@suse.de> (raw)
In-Reply-To: <20181012023012.29923-4-damien.lemoal@wdc.com>
On 10/12/18 4:30 AM, Damien Le Moal wrote:
> The 32 bits overflow check for the zone size value is already done
> within sd_zbc_check_zones() with the test:
>
> } else if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) {
>
> so there is no need to check again for an out of range value in
> sd_zbc_read_zones(). Simplify the code and fix sd_zbc_check_zones()
> error return to -EFBIG instead of -ENODEV if the zone size is too large.
>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/scsi/sd_zbc.c | 15 ++++++---------
> 1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index ca73c46931c0..44b64b4a922a 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -373,7 +373,7 @@ static int sd_zbc_check_zoned_characteristics(struct scsi_disk *sdkp,
> * Returns the zone size in number of blocks upon success or an error code
> * upon failure.
> */
> -static s64 sd_zbc_check_zones(struct scsi_disk *sdkp)
> +static s32 sd_zbc_check_zones(struct scsi_disk *sdkp)
> {
> u64 zone_blocks = 0;
> sector_t max_lba, block = 0;
Does this have to be an 's32' ?
Seeing that it's overloaded with an error code, and never sent to any
hardware, can't we just make it a simple 'int' ?
> @@ -472,7 +472,7 @@ static s64 sd_zbc_check_zones(struct scsi_disk *sdkp)
> if (sdkp->first_scan)
> sd_printk(KERN_NOTICE, sdkp,
> "Zone size too large\n");
> - ret = -ENODEV;
> + ret = -EFBIG;
> } else {
> ret = zone_blocks;
> }
> @@ -668,8 +668,7 @@ static int sd_zbc_setup(struct scsi_disk *sdkp, u32 zone_blocks)
>
> int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
> {
> - int64_t zone_blocks;
> - int ret;
> + int ret, zone_blocks;
>
> if (!sd_is_zoned(sdkp))
> /*
> @@ -688,12 +687,10 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, unsigned char *buf)
> * an eventual last runt zone) that is a power of 2 are supported.
> */
> zone_blocks = sd_zbc_check_zones(sdkp);
> - ret = -EFBIG;
> - if (zone_blocks != (u32)zone_blocks)
> - goto err;
> - ret = zone_blocks;
> - if (ret < 0)
> + if (zone_blocks < 0) {
> + ret = zone_blocks;
> goto err;
> + }
>
> /* The drive satisfies the kernel restrictions: set it up */
> ret = sd_zbc_setup(sdkp, zone_blocks);
>
Remaining bits are okay.
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
next prev parent reply other threads:[~2018-10-12 7:35 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-12 2:30 [PATCH v3 00/11] Zoned block device support improvements Damien Le Moal
2018-10-12 2:30 ` [PATCH v3 01/11] scsi: sd_zbc: Rearrange code Damien Le Moal
2018-10-12 7:29 ` Hannes Reinecke
2018-10-12 2:30 ` [PATCH v3 02/11] scsi: sd_zbc: Reduce boot device scan and revalidate time Damien Le Moal
2018-10-12 7:33 ` Hannes Reinecke
2018-10-12 7:48 ` Damien Le Moal
2018-10-12 10:28 ` Matias Bjorling
2018-10-12 2:30 ` [PATCH v3 03/11] scsi: sd_zbc: Fix sd_zbc_check_zones() error checks Damien Le Moal
2018-10-12 7:35 ` Hannes Reinecke [this message]
2018-10-12 7:50 ` Damien Le Moal
2018-10-12 2:30 ` [PATCH v3 04/11] block: Introduce blkdev_nr_zones() helper Damien Le Moal
2018-10-12 7:36 ` Hannes Reinecke
2018-10-12 2:30 ` [PATCH v3 05/11] block: Limit allocation of zone descriptors for report zones Damien Le Moal
2018-10-12 7:36 ` Hannes Reinecke
2018-10-12 2:30 ` [PATCH v3 06/11] block: Introduce BLKGETZONESZ ioctl Damien Le Moal
2018-10-12 7:37 ` Hannes Reinecke
2018-10-12 8:23 ` Christoph Hellwig
2018-10-12 2:30 ` [PATCH v3 07/11] block: Introduce BLKGETNRZONES ioctl Damien Le Moal
2018-10-12 7:37 ` Hannes Reinecke
2018-10-12 8:23 ` Christoph Hellwig
2018-10-12 2:30 ` [PATCH v3 08/11] block: Improve zone reset execution Damien Le Moal
2018-10-12 7:39 ` Hannes Reinecke
2018-10-12 2:30 ` [PATCH v3 09/11] block: Expose queue nr_zones in sysfs Damien Le Moal
2018-10-12 7:41 ` Hannes Reinecke
2018-10-12 7:55 ` Damien Le Moal
2018-10-12 8:41 ` Hannes Reinecke
2018-10-12 8:28 ` Christoph Hellwig
2018-10-12 8:29 ` Christoph Hellwig
2018-10-12 2:30 ` [PATCH v3 10/11] block: add a report_zones method Damien Le Moal
2018-10-12 7:42 ` Hannes Reinecke
2018-10-12 2:30 ` [PATCH v3 11/11] block: Introduce blk_revalidate_disk_zones() Damien Le Moal
2018-10-12 7:44 ` Hannes Reinecke
2018-10-12 8:30 ` Christoph Hellwig
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=e45aba21-baf3-caab-de83-0c36925ebfdb@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=damien.lemoal@wdc.com \
--cc=dm-devel@redhat.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matias.bjorling@wdc.com \
--cc=snitzer@redhat.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