All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: Christoph Hellwig <hch@infradead.org>,
	linux-block <linux-block@vger.kernel.org>,
	Damien Le Moal <Damien.LeMoal@wdc.com>,
	Keith Busch <kbusch@kernel.org>,
	"linux-scsi @ vger . kernel . org" <linux-scsi@vger.kernel.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	"linux-fsdevel @ vger . kernel . org"
	<linux-fsdevel@vger.kernel.org>,
	Damien Le Moal <damien.lemoal@wdc.com>,
	Johannes Thumshirn <johannes.thumshirn@wdc.com>
Subject: [PATCH v6 06/11] block: Modify revalidate zones
Date: Wed, 15 Apr 2020 18:05:08 +0900	[thread overview]
Message-ID: <20200415090513.5133-7-johannes.thumshirn@wdc.com> (raw)
In-Reply-To: <20200415090513.5133-1-johannes.thumshirn@wdc.com>

From: Damien Le Moal <damien.lemoal@wdc.com>

Modify the interface of blk_revalidate_disk_zones() to add an optional
driver callback function that a driver can use to extend processing
done during zone revalidation. The callback, if defined, is executed
with the device request queue frozen, after all zones have been
inspected.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 block/blk-zoned.c              | 8 +++++++-
 drivers/block/null_blk_zoned.c | 2 +-
 include/linux/blkdev.h         | 3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index c822cfa7a102..2912e964d7b2 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -471,14 +471,18 @@ static int blk_revalidate_zone_cb(struct blk_zone *zone, unsigned int idx,
 /**
  * blk_revalidate_disk_zones - (re)allocate and initialize zone bitmaps
  * @disk:	Target disk
+ * @driver_cb:	LLD callback
  *
  * Helper function for low-level device drivers to (re) allocate and initialize
  * a disk request queue zone bitmaps. This functions should normally be called
  * within the disk ->revalidate method for blk-mq based drivers.  For BIO based
  * drivers only q->nr_zones needs to be updated so that the sysfs exposed value
  * is correct.
+ * If the @driver_cb callback function is not NULL, the callback is executed
+ * with the device request queue frozen after all zones have been checked.
  */
-int blk_revalidate_disk_zones(struct gendisk *disk)
+int blk_revalidate_disk_zones(struct gendisk *disk,
+			      void (*driver_cb)(struct gendisk *disk))
 {
 	struct request_queue *q = disk->queue;
 	struct blk_revalidate_zone_args args = {
@@ -512,6 +516,8 @@ int blk_revalidate_disk_zones(struct gendisk *disk)
 		q->nr_zones = args.nr_zones;
 		swap(q->seq_zones_wlock, args.seq_zones_wlock);
 		swap(q->conv_zones_bitmap, args.conv_zones_bitmap);
+		if (driver_cb)
+			driver_cb(disk);
 		ret = 0;
 	} else {
 		pr_warn("%s: failed to revalidate zones\n", disk->disk_name);
diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index 9e4bcdad1a80..46641df2e58e 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -73,7 +73,7 @@ int null_register_zoned_dev(struct nullb *nullb)
 	struct request_queue *q = nullb->q;
 
 	if (queue_is_mq(q))
-		return blk_revalidate_disk_zones(nullb->disk);
+		return blk_revalidate_disk_zones(nullb->disk, NULL);
 
 	blk_queue_chunk_sectors(q, nullb->dev->zone_size_sects);
 	q->nr_zones = blkdev_nr_zones(nullb->disk);
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 0797d1e81802..62fe9f962478 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -362,7 +362,8 @@ unsigned int blkdev_nr_zones(struct gendisk *disk);
 extern int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
 			    sector_t sectors, sector_t nr_sectors,
 			    gfp_t gfp_mask);
-extern int blk_revalidate_disk_zones(struct gendisk *disk);
+int blk_revalidate_disk_zones(struct gendisk *disk,
+			      void (*driver_cb)(struct gendisk *disk));
 
 extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
 				     unsigned int cmd, unsigned long arg);
-- 
2.24.1


  parent reply	other threads:[~2020-04-15  9:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-15  9:05 [PATCH v6 00/11] Introduce Zone Append for writing to zoned block devices Johannes Thumshirn
2020-04-15  9:05 ` [PATCH v6 01/11] scsi: free sgtables in case command setup fails Johannes Thumshirn
2020-04-16 12:40   ` Christoph Hellwig
2020-04-16 16:27   ` Daniel Wagner
2020-04-15  9:05 ` [PATCH v6 02/11] block: provide fallbacks for blk_queue_zone_is_seq and blk_queue_zone_no Johannes Thumshirn
2020-04-16 17:22   ` Daniel Wagner
2020-04-15  9:05 ` [PATCH v6 03/11] block: rename __bio_add_pc_page to bio_add_hw_page Johannes Thumshirn
2020-04-16 18:17   ` Daniel Wagner
2020-04-15  9:05 ` [PATCH v6 04/11] block: Introduce REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-04-16 12:47   ` Christoph Hellwig
2020-04-17  7:42   ` Daniel Wagner
2020-04-17  8:42     ` Johannes Thumshirn
2020-04-17 12:07       ` Daniel Wagner
2020-04-15  9:05 ` [PATCH v6 05/11] block: introduce blk_req_zone_write_trylock Johannes Thumshirn
2020-04-15  9:05 ` Johannes Thumshirn [this message]
2020-04-16 12:41   ` [PATCH v6 06/11] block: Modify revalidate zones Christoph Hellwig
2020-04-15  9:05 ` [PATCH v6 07/11] scsi: sd_zbc: factor out sanity checks for zoned commands Johannes Thumshirn
2020-04-15  9:05 ` [PATCH v6 08/11] scsi: sd_zbc: emulate ZONE_APPEND commands Johannes Thumshirn
2020-04-16 12:43   ` Christoph Hellwig
2020-04-15  9:05 ` [PATCH v6 09/11] null_blk: Support REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-04-15  9:05 ` [PATCH v6 10/11] block: export bio_release_pages and bio_iov_iter_get_pages Johannes Thumshirn
2020-04-15  9:05 ` [PATCH v6 11/11] zonefs: use REQ_OP_ZONE_APPEND for sync DIO Johannes Thumshirn

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=20200415090513.5133-7-johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=hch@infradead.org \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.