Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp51665lqo; Wed, 15 May 2024 21:03:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0UgaP/e5uJ+6wcpXvIjx7BKR3p1dOXkC/5W4GowtL0x1Ae7WPMvxj27IRkPiznlpQc1008/WKIOkf93WSiLORhtc9NZkCqRjkjQo1IA== X-Google-Smtp-Source: AGHT+IF/hEjn+hpNF8FEDY7FGc0H0vf6EkQqdfY+AK0Nb3XBmhWvs+P5Wfh2eDdI3IJNXGzG4xkL X-Received: by 2002:a05:622a:1a10:b0:43e:3c:5623 with SMTP id d75a77b69052e-43e003c58a1mr252557751cf.10.1715832239453; Wed, 15 May 2024 21:03:59 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e22fd508esi65081971cf.475.2024.05.15.21.03.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 21:03:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-180612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=LEAUrTbF; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-180612-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-180612-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 00CCF1C21150 for ; Thu, 16 May 2024 04:03:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9548729CF2; Thu, 16 May 2024 04:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="LEAUrTbF" Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2051.outbound.protection.outlook.com [40.107.255.51]) (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 031CCB65F for ; Thu, 16 May 2024 04:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.51 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832189; cv=fail; b=nKpwBTaLsDFn/dZwmP5frcXDhW9GN+7oWvpneo2ANyoH06XPhPCC2MlSyXkyaSZmGhTTyXukfG7RV06Fu/leQ+TRa9L19uRQckwxN6VzRBEXNVIGaYceyOiUhf8VvPk8OAP0Gd03HbPlNXkb9bfpvuSL9U/wHdjqMbETWOkCeZg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832189; c=relaxed/simple; bh=UBfgroBIYbXqpoq3UbuWWpZnLNb0i848aCOeSGM3vk8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=uoS0TQgUuyfXflEoCP/8TaL1ggsuQ2PSN458Nfj0+IPhmnrnVFtCJ38iRdNL+ydINs5rciy+IbyQCJmuk73iyuHbJSNGJif1SDcNX3dM5VKiBo5HIL9BHEO7c0+SRq9qlXmFd8SOyLNrmhUsPfHOupfGDSwqx8DiRa4h/SXdoQg= 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=LEAUrTbF; arc=fail smtp.client-ip=40.107.255.51 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=l/I25n9sglNrj65u/MYAfAU2TsG/D3n6jRiI3TaNR9+PcYjx2Lm7yT+5mBIw9zc64gyYaAWgbh1BV9xfHNORz6m2IXpVFyKoNVzRjwe88rDqeXChNQ40WqeeN5SNSPxiFIRyYlWf9eD9dnAxq6pyRCPhe08JOzBvfx4vBZpW2X9DDSDRYZ+RnBcozXlCEHR+72vmOFh704KK2rHhehX6OG6BdJKdLa+6/U12++30wthwZod/YBxfcsgtADGa8bKx+BvK0U16DMTf/7lvV/cVxkdMHM32t7po8FkV6tOll8fEfUCMx745KOtjFHUwD5ETKMST6kD8vBw1hsc5QkkOdg== 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=bX5L80hBxxttj47k9eHP54X/F2oAa3/64jBPrCkfdG4=; b=UT3xVP2HgcOdH0SEThxZYlRMz1c64bcrqwfYrTEBe0UvK6hU84dRYRm1OI3gosWsbAF4oHj/W0N3e4b3ihyhrJJ5haVr4BbvvcgLz4IvffgqNMbYP7a3d8/qecpvPLuQe/RBbaz+YMAydCrHM1pAHrnYJ/jq/hlgiKVerRxT+fN94/ZhvIhP1RFk4+1mdusNYNCDOuJAvFZRBPTymcw7lEKgUqh7MBqlL+Jksq6KUqzS2thqA0dCTDJqsNV8JBl6lMqe3Oa1k87ww4m8y58qYY8x947YuuHh6kjypRbhm8q6yZ7TEw+K6Xwo5s94OE9vACi+07byJtC7KXUo+/pX4A== 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=bX5L80hBxxttj47k9eHP54X/F2oAa3/64jBPrCkfdG4=; b=LEAUrTbFbOlw41sFhBgyMNhLGM504vzFEVyUVS9TANuDfMKOMN9H0A7inv2uC7qUayYR8nIWicinhCkf77qW4lKuPxnIcwymQ+rai5PvHvEzpFj5xl/9AtKG2gTpMfX5Urlyy2RDKwibtAvpQVqAdseHSL+Mz9vYLBAXyXWEVFU3077vE50/Py7I/yRWy6F7FrFOQpJyDgkwvhUq+N8V9V0q1r191TVYKUZLEIQChRbiFKdFchYe4hP3qFoY4o4KJGJMBJVrYTPbwmYJSMUme+FblQ4owO8cG3TSfpgRcBe5klhGUeMfvDNb+DL5uzSQpzuthhiaRuAtmgEKt8v0lw== 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 TYZPR06MB6807.apcprd06.prod.outlook.com (2603:1096:405:1c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Thu, 16 May 2024 04:03:05 +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 04:03:05 +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 v3 3/5] dm: support retrieving struct dm_target from struct dm_dev Date: Thu, 16 May 2024 12:02:32 +0800 Message-Id: <20240516040235.115651-4-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516040235.115651-1-yang.yang@vivo.com> References: <20240516040235.115651-1-yang.yang@vivo.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: TYWPR01CA0017.jpnprd01.prod.outlook.com (2603:1096:400:a9::22) 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_|TYZPR06MB6807:EE_ X-MS-Office365-Filtering-Correlation-Id: 5182e7a3-5d32-4ca0-417f-08dc755d16ad X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|1800799015|52116005|366007|376005|38350700005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?oQOH1Xak63OTmggUHVHmofdcss2QSZgcsBjrucvYGHbxqqjpr3HJuMEnGAzG?= =?us-ascii?Q?avcnMkcMpWqyo1GVaFY1r3Fi16trWAJK+lk5nEBJx/8X3snexl1Tt8hQzIsg?= =?us-ascii?Q?tdO55hzYjpkCLlIWkxORp6QMXSR2YGZ2V5LzA+FPn6RUuz7XHKDWWaSHjPFA?= =?us-ascii?Q?7IOMLWNGOCofPn0Ix30jSU7eXyhyYpoQMFOCps/Cd2SsrR4AKUW5f9xvb1Ym?= =?us-ascii?Q?i5VfPdGQYaNLc4iowalUN42Z7mVVqyG8wjR5aej3JTCTgkE3WRMuYXXJC7Ds?= =?us-ascii?Q?kv2TE73uCqG9RTihKzeM2vC2Pjs/wZiC4voeyOVH4oOOG4Za+BdF4YshHuHk?= =?us-ascii?Q?ibZl3MKpGOwCyYbY6oB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WXVFab+q?= =?us-ascii?Q?sv3iuuJaQSxXjG/6pHRnpInArGVBoWqtE487LoywbdzKC67KTYoqvz6fHYr9?= =?us-ascii?Q?foF5nBmzs2Rz1BubdCvbaM6iPUB3wnuj/i2pswtRrwkRCQ=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)(1800799015)(52116005)(366007)(376005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2PuFGS7N0BL5D867EZ71aI3ogNZjwssIepFJ+Zuha5EeozSijboZjrHZ9kY6?= =?us-ascii?Q?8du3Co8q2ThzYYRkB1zxXDWkV1Hs5il4ESpPKcKA2Ml6O6Wtv6c/MpgJYvTj?= =?us-ascii?Q?P6mn8pJQMhmeujIhENvPHNXyev5g1sN4YjimqPMZNv+yHu2my0VF9mHvKjM5?= =?us-ascii?Q?onHM45m6zJGfYc1AA0FO/Vu8uXbsc2n7RlVF1GVZLF+g5PjQkJBCypPFzCnM?= =?us-ascii?Q?O6p91YiYzAkGrJpgO3mUp925mKwm0U4q1qhIZRUeqQC22E4jYsjLBvgnTqCd?= =?us-ascii?Q?ox6/STdFz4/7Sw3hiaNWOQTFBkeASKLLNttt54e2pMhl8VcDCoolw1VPzbcv?= =?us-ascii?Q?3ZjcY6wqSyCiBzK9FZZWcqaVPVfiZ23WPX2nHUrqQJEvwlQ1xbwpoGUHvSv8?= =?us-ascii?Q?FYTm1tunosBnZKKCrplsJW/kqdhDxQ5B6uqpUV8q3GJLAHOQHJADH2+/1bFk?= =?us-ascii?Q?J/4rxE4WFphdZC6LY27wbGYtMrYz/LVk53JMeKn4gDaf3qZXgxNNPMYpWKM9?= =?us-ascii?Q?ddH8wX1Sq/7AEZGtSKPFsc+R9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yRq6T?= =?us-ascii?Q?+MtPXUKb6+T/xTBmP5QyoPpUNAVa589XZYHgB58wpHHhuBbbp5ihESPoD0t6?= =?us-ascii?Q?WX9V56EqYEUCY5DJ9TrI8let3gLyo7wnrQqx4lTz7NifkTgaVUn7l5lqkA8H?= =?us-ascii?Q?X3n75uQKlQmHt/5zLtNDzp3iiSR/glN1AeG2E9z/?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5182e7a3-5d32-4ca0-417f-08dc755d16ad X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 04:03:05.4138 (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: 70uck+oZMI0TQKsN45MBrJowK6jEjShS3pk4Ye5DeedHa0xKyeobuX2y7RzzLDFCgANe8IprMS5JiYuOmIQVLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 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..2696d1a8b542 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