All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@redhat.com>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: Bart Van Assche <Bart.VanAssche@sandisk.com>,
	"dm-devel@redhat.com" <dm-devel@redhat.com>,
	Christoph Hellwig <hch@lst.de>, Alasdair Kergon <agk@redhat.com>
Subject: Re: [PATCH v3 00/10] dm: zoned block device support
Date: Fri, 26 May 2017 10:27:41 -0400	[thread overview]
Message-ID: <20170526142740.GA34211@redhat.com> (raw)
In-Reply-To: <7e0a0545-ee54-e367-5ea4-8b30e03cc10d@wdc.com>

On Fri, May 26 2017 at  5:10am -0400,
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> Mike,
> 
> On 5/26/17 11:12, Mike Snitzer wrote:
> > I'd like to get your thoughts on replacing the first 3 patches with
> > something like the following patch (_not_ compile tested).
> > 
> > Basically I'm not interested in training DM for hypothetical zoned block
> > device configurations.  I only want the bare minimum that is needed to
> > support the dm-zoned target at this point.  The fact that dm-zoned is
> > "drive managed" makes for a much more narrow validation (AFAICT anyway).
> 
> Indeed, it does. And in fact, no patches to the current dm code is
> necessary for dm-zoned to compile and run. So the bare minimum for
> dm-zoned is itself. This comes from the fact that dm-zoned will not
> accept a target that is not an entire zoned block device, and only a
> single target is allowed per dm-zoned instance. And since the queue
> limit defaults currently to the NONE zone model, everything nicely fit
> with the characteristics of the disk that dm-zoned exposes.
> 
> dm-zoned was coded this way for simplicity. Otherwise, the scattering of
> conventional zones across different targets would have complicated
> things quite a bit with metadata and would also potentially have
> generated nasty performance characteristics.
> 
> In the series, patches 1-9 are solely for supporting zoned block devices
> in a clean manner, and in particular dm-flakey, for testing file systems
> with native zoned block device support, and dm-linear, because it is
> easy and allows separating conventional and sequential zones into
> different drives, with the conventional zones block device becoming a
> normal disk (we have quite a few customers wanting to use SMR drives in
> this manner).
> 
> > I dropped the zone_sectors validation -- we can backfill it if you feel
> > it important but I wanted to float this simplified patch as is:
> 
> I think it is. The constraints imposed on zoned block devices in Linux
> that are not mandated by the standards are that all zones of the device
> must be the same size and the size must be a power of 2 number of LBAs.
> Without validating that all devices of a target have an equal zone size,
> a device created with dm-linear for instance would end up exposing
> different zone sizes on the same block device. That would break the
> block layer handling of zones through chunk_sectors.
> 
> That said, the patch below looks very good, much cleaner than what I had
> done. Let me test it and I will report back.

OK, please apply this incremental patch that adds in zone_sectors
validation, thanks:

diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 0e4407e..53c794a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1402,6 +1402,41 @@ static bool dm_table_supports_zoned_model(struct dm_table *t,
 	return true;
 }
 
