From: "Javier González" <javier@javigon.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Hans Holmberg <hans@owltronix.com>,
linux-block@vger.kernel.org
Subject: Re: [PATCH 5/8] block: replace seq_zones_bitmap with conv_zones_bitmap
Date: Tue, 3 Dec 2019 15:02:39 +0100 [thread overview]
Message-ID: <20191203140239.x5a5ll2u5wgou6la@mpHalley.local> (raw)
In-Reply-To: <20191203093908.24612-6-hch@lst.de>
On 03.12.2019 10:39, Christoph Hellwig wrote:
>Invert the meaning of seq_zones_bitmap by keeping a bitmap of
>conventional zones. This allows not having a bitmap for devices
>that do not have conventional zones.
>
>Signed-off-by: Christoph Hellwig <hch@lst.de>
>---
> block/blk-zoned.c | 18 +++++++++---------
> include/linux/blkdev.h | 14 ++++++++------
> 2 files changed, 17 insertions(+), 15 deletions(-)
>
>diff --git a/block/blk-zoned.c b/block/blk-zoned.c
>index 65a9bdc9fe27..9c3931051f4f 100644
>--- a/block/blk-zoned.c
>+++ b/block/blk-zoned.c
>@@ -332,15 +332,15 @@ static inline unsigned long *blk_alloc_zone_bitmap(int node,
>
> void blk_queue_free_zone_bitmaps(struct request_queue *q)
> {
>- kfree(q->seq_zones_bitmap);
>- q->seq_zones_bitmap = NULL;
>+ kfree(q->conv_zones_bitmap);
>+ q->conv_zones_bitmap = NULL;
> kfree(q->seq_zones_wlock);
> q->seq_zones_wlock = NULL;
> }
>
> struct blk_revalidate_zone_args {
> struct gendisk *disk;
>- unsigned long *seq_zones_bitmap;
>+ unsigned long *conv_zones_bitmap;
> unsigned long *seq_zones_wlock;
> sector_t sector;
> };
>@@ -394,8 +394,8 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
> return -ENODEV;
> }
>
>- if (zone->type != BLK_ZONE_TYPE_CONVENTIONAL)
>- set_bit(idx, args->seq_zones_bitmap);
>+ if (zone->type == BLK_ZONE_TYPE_CONVENTIONAL)
>+ set_bit(idx, args->conv_zones_bitmap);
>
> args->sector += zone->len;
> return 0;
>@@ -415,8 +415,8 @@ static int blk_update_zone_info(struct gendisk *disk, unsigned int nr_zones,
> args->seq_zones_wlock = blk_alloc_zone_bitmap(q->node, nr_zones);
> if (!args->seq_zones_wlock)
> return -ENOMEM;
>- args->seq_zones_bitmap = blk_alloc_zone_bitmap(q->node, nr_zones);
>- if (!args->seq_zones_bitmap)
>+ args->conv_zones_bitmap = blk_alloc_zone_bitmap(q->node, nr_zones);
>+ if (!args->conv_zones_bitmap)
> return -ENOMEM;
>
> ret = disk->fops->report_zones(disk, 0, nr_zones,
>@@ -465,7 +465,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
> if (ret >= 0) {
> q->nr_zones = nr_zones;
> swap(q->seq_zones_wlock, args.seq_zones_wlock);
>- swap(q->seq_zones_bitmap, args.seq_zones_bitmap);
>+ swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
> ret = 0;
> } else {
> pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
>@@ -474,7 +474,7 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
> blk_mq_unfreeze_queue(q);
>
> kfree(args.seq_zones_wlock);
>- kfree(args.seq_zones_bitmap);
>+ kfree(args.conv_zones_bitmap);
> return ret;
> }
> EXPORT_SYMBOL_GPL(blk_revalidate_disk_zones);
>diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
>index c5852de402b6..503c4d4c5884 100644
>--- a/include/linux/blkdev.h
>+++ b/include/linux/blkdev.h
>@@ -503,9 +503,9 @@ struct request_queue {
> /*
> * Zoned block device information for request dispatch control.
> * nr_zones is the total number of zones of the device. This is always
>- * 0 for regular block devices. seq_zones_bitmap is a bitmap of nr_zones
>- * bits which indicates if a zone is conventional (bit clear) or
>- * sequential (bit set). seq_zones_wlock is a bitmap of nr_zones
>+ * 0 for regular block devices. conv_zones_bitmap is a bitmap of nr_zones
>+ * bits which indicates if a zone is conventional (bit set) or
>+ * sequential (bit clear). seq_zones_wlock is a bitmap of nr_zones
> * bits which indicates if a zone is write locked, that is, if a write
> * request targeting the zone was dispatched. All three fields are
> * initialized by the low level device driver (e.g. scsi/sd.c).
>@@ -518,7 +518,7 @@ struct request_queue {
> * blk_mq_unfreeze_queue().
> */
> unsigned int nr_zones;
>- unsigned long *seq_zones_bitmap;
>+ unsigned long *conv_zones_bitmap;
> unsigned long *seq_zones_wlock;
> #endif /* CONFIG_BLK_DEV_ZONED */
>
>@@ -723,9 +723,11 @@ static inline unsigned int blk_queue_zone_no(struct request_queue *q,
> static inline bool blk_queue_zone_is_seq(struct request_queue *q,
> sector_t sector)
> {
>- if (!blk_queue_is_zoned(q) || !q->seq_zones_bitmap)
>+ if (!blk_queue_is_zoned(q))
> return false;
>- return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap);
>+ if (!q->conv_zones_bitmap)
>+ return true;
>+ return !test_bit(blk_queue_zone_no(q, sector), q->conv_zones_bitmap);
> }
> #else /* CONFIG_BLK_DEV_ZONED */
> static inline unsigned int blk_queue_nr_zones(struct request_queue *q)
>--
>2.20.1
>
Looks good to me.
Reviewed-by: Javier González <javier@javigon.com>
next prev parent reply other threads:[~2019-12-03 14:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-03 9:39 avoid out of bounds zone bitmap access Christoph Hellwig
2019-12-03 9:39 ` [PATCH 1/8] null_blk: fix zone size paramter check Christoph Hellwig
2019-12-03 9:39 ` [PATCH 2/8] null_blk: cleanup null_gendisk_register Christoph Hellwig
2019-12-03 9:39 ` [PATCH 3/8] block: remove the empty line at the end of blk-zoned.c Christoph Hellwig
2019-12-03 9:39 ` [PATCH 4/8] block: simplify blkdev_nr_zones Christoph Hellwig
2019-12-03 9:39 ` [PATCH 5/8] block: replace seq_zones_bitmap with conv_zones_bitmap Christoph Hellwig
2019-12-03 14:02 ` Javier González [this message]
2019-12-03 9:39 ` [PATCH 6/8] block: allocate the zone bitmaps lazily Christoph Hellwig
2019-12-03 14:03 ` Javier González
2019-12-03 9:39 ` [PATCH 7/8] block: don't handle bio based drivers in blk_revalidate_disk_zones Christoph Hellwig
2019-12-03 14:04 ` Javier González
2019-12-03 9:39 ` [PATCH 8/8] block: set the zone size in blk_revalidate_disk_zones atomically Christoph Hellwig
2019-12-03 14:00 ` Javier González
2019-12-03 15:18 ` Christoph Hellwig
2019-12-03 15:34 ` Javier González
2019-12-03 15:42 ` Christoph Hellwig
2019-12-03 17:17 ` Javier González
2019-12-03 16:00 ` avoid out of bounds zone bitmap access Jens Axboe
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=20191203140239.x5a5ll2u5wgou6la@mpHalley.local \
--to=javier@javigon.com \
--cc=Damien.LeMoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=hans@owltronix.com \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
/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