Linux block layer
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@wdc.com>
To: linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@lst.de>, Bart Van Assche <Bart.VanAssche@wdc.com>
Subject: [PATCH V6 04/14] scsi: sd_zbc: Use well defined macros
Date: Mon,  2 Oct 2017 16:15:25 +0900	[thread overview]
Message-ID: <20171002071535.8007-5-damien.lemoal@wdc.com> (raw)
In-Reply-To: <20171002071535.8007-1-damien.lemoal@wdc.com>

instead of open coding, use the min() macro to calculate a report zones
reply buffer length in sd_zbc_check_zone_size() and the round_up()
macro for calculating the number of zones in sd_zbc_setup().

No functional change is introduced by this patch.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sd_zbc.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 7dbaf920679e..bbad851c1789 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -475,7 +475,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf)
 	return 0;
 }
 
-#define SD_ZBC_BUF_SIZE 131072
+#define SD_ZBC_BUF_SIZE 131072U
 
 /**
  * sd_zbc_check_zone_size - Check the device zone sizes
@@ -526,10 +526,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
 		/* Parse REPORT ZONES header */
 		list_length = get_unaligned_be32(&buf[0]) + 64;
 		rec = buf + 64;
-		if (list_length < SD_ZBC_BUF_SIZE)
-			buf_len = list_length;
-		else
-			buf_len = SD_ZBC_BUF_SIZE;
+		buf_len = min(list_length, SD_ZBC_BUF_SIZE);
 
 		/* Parse zone descriptors */
 		while (rec < buf + buf_len) {
@@ -599,9 +596,8 @@ static int sd_zbc_setup(struct scsi_disk *sdkp)
 	/* chunk_sectors indicates the zone size */
 	blk_queue_chunk_sectors(sdkp->disk->queue,
 			logical_to_sectors(sdkp->device, sdkp->zone_blocks));
-	sdkp->nr_zones = sdkp->capacity >> sdkp->zone_shift;
-	if (sdkp->capacity & (sdkp->zone_blocks - 1))
-		sdkp->nr_zones++;
+	sdkp->nr_zones =
+		round_up(sdkp->capacity, sdkp->zone_blocks) >> sdkp->zone_shift;
 
 	if (!sdkp->zones_wlock) {
 		sdkp->zones_wlock = kcalloc(BITS_TO_LONGS(sdkp->nr_zones),
-- 
2.13.6

  parent reply	other threads:[~2017-10-02  7:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-02  7:15 [PATCH V6 00/14] scsi-mq support for ZBC disks Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 01/14] scsi: sd_zbc: Move ZBC declarations to scsi_proto.h Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 02/14] scsi: sd_zbc: Fix comments and indentation Damien Le Moal
2017-10-02 16:50   ` Bart Van Assche
2017-10-02  7:15 ` [PATCH V6 03/14] scsi: sd_zbc: Rearrange code Damien Le Moal
2017-10-02  7:15 ` Damien Le Moal [this message]
2017-10-02  7:15 ` [PATCH V6 05/14] scsi: sd_zbc: Fix sd_zbc_read_zoned_characteristics() Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 06/14] block: Add zoned block device information to request queue Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 07/14] scsi: sd_zbc: Initialize device request queue zoned data Damien Le Moal
2017-10-02 16:57   ` Bart Van Assche
2017-10-02  7:15 ` [PATCH V6 08/14] scsi: sd_zbc: Limit zone write locking to sequential zones Damien Le Moal
2017-10-02 17:00   ` Bart Van Assche
2017-10-02  7:15 ` [PATCH V6 09/14] scsi: sd_zbc: Disable zone write locking with scsi-mq Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 10/14] block: mq-deadline: Add zoned block device data Damien Le Moal
2017-10-02 23:06   ` Bart Van Assche
2017-10-02  7:15 ` [PATCH V6 11/14] blokc: mq-deadline: Introduce dispatch helpers Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 12/14] block: mq-deadline: Introduce zone locking support Damien Le Moal
2017-10-02 23:12   ` Bart Van Assche
2017-10-02  7:15 ` [PATCH V6 13/14] block: mq-deadline: Limit write request dispatch for zoned block devices Damien Le Moal
2017-10-02 23:44   ` Bart Van Assche
2017-10-03  0:19     ` Damien Le Moal
2017-10-03 20:56       ` Bart Van Assche
2017-10-03 23:03         ` Damien Le Moal
2017-10-02  7:15 ` [PATCH V6 14/14] block: do not set mq default scheduler Damien Le Moal

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=20171002071535.8007-5-damien.lemoal@wdc.com \
    --to=damien.lemoal@wdc.com \
    --cc=Bart.VanAssche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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