+static int device_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev,
+				       sector_t start, sector_t len, void *data)
+{
+	struct request_queue *q = bdev_get_queue(dev->bdev);
+	unsigned int zone_sectors = *data;
+
+	return q && blk_queue_zone_sectors(q) == zone_sectors;
+}
+
+static int validate_hardware_zoned_model(struct dm_table *table,
+					 enum blk_zoned_model zoned_model,
+					 unsigned int zone_sectors)
+{
+	if (!dm_table_supports_zoned_model(table, zoned_model)) {
+		DMERR("%s: zoned model is inconsistent across all devices",
+		      dm_device_name(table->md));
+		return -EINVAL;
+	}
+
+	if (zoned_model != BLK_ZONED_NONE) {
+		/* Check zone size validity and compatibility */
+		if (!zone_sectors || !is_power_of_2(zone_sectors))
+			return -EINVAL;
+
+		if (!ti->type->iterate_devices ||
+		    !ti->type->iterate_devices(ti, device_matches_zone_sectors, &zone_sectors)) {
+			DMERR("%s: zone sectors is inconsistent across all devices",
+			      dm_device_name(table->md));
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 /*
  * Establish the new table's queue_limits and validate them.
  */
@@ -1412,6 +1447,7 @@ int dm_calculate_queue_limits(struct dm_table *table,
 	struct queue_limits ti_limits;
 	unsigned i;
 	enum blk_zoned_model zoned_model = BLK_ZONED_NONE;
+	unsigned int zone_sectors;
 
 	blk_set_stacking_limits(limits);
 
@@ -1432,9 +1468,10 @@ int dm_calculate_queue_limits(struct dm_table *table,
 		if (zoned_model == BLK_ZONED_NONE && ti_limits.zoned != BLK_ZONED_NONE) {
 			/*
 			 * After stacking all limits, validate all devices
-			 * in table support this zoned model.
+			 * in table support this zoned model and zone sectors.
 			 */
 			zoned_model = ti_limits.zoned;
+			zone_sectors = ti_limits.chunk_sectors;
 		}
 
 		/* Set I/O hints portion of queue limits */
@@ -1464,17 +1501,18 @@ int dm_calculate_queue_limits(struct dm_table *table,
 	}
 
 	/*
-	 * Verify that the zoned model, as determined before any .io_hints
-	 * override, is the same across all devices in the table.
+	 * Verify that the zoned model and zone sectors, as determined before
+	 * any .io_hints override, are the same across all devices in the table.
 	 * - but if limits->zoned is not BLK_ZONED_NONE validate match for it
+	 * - simillarly, check all devices conform to limits->chunk_sectors if
+	 *   .io_hints altered them
 	 */
 	if (limits->zoned != BLK_ZONED_NONE)
 		zoned_model = limits->zoned;
-	if (!dm_table_supports_zoned_model(table, zoned_model)) {
-		DMERR("%s: zoned model is inconsistent across all devices"
-		      dm_device_name(table->md));
+	if (limits->chunk_sectors != zone_sectors)
+		zone_sectors = limits->chunk_sectors;
+	if (validate_hardware_zoned_model(table, zoned_model, zone_sectors))
 		return -EINVAL;
-	}
 
 	return validate_hardware_logical_block_alignment(table, limits);
 }

  reply	other threads:[~2017-05-26 14:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08 23:40 [PATCH v3 00/10] dm: zoned block device support Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 01/10] dm-table: Introduce DM_TARGET_ZONED_HM feature Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 02/10] dm-table: Check device area zone alignment Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 03/10] dm-table: Check block devices zone model compatibility Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 04/10] dm: Fix REQ_OP_ZONE_RESET bio handling Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 05/10] dm: Fix REQ_OP_ZONE_REPORT " Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 06/10] dm: Introduce dm_remap_zone_report() Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 07/10] dm-flakey: Add support for zoned block devices Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 08/10] dm-linear: " Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 09/10] dm-kcopyd: Add sequential write feature Bart Van Assche
2017-05-08 23:40 ` [PATCH v3 10/10] dm-zoned: Drive-managed zoned block device target Bart Van Assche
2017-05-09 14:50 ` [PATCH v3 00/10] dm: zoned block device support Mike Snitzer
2017-05-09 15:09   ` Bart Van Assche
2017-05-16 20:03 ` Mike Snitzer
2017-05-17 18:54   ` Mike Snitzer
2017-05-18  1:55     ` Damien Le Moal
2017-05-26  2:12       ` Mike Snitzer
2017-05-26  9:10         ` Damien Le Moal
2017-05-26 14:27           ` Mike Snitzer [this message]
2017-05-26 16:19             ` Mike Snitzer
2017-05-18 15:47     ` 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=20170526142740.GA34211@redhat.com \
    --to=snitzer@redhat.com \
    --cc=Bart.VanAssche@sandisk.com \
    --cc=agk@redhat.com \
    --cc=damien.lemoal@wdc.com \
    --cc=dm-devel@redhat.com \
    --cc=hch@lst.de \
    /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.