From patchwork Fri Mar 23 14:47:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Denis Semakin X-Patchwork-Id: 10307285 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4AE18600CC for ; Mon, 26 Mar 2018 07:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35D9A284DA for ; Mon, 26 Mar 2018 07:38:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A0A72823D; Mon, 26 Mar 2018 07:38:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B27E1205FD for ; Mon, 26 Mar 2018 07:38:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C92F381DF1; Mon, 26 Mar 2018 07:38:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 94AC85E9E0; Mon, 26 Mar 2018 07:38:00 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C1B6D181BA07; Mon, 26 Mar 2018 07:37:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2NEq0YA008451 for ; Fri, 23 Mar 2018 10:52:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1449B691F5; Fri, 23 Mar 2018 14:52:00 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22778691E4; Fri, 23 Mar 2018 14:51:18 +0000 (UTC) Received: from mail.omprussia.ru (mail.omprussia.ru [5.134.221.218]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24EE9BB9CF; Fri, 23 Mar 2018 14:47:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.omprussia.ru (Postfix) with ESMTP id 7E874828DA; Fri, 23 Mar 2018 17:47:50 +0300 (MSK) Received: from mail.omprussia.ru ([127.0.0.1]) by localhost (mail.omprussia.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id egVQE8UY3Anb; Fri, 23 Mar 2018 17:47:50 +0300 (MSK) Received: from localhost (localhost [127.0.0.1]) by mail.omprussia.ru (Postfix) with ESMTP id EF85E8294A; Fri, 23 Mar 2018 17:47:49 +0300 (MSK) X-Virus-Scanned: amavisd-new at mail.omprussia.ru Received: from mail.omprussia.ru ([127.0.0.1]) by localhost (mail.omprussia.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FVwgMhbr_jbN; Fri, 23 Mar 2018 17:47:49 +0300 (MSK) Received: from mail.omprussia.ru (mail.omprussia.ru [10.189.15.5]) by mail.omprussia.ru (Postfix) with ESMTP id DEDED828DA; Fri, 23 Mar 2018 17:47:49 +0300 (MSK) Date: Fri, 23 Mar 2018 17:47:49 +0300 (MSK) From: Denis Semakin To: snitzer Message-ID: <695931032.318989.1521816469739.JavaMail.zimbra@omprussia.ru> In-Reply-To: <20180322151045.GA27598@redhat.com> References: <1496940834.549721.1520933025411.JavaMail.zimbra@omprussia.ru> <20180322151045.GA27598@redhat.com> MIME-Version: 1.0 X-Originating-IP: [10.189.15.5] Thread-Topic: dm table: add support for secure erase forwarding [was: Re: Adaptation secure erase forwarding for 4.1x kernels] Thread-Index: /lRau2B/l5PpSEmF2w2aOC7oyNoYZw== X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Mar 2018 14:47:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 23 Mar 2018 14:47:55 +0000 (UTC) for IP:'5.134.221.218' DOMAIN:'mail.omprussia.ru' HELO:'mail.omprussia.ru' FROM:'d.semakin@omprussia.ru' RCPT:'' X-RedHat-Spam-Score: -0.011 (SPF_PASS, T_RP_MATCHES_RCVD) 5.134.221.218 mail.omprussia.ru 5.134.221.218 mail.omprussia.ru X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id w2NEq0YA008451 X-loop: dm-devel@redhat.com X-Mailman-Approved-At: Mon, 26 Mar 2018 03:37:09 -0400 Cc: dm-devel Subject: Re: [dm-devel] [PATCH] dm table: add support for secure erase forwarding [was: Re: Adaptation secure erase forwarding for 4.1x kernels] X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 26 Mar 2018 07:38:01 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP >I'd feel safer about having targets opt-in with setting (a new) >ti->num_secure_erase_bios. May be add a new field "bool secure_erase_supported:1" in dm_target structure instead? And set up it "true" in constructor for linear targets. ----- Исходное сообщение ----- От: "snitzer" Кому: "Denis Semakin" Копия: "dm-devel" Отправленные: Четверг, 22 Март 2018 г 18:10:46 Тема: [PATCH] dm table: add support for secure erase forwarding [was: Re: Adaptation secure erase forwarding for 4.1x kernels] On Tue, Mar 13 2018 at 5:23am -0400, Denis Semakin wrote: > 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? There were various issues with your patch that I cleaned up, please see the following. But I'm left skeptical that this is enough. Don't targets need to explicitly handle these REQ_OP_SECURE_ERASE requests? Similar to how REQ_OP_DISCARD is handled? I'd feel safer about having targets opt-in with setting (a new) ti->num_secure_erase_bios. Which DM target(s) have you been wanting to pass REQ_OP_SECURE_ERASE bios? Mike From: Denis Semakin Date: Tue, 13 Mar 2018 13:23:45 +0400 Subject: [PATCH] dm table: add support for secure erase forwarding Set QUEUE_FLAG_SECERASE in DM device's queue_flags if a DM table's data devices support secure erase. Signed-off-by: Denis Semakin Signed-off-by: Mike Snitzer --- drivers/md/dm-table.c | 28 ++++++++++++++++++++++++++++ 1 files changed, 28 insertions(+), 0 deletions(-) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 7eb3e2a..d857369 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -1846,6 +1846,31 @@ static bool dm_table_supports_discards(struct dm_table *t) return true; } +static int device_not_secure_erase_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_table_supports_secure_erase(struct dm_table *t) +{ + struct dm_target *ti; + unsigned int i; + + for (i = 0; i < dm_table_get_num_targets(t); i++) { + ti = dm_table_get_target(t, i); + + if (!ti->type->iterate_devices || + ti->type->iterate_devices(ti, device_not_secure_erase_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 +1892,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_table_supports_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)))