From patchwork Thu May 16 04:02:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665707 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2070.outbound.protection.outlook.com [40.107.255.70]) (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 76CFD4C63 for ; Thu, 16 May 2024 04:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832187; cv=fail; b=Ok1zp5ddqufFYMaup9oUDKIfhGk2d1R5ssoXqqInWosBwbNSCmZs1HZ9L3sLt8Fr3pzJP05zqmQDu0GyKfbQjBtP6SiZNzNL6ohL1Rorm0l5EpAPbVBtU9hbrdHFHze1cL9zOFue7Qu2RdzDfLjmyVejyt7Y7EF5dvl9N/JKjJA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832187; c=relaxed/simple; bh=d+6J0DopE8a1tqTqwm3DC/qdhoRyEx3y9opRon/FBkE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZPUA32N5ByOm8lH2CD88DsFFfQ8ouJJvAvNxUgGxr/FBosEcs0cH4xwR+0cPa9S24P1AFys++TlxnnTM1fDbXvfGqWkTMfQU4A1Xv3LXRVtqL+3vxPYNQD3Ppvt8LQucd7FpkwDkcgg+bkbk/CVldeIqr8hxBRA39BrjgbBmoTw= 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=d5cl490q; arc=fail smtp.client-ip=40.107.255.70 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="d5cl490q" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h7iCakEba/dqyv1d2TroV6PZmiuINWVf+D8N4KRv9EGX5somammvZI6fkWRmdXuVk2qlswOUBHUw4BmfYZ7gIJ7jCB4N5Ub9qGGV4fY9uoYWFOAkCdIY6jajZ53TbcnHYUwZaNEfg5BKiTb1GM7/RVcwzEeHmjrC1/0PvvRwHra+ygwLj62pPd533ZP6uFUjQIRcnS44fSH777Zi8BZqK26uL2KsOSV7L8Gc+Le/IUnIcAvyvboiaeOS62z2wIB57+uGobnq1L2o728zP5ZQ4JxqZjpFtqWMqDphWaXQgKMQFhyqMYqB5CeAmqikzmqLXAuaMvgKBOydPh/mZxmC+w== 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=4Ly6WgXtiz0dA/xzmP8OTqpgBcoRWGdPsXGNgS1wPGE=; b=ako8OfN0/6idztOMu4ggTWxP4AJjjSSOEHWZAb0gelJB0/5A7gHZ0Iie+6fbrHG1jDLY4HOaiQ5fa1d2uA3KEmWyE9iVYG9ggT7UqQ+KN2zCVrS4AN9oBhs7Fr37xM7gRo6ZYwOGuYcacFxD7qyUBmlg3QBgiKx+AkyIhrrW35od1e/yUenHnn7t3GMWxoucr6ISemGXX/ZcpRZod4iaKxmuuJyNh5L6/hhnUhnkqg5v4RBEWqy4Biz9PoNxHG0tks28PRmbbGrubhjy5iyTFnqOuRANiRKWnS8ihdQ0R/T6GnGpEUovLnvA8zuUxs0OYSqWwn4AGnMf5ljDhcKCMQ== 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=4Ly6WgXtiz0dA/xzmP8OTqpgBcoRWGdPsXGNgS1wPGE=; b=d5cl490qJBFVZ7r8unUi7NlDnshmamU41SOqEgAN19sk5A17BmiBeXx8LpX/+6vwUpKSmgUelDH69yKTYpH2kwC3TBVLZI472neuKtyCn9oMv850GuoxoUs7EgI06gIkhl0JYlSrQDpGdkAh61ybfzuiGQNuGfyMX3/5Tl2v+6QtViiZ6bE+08oE+ANO2YX3nB5cT+1hHrPYSbcNrrrhDHNJD23peopr8HPH0R44NKeYTU3hkareArI7qmMOvgVD0gRs6Ocpv+3HIt2rA7IRR19pVbZLaqdk+NryZjBx9gbBxYYdDRauNUq07+NV4wcB2HYzyhFYevqvmtVi99k6Pw== 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:01 +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:00 +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 1/5] dm: introduce flush_pass_around flag Date: Thu, 16 May 2024 12:02:30 +0800 Message-Id: <20240516040235.115651-2-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> 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: dm-devel@lists.linux.dev 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: 9c44fe5d-207e-4491-786d-08dc755d136f 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: FdwwhYe5Syn2s7EH4wBJ/4MOnC7eSQy/RqeCTvunN0eA1iOOAV5+2fTRs3ywc8UYN1ElAOL2qdUHyIWxcaXqtuaggEHbofGaByDda1oAOv5CjCjDv/SeV/uLgwFl2GvFQbQWVsOIvTC7VhBJrJiWAJgrFJjeWCA945a/LGz6PImHWjQft1ZuzDN7F5jq0nHBPSTKmcS6SM6F/Ia2eUi7GHeh9I+dgJyCV/D1U7AK8VVkJbxHj7ntLpb/CesRAjAuia0Ts7fZh4vlDDWHhFcKc5YRgDGn2EjXTggbm4xsOdgtxHM7368+D28USPitCwcy6DKqXmzKuGobanj82RbEvSOu4UKtdnXKcoHbjaGfecGFuujlGK5Z60zfQUfCPqOmFg+tqij5fQe6o0+E/7H9GhfmDvqbsOMSlIta5MOuxdENo3ElAjRgDC4EJck4exv71PyOaCsDl5ve+59MrmLG1SmCghUm4DDQjMNBFyCNgp3PJtdsnT9pRIlp2QxX0BO+A9y4OcHrzJK8fFqEHHYQylT7AyHvOaEan3lsm6Bz4VYPbax+6mwtvQtnqa7AELoIQavu9E3fl6AnueB0Lqna9fxTy/pt/FLtvLqAexBkVdDCs028vNMkZ0lyJDZGwzbqR3muG9HkgvvBNZjlSWEcS8eXruQw8uTOP5YBAYjadRd7sxnOYZ/vFByy1a8IfM++WW4HqJDyHGBZmW3sS2B9DkW7kW+9n7LDXPBpBEpyIiL7XwpL/Vqicv5PbxLqq09zTiTpr4I3itu/ZDQURwfCChSVQNm07j7ZnXkybZZaFKhqHORijxp4/gfXBeDU55e76E2TqTprHhaeu+DroV3N/6iSE1p5vaFIbueUyH/gYwdAdHKiKZm8pZ9PdIPHp8icrIVjcbWOrSkJKlx5PDqgW4dkb16EBU08p6r0YLuaOs0M0M3vpziFD4hYFt14HPUP84gQYvwT+CHH89boU8wSAOdNIMLdH0ZdBXSaaDwIrrvrKl6RzrV+0jT4+5VKQaRXCtiKjGMF1ALufCeY8Hu9fo09W6epzmEqjp2majD64khDh6tdL1Xnr+2Qn0jzJi7EUCfTjeDnbiG49OP8jnCE9sKBZ1rFDPnqR/oGGSn32eSIznACt7MPAFr1pu1AJrgPeKBbSKJOP5y6edzA/bDm6gjzxTO9a6piDTVBpw6vrLQeY3JJGY1PAcIMzJu29DrAUamGElWgW5KfuKELYdOGNlJ+V6pAYC4tdC5KQ2n4YKA/Noxe/Eigqf5JGzzvix+3kN/HEA57L8upS1676GwxJEmrXbTYHTWJqFL4RsAFAxJMSbg2Vpl6kSpImp59g+BI5RccKuPaUKhGucPWQiZTVw== 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-Ant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BQt6uZQ8e12bF19wLgoq9WKUKPkEqTi2icO0uVSFLQSZjFompqoQ4Yp0uegEvFtTDTvrXnlYMoukR998BS+5iPqwRkGYs4rdug92Jw5Aa4RVbej9aSg1Woc3OUBVdkypaPn23WYFNCSeOMjUA8NMhIytlMhLI4XucUKm8yhiXtJ9+liRx6fo3edVxbtlmOc4quIUApdhsmDqrhrK6Pd9s0AR5YQ6lzaPYlMk2UE0d52kct8EOn5B/ZhZDF1G/5q+lKNHE9EnDDJAtV0iqR1T6Y5hIqyd1jf5RNM89TFoXHbB1Snp1FQaDWQcxKLqgp/Eikirfu0nnSkpcZx4gcyPe4UaMcG/XI+zGfi0buqXKAuaqpvQDpsX7SBIdqVZEB9sHMItxqKKUcYoKWdKCmCJRs/eqsMxkmox+xowNiRj4xnenuEGW3AHCuJAayD8pUOePMjUr2Z9ITLsXRAwlmuBA+UVg0XWmhAoiIQ5BV7CbokKQp2zc2hCwIQfGIf5Dgu7/RvBWl2EnOGYCrRzVadEeQYuDfDA2WcqbnJSDxsB7RyC2Whms99y2aJE/akcl2tl/qU X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9c44fe5d-207e-4491-786d-08dc755d136f 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:02:59.9830 (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: qLlIFVmCPhGUs/p1DBNJlv9rb2BaT2i0c7ZSD1iQ4tskE2lpSwD0j8UeCpho7uax0aUVKHQIjp0+RA8MzNEmyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 introduce a per-target bit "flush_pass_around" and means that the target supports flush optimization. set a per-table "flush_pass_around" bit if all the targets in the table have "flush_pass_around" set. Signed-off-by: Yang Yang --- drivers/md/dm-core.h | 3 +++ drivers/md/dm-ioctl.c | 4 ++++ drivers/md/dm-table.c | 3 +++ include/linux/device-mapper.h | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h index e6757a30dcca..b273f25b634d 100644 --- a/drivers/md/dm-core.h +++ b/drivers/md/dm-core.h @@ -208,6 +208,9 @@ struct dm_table { bool singleton:1; unsigned integrity_added:1; + /* set if all the targets in the table have "flush_pass_around" set */ + bool flush_pass_around:1; + /* * Indicates the rw permissions for the new logical device. This * should be a combination of BLK_OPEN_READ and BLK_OPEN_WRITE. diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index c2c07bfa6471..bb178df2a340 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1445,6 +1445,8 @@ static int populate_table(struct dm_table *table, return -EINVAL; } + table->flush_pass_around = 1; + for (i = 0; i < param->target_count; i++) { const char *nul_terminator; @@ -2279,6 +2281,8 @@ int __init dm_early_create(struct dm_ioctl *dmi, if (r) goto err_hash_remove; + t->flush_pass_around = 1; + /* add targets */ for (i = 0; i < dmi->target_count; i++) { r = dm_table_add_target(t, spec_array[i]->target_type, diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 41f1d731ae5a..bd68af10afed 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -738,6 +738,9 @@ int dm_table_add_target(struct dm_table *t, const char *type, if (ti->limit_swap_bios && !static_key_enabled(&swap_bios_enabled.key)) static_branch_enable(&swap_bios_enabled); + if (ti->flush_pass_around == 0) + t->flush_pass_around = 0; + return 0; bad: diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 82b2195efaca..0893ff8c01b6 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -397,6 +397,11 @@ struct dm_target { * bio_set_dev(). NOTE: ideally a target should _not_ need this. */ bool needs_bio_set_dev:1; + + /* + * Set if the target supports flush optimization + */ + bool flush_pass_around:1; }; void *dm_per_bio_data(struct bio *bio, size_t data_size); From patchwork Thu May 16 04:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665708 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2070.outbound.protection.outlook.com [40.107.255.70]) (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 610578C1E for ; Thu, 16 May 2024 04:03:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832188; cv=fail; b=AkMfAjjRm1P76nNHyeu1jRixG2RzcZIgqIWpf5HKVPMALpFIxmTqekHQJiqLwPlrbyEG1Z8FeyncvgYtcDhcE9pJsbBhTHyGEJx9drb6NM4iVBnPPNeOmk38IqagfdCNs5uoDSCuTok3vrKlSmPldDxFVfk5zLl9dHjdCnCSFM0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832188; c=relaxed/simple; bh=Dd2Ne+wYYQlf67SHMr3G51DSNztSqYbRu48pXFAFIJc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=olk0BiMYsCvGLe/5NweMDT3MVXeJygvvzCkJkQucU09d75DOrs+RnbW93cFkDVBI0IRGi0gvmOy+tuiN2cAF32Ioh59pvbWL3FXFXwO4jZoGILZZQ+pi3yyWZaT9SFA7b0YNMpcsKKNBDOVZoheUIVxhuWd/oI9IRpzy0+gWYHQ= 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=hR8dt4rq; arc=fail smtp.client-ip=40.107.255.70 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="hR8dt4rq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EY9Wac2DlK4bA/i30wmWrtcjkeSLXkLbt/c2rsE27CL4pQzhgo5fg2h6e/C9b7FU0Kx8dIWkCyemGLWmtzQWNX3eIva0QvftNhgavsVnXD8TAa4lRhfb2j96u8FsQF8e0Y6z5l3CEqh6+Q2WSxwth9hafDRdD1wrCHch2VnBgvZd6UocZ1fW6OFpXUtXbIAZ8y89qyXal3F5FktgWTg0oLmKnbbIrmy13LKu37CjO1D0t5q0maufSdXAhbE74zNcm5oH3i6Gj0/1sdoMgG6CEDtuV64pD/hugVc1giFX7zBz/64v13U4K9K+sEOuZkh50ufrJpFsFgA/Ivy1hCELtQ== 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=GJNf9BhDEBQw+QBjmIK43ZXJQ02KyxkOt212RsPDMms=; b=acDqjHsscYdRgRS1+k6rxHL6NLOBClreSxfZ9sVnRiHr5qCJLLsG0+AjgQfUiVmeyzBHAHAYh3cpwWcrgPKDKsyR5sz7LMYteC1YEzpEmW7+JgNTB7rPQyprIwXbWjbvUIaRoP/BtSBdvNOgvhtqSfKdAv9EtIwAwpRGBBmmz1k4HGhN3GQXFe3sLiKSudpUvs4mFLjD3ZlHMktROAUmPCbAgo8tNgOQmkpBb+4rRN8CMcjc9xdh5tx35Fwsi5ky1Zr1oa4ZAJlncDykTq2nPRN3NnhkICBT+d0qLD9KhAkrstv0K/oYYvc7eFVHiA9JcSBx4Dy5CYPTi3hkKFdkfw== 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=GJNf9BhDEBQw+QBjmIK43ZXJQ02KyxkOt212RsPDMms=; b=hR8dt4rqFahSat3A5hztYWEOH5uCwShoDEzwaN1ZUKZD1kNjI0JjBX9yj93brWW+epwezD28adqKpJo5qamiIBwFr5evnihCl4A4gyHcGCjcdziXpnd2MKz5GpS9STjMHBp36uAxX09QGpZaQOnYrL77KVaaQeRLK4tKP5CV0Abqs5VQ/85jc5NhMtY3GDfg8W6oUJbCPQaKYIYf99NonJRytx8HQl9yVGNCqk4EeskqQqysOAsxa8oG0fbEdlE7UAUPNC94QKiRdswrn2128O39UXU5Fb3UmGmCmyx1D42iezBs2EGtawMwEmE3k3KQ8Rf5Jp1BrokCh6EtiVfsig== 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:02 +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:02 +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 2/5] dm: add __send_empty_flush_bios() helper Date: Thu, 16 May 2024 12:02:31 +0800 Message-Id: <20240516040235.115651-3-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> 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: dm-devel@lists.linux.dev 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: 9af02178-02fe-423d-0bbe-08dc755d152b 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: HRy0chjtiArK8X0jhwlQ2a6K+uvXvVzlKMbG9GzI7BZWe74hEBJGZGbR8BcnHVIUxkFGRh8HgIyrHo38MGDXWQE3UmVmhg5t0IKMGtbq36r7/CZ121bLu/CuUOZIlgEt6SscB6oO7s070pH0LCdBnFu644UuPOEJ2BG13Rc7oY7ZE+I86Tf3QfS5N4oOmIhrYfr7TUtQyphIge81dTbJ57RMSgYhkTQNBiRr6b1B7QvwSzePwHlXjp4yTQLlscy5oe9H0lVOT9XWsMcHlkcWKt/JdSbQE731Fc6YgteulBPsDCm2/b8pMx6ISJXgAGLv95aVy9/mc6X2Q8+cpzyCQlgm3X8VksrW5xhrFOrYqvqXr2omwhtOix+cUJU/edzrIZLJo1D9iul3LMpXfCezlLInPwNNT08PoUAbXVaXV7l3ALEMPGFWhwg+D1huLzKtymJtdkjT/Q5xlWwdEKTKRNikbg0+d99R1JRfUy5bQTeCDGAVafIrTZjhONPNWkiIdCQtrsrIylyMYaxdaoylbfrxdDRcf7kFZr5rSk2iCzeznbs85uGO+fTGFOm4Bv9OpEQnx9S9If3DFugs1m4+Yez1kd4x/gu4cRe6e3OH1caBOBFGM8jpsz/e4UZjXKjUjcyF6/z3NKubGveTnAFQJQufOe7Rg02prRVOEcmtyzte0VIFtoY7h+ReuYu1uF12rzATiefuOVS3efiB9fAhNvcENpHIR1dslW8cDEwpKdNWXbZccCRrWxJfMvdttMLNl1sDF+PJCJqJhJHLu6bdiEFnVzjvG4xvuW6qsj1VYe7gyEPYxjYblWcCkl0bzKaeEo4792ol7XyzfMZJd33r1mEIDLCMxoN7CL1ZbDHJ4crqhqNj0mSuu4hVpOJBb7t4h4295IeSUwSKlWI06VaEQvwqWTzxduYt6pkD6YfsS7YdMoWy/tquNBeumCJgNtYpom3fJfFkjxDs/QvLSD7A2BB/pgV2+mo8YRx+uXS/XG66WKoXosFSF7+W+gv0aGZPl8J+GzebeEj+WIpI31BtTmmZrjxpee2pEV27/xfwqjKsglhM3ouePlGlH3OwMRHU20nozHeAxAcgo16H18EYm9xCvB8jTuNccoPD/Zv7q61ns22zCQXDfxFoAf5Ve44GVvz+fcpY2kksttH6/rpHkEgKQnY46HQ667I0rJStNiF1eujikf8iuJ7aJRxssLob0jTDh8HsLApksOy2lTx+UO9kuIADtBem4hc4+5tL/MNqeKr4h692yViMU9L9lH3o5cx+DPRypft1gIUiLBhET//NgJGk6YAQ+2oPk4zkmSGg3/B1+rn5/1Gx1Q1brFtbMGGzqgoa/cuxv35qWH06YA== 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: tmoC+OPnjyknlQ+qsjgJVYsGjTAxdXJF52nwIm79Fu6P65cJ7Duwookp1LOXbxDOvvsEylslLplxeTfd/ul0ChG+OAaUTkCiHilIMpby1ux5qwK7jLasPyA6GMmexPqajZVk78Bp0b+wsVMIfkjaiksrQMq5sktjTsV6tOJI867wT6wrOf8eCPKpTnGS0PCIt4PDFgDELTI+9s3u6f3wrdcgNAOUbexdeweQMzcWGz2cg7zIrNyc21rpvmEAcCNZ/jzUAN8MhPaJAzn6WaA2VB8anp+G1gJhIIei8un25Qi5I9IEOy3KCqt1TXGb/+PlT9VHHIll/4lE8X8pngY8swtmKNohk8H5qNhvd4zOm8gVF9isGAs9WXqlwL9eFg5M/ftQBOGV2xw+JJ8PplIQy2Asu9uWuLOGr4orA97j9COdnJ85lINcnRfDh/JtXggc3hE9jz/PPmSXypyhgkq+OSWSwEBOfFRv2SPhM2bGTWlRsAixgi90E/S9bTlipVLBzrCzgtO3Epcp70IG3eqkndQzZUMYh9SLLm7ScSuK5k9KP6CQyMP6Bp8UoBXYv8DCg5wmLccpaIAw6A5+L2e/WK/s+d8Bms4+wMR8cius+sW/Pp6ITI6zRo5M21c4Oce/s8qJqm0usDzFaKFs1MxS/MwXSmcC5EmBeZx9m40OPkuewXkkMrVIe+3xu8rg0+Nsb2z7BhnRqkILEcp3tWymHAeRWKnJuspEJ7ZXdERzYxOGggSm6T9GFrwlIK3NaLRurK/lpvYWCfLfUdbW3C4ExmLs28RKMOJA3nNXuXEPJHJmJ4p0xXFzHMihiakZyTQhFJNNwf+sJ6J3UxpRm7jyTOUsvbddbKFCykIjBSUR1BtBmExS1sKbPiIUEhouy5cdQWPsi3EuT5xn2tqAhNcEk9v4cFL0D6bsGYBCez4u6+AkxqctdO9bmJAJCwVbWgQXH3FlCETIaZC9H8rJovGqAxdwYQtdR4W69E7d8opdMLiulYeoZeKNA0tz+7MIyW5rXq3pVSQTw2WfECMo1w+wPb2UJ8QJRd2TbYV5svLsj+ieug00juyZYZshXvBPTVpYl1G9GM6uNDCRObZCiaFE97GeGwqsjg6ciUHfUjo/c60IQSPnA+2Qu8g0X5CGs5uTMtt6bCJ0lpu8hZ52hhNqpwePfFuqvFaBOHXfwnT9hM0bSMli+96YX/YQMUxCa9U3RnydKJd86Qp9q16gf28Gy7ajZELQjtQkXzFb0TILf/P12I0n+igeUsNv9NIZEYQqNjxeJrE7PfMKNsMWbt7/0HtOQL2DvZ6g+y4q0+CQid3LrU0gR0cJ4ylxJDPfuo/mZmTjZu5eCNgPxlgpVp9sGgZ6T2DPS9GMjICDYmt6GzdqLW2Q2vi6bMpg+vVXglT4XSMi5R8Nq6cuDb45IaahVg7DQ1rtvzroqRe05TIAT/Qtpes5Kvv3pYHlivQ3/gNg0ob4y4rc0HHEHPLKudOOON7rEdP7H8e2KPsZX/PDfGSKq1UljDVDwPedi2ensYD3VbmzciDBNA9MMt1+OBL2PgcXNKIdeiPpMVzDnDC3HtWx/P5Ll6ClhAGa6c1yGxx2 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9af02178-02fe-423d-0bbe-08dc755d152b 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:02.8870 (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: OvFOv1Wg3dEJcN7P/JnRcB2C5VLfYXA6dUr/72BT7Dlkz7BLVdEml0mrny6fSflkwY01a5sMR09lVkvGR44Xqw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 There are no functional changes, the helper will be used in later patches. Signed-off-by: Yang Yang --- drivers/md/dm.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 56aa2a8b9d71..25215b93c3cf 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1543,6 +1543,20 @@ static unsigned int __send_duplicate_bios(struct clone_info *ci, struct dm_targe return ret; } +static void __send_empty_flush_bios(struct dm_table *t, struct dm_target *ti, + struct clone_info *ci) +{ + unsigned int bios; + + if (unlikely(ti->num_flush_bios == 0)) + return; + + atomic_add(ti->num_flush_bios, &ci->io->io_count); + bios = __send_duplicate_bios(ci, ti, ti->num_flush_bios, + NULL, GFP_NOWAIT); + atomic_sub(ti->num_flush_bios - bios, &ci->io->io_count); +} + static void __send_empty_flush(struct clone_info *ci) { struct dm_table *t = ci->map; @@ -1561,16 +1575,9 @@ static void __send_empty_flush(struct clone_info *ci) ci->io->tio.clone.bi_iter.bi_size = 0; for (unsigned int i = 0; i < t->num_targets; i++) { - unsigned int bios; struct dm_target *ti = dm_table_get_target(t, i); - if (unlikely(ti->num_flush_bios == 0)) - continue; - - atomic_add(ti->num_flush_bios, &ci->io->io_count); - bios = __send_duplicate_bios(ci, ti, ti->num_flush_bios, - NULL, GFP_NOWAIT); - atomic_sub(ti->num_flush_bios - bios, &ci->io->io_count); + __send_empty_flush_bios(t, ti, ci); } /* From patchwork Thu May 16 04:02:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665709 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2070.outbound.protection.outlook.com [40.107.255.70]) (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 08F7317BA1 for ; Thu, 16 May 2024 04:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832190; cv=fail; b=VbS5FtFK40j+5X6j1o/Vl5njMRBlQ9FCLmv0x8oG4LZeoy7pXfywMWaY1UY3opYsTaDx0r77iQiztJcyX31YCpPK7IUmzvTBKccfB4Sehom5usYvvV8IaXMEdaCcHlsvmwNRMg5DPXGdCMeT1duyn2JeIzcguT5ybEPeeJm2tYA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832190; c=relaxed/simple; bh=UBfgroBIYbXqpoq3UbuWWpZnLNb0i848aCOeSGM3vk8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=IBH0h4wOnZBiw68B7MydaosA/Ofeya+q0v9S0Bh6NJO9I6HDdnOvc1QtKfwCmFnQ0VOhZbQg8y2ReTrIuYZFck/Y4Qzhs5tJlvoEqqD+p3ik86TNRyspARj5o64HK76Pf/G1Nc6m/K0ZMRClh21APZWXj9F9G/DGZPEBxvHZwYk= 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.70 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="LEAUrTbF" 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> 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: dm-devel@lists.linux.dev 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: oQOH1Xak63OTmggUHVHmofdcss2QSZgcsBjrucvYGHbxqqjpr3HJuMEnGAzGavcnMkcMpWqyo1GVaFY1r3Fi16trWAJK+lk5nEBJx/8X3snexl1Tt8hQzIsgtdO55hzYjpkCLlIWkxORp6QMXSR2YGZ2V5LzA+FPn6RUuz7XHKDWWaSHjPFA7IOMLWNGOCofPn0Ix30jSU7eXyhyYpoQMFOCps/Cd2SsrR4AKUW5f9xvb1Ymi5VfPdGQYaNLc4iowalUN42Z7mVVqyG8wjR5aej3JTCTgkE3WRMuYXXJC7Dskv2TE73uCqG9RTihKzeM2vC2Pjs/wZiC4voeyOVH4oOOG4Za+BdF4YshHuHkibZl3MKpGOwCyYbY6oBG4Gk4jLAuBeylvG7fJPjAVfAIclT1X4mQDWbTNCXOBz+G9YadcNk7PkhZam0uPPuNt9Q4tyMRFoOUu8HGi/5x02kD3Gm/ITzrJJI1Ke5mwhVb0Q5AanKl9+LmsM2VLcmGPJBwM9tVmopv1E4MLCkegu9bP4fu122mBKKnyTaeyYXZbTNow5xW3OGiuFAWAiTlbFTOC3W+7tCvZfoqVecN67KqCE/zqUQNMrBRSlin8QK3Jtuo51HpJyYHmYCSDf6xFY07+xaqdCZi+jCJ/oVxf07nz/LTIL+BOrQRaPp3Ywu07NAPb9PXBDxEivZJrgC3RKMr5GngXTW9oU/348c2AusDycMiBdG/0QmHpI/ug2hLOnY69sVLdW9KMHft5DjTfWUbuwUDI87yPHDpsarF5jm/fwYHaZDZSTwLS+N4ICEfmucqgHHM3tI+ucZ7eddSk/GTTpuUVSBt0bGbNHcyOyHNQw4nBUE/fFZDRMxuRwoiazruO5sHj0L+YZZ+RBC4sAp3z2GHUBWvkBVNX5LbXAVTGAeqjBQ2COR0oNNXuAiVLfHdjtYI99zZKmiKCAzk2ym2yudCLkst8PaxmKnGhEmVbbKH7Wh29RHGSdlQStgT50tr2hRH1pN44cJExYTULeyZQhLYcKOz0ou1fUhFtbhWy3wpvNO9cj0jUROqNWRo+ZnrnN7HRULbOYiAFYCXmSe7mC5yaZkkhsRZWngVEeTCXEBFza1e0ZAF3oyYj+dUMKXPnkTeGcJeGtJz8iphg7xS1JBG96G1CJvmSGcGaLX2Cp+3qwSK8SorQ/kRQ0IuaOS9y0MJ9FRLLbBAxFd0ikNdS+2VQB+hRFieiTehkMMIbuyI+bj1/FdIr4jNWXVFab+qsv3iuuJaQSxXjG/6pHRnpInArGVBoWqtE487LoywbdzKC67KTYoqvz6fHYr9foF5nBmzs2Rz1BubdCvbaM6iPUB3wnuj/i2pswtRrwkRCQ== 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: 2PuFGS7N0BL5D867EZ71aI3ogNZjwssIepFJ+Zuha5EeozSijboZjrHZ9kY68du3Co8q2ThzYYRkB1zxXDWkV1Hs5il4ESpPKcKA2Ml6O6Wtv6c/MpgJYvTjP6mn8pJQMhmeujIhENvPHNXyev5g1sN4YjimqPMZNv+yHu2my0VF9mHvKjM5onHM45m6zJGfYc1AA0FO/Vu8u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8W86Wxiv4T8aOiyWDgLPo2vTZWaskKekq2mJSVB1KfZtvaR29tuJEpor5sg3GOZX3jfHbY8YAYa7IjLXKffGCU0J8F3xrnNV9C1NC1sXu5hX6m+E4Q4W3K/4oZIh7fieygNn01OjbjCSOVTfOwJkVEjZfpvTrrypiWI4p3eZIUC9FEyRq6T+MtPXUKb6+T/xTBmP5QyoPpUNAVa589XZYHgB58wpHHhuBbbp5ihESPoD0t6WX9V56EqYEUCY5DJ9TrI8let3gLyo7wnrQqx4lTz7NifkTgaVUn7l5lqkA8HX3n75uQKlQmHt/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 }; /* From patchwork Thu May 16 04:02:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665710 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2070.outbound.protection.outlook.com [40.107.255.70]) (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 B821D2AF19 for ; Thu, 16 May 2024 04:03:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832192; cv=fail; b=phdDUbbpHE/GigHN7QZgo599p8W21lUEcoxZ6RyE5tcJLrXCOrLtEmkT7Ln5/NtIeeXgiMyp66uHeiEJ2wJYYmakvoaRtSrivq7UDz1sytAN02QDs2Yqv2JCKScezKsW1qui1a8UYC0107FGKkA0mKLVUwOOlc+MpgIH3SRQUhs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832192; c=relaxed/simple; bh=Ka0RlUPOcraRrZGtj2xqynrRqvKUIqfl5gHglLt+BvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=nRVT59XnprpI4j0IUa1JwM9HjpW26UZeaWnRs9fkeNJoNIA/ywLJMX0c0UX7eRO6dx89Md281qVrciEDI2wH8g7IDscj5JOZw/saRx7jm4i+TB35HWlUp56MihZaW/kmrfFAb8QvaWTr89ZDXlLZ1c//XPNAyCk9G0dlBQnJxSE= 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=V1fMd5TB; arc=fail smtp.client-ip=40.107.255.70 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="V1fMd5TB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IYHn73MYgEBPDnqEBrCrQVe4wIXYTxZoMDb0iIX55SL7SxtLp3XYlutLF/Ro/hw0GM3TOK9LGt9ByJuLXh3cdS5EcltQwAsiN1gIlWa8yR7q86xUQbopK0BLRcfKXSE0W22O5JjAouukSvOeg4zpKVUJCe1M1nKZ+0wcgsogaxGvgNfR8EC4r1RUzsxy1fXZi6YLMfwnNTGhOVIOkRdeQ7aMg4olHMZmP9v+2x7DHfg6k3Kv9aK3/vjy5MCbz7AKy5rJbiomXiSfeSvl8Hx4WDaj7gbN9gdmo8QU8cbiCrKO8lgcPch6rJLIdn5RrqeNGrxMrytxU46x/IGGynEKag== 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=IGw8QMlOkK53XoUQo8KmpkoyGxRrVd+a4gf6PImb2ko=; b=nKs5WdZzwkomYPS0Mul/DmPZJII3hnGM5ZYTHyiG7XSKo2pvF/A7MhDXznMELys5IscoPka3Q7k16vCDdPALLCPgRL21FXTs96gHzm+P0oua/tgGWSPDpO50utATtJRlCRd1VQAaiOYcVy7a5YBhfjc2Vpn1hq761zpvIX9/aCFHO5GPN2/9QKcKTewAJ8ATXfrHAXxahnOwiZjNfbvrwpqzdy+xSTuaDQHP0wlURfOfOBHUk/DPQi7xAMeXZPDiNm7bsCYpyeLuJRRRMUPxsib5d5qxtn6kOI8h/MGFn6KIB6fMLvJfJw4q6y6oqrhPn5lK/ooCNYF/T6lvRbvBIg== 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=IGw8QMlOkK53XoUQo8KmpkoyGxRrVd+a4gf6PImb2ko=; b=V1fMd5TBeEERok9k7hFMGtZlL5Q5clxT2+WMQzHnpzxvM3viuUWvMZHjSAMmD5AxLR9PN0W7gBy8Jpv12enFR9xWU1SRT12inhA/hpxqYtxCnVe7yTEl3bAuzJcoX6/sUAECQlk/D8MEAYJ7lXcyu5N0NzaOL1u7RWxZzVjONiMbasEdOSsTJV3JVcADwmgs30XQgbU/pEcsgV+GIPT289uM+4DxPCWyNwy3oNpuMzqCN/yMZZTK1x0yngvAC20NspaDdKfX3WqsEJxpD68iIKTdHdagWrmCZHzTXyInxFDNv0SHuCouWMubdgoTnZ1wRhIgThkQnoazyLn+hI9lTA== 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:08 +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:08 +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 4/5] dm: Avoid sending redundant empty flush bios to the same block device Date: Thu, 16 May 2024 12:02:33 +0800 Message-Id: <20240516040235.115651-5-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> 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: dm-devel@lists.linux.dev 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: b89b3dc9-ed10-43ab-ca0b-08dc755d1832 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: yhv6CWBVdzL/jByVitzlQRNMX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tfpo6JSX8cXmJFyqrMIK7eVQNAHgbJ2ZnR7ujW3509X8Sg6eiXVJP6DXpBrKw93r8JsJdqzuDMTOqYk+v8Ag8g1mckyKI1a+btb3qO1pwO5jagv8E93wcvX2pggJyB1HyWnNyIAx2YIXRv98HvfsMVvf3T/9PE5oBtoq/XxOAghY1fTfLPvW1Rp3aMA03Y+foziT8k4sEY84cyULe0MOBpDIEyd4ZBTTPXfLE5R+C7IfxhYu6HzfIscGanMaQ14+REFm9tJ9nDD0Mfg== 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: C0+vmcGrBrcHUoHV90iGBt6PLFd/qXcECOu7NXB6j1EJEYu0qx6EOYuGBkV2s0H4IyaSsjwtTlYjhwpu06mbxMcVBNkub7FP888fOCJxGGeuJyIOg8nTTB3wh+5Wch8k9mz3yn4kGHRhlSeq1/gL5N/XwEMH6Qj3spJSE2CtrDtk18wHi8NtR/D1b/LsNFNB1w8iIBL7nfgP8mYdGfEkd2khO93tKgvWijVXxMAClyNwHqXKD07LAr+mYAosLMyB9deRpD9vf3mH++uh/rErvNZgSLLCqJQzhqA65mnFk7XTChwwxxhLM7iKXr4gAp6HUZ7HNKZM++i6BLr9k2G1NS8mf8mpAtqC2LdgNbF9kOkjTenlIV62zaSJw0sVkbYYtprCFqFvMM7uUAxoPY5bTCghWBhp02JzrTGqbokDi8ak/4sn6kFgj5to+YeOTff7IZu1nJ7mNpvq4f04u4OZN+1lWI1yhKcaqDukUZchPLorsIwoaXUmFvnN6CCKzFHs795B3+ZhysE4htwLFQZgqxfilh7jan43kDulxpZNnEJlfIwmpv0f9HLIAZvSC4fgkjLeJCPu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-43ab-ca0b-08dc755d1832 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:07.9543 (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: CXCPGhp6pFtCw+jrl1s5RCiGxcrIuvMBU+KnfJB3rg9bisfFXPE3lACIbhgpk799qQI+91zmPvclQc7g/Dk1cQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 If the num_targets is greater than the number of dm_devs in the dm_table's devices list, __send_empty_flush() might invoke __send_duplicate_bios() multiple times for the same block device. This could lead to a substantial decrease in performance when num_targets significantly exceeds the number of dm_devs. This patch ensure that __send_duplicate_bios() is only called once for each dm_dev. Signed-off-by: Yang Yang --- drivers/md/dm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 25215b93c3cf..9dd0f5c97028 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1561,6 +1561,7 @@ static void __send_empty_flush(struct clone_info *ci) { struct dm_table *t = ci->map; struct bio flush_bio; + struct dm_dev_internal *dd; /* * Use an on-stack bio for this, it's safe since we don't @@ -1574,10 +1575,18 @@ static void __send_empty_flush(struct clone_info *ci) ci->sector_count = 0; ci->io->tio.clone.bi_iter.bi_size = 0; - for (unsigned int i = 0; i < t->num_targets; i++) { - struct dm_target *ti = dm_table_get_target(t, i); + if (!t->flush_pass_around) { + for (unsigned int i = 0; i < t->num_targets; i++) { + struct dm_target *ti = dm_table_get_target(t, i); + __send_empty_flush_bios(t, ti, ci); + } + } else { + down_read(&t->devices_lock); + + list_for_each_entry(dd, dm_table_get_devices(t), list) + __send_empty_flush_bios(t, dd->dm_dev->ti, ci); - __send_empty_flush_bios(t, ti, ci); + up_read(&t->devices_lock); } /* From patchwork Thu May 16 04:02:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665711 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2085.outbound.protection.outlook.com [40.107.255.85]) (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 0178A3E49E for ; Thu, 16 May 2024 04:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.85 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832195; cv=fail; b=OzB/tZb/SoPDL7XLCdT4EYg9p0ze6TGmJtqSuCzgBMl6/m0eqSeue2whl2PfDsvuKzcFkw4Il+TRAoMBQsCPrbBvHWVv8P0hBI/z5pLnSI5dRKt14xGzVTjLEIThLkGMJjZhOmVMkuCg63apfGkKc+K8ih8Ffcc1ribO2LNs4Ec= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715832195; c=relaxed/simple; bh=pPWvRKMPkRY+EnBmIi6erbgSwiPgbkjhyxIFZjHSVZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=E2rvwXMEmXTLppsdBcPRgzuc6YuUKdAO1nMlB2pB+WpXgjziIDqds4CKa6/+FKnU4o3nbfdIypRlDPScHZTYNOtLYoUk1d4mYxrNXjAf1Bf+P2tTMkjI+QGPg3aFIXURD6QS3owrnRTL+X3PFd0/xClZyQFjSWx5FUIWMSceUdU= 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=Xj6oaKs9; arc=fail smtp.client-ip=40.107.255.85 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="Xj6oaKs9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=diMSQDWAvcO3PQTmqbDHgtStmSNel63evlDswiQGXj5ym/I1ft65nSL4FubWBP/VEKBsf2JcPofskjqUaqOKUnwnRUnfx3jr+lX8sZDqDmSvnxW4OKwZYLn5mwJHfp/CI4ff7EKA/CC2b6Fa8ZxqP63U1c7LVrnTOPcfv+BjF6+ZkAeUyZhgDn/aWVuw6W11csS/xA31DJ+oCilIUaQwePbQpvgRrFYPenNP1vCZ5f3tG7rG+mvifarzMjx9uVftoqOdV/W3uSvxGS79Bk5bMZpacgBls4UunRHTNAJXhleO2TxPEuJ0u9B6yujihCn7a2qTDQ7WGSgwh2f4a+kqTA== 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=BRt2mpHtqBUQEwpYTcZxeN7e22kn1HBl7EsDYJP5O38=; b=UIeJsBPtDPMga2eTW8Q2WtGzmViD9lAT7ycs+SL87ihUJpjSJuFjLq81/soiZ67dbwgzUYyNMK+f4M3FVVU30LWWvWO3McNgJAfP+dIaRZG2CdZlrqVasTwovnFzHCNk+ldMhZUKRBFAmwmLVyJ91QLE9FrF1b1ZzlP7+ONPqLNfFTSJGVm0YxcHwx4s9+lbX3fq1hgbMJBt0QA4yZCNp9v+q3qmOu0qK5H/CNdznRfqWG4u689UBCCaNMi4kFJ5BjuOfiQJTwuwWHhiIb/64WTHDdd9u4N6wxElqOV2w7vMy368oUEqRPFLe93xC2sDLy01AJNXDFF5+meL86YHrA== 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=BRt2mpHtqBUQEwpYTcZxeN7e22kn1HBl7EsDYJP5O38=; b=Xj6oaKs9QcTKYF/jK/GDJPi2+NbeWL0MfImlPncEWk8n+ndjSIUNehev0VGQSvCx365xeOAzH/qESFfOAz1ORwxdY0pRj+XFn3a9m1TlvQKGToYNWnS0lHtJPDKjjcBwbGYjC9HuyF5eSWYWC4147Nus6GGE4j3UUI2fvQtF4DhR34T6agToTY95eGGPBCg5uTA7GIBDRhvMr5Eep+j8HPRZE5Mmn05qrd0D+6oG5jkKtZf0JapwV+u/aCEp20bAL7cshmri+gzmLPRZYykOJfr7YOdMb8jcxRoNCTi+dClxYm383Wvwm+t/8fmIITwACGCBMwfHQT3WNPi/xZ+BXg== 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:10 +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:10 +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 5/5] dm linear: enable flush optimization function Date: Thu, 16 May 2024 12:02:34 +0800 Message-Id: <20240516040235.115651-6-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> 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: dm-devel@lists.linux.dev 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: b55282d8-3641-4abe-d945-08dc755d19de 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: Ro2YuFHn1bkJC9Xmajkui/McbYeJ7gqshFqOC1ccRZqzy23xlpLr4pF/I9VLtAffn0gTBYgGkxEmZ6w5wd45MMDwUiM/V7dI0gn2cPTPB0qWW3rDDBcspIDAMviWqXh7PLHWYTIHQb2Y2ptwHYJcg/8QoGKmvt7sWmUJVDBrRPSv/f29cD9VObH2pygHDEwSe6IF1v3U4HTN+7S3hS+fRdu0W3hiX53lT2s0lUZLGSOazqO0JBirwoGnb6jvfBI+/zFfHAskWwuxVHM49kk6LCm+xtO29O0IdzMNt4v8Z/i6fY1vRe4S6DnpvIfMXG+M+V88MZj0a3eyeoHkPu3OjNf/8EXz9OmwEi8m0jbt1rnZ9BHfI0bAQpePOGJJtR4ARXE6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.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: FEISBvIKuXMhCI4kcbj6uN9QzQRVKwofGsVYzIfA7LWcA1UI9MtZOxVqvL+ZtZLkL7Q4V6f9KMmcKz5Pwx67Tl0hM10PZ6qM8ATAQQ43SppvVxZkBk6Zvp4PfBGFKyvL2U7kRQPitHgACIRQXmPNAhTeseo+n3LPoi8nnv2rAQnWyf0+ruRBwTsqW0siKA0lxjPoOlaKpNsAuXWiBGotajD/22up6KB9bEl4hql16MaZpYSSeSfAtyYuQDWbA76LHJC6La8s+qPIH88QFqATg859xusqohT2wLqxaBgHhK9imBUf+FluuTDiO4bVp2CKgiN1Zr92Mbxeu5dnAnRPHEcpYzfhxSJr9FLWxUe/3b2jzaUHglw3PHkqDY1Z+vDUbuYJGtZOaFqKWVHsMC22lHiEgSLjc1fe5Wkjkrj+kyBrQtjrRSOmxKYqJkpJNgMXFn/R9YFQ5N3SpWUPhvYYVxYsVh9OUa9agEEXd3ZACfn/+HIqoklncKqti3D2SCJ4124LjLiOaDi/AHWsl8gESD0Wgz0x8R1qtJKXdxC1Rn/PBFfaxlE1f6qCJhaCIE8fpdPbIzaK/f/OpoCe38NbBtxkc3oIUeHVu0DQc5fyPIIgtCMHrjjG7bzvTyhECev/qY/8U7fjS9U8o/A6LsjDefoxqmOMrvzZvZH+8SHbypV7wxZGBlqVjhnjq4nsz0OI516gBXNRQmRwoT3D5HFtBnnU2ayir4Ee2l260AKAeQDi21HaTkiAnndou31SuwSCPlBWq4Z2CACeqq8EcdcQGxauZtDIKJFX3/Ahng6Gwt3I1H8i8QGp6JWfUKjhfaydbhv78P5UIb0gzJPrEWOlYcoLzBok8rtwDrKdi6S6vxMkkSzMDwzpuxfd/qj/v5lewNLfEdYL+idLIB7NeQKcYMm4kBuY/zBqp2ktLHLTDO073fdL5pK3PQXZUkhfpJww7LkzSkZ4+uN2W8S4Tm3O3Tfie5qkoIa6LlogGrRW6nKLgKdZkdap+S/DqC5HsYr1/PMt1cXg7Sv+plxAXJGnW0q15v9oBEfrxiKyiipV3X6u1xmJovSU6SNdUVxv4Pp/guNKNV3AHqKOE3gyHQR2vUNvwMYGupZc2vpwBoK46hXCL0MCkwlbBx6IkgOm+1wgFieXgCPAvjKsF2RxzWj4+cVwiVNtcTrx72WiaCMpy7SuJ+GMnBRxBKtZo+IrLFQNtbabIo7schkrb6d10pnurhbBW/lM0Tf0k+/TV0IleqSRjBzDe+NSK8ij8nOmuYN4gxv08KBkEVaTftCLIqNW/87huAlF2XRY8lrTSvhInxyhJRWS+trtxm71ZnTll6isd75EnTctQriCGQ4STvcRC1ZGcKNmNQMba+vZkjmUdiatywM6liYZnur/CLLpFQ0AyYDhs5foGUMCy7fdykqa4Uw7AdMBETORY4jfNeaTrXfzieh1uDc2mNObYERMi7QX1PVAK/rdhQQxn693h+TA11J/JQF3Ks3BgHZJnuRZq3rfkdJSuL5HAqOHLA2L8gV1xJIPFEjOBFFOgmqBcXrDwLLD0V9Z9w4ev2R80pTDlqnCSNO4owPJh33kfcPyhfww X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: b55282d8-3641-4abe-d945-08dc755d19de 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:10.7652 (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: 8T2KekCUOq9JoTndhiNvgS57k9UpLFQPcxZw6qvZrvkP07lh+OlnNVKk5G4eXilhNCDfBb4jEXNFq/WeQdP5bw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6807 __send_empty_flush() sends empty flush bios to every target in the dm_table. However, if the num_targets exceeds the number of block devices in the dm_table's device list, it could lead to multiple invocations of __send_duplicate_bios() for the same block device. Typically, a single thread sending numerous empty flush bios to one block device is redundant, as these bios are likely to be merged by the flush state machine. In scenarios where num_targets significantly outweighs the number of block devices, such behavior may result in a noteworthy decrease in performance. This issue can be reproduced using this command line: for i in {0..1023}; do echo $((8000*$i)) 8000 linear /dev/sda2 $((16384*$i)) done | dmsetup create example With this fix, a random write with fsync workload executed with the following fio command: fio --group_reporting --name=benchmark --filename=/dev/mapper/example \ --ioengine=sync --invalidate=1 --numjobs=16 --rw=randwrite \ --blocksize=4k --size=2G --time_based --runtime=30 --fdatasync=1 results in an increase from 857 KB/s to 30.8 MB/s of the write throughput (3580% increase). Signed-off-by: Yang Yang --- drivers/md/dm-linear.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c index 2d3e186ca87e..3e1a33b4d289 100644 --- a/drivers/md/dm-linear.c +++ b/drivers/md/dm-linear.c @@ -62,6 +62,7 @@ static int linear_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->num_discard_bios = 1; ti->num_secure_erase_bios = 1; ti->num_write_zeroes_bios = 1; + ti->flush_pass_around = 1; ti->private = lc; return 0;