From: Denis Semakin <d.semakin@omprussia.ru>
To: dm-devel@redhat.com
Cc: snitzer@redhat.com
Subject: [PATCH] Adaptation secure erase forwarding for 4.1x kernels
Date: Tue, 13 Mar 2018 13:23:45 +0400 (MSK) [thread overview]
Message-ID: <1496940834.549721.1520933025411.JavaMail.zimbra@omprussia.ru> (raw)
Hello.
Here is fixed patch for modern 4.1x kernels.
The idea is to forward secure erase request within device mapper layer to
block device driver which can support secure erase.
Could you please review?
Thanks.
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
index 7eb3e2a..d955a57 100644
--- a/drivers/md/dm-table.c
+++ b/drivers/md/dm-table.c
@@ -1846,6 +1846,33 @@ static bool dm_table_supports_discards(struct dm_table *t)
return true;
}
+static int device_not_secerase_capable(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);
+
+ return q && !blk_queue_secure_erase(q);
+}
+
+static bool dm_targets_support_secure_erase(struct dm_table *t)
+{
+ unsigned int i = 0;
+ struct dm_target *ti;
+
+ while (i < dm_table_get_num_targets(t)) {
+ ti = dm_table_get_target(t, i++);
+
+ if (!ti->type->iterate_devices ||
+ ti->type->iterate_devices(ti, device_not_secerase_capable,
+ NULL))
+ return false;
+ }
+
+ return true;
+
+}
+
void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
struct queue_limits *limits)
{
@@ -1867,6 +1894,9 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q,
} else
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
+ if (dm_targets_support_secure_erase(t))
+ queue_flag_set_unlocked(QUEUE_FLAG_SECERASE, q);
+
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_WC))) {
wc = true;
if (dm_table_supports_flush(t, (1UL << QUEUE_FLAG_FUA)))
--
Best regards,
Denis Semakin
next reply other threads:[~2018-03-13 9:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 9:23 Denis Semakin [this message]
2018-03-22 15:10 ` [PATCH] dm table: add support for secure erase forwarding [was: Re: Adaptation secure erase forwarding for 4.1x kernels] Mike Snitzer
2018-03-23 8:14 ` Denis Semakin
2018-03-23 15:36 ` Mike Snitzer
2018-03-23 13:37 ` [PATCH] " Denis Semakin
2018-03-23 14:47 ` Denis Semakin
2018-03-23 15:38 ` Mike Snitzer
2018-03-26 7:45 ` Denis Semakin
2018-03-26 9:58 ` Denis Semakin
2018-03-26 14:12 ` Denis Semakin
2018-03-26 16:11 ` Mike Snitzer
2018-03-27 8:54 ` Denis Semakin
2018-03-27 9:03 ` Denis Semakin
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=1496940834.549721.1520933025411.JavaMail.zimbra@omprussia.ru \
--to=d.semakin@omprussia.ru \
--cc=dm-devel@redhat.com \
--cc=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