From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Bart Van Assche <bvanassche@acm.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>, Hannes Reinecke <hare@suse.de>,
Shaun Tancheff <shaun.tancheff@seagate.com>,
linux-scsi@vger.kernel.org,
"James E.J. Bottomley" <jejb@linux.ibm.com>
Subject: Re: [PATCH 3/8] scsi: sd_zbc: Verify that the zone size is a power of two
Date: Mon, 18 Apr 2022 08:09:52 +0900 [thread overview]
Message-ID: <eb2e59d1-b28b-aaa3-ca70-46f7ccfbba06@opensource.wdc.com> (raw)
In-Reply-To: <20220415201752.2793700-4-bvanassche@acm.org>
On 4/16/22 05:17, Bart Van Assche wrote:
> The following check in sd_zbc_cmnd_checks() can only work correctly if
> the zone size is a power of two:
>
> if (sector & (sd_zbc_zone_sectors(sdkp) - 1))
> /* Unaligned request */
> return BLK_STS_IOERR;
>
> Hence this patch that verifies that the zone size is a power of two.
>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Note that this is already checked in blk_revalidate_disk_zones(), but it
does not hurt to add the check.
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> ---
> drivers/scsi/sd_zbc.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index d0275855b16c..c1f295859b27 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -666,6 +666,13 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf,
>
> *zblocks = zone_blocks;
>
> + if (!is_power_of_2(*zblocks)) {
> + sd_printk(KERN_ERR, sdkp,
> + "Zone size %llu is not a power of two.\n",
> + zone_blocks);
> + return -EINVAL;
> + }
> +
> return 0;
> }
>
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-04-17 23:10 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 20:17 [PATCH 0/8] Support zoned devices with gap zones Bart Van Assche
2022-04-15 20:17 ` [PATCH 1/8] scsi: sd_zbc: Improve source code documentation Bart Van Assche
2022-04-17 23:07 ` Damien Le Moal
2022-04-15 20:17 ` [PATCH 2/8] scsi: sd_zbc: Rename a local variable Bart Van Assche
2022-04-17 23:08 ` Damien Le Moal
2022-04-15 20:17 ` [PATCH 3/8] scsi: sd_zbc: Verify that the zone size is a power of two Bart Van Assche
2022-04-17 23:09 ` Damien Le Moal [this message]
2022-04-18 16:54 ` Bart Van Assche
2022-04-15 20:17 ` [PATCH 4/8] scsi: sd_zbc: Introduce struct zoned_disk_info Bart Van Assche
2022-04-17 23:16 ` Damien Le Moal
2022-04-18 16:53 ` Bart Van Assche
2022-04-15 20:17 ` [PATCH 5/8] scsi: sd_zbc: Hide gap zones Bart Van Assche
2022-04-17 23:22 ` Damien Le Moal
2022-04-18 16:59 ` Bart Van Assche
2022-04-15 20:17 ` [PATCH 6/8] scsi_debug: Fix a typo Bart Van Assche
2022-04-17 23:23 ` Damien Le Moal
2022-04-15 20:17 ` [PATCH 7/8] scsi_debug: Rename zone type constants Bart Van Assche
2022-04-15 20:17 ` [PATCH 8/8] scsi_debug: Add gap zone support 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=eb2e59d1-b28b-aaa3-ca70-46f7ccfbba06@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=bvanassche@acm.org \
--cc=hare@suse.de \
--cc=jaegeuk@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shaun.tancheff@seagate.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