Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp129125lqo; Thu, 16 May 2024 01:05:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUtXvajzhIOoqc2JMovdVVZJ7GLLk5elsE0ajld/6kRWe7VbnYH1f221ugYOk7Z+d1JFcXnkcGSPjKt8Vtd8qDjVmJeX3ZmIgzGzVocXw== X-Google-Smtp-Source: AGHT+IE18URXl+VvpgzC+UidZvbi5hWEX2MN8M1TrIQnUaywmF/kgEH+8cN1CdJjyFGLtdgjG97V X-Received: by 2002:a05:622a:1906:b0:43a:ed55:f3a9 with SMTP id d75a77b69052e-43dfdad7b2amr248947501cf.30.1715846701868; Thu, 16 May 2024 01:05:01 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-43df56ee751si162153181cf.794.2024.05.16.01.05.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 01:05:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b="QoB/nVXB"; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-180732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 874FF1C21B73 for ; Thu, 16 May 2024 08:05:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F75B13541F; Thu, 16 May 2024 08:04:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="QoB/nVXB" Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2086.outbound.protection.outlook.com [40.107.117.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B540B132808 for ; Thu, 16 May 2024 08:04:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.86 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846655; cv=fail; b=rBHPwHFAkKdn8pLkiTryaLMjPjq0glg53cDalanZSASqCDiAlSuHUMJz0WahXjLjmy8j2eX/2PYzm8C52lJc/lR8G1cBuUFH1siFBdi7O50FZYUQVSnbU3aeW3vLnBH9eju366dFL4nBN8JeZLQ4/XcgY/NYe48OKozgTl/rNqg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846655; c=relaxed/simple; bh=geiOUcwvOQEWvSWzvmzuzbbdH8s7gm3NIqsdxOCEO4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=TAsptbboY9hOtif8H6z+dZ5bZLlo57o5eluLAT+eul7U2d81FUEFctUCMtCPa1zx9aeVzKaGvBXy+mRNHFZ3Y66IJhn1WzmZ+Kvg9JsvnmBF7TpaiGHMG2JEBRneIylsYlcxZh+ThsaAuPEH2MeaVUSVz+986HYpRuiuI1g4Iz0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=QoB/nVXB; arc=fail smtp.client-ip=40.107.117.86 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9jAV9fKkfPvEznJn6kWn141AdDam40qObz94FYiQO3RR4rp05gbDHnfBFsVN8DjCFqwxbH6M6ydD8B4hImp4F3i56hO1Er4GX/ejpdMt6VSecl9SYnebCae1Qci8mJk5zuQ7+tnD94lfD5Eh+7hXUuQPKCAZe5a9RUTPktor4aQtWLZB9f19g/7WG0vcWh35ld9mIjviBDWn0O6zvttRcL/0vx7DTYNkXgniI5b9cNYp0KaUcJgATXYgfTuPYzWH95/LCwGkCxLAMuD6BhpQvb+g2Jr2BRXRS03ojjhffT0yVaWj2EJZ55IXb/WD1GEawT0huItbLZ5ybiRaogW6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lzCRbOJSPZPENWNCT94N4Qep991CBkBUtd0EM6pObP8=; b=Pyy2zyEaVGNu8Kl+Ke9wUVLo099Z/INu3UCrtjg+/m2U9wDaVHPJCdHm42YGjT5BfzrlLDUoNrOELFNMOuddQaKFHIIYhe1t5+pQ99Nfe57KsQw0voZuWo0kFSWd66LrhotUSuW50WsUrJmWXQ82bzCnoc4rZcaypmE/aCS0rHKSgacwoC5Aczatu/UbneOnuqsbNt/78Fzo4mzMBLKe9rypjlZkxL0jHl+qaVeimBuangHioOwY/0Pn0y+8ZDcqO3NzFliYk2AQln7R4IhjKB9hjlvdn83qtPD2UT8fO+lQLB2fZZjv8wRRH2hiAETsUQ9xFs13JvBujvMWTUIV6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lzCRbOJSPZPENWNCT94N4Qep991CBkBUtd0EM6pObP8=; b=QoB/nVXBQMa7lutNNyoUPZB/88hDQPho5NXEZxNZMWUbOUiFHHX67dIMygtUraVnsyS9Xl/IpsV0V/dKtWHE2jYAGyQ/9/GElfuRaMYnQmgb5ZrScqE8uBhy038qSG56zKpBm0B5Bu84UDrnj/fjUnjkqSan11LwOOK5dQ6Vp9v9bFcFdAJCEY5aZNCpKBqypvuVMz9QZkB9dfLPBxrZNkAtatG6rG2KRyerGQ+jwJOesjPFfvyzxWTwPeYVjk2WKpdNnmyqVETleilsh9JGxyTe650c6AAeRemITvsYnQsAY1LGnJZLW8icojsmwvVq/j4JRuKQIuwpQL+NaM22xg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:11 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04:11 +0000 From: Yang Yang To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Yang Yang Subject: [PATCH v4 3/5] dm: support retrieving struct dm_target from struct dm_dev Date: Thu, 16 May 2024 16:03:16 +0800 Message-Id: <20240516080318.120231-4-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: ae48b68c-8f66-4cee-4884-08dc757ec4e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?HzsAvWL2b8dg+ryAm5PvRzLbZsLRoKsR857oy6OonW9wvZT1FRX/WABH8rQ0?= =?us-ascii?Q?4Tj03TLr5NbT8cOTfJv715j3Za3J58DFLabGtgZ3fXy1EwBDE1IjWVfOpaWc?= =?us-ascii?Q?v98lTh+g7OK6Ps+9EwOpB60zd/husDROpz1N4MUiAUfG5pyLA0jWeeWhksN/?= =?us-ascii?Q?cLIvbimOhJIrXzNMHzFZU26a7z5heFneBt2s1FUW4Io1Crf+tE65WCPbQUvC?= =?us-ascii?Q?1agyVBG7+RHVxnj5GO2hoc7+U/Q86FIoDLoOD0k2u+E5kwFbFkcrPMHQU9H1?= =?us-ascii?Q?mc1+pXjhn0JsDQl+mP8ctcVUT2X5rB/Gtg+1MS/PFpN+1yXA2MmX80wxOb1O?= =?us-asc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HCryLEKJ2?= =?us-ascii?Q?EqiTvQXnD/wdSucdYatrvt0kZyfpyXomxUUKNvmgLmgRx7A/mIO9hgK3cLA/?= =?us-ascii?Q?/p1CcGr3josVscYM8yBxGk+k88YOg3eYG+PFaW1vbiGs1Q=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JI5hQhYJLt4jrmoUV7fplwiGtTRC+vBBsxBKrUA9AhKAcQVMCh1eSX+IC7U6?= =?us-ascii?Q?b/LQTxGb+Qk9SDopGVnDzMYEcFIcM4o8K0JwI+gN3oXircBzheED4eIR+Ixu?= =?us-ascii?Q?HGB7YzXHFwB4K6q/VSqDs6LDYh46Ogv/PkTlQGMyOz+Sw450WiENzRsKc7av?= =?us-ascii?Q?qq8BeqOOeuxlvGUdQqYtWAdER/QQxKMiIdcdJPoiGHyeyYvlK/RrONu4ZHPj?= =?us-ascii?Q?EMfOKwTeteyhtK8S3xGmuV3w+GwzeoD74yne/5P90M/AiFEYjP3BgcDbPxLv?= =?us-ascii?Q?UyiUmf1VE2IdbnznkZcFctSF1i5RZfHNKukT3AKVfqFvYovy4fAI1GrfpIyX?= =?us-ascii?Q?2gTrfeqwnLSUGY4gN+/++qGgKa0ICXG/U24Yu7yuHOq4d/76SpecqBkB17qD?= =?us-ascii?Q?bsWC0vPCFuscbQFN8YgHWoBFP01qkcRgMlDnmphnKDKMYyS1CivFzEmt+Ncj?= =?us-ascii?Q?smtpoIcTsfpkR1Z6NYCuP8c0qFveIQ/xXv34OME7qz7Hd7Nh3FmnVbPj7YMi?= =?us-ascii?Q?Jfk4MeJSyqzVsnBRZQNPq18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m1rXxd8OIyKsHrjuuBsFc2rgQb1wDd02QCVjsqgiBXjbiw+6DU6UxMVP?= =?us-ascii?Q?Ig/J8pJswisFFwxiJ/54k1QyYfjNBkrFHdrJwGktWr/jKqwRxj2XWQsVi77Y?= =?us-ascii?Q?kkX7SwscvyCG0a7HbgXqvimz1YzcMwIQYyqv+AYv?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae48b68c-8f66-4cee-4884-08dc757ec4e4 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:11.1097 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0Kzg/4vYoqKQFIbY6x1kmUbPaOCegpT1tms0a74dDcIbZqcNMUm+SD5lmCWJjWkHFVBc8mirv099uWy9yDVDog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 Add a list to the struct dm_dev structure to store the associated targets. Signed-off-by: Yang Yang --- drivers/md/dm-table.c | 16 ++++++++++++++++ include/linux/device-mapper.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index bd68af10afed..4817ddb660c4 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -2134,6 +2134,13 @@ void dm_table_postsuspend_targets(struct dm_table *t) suspend_targets(t, POSTSUSPEND); } +static int dm_link_dev_to_target(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + dev->ti = ti; + return 0; +} + int dm_table_resume_targets(struct dm_table *t) { unsigned int i; @@ -2162,6 +2169,15 @@ int dm_table_resume_targets(struct dm_table *t) ti->type->resume(ti); } + if (t->flush_pass_around) { + for (i = 0; i < t->num_targets; i++) { + struct dm_target *ti = dm_table_get_target(t, i); + + if (ti->type->iterate_devices) + ti->type->iterate_devices(ti, dm_link_dev_to_target, NULL); + } + } + return 0; } diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 0893ff8c01b6..c6696f88bf66 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -169,6 +169,7 @@ struct dm_dev { struct dax_device *dax_dev; blk_mode_t mode; char name[16]; + struct dm_target *ti; }; /* -- 2.34.1