Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp948749lqg; Sat, 2 Mar 2024 08:13:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVQrGsxIBdetaX0A6V8QPkavvWSt09YQEwfMeC6Iu2GIw+MLaYpjthd79Hd8kQXcQ5QHs1Q/0/FU/W6Fbc2uNFeZKAuz+UJmDCEWUkiew== X-Google-Smtp-Source: AGHT+IEesrrVuaf/hzuDtR+RX8p+ZTDRKSMCfPiJ3nCMyEQ0OgX4chHDfJ2tTSXefjYATs7lWNTV X-Received: by 2002:a17:902:6846:b0:1dc:854f:9a7e with SMTP id f6-20020a170902684600b001dc854f9a7emr4655953pln.60.1709396011887; Sat, 02 Mar 2024 08:13:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709396011; cv=pass; d=google.com; s=arc-20160816; b=Sgw/3rkd8RKQpkbvqhjBV5dWUbwLjv4eLxaEOQIbbztwMn30fPdaMqndwawEyfD67c IARyLoyxAc93RvwEw78i193XgRPHW+QN9Dn5MoYXktx/0hbgnqgioO6pSp0PzVp1V6QA Ov3y9n6sXRhXf7HJehyU2xwwCOXP6gZcc7Fp2jdrUx8gNBJ7+TZdO6H1ltxya5Kmfn9p k3ZuoaB5zkVE8Xl3B7grH1SwOwbB93bJ/RYV0Fg0JnnaaaaHdhIsqzegs++soAp9bTFf w7iLN9YewoI/s7rrz1WBY64dLqPlSYgkM2pJrUVLucqqhk5zR1WtoSIRRqcHoqrNN7nH D1eA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=9z4aaL+eoV7uAuWVMK9/aYASmrv+Wksdp8IvJ6mzxpQ=; fh=1HtcD1+INVQwfEQFtybcPk40/f6r2OBF9FdmnojFdEk=; b=GmfWD8LgzQoO3Ozkx58ZT40/CIj7fkwaetCCt9kyF838dPh0Kc0MFNidqwxGTFPIxM 8IONOvyIMQQpePw36rHdw98h57vcZiRLyLznUj0uv53vQPUqxeaP6KInegbdtT/yaEUN d9yhodw/oemOEZrqUM2N3VM6tUb8uYfOZUf7UUQR+i/mZkXsDl8nwfb+BE7HW1ipLOnd szrx4uHvn01zQOIuXRQzY1MI9bBuPelG4pLEaWBakjO+3ShaG0iy55iUn2zr1e1lmvKD yIJU9sGApKzCK0+GbcDXRgTjRufRy06cl8rQ9OwPEGTYMTx0FH24tW0FrCNMCmSgQnIp P6Rw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-89493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id im1-20020a170902bb0100b001dcfa29aabfsi1308742plb.650.2024.03.02.08.13.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:13:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-89493-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 713B3B219B0 for ; Sat, 2 Mar 2024 16:13:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDFBD1BDC2; Sat, 2 Mar 2024 16:13:17 +0000 (UTC) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20F901947E for ; Sat, 2 Mar 2024 16:13:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709395997; cv=none; b=oyyAFCJCXYJ3BOxoWtS+e/FWDOrQT2gZrSl789zXsP1qeVvwFbAWBJMOP0kKYeHgS8YVI9c4YgQhRZA3u3Mcr78YzBXWgizZI64T7ahTsnXiLbe5uSNaBt7HHHPQ0+av2RT933jfltTIh70pRQKDewNTjxe/lIp5e/mqmCkczJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709395997; c=relaxed/simple; bh=FbjTuTWqBDQsWRS0dZyGAKYtWVxCCDP+Jy5p1Tkb6xY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MLcFhPpft+TrN5oU4LQxl10oRlj0Pm7ktHUWLRaX/Bfi782CzkqNAIyZs/4lZ/Z+HL+bUYfOm8bR3D8OUVigOPemCNHhm8Ua2EKHQhdsH+q6WEex053R0kARpILGm8HB2UC3GfY1XCR2RXZVTc/cWqHGjq0mVqn+OPvP1/wN2jM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=redhat.com; arc=none smtp.client-ip=209.85.161.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-59fd6684316so1170043eaf.0 for ; Sat, 02 Mar 2024 08:13:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709395993; x=1710000793; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9z4aaL+eoV7uAuWVMK9/aYASmrv+Wksdp8IvJ6mzxpQ=; b=bv/HvKNg5WHyFpIBp/pEWLQDPEOmFSnJT/LEFYAsCCKc1o9XoeJ+Zw/wWGM2gHTT+f RB6JB/RCIGyX/6sHmo/OqpOdxg1WuvYmMoM9RmlAE6tbTTbRdygUkjEQzppB9fZDpCTy vPAfmbOAGSQsyLNCrGrZp/dgaAzCgii6C20Tmmffl2jmy0E9tVSVZ7ppJ6L/jhvbA3+1 Z9OGECVyUnU/Obug+t61EX3e2lLm0UOWyVbAbelu4OrWURHXJyy8ZPehzR6QKBpsILlH NZv9X9Oc0XpHAlB2lMlBeCi+X/G9pPu62avUQbhbBYYrkJtZoyL2ti6BjjGqaqC02YP4 DjBQ== X-Forwarded-Encrypted: i=1; AJvYcCV0ynA1wHcoHJh+fQJUSVMfrOk561j4wSU8+vVrsLpNgASvkGIN6XJI/ibFUuqAaHcX9mAnF41xCfE/aPWNVn1J0qAldiumHmfsbRJU X-Gm-Message-State: AOJu0Ywop3coxy/L2bOh3rLMK2vZqRR0eUCRzKGaSf/a48ILVG91qFI4 qUhqaKmUMO/Hi7EGDNx+XZHQ7HlpBzC/g7/2uFWde5NyFF4L5Yt0lLtbs/BpNA== X-Received: by 2002:a05:6358:181:b0:17b:eec9:8ee8 with SMTP id d1-20020a056358018100b0017beec98ee8mr4991319rwa.12.1709395993108; Sat, 02 Mar 2024 08:13:13 -0800 (PST) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id kr9-20020a0562142b8900b0068fcd643b9dsm3093596qvb.22.2024.03.02.08.13.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 08:13:12 -0800 (PST) Date: Sat, 2 Mar 2024 11:13:10 -0500 From: Mike Snitzer To: Fan Wu Cc: 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, eparis@redhat.com, paul@paul-moore.com, 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@lists.linux.dev, audit@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v13 13/20] dm: add finalize hook to target_type Message-ID: References: <1709168102-7677-1-git-send-email-wufan@linux.microsoft.com> <1709168102-7677-14-git-send-email-wufan@linux.microsoft.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1709168102-7677-14-git-send-email-wufan@linux.microsoft.com> On Wed, Feb 28 2024 at 7:54P -0500, 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 > > v11: > + Introduced > > v12: > + No changes > > v13: > + No changes > --- > drivers/md/dm.c | 12 ++++++++++++ > include/linux/device-mapper.h | 7 +++++++ > 2 files changed, 19 insertions(+) > > diff --git a/drivers/md/dm.c b/drivers/md/dm.c > index 8dcabf84d866..15b46edae49f 100644 > --- a/drivers/md/dm.c > +++ b/drivers/md/dm.c > @@ -2266,6 +2266,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 772ab4d74d94..627400b2d9af 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); This needs some documentation, e.g.: this hook allows DM targets in an inactive table to complete their setup before the table is made active. Mike > > void dm_error(const char *message); > > @@ -210,6 +216,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.43.1 > >