Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3087251imm; Fri, 19 Oct 2018 05:02:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV635OoounppdmqMWukSFH07MbCCd818/KUhk81F8dBRMPHg7HV8OmjfwXn857Dzks+aVz4PQ X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr33724441pfg.10.1539950576214; Fri, 19 Oct 2018 05:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539950576; cv=none; d=google.com; s=arc-20160816; b=yxOctKccedHpTTOOJSZgYFjCv4zDqmXLPGB7ABxOlYm6NpiNJn4ndUF/qla8772J5+ TF/ViSEHbXgru67NweDiNUaP3oV5NkkEIr45SNqrGNI/18x6O8Rj9PDXaFmKOlqvUtsq /qWYGDmUNMIikLXLZC+rEjSyo0BJ3pZpzZgUTeJJSwVVg0J1nrUz3coC1HTE8wfIKrE6 ECsxcIRQZxGRWevn8AnJsogihESVxAwRxR1k2O87L0DAeDM732D9dxn57LYYXNBEpBvw 9mE4drRcI8w4FhkDHvgbRv62VNMHHlgJS0nWtac9YA0/ROqIufkW9McHYlXXz+ypxCYf xMiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=yspuIxleTrbIk74rb12xy3Vnwj/UcKWd+3/gMFYQoJU=; b=Tvi9AmuOCM8IjYrbVGPs2KJZoqpc0JATl0xWbyEoJPPQAKKwf2zM+Ab1+sfxKkpz1h xOAFvbzZc57pbQlLbpgPIg+yAkDLDrSbAOZJKCu6z7f6h+I0ffykdMqqSnPmiXBatPtL UTcxCGUToUsa2zRjrwjPaqlLOj/hQJSAeVt+kP+uvW2UNue7Yo4I9SjdmeqJHadGWTzP q/03jvWE3Vjbyvg73CKxGHXv2x4DSJyGg2AnPJUm3+xrnkwHFn8c3buceS9nBlqcVNIX kutIFgDouJzfhGbrV0aU3jmK1hzNVB7TtpPNN7iAQJw4RQPchUHhFXKdBxXNwpYdB5Np 7Waw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f25-v6si23876799pgb.170.2018.10.19.05.02.40; Fri, 19 Oct 2018 05:02:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727565AbeJSUIA (ORCPT + 99 others); Fri, 19 Oct 2018 16:08:00 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:50096 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbeJSUH7 (ORCPT ); Fri, 19 Oct 2018 16:07:59 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id 20FB172CC59; Fri, 19 Oct 2018 15:02:11 +0300 (MSK) Received: from sole.flsd.net (sole.flsd.net [185.75.180.6]) by imap.altlinux.org (Postfix) with ESMTPSA id 05DDD4A4A16; Fri, 19 Oct 2018 15:02:11 +0300 (MSK) Date: Fri, 19 Oct 2018 15:02:10 +0300 From: Vitaly Chikunov To: Mike Snitzer Cc: Alasdair Kergon , dm-devel@redhat.com, Jonathan Corbet , Shaohua Li , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org Subject: Re: dm: add secdel target Message-ID: <20181019120209.osicx2v3vebvsxqr@sole.flsd.net> References: <20181014112439.8119-1-vt@altlinux.org> <20181018200124.GA6996@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20181018200124.GA6996@redhat.com> User-Agent: NeoMutt/20171215-106-ac61c7 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 18, 2018 at 04:01:25PM -0400, Mike Snitzer wrote: > On Sun, Oct 14 2018 at 7:24am -0400, > Vitaly Chikunov wrote: > > > Report to the upper level ability to discard, and translate arriving > > discards to the writes of random or zero data to the underlying level. > > > > Signed-off-by: Vitaly Chikunov > > --- > > This target is the same as the linear target except that is reports ability to > > discard to the upper level and translates arriving discards into sector > > overwrites with random (or zero) data. > > There is a fair amount of code duplication between dm-linear.c and this > new target. > > Something needs to give, ideally you'd factor out methods that are > shared by both targets, but those methods must _not_ introduce overhead > to dm-linear. I see three possible solutions: - integrate 'secdel' into dm-linear; - export functions like linear_dax_copy_to_iter and fill them into secdel's `struct target_type`; - call methods of linear's `struct target_type` from secdel's one. > Could be that dm-linear methods just get called by the wrapper > dm-sec-erase target (more on the "dm-sec-erase" name below). > > diff --git a/drivers/md/dm-secdel.c b/drivers/md/dm-secdel.c > > new file mode 100644 > > index 000000000000..9aeaf3f243c0 > > --- /dev/null > > +++ b/drivers/md/dm-secdel.c > ... > > + if (mode == SECDEL_MODE_RAND) { > > + page = alloc_page(gfp_mask); > > + if (!page) { > > + DMERR("%s %lu[%lu]: no memory to allocate page for random data", > > + __func__, sector, nr_sects); > > + /* will fallback to zero filling */ > > In general, performing memory allocations to service IO is something all > DM core and DM targets must work to avoid. This smells bad. > > ... Yes, but we need to create and write random data, so I don't see other solution. In zero overwriting mode page is not allocated. And it's fall back to zero overwriting if page allocation fails for random data. > Mike I will address these and other your concerns in v2. Thanks!