From: Christoph Hellwig <hch@lst.de>
To: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@lst.de>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Johannes Thumshirn <johannes.thumshirn@wdc.com>,
Matthew Wilcox <willy@infradead.org>
Subject: Re: [PATCH] block: Fix partition check for host-aware zoned block devices
Date: Sat, 16 Oct 2021 06:34:50 +0200 [thread overview]
Message-ID: <20211016043450.GA27231@lst.de> (raw)
In-Reply-To: <20211015020740.506425-1-shinichiro.kawasaki@wdc.com>
On Fri, Oct 15, 2021 at 11:07:40AM +0900, Shin'ichiro Kawasaki wrote:
> To fix the issues, call the helper function disk_has_partitions() in
> place of disk->part_tbl empty check. Since the function was removed with
> the commit a33df75c6328, reimplement it to walk through entries in the
> xarray disk->part_tbl.
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
Matthew,
we talked about possiblig adding a xa_nr_entries helper a while ago.
This would be a good place for it, as we could just check
xa_nr_entries() > 1 for example.
>
> Fixes: a33df75c6328 ("block: use an xarray for disk->part_tbl")
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Cc: stable@vger.kernel.org # v5.14+
> ---
> block/blk-settings.c | 20 +++++++++++++++++++-
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-settings.c b/block/blk-settings.c
> index a7c857ad7d10..b880c70e22e4 100644
> --- a/block/blk-settings.c
> +++ b/block/blk-settings.c
> @@ -842,6 +842,24 @@ bool blk_queue_can_use_dma_map_merging(struct request_queue *q,
> }
> EXPORT_SYMBOL_GPL(blk_queue_can_use_dma_map_merging);
>
> +static bool disk_has_partitions(struct gendisk *disk)
> +{
> + unsigned long idx;
> + struct block_device *part;
> + bool ret = false;
> +
> + rcu_read_lock();
> + xa_for_each(&disk->part_tbl, idx, part) {
> + if (bdev_is_partition(part)) {
> + ret = true;
> + break;
> + }
> + }
> + rcu_read_unlock();
> +
> + return ret;
> +}
> +
> /**
> * blk_queue_set_zoned - configure a disk queue zoned model.
> * @disk: the gendisk of the queue to configure
> @@ -876,7 +894,7 @@ void blk_queue_set_zoned(struct gendisk *disk, enum blk_zoned_model model)
> * we do nothing special as far as the block layer is concerned.
> */
> if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED) ||
> - !xa_empty(&disk->part_tbl))
> + disk_has_partitions(disk))
> model = BLK_ZONED_NONE;
> break;
> case BLK_ZONED_NONE:
> --
> 2.31.1
---end quoted text---
next prev parent reply other threads:[~2021-10-16 4:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 2:07 [PATCH] block: Fix partition check for host-aware zoned block devices Shin'ichiro Kawasaki
2021-10-15 7:32 ` Johannes Thumshirn
2021-10-16 4:34 ` Christoph Hellwig [this message]
2021-10-16 14:26 ` Matthew Wilcox
2021-10-18 8:22 ` Christoph Hellwig
2021-10-19 9:52 ` Shinichiro Kawasaki
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=20211016043450.GA27231@lst.de \
--to=hch@lst.de \
--cc=Damien.LeMoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=johannes.thumshirn@wdc.com \
--cc=linux-block@vger.kernel.org \
--cc=shinichiro.kawasaki@wdc.com \
--cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).