Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1637840rda; Mon, 23 Oct 2023 20:53:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHFCX5qwRCetSDq1PtaewTD55+FNyyExbUkRNhQ+GmrB7rhJjZ8+ct0iVC5u539+LAQF5oA X-Received: by 2002:a05:6870:82a8:b0:1e9:dd4b:d0aa with SMTP id q40-20020a05687082a800b001e9dd4bd0aamr11833822oae.48.1698119619604; Mon, 23 Oct 2023 20:53:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698119619; cv=none; d=google.com; s=arc-20160816; b=VLN87qcJwBZTfghr1BZV4lSxX4GJf1IZiABIkw4t6r4VlOpwlWhizGQm0tkS3JjVpx XYnMmibU6jRMUAuG+hLcxvN5LMV+P5zU4s0tZWDPkRGJqLNIL/591JQJz3L2Ecm7jsmj S55P2TPFHdRdZnTQbAs8ZiW6PZ9xAGi7QcxHKKsEjVoSAQOaywM+SHjjz7+BKywVN8Yz q1+sR6fRqXZRJ0liwQNpaoS7BGMTGpq/BaHpvboKormh9iTOXyZIhDcDV2k0fsa6axRj 4Gd1uL/6KTncfqGDfzGktlK0Z/v63+BgDy5qzi/QCI61+PmpQAW9Kmf6Jutxr7PwWTlc s+yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:subject:cc:to:from :message-id:date:dkim-signature; bh=qf06v0uPyEibN6HVL4g78GrmaDMN+Y6zqErrL4AHRpg=; fh=wT7ne114MvKPMftSKn5e2Yopb6Fqz4/qWpN6WXdRdRg=; b=B/5yOYj05J27b5yJd1Ju498tP2M8NtUtmXNNcgXCfQ0N0df0LATBEEgE+c4INuXWdW Uffj8tL0rDWKlVSa/EFZ+QP/jTEJn7Ho28Rl76BlFhSH9KQwcdZaVSFDS2Rdus0EA2eC hIghscFB6N7vvGylKrkSu8X014MVmF+J5gFcCz04gb3jFeTeo+ZRHigYKFw6WBdhWBQd esZ5jJxeh/Y8K4KHX4IjgbQSY1UXzM2FXp+/OY5ZykMmLDlBpfOWm4iUrxMWowHO5yY7 0A3az0X8wY41E/rXrYM1Z8gTdRIRhS5GjOStS4jaMou8MB/Hpu3FeQWpWNytFfennS2K l4pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=LPSttgk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b5-20020a056a000cc500b00690a7aefa50si7680944pfv.325.2023.10.23.20.53.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:53:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=LPSttgk7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 77E0F806503D; Mon, 23 Oct 2023 20:53:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232543AbjJXDxc (ORCPT + 99 others); Mon, 23 Oct 2023 23:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232304AbjJXDwr (ORCPT ); Mon, 23 Oct 2023 23:52:47 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74B18D79 for ; Mon, 23 Oct 2023 20:52:32 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-66d11fec9a5so22123716d6.1 for ; Mon, 23 Oct 2023 20:52:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1698119551; x=1698724351; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:message-id:date:from:to :cc:subject:date:message-id:reply-to; bh=qf06v0uPyEibN6HVL4g78GrmaDMN+Y6zqErrL4AHRpg=; b=LPSttgk7Qv+YzGWvLuwItsNg1cdw80wadMUUgFQnJQh1lLcRxguvT8dpaBb9zkDHeb S1u+ySEcWIXHFfsbzopRwYX83zdwR054lNJplS59qgJGOKnhfouIBAa9k7Tch4IDIqgW 6DTNjUsOYIJq4sVigcipZdCLuVTv+/hNo3E69ObyRNXPW/eOXJT5uHRgO+WWfwsp73cY XH73yHsmO5ZuyFq+HzTv9SLOhpf+9irJ1aKzUCPoENDEQrTf38jFCJjcGOUNRqui160E 5ODb46TPq3MgBIag8VMrFSW5I5Ofz9Alj7yoo2yyujJ8uKs6HZshqb83wQjtlzmAMPBH VQNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698119551; x=1698724351; h=in-reply-to:references:subject:cc:to:from:message-id:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qf06v0uPyEibN6HVL4g78GrmaDMN+Y6zqErrL4AHRpg=; b=K9AfrKoUI84HQPHVaw2aHm3uNcJ6+6vvpO/x1fY0Kd8lBqVH5GYsa35hQyh0tuiPM/ E+GrZUwXzOHKl1EJHZ6QZuR943xvoDpsvMC1fNfTOrZDELPIbv6n50BOczLOaK6R2/7A iJSOPbOnqld1eRtZPy7EP01okeDQ644ke+k8EtT/n8JO12quQ6rUbDSTN98Xrvkqqidt ZgvqMieAUr5Oo+AEopS7ki+oHLnNHidE2OK3YQsCne5HfGAGeHFcEJrhj3R8zTPcjJx7 OrkIAbNzSNV1wCJhddtWhn+q+kTlXZ7dVl66qzsyS7Z4PVvyq+/RRbD4vUPRsEqZ/CUD BFrw== X-Gm-Message-State: AOJu0Yx66ooiMyJifsqxQbgpk4rLbiVfvSkaI75gh2TI1tQ0QUmIb2Gu zaov3AKfXsmkhcbRFuHcL2SR X-Received: by 2002:a0c:aa11:0:b0:66d:63ff:80ab with SMTP id d17-20020a0caa11000000b0066d63ff80abmr7949580qvb.7.1698119551260; Mon, 23 Oct 2023 20:52:31 -0700 (PDT) Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id lg8-20020a056214548800b0066d05ed3778sm3363056qvb.56.2023.10.23.20.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 20:52:30 -0700 (PDT) Date: Mon, 23 Oct 2023 23:52:30 -0400 Message-ID: <2121d9724f32ea5926574f9aba806b69.paul@paul-moore.com> From: Paul Moore To: Fan Wu , corbet@lwn.net, zohar@linux.ibm.com, jmorris@namei.org, serge@hallyn.com, tytso@mit.edu, ebiggers@kernel.org, axboe@kernel.dk, agk@redhat.com, snitzer@kernel.org, eparis@redhat.com Cc: linux-doc@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fscrypt@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, audit@vger.kernel.org, roberto.sassu@huawei.com, linux-kernel@vger.kernel.org, Fan Wu Subject: Re: [PATCH RFC v11 12/19] dm: add finalize hook to target_type References: <1696457386-3010-13-git-send-email-wufan@linux.microsoft.com> In-Reply-To: <1696457386-3010-13-git-send-email-wufan@linux.microsoft.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 23 Oct 2023 20:53:38 -0700 (PDT) On Oct 4, 2023 Fan Wu wrote: > > This patch adds a target finalize hook. > > The hook is triggered just before activating an inactive table of a > mapped device. If it returns an error the __bind get cancelled. > > The dm-verity target will use this hook to attach the dm-verity's > roothash metadata to the block_device struct of the mapped device. > > Signed-off-by: Fan Wu > --- > v1-v10: > + Not present > --- > drivers/md/dm.c | 12 ++++++++++++ > include/linux/device-mapper.h | 7 +++++++ > 2 files changed, 19 insertions(+) We need an ACK and confirmation from Alasdair and/or Mike that this is the right approach. > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 64a1f306c96c..3be9cc35306d 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -2239,6 +2239,18 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, > goto out; > } > > + for (unsigned int i = 0; i < t->num_targets; i++) { > + struct dm_target *ti = dm_table_get_target(t, i); > + > + if (ti->type->finalize) { > + ret = ti->type->finalize(ti); > + if (ret) { > + old_map = ERR_PTR(ret); > + goto out; > + } > + } > + } > + > old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); > rcu_assign_pointer(md->map, (void *)t); > md->immutable_target_type = dm_table_get_immutable_target_type(t); > diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h > index 69d0435c7ebb..4040e84a8ec7 100644 > --- a/include/linux/device-mapper.h > +++ b/include/linux/device-mapper.h > @@ -160,6 +160,12 @@ typedef int (*dm_dax_zero_page_range_fn)(struct dm_target *ti, pgoff_t pgoff, > */ > typedef size_t (*dm_dax_recovery_write_fn)(struct dm_target *ti, pgoff_t pgoff, > void *addr, size_t bytes, struct iov_iter *i); > +/* > + * Returns: > + * < 0 : error > + * = 0 : success > + */ > +typedef int (*dm_finalize_fn) (struct dm_target *target); > > void dm_error(const char *message); > > @@ -209,6 +215,7 @@ struct target_type { > dm_dax_direct_access_fn direct_access; > dm_dax_zero_page_range_fn dax_zero_page_range; > dm_dax_recovery_write_fn dax_recovery_write; > + dm_finalize_fn finalize; > > /* For internal device-mapper use. */ > struct list_head list; > -- > 2.25.1 -- paul-moore.com