From: snitzer@redhat.com (Mike Snitzer)
Subject: [PATCH 5/5] block: Inline blk_integrity in struct gendisk
Date: Mon, 21 Sep 2015 16:45:07 -0400 [thread overview]
Message-ID: <20150921204506.GA36289@redhat.com> (raw)
In-Reply-To: <20150916010720.GA21398@redhat.com>
On Tue, Sep 15 2015 at 9:07P -0400,
Mike Snitzer <snitzer@redhat.com> wrote:
> Long story short, DM changes that eliminate the checks/code for
> allocating the blk_integrity structure should be all that is needed for
> this patch.
>
> I'll work through this further. Hope to send an incremental patch that
> fixes things up in the next day or so.
Here is what I came up with. Leaves something to be desired given the
integrity profile is being established on first table load (as opposed
to during resume like the old DM and block integrity code did).. but we
can iterate on this as needed.
Feel free to fold it into your last patch and add my Signed-off-by.
From: Mike Snitzer <snitzer@redhat.com>
Date: Mon, 21 Sep 2015 14:58:44 -0400
Subject: [PATCH] dm table: fixup block integrity profile processing
Not very different from what Martin originally proposed but subtle
changes include:
. only register the integrity profile on first table load; subsequent
loads must have a matching integrity profile
- if profile is already registered, verify new table's profile matches
. resume only verifies that the DM device's integrity profile matches
all the underlying devices' profiles.
- if they don't match the DM device's integrity profile is unregistered
Signed-off-by: Mike Snitzer <snitzer at redhat.com>
---
drivers/md/dm-table.c | 77 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 63 insertions(+), 14 deletions(-)
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index e2f98fc..061152a 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1014,6 +1014,11 @@ static int dm_table_build_index(struct dm_table *t)
return r;
}
+static bool integrity_profile_exists(struct gendisk *disk)
+{
+ return !!blk_get_integrity(disk);
+}
+
/*
* Get a disk whose integrity profile reflects the table's profile.
* Returns NULL if integrity support was inconsistent or unavailable.
@@ -1026,10 +1031,10 @@ static struct gendisk * dm_table_get_integrity_disk(struct dm_table *t)
list_for_each_entry(dd, devices, list) {
template_disk = dd->dm_dev->bdev->bd_disk;
- if (!blk_get_integrity(template_disk))
+ if (!integrity_profile_exists(template_disk))
goto no_integrity;
- if (prev_disk &&
- blk_integrity_compare(prev_disk, template_disk) < 0)
+ else if (prev_disk &&
+ blk_integrity_compare(prev_disk, template_disk) < 0)
goto no_integrity;
prev_disk = template_disk;
}
@@ -1055,23 +1060,40 @@ no_integrity:
* profile validation: First pass during table load, final pass during
* resume.
*/
-static int dm_table_set_integrity(struct dm_table *t)
+static int dm_table_register_integrity(struct dm_table *t)
{
+ struct mapped_device *md = t->md;
struct gendisk *template_disk = NULL;
- bool existing_profile = blk_get_integrity(dm_disk(t->md));
template_disk = dm_table_get_integrity_disk(t);
- if (template_disk) {
- blk_integrity_register(dm_disk(t->md),
- blk_get_integrity(template_disk));
+ if (!template_disk)
+ return 0;
+
+ if (!integrity_profile_exists(dm_disk(md))) {
t->integrity_supported = 1;
- } else if (existing_profile) {
- blk_integrity_unregister(dm_disk(t->md));
- DMWARN("%s: device no longer has a valid integrity profile",
- dm_device_name(t->md));
+ /*
+ * Register integrity profile during table load; we can do
+ * this because the final profile must match during resume.
+ */
+ blk_integrity_register(dm_disk(md),
+ blk_get_integrity(template_disk));
+ return 0;
+ }
+
+ /*
+ * If DM device already has an initialized integrity
+ * profile the new profile should not conflict.
+ */
+ if (blk_integrity_compare(dm_disk(md), template_disk) < 0) {
+ DMWARN("%s: conflict with existing integrity profile: "
+ "%s profile mismatch",
+ dm_device_name(t->md),
+ template_disk->disk_name);
return 1;
}
+ /* Preserve existing integrity profile */
+ t->integrity_supported = 1;
return 0;
}
@@ -1095,7 +1117,7 @@ int dm_table_complete(struct dm_table *t)
return r;
}
- r = dm_table_set_integrity(t);
+ r = dm_table_register_integrity(t);
if (r) {
DMERR("could not register integrity profile.");
return r;
@@ -1260,6 +1282,33 @@ combine_limits:
return validate_hardware_logical_block_alignment(table, limits);
}
+/*
+ * Verify that all devices have an integrity profile that matches the
+ * DM device's registered integrity profile. If the profiles don't
+ * match then unregister the DM device's integrity profile.
+ */
+static void dm_table_verify_integrity(struct dm_table *t)
+{
+ struct gendisk *template_disk = NULL;
+
+ if (t->integrity_supported) {
+ /*
+ * Verify that the original integrity profile
+ * matches all the devices in this table.
+ */
+ template_disk = dm_table_get_integrity_disk(t);
+ if (template_disk &&
+ blk_integrity_compare(dm_disk(t->md), template_disk) >= 0)
+ return;
+ }
+
+ if (integrity_profile_exists(dm_disk(t->md))) {
+ DMWARN("%s: unable to establish an integrity profile",
+ dm_device_name(t->md));
+ blk_integrity_unregister(dm_disk(t->md));
+ }
+}
+
static int device_flush_capable(struct dm_target *ti, struct dm_dev *dev,
sector_t start, sector_t len, void *data)
{
@@ -1457,7 +1506,7 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
else
queue_flag_set_unlocked(QUEUE_FLAG_NO_SG_MERGE, q);
- dm_table_set_integrity(t);
+ dm_table_verify_integrity(t);
/*
* Determine whether or not this queue's I/O timings contribute
--
2.3.8 (Apple Git-58)
next prev parent reply other threads:[~2015-09-21 20:45 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-14 17:57 [PATCH] NVMe: Reread partitions on metadata formats Keith Busch
2015-07-14 18:49 ` Jens Axboe
2015-07-14 19:01 ` Paul Grabinar
2015-07-15 3:48 ` Dan Williams
2015-07-15 21:36 ` Jens Axboe
2015-07-15 22:28 ` Keith Busch
2015-07-16 9:19 ` Christoph Hellwig
2015-07-17 1:47 ` Martin K. Petersen
2015-07-17 9:30 ` Christoph Hellwig
2015-07-21 6:02 ` Data integrity tweaks Martin K. Petersen
2015-07-21 6:02 ` [PATCH 1/5] block: Move integrity kobject to struct gendisk Martin K. Petersen
2015-07-22 11:32 ` Sagi Grimberg
2015-07-21 6:02 ` [PATCH 2/5] block: Consolidate static integrity profile properties Martin K. Petersen
2015-07-22 11:33 ` Sagi Grimberg
2015-07-21 6:02 ` [PATCH 3/5] block: Reduce the size of struct blk_integrity Martin K. Petersen
2015-07-21 11:53 ` Christoph Hellwig
2015-07-24 15:14 ` Martin K. Petersen
2015-07-22 11:35 ` Sagi Grimberg
2015-07-21 6:02 ` [PATCH 4/5] block: Export integrity data interval size in sysfs Martin K. Petersen
2015-07-22 11:37 ` Sagi Grimberg
2015-07-24 15:26 ` Martin K. Petersen
2015-07-21 6:02 ` [PATCH 5/5] block: Inline blk_integrity in struct gendisk Martin K. Petersen
2015-07-21 12:01 ` Christoph Hellwig
2015-08-20 20:41 ` Simplify block integrity registration Martin K. Petersen
2015-08-20 20:41 ` [PATCH 1/5] block: Move integrity kobject to struct gendisk Martin K. Petersen
2015-09-16 17:26 ` Mike Snitzer
2015-08-20 20:41 ` [PATCH 2/5] block: Consolidate static integrity profile properties Martin K. Petersen
2015-08-20 20:41 ` [PATCH 3/5] block: Reduce the size of struct blk_integrity Martin K. Petersen
2015-08-20 20:41 ` [PATCH 4/5] block: Export integrity data interval size in sysfs Martin K. Petersen
2015-08-20 20:41 ` [PATCH 5/5] block: Inline blk_integrity in struct gendisk Martin K. Petersen
2015-08-21 23:47 ` Busch, Keith
2015-08-27 0:25 ` Martin K. Petersen
2015-08-27 0:25 ` [PATCH] " Martin K. Petersen
2015-08-27 8:28 ` Christoph Hellwig
2015-09-03 20:38 ` Keith Busch
2015-09-04 3:25 ` Martin K. Petersen
2015-10-12 21:05 ` Block integrity registration update Martin K. Petersen
2015-10-12 21:05 ` [PATCH 1/5] block: Move integrity kobject to struct gendisk Martin K. Petersen
2015-10-12 21:05 ` [PATCH 2/5] block: Consolidate static integrity profile properties Martin K. Petersen
2015-10-14 1:11 ` Dan Williams
2015-10-14 7:23 ` Christoph Hellwig
2015-10-14 19:42 ` Williams, Dan J
2015-10-14 19:47 ` hch
2015-10-14 20:00 ` Williams, Dan J
2015-10-14 22:42 ` Martin K. Petersen
2015-10-12 21:05 ` [PATCH 3/5] block: Reduce the size of struct blk_integrity Martin K. Petersen
2015-10-12 21:05 ` [PATCH 4/5] block: Export integrity data interval size in sysfs Martin K. Petersen
2015-10-12 21:05 ` [PATCH 5/5] block: Inline blk_integrity in struct gendisk Martin K. Petersen
2015-10-12 23:06 ` Mike Snitzer
2015-10-13 0:31 ` Block integrity registration update Williams, Dan J
2015-10-13 1:53 ` Williams, Dan J
2015-10-13 12:26 ` hch
2015-10-13 17:38 ` Dan Williams
2015-09-16 1:07 ` [PATCH 5/5] block: Inline blk_integrity in struct gendisk Mike Snitzer
2015-09-21 20:45 ` Mike Snitzer [this message]
2015-10-09 7:36 ` Christoph Hellwig
2015-10-12 1:17 ` Martin K. Petersen
2015-08-20 20:45 ` Simplify block integrity registration Mike Snitzer
2015-07-17 1:44 ` [PATCH] NVMe: Reread partitions on metadata formats Martin K. Petersen
2015-07-15 17:37 ` Paul Grabinar
-- strict thread matches above, loose matches on Subject: below --
2015-10-20 2:24 [PATCH v2 10/12] block: move blk_integrity to request_queue Martin K. Petersen
2015-10-20 2:45 ` Simplify block integrity registration v2 Martin K. Petersen
2015-10-20 2:45 ` [PATCH 5/5] block: Inline blk_integrity in struct gendisk Martin K. Petersen
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=20150921204506.GA36289@redhat.com \
--to=snitzer@redhat.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;
as well as URLs for NNTP newsgroup(s).