From patchwork Tue May 14 09:04:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13663881 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2051.outbound.protection.outlook.com [40.107.215.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 8F9942C85D for ; Tue, 14 May 2024 09:05:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677556; cv=fail; b=p9t+xkypvj9dcf8caUNmoaeYCD4w8JXCVlYCr7jsypcCCyFBCLx/rPRSx5ucOUdRWD71tu3CjimPdwSS2QVBNaRWTZziwciMoAqXBIkC4WyNmQnPvME2ymceY7x7ziPAdQ0Td5bD2qJpDqzKG1xiNr3VhECFUEGi6IlMK+9uyIk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677556; 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=tniq7SDUjcfD8mCRFBwDNug22FEzaB6GeQmSfS5AXN4kiiZwlWwGlpRElO2tJ7VUkn5Ls2DSwsLNCq/wHyRfvYmJpp2w+Y/bjRq3gbFaEOxgnUWRPuhKUi0Thnvv/YlIC4m79+114Ox1pPM0V/ie7To7zvDzUo3ZgzvKLFcct6g= 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=LM0rILLw; arc=fail smtp.client-ip=40.107.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="LM0rILLw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eHGgdT47Bc+EmStViV7mEvGWa0jxcqzPeFkugI5ozzD2JZJwmch2aBUSM6F109Eff9nc0kMA0AsO3/74lLY7C3rQy+ZFe8xTWmxlBi0DiEnEKf7gUA66tUkRiBs15gcVK9N7IoT0uGo5nyQfKRzTAmAqRunF4plovdTbvCJlhzqlerYVwizYfqbaJb7kHKPPsJ/rY6ovncdE3KSNtEjFiOHBCF4CVzyWjfQIWGjLIyLvl/087RFRYyiI6XuF/7YqCHhcG5cBOEH4LRAlA8KXfK6zy6WGKGGiGzCoSx19WyGyFlHZtS74wPpBKZ6Nhbys6kU+zbV4n9AiRJuVmgoO2A== 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=Ykn2MKHRd5FO4padJBdLALtEqtcNJgPfxfx6Rj2SLJxQZHDzwizDfKKFFQM7LwoRJeAcQrFXNymTQ/cgCW9Y99Fj2p9bMBbg+bfdkJ4bs35In8V7hkoITxeljtzuLAzD4Rg0ZNO9eUE6fAnWj/tl4qb3F7vil6XyzkgQdZnaNm12t8pr+fjLoiZemBnHrzvvnSX94kVr8g5zxaYtQSjqHXgb26Mv/C5ZKDN8hgXupV9LtN9VV2F3Z/32bJIUusuqL96+/9OVmeyTz1FqVAXMVJrsM44Ly/IzAaSV5uMG65S7hX/ErZd8D+XPjLXZ7KHp85bNWRok9YaEEx49Gp/VfQ== 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=LM0rILLwbzyJVUqPcDr+ciRyku2jtjYt/jabd49siiQV2QZmfvsrYXAIiq5QUoAOtHk2ApKHWJC+oqOhPMTp2QIfSv6dG6ltxCIz6s0j1qTWTx8HlRz6+uh/pt6leSgFnM7MNC9DGB8gDqL0EfoTMBPtC8d4ikF22KRI5iXkCMv5VK9dUlIj7Cbyjv7nXJC/eWPdmNXo5E6hl5ENYmDy5QWxytnOx1a+6hz2BFHHIoklWwV2Z7NOZi0JnKVYpSyaB2RSrxywILXctmtmX/o/Tn6auxuOvBekuWJfoVNY/68JpCOfP9lFg7j2cjxyzS9cBHZCUC7mDPK+QN0al2zTkg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) by PUZPR06MB6102.apcprd06.prod.outlook.com (2603:1096:301:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 09:05:48 +0000 Received: from SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e]) by SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e%6]) with mapi id 15.20.7544.052; Tue, 14 May 2024 09:05:48 +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 1/5] dm: introduce flush_pass_around flag Date: Tue, 14 May 2024 17:04:40 +0800 Message-Id: <20240514090445.2847-2-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240514090445.2847-1-yang.yang@vivo.com> References: <20240514090445.2847-1-yang.yang@vivo.com> X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) 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: SEYPR06MB6398:EE_|PUZPR06MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ddbe501-f402-4523-fd93-08dc73f50bd9 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: tv9uyUug7qbgWIg/WUd6y+j15lmemrDBtfeFb/QKE866LtICExhC7F+wQM39QwtUieO0PNuQxfnJxTUo2QwhO2zPlSwg0P1j4fx4QBCzxavS1gT5OxX6xvE7QpmdRy3FgfDo2PWb3LWc6lMC4u3/LN7m3DcH2DDnblF2h34ajPzS4UiEFJTeddEgLYceLNTJhKGTNoU0XB2sjDe6Vs2XT/7lGxTxasZn/ppn833Jkg6DXanCNC015zQIi7rIy63yMIESEPw0udGN86SywynLKAgoGc9OlIrubngnI8E6qur0ueeRGshFYHViB3QDFUugjPAeDXp0UGy/YsU5k2Vp6NGOfZWvCYcZYRJfY5Ft17qh751hYLL+slfZttFsDX2c7eUokotZFg7UGB3nmMDMyhnn0h2XLbJlOi3MUnFWZii1gBgBXA2IqRR8CXUjE1LMrXUoffAR9r9VGiPb5k6u8N1Tq4/VtFLxzB1H7hzIZXvnl/R1FFexJ/BbSvnYqFE/iox7AqxRCaClJZlrI2idXXEC5AMNE4vGVHpq4T/75q24lxXx1OH82xdQAPHxWAvuFsGN1dmn5rk8mhiDUIackIb960DFS3wfablSFJpJjjprO0RZEOQwb6s0WF7048XKayVm63w7Wd+84eTZxWx4ppsO6KZ2iQWldksmgFHsm/pzpOMNv9BBmtfPR99TsTalAFfHtBgY2DdnnlgLQvg4SJ2laJjEc2Q/6WuyN6G6BkSRdjVqE/FASJcLQBqykEYuDD4MfzmMObzpo616F9gm6pyeFXzRaCdKg84tw2l2ygSReqyMCo5fng+6q9qYCm6/kkwxR+laLdDexEW2oOO3ruWlqMdd3f5hBED6RHmjKrvxbKjam8GFCzL1ROBDscCqklazmPD04aO7KFrOQSjpFddJRWmK1vSrlVLnU4D5brFoICbgowBVnQZjT/inMgwVXBLgqnDkOAYtd4qo07TiFyfjPYlUzjcm623Pfu/EVDBDfCkq+Qt4HYEl96wrNQMa9hj2Ntm//CHRgF7x3fotRmnjxU9st6nyl2saBRWrttOP2cPzthZiLIgpsLJS0woshfGaGMJswxWYE/mfDVyjbpATAhwVvjmz4kmncHBXr0J5vRZHYMpwWHTEqbVoftalhM0HD+Yn13Tsouz7jbC74BRM75Y0yvy6EYspFOQlf7KT4MyTQI+pMYkHkj7qqmHmENNe3rRMZoricl19RvNuoX+i7sMa9H36Mnx3lIkSmSVLtypxSlyT396Wr852XjPhCUCbQuZdsXCrDafitaXbUz3sWrN/ADEG1jIHN0SK5KjxY7LLpvWUu4cshq/wwxKyiaTWsRAY41FXT0B3LIgnqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB6398.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chunk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25ImP8ruS38H+p4TPBWjxpoB/oOToUuL7ZIXNsTdVeOBAL68JuMZnoKYV04+WYpGhqQmQnOZ29Qp86Szy60GAhLDGAhb93b8G8bog0eRFknZ7I5ZwxCsCZM1zChG1Lwlpaj9mkmNkGJDmMB8gUS5mxLJYjM+3YcSSgfslcWnCBv8TdUqEuASeZPRPJMNT6BeWnMcwDER9F2gzOU8FItXq+8b3J1ttd6pH56mCJxfMHpHQm/f30Yv55CV10IJtt5xI6vGe5YTS7K5OjCw63W1sVRq5fH4+YMXopH8mRnXwFsiuotaRWPZfPtksW35nVrW+qexXS0iMU8lqGTbbjRrJT/CH15cu6kIODcvj7aPCasFffFuZ8g9G39s4FzpDb3yQJ08OlUxDvc1Gy/voTUAjPB5inNmXkYsiwdahgyT17tvT2UtvZFTqSvQQtPPPtZnyKoFgq9JcroecJhQ6WUA5u6lFfc/KCPwf8ROgBSCykZKsE+12ERfbR6D3Mu9EVAvbgt6fadfE4YAx5rhXxo5/QQF5quBQQah66UBh X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ddbe501-f402-4523-fd93-08dc73f50bd9 X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB6398.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 09:05:48.4485 (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: p1PnDxemO6cYZHZgitbqFghnwBTbiUYj8bi3t1o4Oyv68Dyv/fHIUQz1lNyKDZl1r/cnP1Clwis5E8lTte2MZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6102 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 Tue May 14 09:04:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13663882 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2051.outbound.protection.outlook.com [40.107.215.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 69D382D054 for ; Tue, 14 May 2024 09:05:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677558; cv=fail; b=bZH2D3+jfAZbbMKJFsWV+4L60USgOVMbWEW5nHLlpIfTh9lF/GeM5Iq8cKC4ykCuW92PoKhtng/GANs5ixTPexlaqK5vsXkyUuvRZQkX7DuqkfYd2Gm/zwxmCBkkSUy4YrAFQ3O8/Xo0L8TqTgmpE1Gne4u3eRcLOJJXCIVBGK4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677558; c=relaxed/simple; bh=Dd2Ne+wYYQlf67SHMr3G51DSNztSqYbRu48pXFAFIJc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Po594MCKm5jQEbLU95LRMMBC6a7UFFBruYopr8jqPO3uIfxXqfcFeq5ZOnsZsxvpnKn+hNBb3i9INkF9bsZ2Af4hrE8Mlq3aCu29OT0pQGnxWNWQ69HrmO44qzCig0Dqt+JNIFLBO5LbpbqqC9DkEgbVAZINOjf9z2SpgEBWPTU= 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=f6aUMyaF; arc=fail smtp.client-ip=40.107.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="f6aUMyaF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jUFzOSAvVX6aVOpLKyPyLofAsXU7JgaqUVqhK+nC90xcVAJ2Vcnlt7EhfNLh9FaCLFtcPnsa+kVeAoCHsChf3Hb1Ogp3oIaPc0anejvMQ+w/QRVJQUO5mBaaqrxme4gQTe76F+L49pJ/SUqfeeIBjRc+pevojhmrPPHQ05m8x7W20wOKJkoZsKJLpNrz6QQ1/RIuySIecWBGyj0l1KT6VosPVH5bhla22raHRCRNlVhh8hUh8HudlmzWvxxVz8VBPmkcmiPpaJPqzWReOrbDGt2ZDDAAGF11tHr9VMLe22mMStDisfxxvZT5ypq68jXQFSZuKYua/fuYxG+V4CaFvQ== 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=dzwAxpkNC6AaKh9MSp/gwe0fT4oQIrDkGAdnwtSO10kEkX6AEV64Ng7q5xbrHsn+wZIkDRyWxd2GTCeW8zgy8E/tEBKYlQPOR93rWZsNnsuu6Ja4umAvkqPfn/wQ1vwV5J3yxNXb1WM1O94TJDCZkEg5sm0VD8n5gPhWivPlb8b93G4534vSgXV16dh5STtqOPMpksSkuPRntzWzbugHoxEXxuoX50wbo4Eu8OWnFimedsGv/EUbbxcQDC8MsXS7p1uG45uxUim1tGEZYtesay5yiP0W6ceZsAbo0MVnwCZffLE39hg8o4c/uzhqvtF4Jil0D7SQy7BHaq2ktzXFnQ== 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=f6aUMyaFppsmccqZJbOELNbcsyv8pPTQ8W1dPmlR5Lac04n7szoBYIRzrGRujb2wgefBQErBKhsNBaxVQyPEjK//3SVz0CN1lCrAMRRxY1B/2Xp+x5CkDUesPn//KysZu8BV7utnzkxjgfosDN38hi3iiL4f6cQY5XpGkbyp42TdHD6AN+027cEzlcN67BJrY8Sn0rFLHj2h3YhwBFpH72tNBtf9UTP72qlhuvQpf8SQqJP5XvhbTxH5oYn9IJo7Oxjn+OoeRpnZmULLGEcFdDdT4bwgTAqjoxp3VBGp5QF0wevASSdkH6DRVGATNl/9TH6fWik34g1XAkZfT3FVKQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) by PUZPR06MB6102.apcprd06.prod.outlook.com (2603:1096:301:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 09:05:52 +0000 Received: from SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e]) by SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e%6]) with mapi id 15.20.7544.052; Tue, 14 May 2024 09:05:52 +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 2/5] dm: add __send_empty_flush_bios() helper Date: Tue, 14 May 2024 17:04:41 +0800 Message-Id: <20240514090445.2847-3-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240514090445.2847-1-yang.yang@vivo.com> References: <20240514090445.2847-1-yang.yang@vivo.com> X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) 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: SEYPR06MB6398:EE_|PUZPR06MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 8690b0bd-e8da-459b-2927-08dc73f50e53 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: mPXI4ddRs2oeaaFR+COxloOCSzRo4HV/32WMaNqgzyXGzKhnCXSEvEcI6RNbDQ6ES1nclXxCre+hz4NMmNTtO6kURWoVfKpU+47WOnsxyEWfkMNb4SZ0PWxGvP+TOYcfjzKABpFYAsuZvtgWT5jQcfPusBxGy9qz8r6OM2FS0UE7LZZTAt79YsQ0sXEwDgmvbNBvY85hRGJAclhYCKtd8s1a/OlRKqOAUaMajSxnc/O8ebiXTpeLFChGhAwlmYScMq7y//iaN82I81DYgKqvy70cZbkDcGpEigkpNmz1eQiq4khGccBDV6ErkYwcV1a/iBEgB4o2jLJYtYWVOi/pZ7lXUhP3VFrrA8qq/gaxwoGBOeG5ytn66VEYY6SnEBERcq5vSZ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ONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tk7rSAqmPfWkIom1RMLyFhuZUjkXlIEaq7FF2+m7opIzHcy4+blM8lYoGZOiccxEf/k5AiFMw9vdPzV4l67Sf14Qi0wPwmlFAy37N523fnCCeXtG11BHtvUv7eKR/YMGqhx9xqIWeE3S8jbj83rsVYQZiMqx266tXNC6ekFfqfvFXJXyeJd+TVJRVtDBbj4ypnPnBIS38JrxTZSTz2NLGlVX99eODJ3Y7gsjr6CmIGHndZq2KKrgtu+I08+Tv0KF+eKN86bxISWoI2TkcKq2d9uyVYIBKiDO8aXutOBjT0cNGkcVWR7S/m8Yzr9VckOfEJYIPjjxya18qOQ6tpSVNEXBM+V2ewl/H8cVVLnzq2GxBKCAMk81gr2YI/nSjKUU6M/QU0r/evJlpV3h3OICBvk3bHbVgLmb/FSJAwqlrhaan50gV81FoL95yGRgc2Sk93F+2GihbXXJsy123HHSQZsfYkb46lfZYZlNLv3OBNS+XJ+21+EQuabgE0eFLZ0EnYxsMvgqVCC1FYqrag2hxBVIN6SNBAnQYWJVX+jXxuJZWPaKQz90RL0a0hd7RmjDO2fSkr/6OBstbQ0WkHaoO2KKtLHTexqywTkUap+bC7UVXMTjF4uXIXu6pRCoM03gdgHp1lWYpAZNIpiUW8RbYuAlhc3eEo3lMOE8/DL5ATY5kt5ihVImLU+jrx2Eltxt9KJvdhz28gDdff1qbOMCGtGU3FDo9/FH9cTRxMOjHtniKPRaRSs4xsEGBgGTDhTO6kTgSTI7njXLRVQRRhnU/4NY3L9UhpERbceTbPAUtol01UwGQtusJx1PDiGZu1nwN2FW/3W3dl0YXgnImSp8Q9T9EXwgiDz7oRzERwYtcH1Y2pD7HJmLc43izICOZxqmATcfgK5+EjcVFsqNcSrNQuuyXB94JNvtb+IoHBIP7GKMwkkYmHjX0nhUMp4kvo9x21a/FfVYu7dqrrpKcxc+bQZmhLtGw5kID5Tfg71nCOjlp89zxaNHWqjP61ACASTdElcJJ+CcjjZ/bMObNAHC9WkIcwgzgT0vpzlx3bp6Msrv1bZOExL8nTMDrIB4w9hUmkfA2rEFp1ZkonBnim9a0JI+2E6MpXFG4FwqKvZjPuS927tXLaeUs7Y4ndOW9xWU52GVJlxdu3xJ7ntJ18v8aVNoDzwKb17IX8AQmNQqFrcGxWk6hCrwwWcjhkKrO+8um1chW/Bxu8DznIgkGRuRmzwJDRwLmaKI2LBhsrL6/uBNWBJNunvGo0/EEEFcbNBXF6Hii9v7KaTP02Qe8GjsHIEAiqyr4BMmNtasyKnlENLTGAOvqUM+ZFrpJ9g21DYbAKM9AnFrf5uxeaZNXVmjuFP2GoU+YDsx71GW6dQu1f9WM4qmdP53nf2tglxf4po5MZnk9l7eAYpOUI8rAEPBzO49dvm59N7J1ipPG8K7nAHCqUWRMFYK+Gq1yLFlqno5U6Cu3EGn4/+S4OC7YrYEFUIlP4x4cyDOiP37HOGZtHHD+QbQzwDV7Me3H/aC/8bKKMHVmJK0TdrputodY7SMqWZjPwOxssRx2WfJbQX3xTptGHTHnWLh59SarzibVUe2 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8690b0bd-e8da-459b-2927-08dc73f50e53 X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB6398.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 09:05:52.6184 (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: 3GdhOrPvHV4qsNMP5YQxnd/40qFnqQsSWyFL0e43gH5BG5gS7CL0uRBr/b3rSa8gQBNE9FurT01Jx4zEMYfXng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6102 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 Tue May 14 09:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13663883 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2051.outbound.protection.outlook.com [40.107.215.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 6427336120 for ; Tue, 14 May 2024 09:05:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677560; cv=fail; b=laJw4xfyIHyOoDE9jG1UmjsmM86IGPZquuM2ZsQ2IMKDXwjJJKZSHnYr4nmPJCGlMJtinOJAyrGI10AJ6GtUIdiPmOe9Yo2PzoRgRAYJx++iva8fJDxiAJ5YsIbaUHr/5qzym9996/EpwTCnnfN33CZB0cVBPyEav9O6IVfKptw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677560; c=relaxed/simple; bh=VHZwr8tNtZIJf0LYeloQo1WBZMXdRCsXX3k+TDqo7GM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oywUSnMN5ZGoIR1odF7AG12H1tS1OwauH2XP1SJCbz+39sijFg8wvtdOv/xBMLMWOFfSQS3ubm+f9IRKVQsyO6TIUsg53df8MFDmYH+mJDHJRbc8bmhx178DvqOuINpbT0B2WquR2ERnnZRzFg2XJJBu+38l7Omg6IJ2r5pcnOo= 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=py3ShVAw; arc=fail smtp.client-ip=40.107.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="py3ShVAw" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NKx/1AdCkuyEC62D9tK8KGiPLQHDKq3tE/q1j9N2maKMQt5EEwR8JwvZpejzGOdOXzacW0XNadRVLY5ps68RJPQTXEYZxVTkhKp5Yjc8XJT757RqchiXbqOMzytkDMIvP2O8WDgPCKbi1RlZUW66z9c0cqCP1o6gzFAArCmchh60pGMUsBreYILu1t7VniemXVuwDfxrUY4es71npedRf8HO/a+D9+C2rL9WJbk+pOZLvLY0Aao59yip7fWJ0Mf3bDHJLRU8WhuavYy7pnTrmltPdVOe/aNOEDNVoefUTfohCmaeth7QMZbBdiBgvYDMzhNSlEXCqBDZDMPQlZueQA== 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=nIEas/sTtxUKYLg98jqka6RbqrUbl8OXP/nhpbEovzA=; b=E1VJ+llqwKZXpfxuy+Sg2YXldDcFl0Bslvp0PZXP/Q8YXEtj+taR6yMqzhL1sozcY5J4siG7hoXizcmE/CLU/S2FHUa/Nq8nQGB0jpiMSLVWo6zmix7ZuVEkbdAAhyVAskHUei1t64kqPqJDlminSj17c/U48lASNMd8Sb036D+Nmismdqrxx8EnqC0JWHpVc2ZOoTegtwGJfDygi3UI5WBeSYdqt0Lqs9ldLuJnUVxYtTqJAsdMD2ml6XjTKGjZ6FpdaIR9UYZ5JgeZ6Ajn9wwwvcOUIUzoV8W6JuSL4I4fFA3UKXlekbEj3NeuuLP5EfjqOL3KrN2Fd7BMigXiBg== 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=nIEas/sTtxUKYLg98jqka6RbqrUbl8OXP/nhpbEovzA=; b=py3ShVAw/tHfyBJCT8S9Nk5hiPNLapifaqIfLVEIyJiN+GP/fpx6UUxiIeThyQ7femPWH/YEy8Qcjm6loG6FD+mAZG+Nog5/AZv2P7o+o6oR03cOXHfrl1eChZpigCr8buLIYnwyw+TO5/2DhnrNHTngcFgUAdu87SV28DFskvFp7som3L+uPCEd4WrHfzbZcX4fv8Z0LISrPDoiDX+iNV8JDid6ApraRj+ZvUuEbEN5X1KBRwpqdfsbkFi3PGlpItWM0NF9SN7ExVOqFLMOgaq/zA/gpLDmoJBZd7Sfau/kGYX9Gcb2uln3KLA1s2xX9D3x4m62XONUUZM4j5Ojsg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) by PUZPR06MB6102.apcprd06.prod.outlook.com (2603:1096:301:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 09:05:55 +0000 Received: from SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e]) by SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e%6]) with mapi id 15.20.7544.052; Tue, 14 May 2024 09:05:55 +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 3/5] dm: support retrieving struct dm_target from struct dm_dev Date: Tue, 14 May 2024 17:04:42 +0800 Message-Id: <20240514090445.2847-4-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240514090445.2847-1-yang.yang@vivo.com> References: <20240514090445.2847-1-yang.yang@vivo.com> X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) 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: SEYPR06MB6398:EE_|PUZPR06MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 01a95b6c-f61d-403f-a869-08dc73f51033 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: CC4KXHZ7tk6bPHvxBA89SYsJ26rQ5/sUzCuqBzxugKafRjh+omuTLj1TY3yllg/qkAJC2dGVShtQrd39t8blc6WbghTkZjvlDx4l3mfVz1CKjRiqRrlK99X3s1tqw/zRNLpJVrKxuANlYwv1pq7MwgX8XduwwLLYUkvoDwU9bzuKf3lydAGuzqL6Z4i7ZU2s1ObFQ3WJlRUMU8UcIOpyxat4TJjdZdXaSaBWNjQXpi91qvXejOFshoEfOHWte5PvlLNSZ9fOgTorf71wR5kvfTupx79rIUmapqyYTFDqVbUxxyD4zD5xx3EkORrzYfMGXW6CH6JqLlFw0/k8fAgRFjNn0iK+Rd+FnELvpb2KicV8v+Tv6gO/GW9akD/7yak4kvFeBSkUQHEXNO62VG5jPTWBrXsaRcBeHZehWyI82ajL7q3Wb4+78NjBTaqmLoI0+uB6Hjiu5ncGnWjKa9H/tkXCUQUjeW3lni71gJ64JH9foqC/WsEfQG27+BkskfQFTAa/8+QI4ZpU5zGSyRCx2m8aEPZgK6eW8LPl5HroNwi8MIHYx0rIgVvaB8/urSqeUhWXrsv1cr2Ec9/B/CNkj0rcpKEbEkTsgs62rIJo5ctH9FEJNimKUJGkMAPr0g5fsbddV3G2xlou15puX6y9dsduTwE2+uVcKdUTiRQZ7OaPrGMD62b0JT9pGbtkDTN1uwcnUFNfwiLF6WsVAUapwE3Obg6szMGGRhRspOyEoSFZfp1wqTJkgKQY094AU1p0rTcfAKb1vQizM8U6ksvH4eGClcUdXYJTxAaXJfF51zuZ3w5arG1ZWJ0Qu9XbCVOztu4biIFLBgqXsv0T4OXa1EGR/nOJiT6qSKVS41dlpUhEJ4QGAK8TKBW2XS/oeUQiF/YQFG2BpwttOTULj1CqHrUNqMrwNsFEc4dAn9AE8uRhLosrVzjaEIYn1REMOOzPL8VrVP2c7ib8/WyWfIOIWYZyvfxN0xoUqPbGhEUcHt/put3zNq8IsSz66noQTQ/DxpLXrPvwNsYUdqyTo4mC1f8S+4SmaGcFQ05jQUPfBifyBmk/Qnj+2UpfuR/CcN6MNckdN2dXm9W11xOxYnurCxc17OJ/gJthNhscUeE+HTwA8rlaSjvj/RkTGN+7dMTZxrdiGj3IbaYbTwsoTF7uBHvVD8TL12ICZz5u+UUATuOE2Xu2T+cAcKG4woohvg7dCDffrlEQDpeq0LAIIgkCd/NSP06DnF+NtT4EIm+/ShGbwg0efgFtV1wA05ONd2kqIXVfuJklNXSBKsFgzxehf6LBuTol40HNZmAMIXSncsOaClpCDG0J9mwSD31yzjTVeCb5YcYv2XwL13UFcFW/BA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB6398.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: /FcNCiaJvIKCnhWD2Q6hw1ZgCwTOec5ylyaa/3SXMy4Z+vFSMVEbtRD6vyflRiA9ZxpL7+HjCOr6QqPRDF6isf2q1xPTyTq7b3WufR1cfOPBmIqP+b5dQ4Yzfi/96W8bCfJlT7/e+O+Z/GetVZTpKajkdCcq1eYhBKyeHcMwniwIgL0yE186Nvq1FtynU30744idB/b3oMtz4R53/yuvs5P/uW2lkywXk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tMe+mXoMeFg7IKUOIybjTh/c+nNAcV6871sxJ4fLvPVuOifJx2Ncox/Eaxrqa4q70vHAy24r+JuKNRagKg9bN77Xsgn1SDzQmVNT2H2zw1bmsDC9gIsBFgQbWaf31mSff76i8D8iyjmYz8PQDEI13zBFtEkq6g+A2JH0lPGKLgTNUTbQIH042d3qNMNsyHFoqDvZcbAz1lyP4bhm7UJUM4EzLYq5K53wcYYvOjhlq29wMJNWj49tvFwrPxgMDIi68BLpVG5Y/oLa7xS2ZX2B+F4nPcbzTtGrbhr9Hlj8snHvwG63DsoAML X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01a95b6c-f61d-403f-a869-08dc73f51033 X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB6398.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 09:05:55.7555 (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: 4LYvc197lNDsOIbnMV29w5KgiU1/5d4h3rpsSiVNJ6HUW4RQEfnUaqpNiZzpCPy7LcvbCsKsIQTKneQnnb4dXw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6102 Add a list to the struct dm_dev structure to store the associated targets, while also allowing differentiation between different target types. Signed-off-by: Yang Yang --- drivers/md/dm-table.c | 36 +++++++++++++++++++++++++++++++++++ include/linux/device-mapper.h | 3 +++ 2 files changed, 39 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index bd68af10afed..f6554590b7af 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -741,6 +741,8 @@ int dm_table_add_target(struct dm_table *t, const char *type, if (ti->flush_pass_around == 0) t->flush_pass_around = 0; + INIT_LIST_HEAD(&ti->list); + return 0; bad: @@ -2134,6 +2136,25 @@ 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) +{ + struct list_head *targets = &dev->targets; + struct dm_target *pti; + + if (!list_empty(targets)) { + list_for_each_entry(pti, targets, list) { + if (pti->type == ti->type) + return 0; + } + } + + if (list_empty(&ti->list)) + list_add_tail(&ti->list, targets); + + return 0; +} + int dm_table_resume_targets(struct dm_table *t) { unsigned int i; @@ -2162,6 +2183,21 @@ int dm_table_resume_targets(struct dm_table *t) ti->type->resume(ti); } + if (t->flush_pass_around) { + struct list_head *devices = &t->devices; + struct dm_dev_internal *dd; + + list_for_each_entry(dd, devices, list) + INIT_LIST_HEAD(&dd->dm_dev->targets); + + 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..19e03f9b2589 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 list_head targets; }; /* @@ -298,6 +299,8 @@ struct dm_target { struct dm_table *table; struct target_type *type; + struct list_head list; + /* target limits */ sector_t begin; sector_t len; From patchwork Tue May 14 09:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13663884 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2051.outbound.protection.outlook.com [40.107.215.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 57C4C2554B for ; Tue, 14 May 2024 09:06:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.51 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677561; cv=fail; b=nEcYEiHSY4wXtTZeccR12z2KABW6gFuHJf7ETIDrU4xQ6jIdpc8ryiD/xabS/B4+OLkaUH2sVbekHW0tCc7jnzC7KKwoB9bSYYY68rdi2bsOWGs6TYxCMNpvuur6unQWso4nxmM+qT2grHrVzIvNnv1PqJCcn2VUNBEUOg+xOvc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677561; c=relaxed/simple; bh=1o14Mua+SqeY4LUvV8RgJ9XYncUl4tlLf41aVfYF+D8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tWhdETj4D+d3qOCMCE4fqW3WopwVdKv9oj6rj/A3pjDY3yj3TPdgfv3rZvREn4aWisiIXkf3oHLJFUWqhNZ4eYq1DyMrTzeClNAE1+O2qASePWZWUx+5cVyWoV1bDSZFuyH77U0S61ez6Gu/mNijLPGnSOLGTusxa8i6CiuUf38= 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=fp/EKCYx; arc=fail smtp.client-ip=40.107.215.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="fp/EKCYx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sgk9rq8hFLZZz+it3OdmUmUIfMrPg05SnmLT7aK9VzkUSGF7YK3HhNTTL/sU/pkYpVu66UpoVoUP9CO6cLeL0rc9yl24vmKDDy7MMMI8VxpJR7HjVXPAmko67JJTs9TXSmhegVyjREZHRclwCopjhPMTnOyYsOm21QraKs15mUCM7w7gPR0/IT3KqriR+JIrDOCuZ6l4V9oVcdCCx3xQnBU6oJD+ZLsuAhv2N/YszKGular/+fjbvA7HMRB4ejSU1451JPHkrH5ih/PLAmH0jPQEk2u5v3TYqmKjMNDCVGDYsdPjxP91a83NhDrNBiDdjlS2TSWgwd708LJHc2pi0Q== 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=3dEkBvgw1T5f89zF0xw1Ge5vvbQ0RyN1jXaZ/3XW04E=; b=acBNIXBb9AA+ZpA+nIAwnzTyIDVUz/u/s8Oe61jpPDUGUewSIA4lBmmYRDHFtwZcyPduOJjeEkVWbyWp6vyFmSzNt+1OsAsHulB+XwF+szNZGv3U7fz2uTCQdTL/VA79mraPPcBAI0IE3k7Pu5vJa0SuUn94pbTmWhb1t88TQkq1lxm+VEmpwCOtYp2OFGc/j6ePulsXSHUkzqatnBHiN2yOCSUX+wp+CmuEnk3d4LyciCNiIpLhXOY1ufMH4dcA54fjMKV2MsLJ3I2WFUi0SDGgGgNdJOggzmuRXm/lil4mZCP4lLLwVyYNZpmI/kc1PskuWkXEpd4jTe18iLyaXA== 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=3dEkBvgw1T5f89zF0xw1Ge5vvbQ0RyN1jXaZ/3XW04E=; b=fp/EKCYxNXkgIFi2duxz9bXvzp6mzKPahJGe4vgkfq7Z0afMNnveDXf47ymcCWaeThYElD3GhJX26DfdnrAqx5mU9JglfnMtpoW+lRVmDzGLMKw3WwulHOmQj7jzSc3yL7F0oWnFRT/mdbO48z2C3tqFyNUP3GbHbRd5mbAqriH8fn/HIqYHgidAPmg7M0HkoUY7PUqZfcsQPP33W6Iw8omsaY+6paUpD6uF3NCeQjc1klh7kMgK4cCkCqt3ifeJAuMqemShyaEy9l6OTKxYTW5H/XSeaFR8/4bqk7ZRJy0aE4G6Hye7p+2t4D6nPdh6evZ3eTSsYuGVjQb+qh/LEQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) by PUZPR06MB6102.apcprd06.prod.outlook.com (2603:1096:301:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 09:05:58 +0000 Received: from SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e]) by SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e%6]) with mapi id 15.20.7544.052; Tue, 14 May 2024 09:05:58 +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 4/5] dm: Avoid sending redundant empty flush bios to the same block device Date: Tue, 14 May 2024 17:04:43 +0800 Message-Id: <20240514090445.2847-5-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240514090445.2847-1-yang.yang@vivo.com> References: <20240514090445.2847-1-yang.yang@vivo.com> X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) 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: SEYPR06MB6398:EE_|PUZPR06MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 782f40a1-db33-4e00-54da-08dc73f511f7 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: 2EbnNnlXKT+KfHsiRQnsDKO3s+QbXp6xAsHutx1ImZ0JviAQVYydZaEbRp653POAkqQd5Ly6bB/lZaGE9olj/fVXIYhf8sXkC6i9lzjjTHvDO1ImhrNEZndzNEE9B7LYGxFJHFKPCcxANsp1+Z32qtTaFDJQULoQwU4arklRp0YkMZeu9oo0zEpef+Wbe6KspuVisYmlqv+0QsWITKnm+58mg9+V5OXWn/G/1RjLntGGbn3Exh9WOaXiv5KzX953r6/qPTBuDe+r2ENjV/4N2gQxHc6mQTa7DsbDZWV4T7Lxl+KiOLLc48ZVa5eq5EiHXKdhsApIYi4EMo1PAxcYxIEDd7Osd/V9O46InoaEDYV0NvbPmDvxX4wn+bnQ/WEpnvLbIiJf3oO/2I8NaCXu2sumx51mIefMFkTB2ZuQXsFKa1XnWuBp1AXkq7JtyZ0v5NHGAOlZ6o7JJHS7bKDT+0GzmGhjElTpX9uMkrCvePRm05Vr1xsTLQapOq3TvG4UFNCEDzz7KUJ8MEUy04hqVo1rIbsIECvd4fR9YCx/fPUa3iFc1+gZKXQCdrW1NNSJfdYLsBJO/63HQLli5JFRkIE8p2dfomH2b1HJZChlxEhyKrWU+VTk3Xc9/VwLTI1qzUPuyeU3uaKXuuPa5hNWdog/fpBSqC4XXq46QY2JCQMdp7JK6FCQ26F/O03SZ80O+0vwsCEcFK69JPvlNLHANVObAZN3f6vZwCeTVAtGNsS9uVTLaZQBjh4+w/vORKhS7S3ygKQKZZs5KM7KQLXjQwoh+C7wGmwSL0037/l0mcKrLMPMhkDpypXen+6dn03HGiv+8CTXnftBgbC/sPU1PN7szOQn/5UiiBpCM8qHxzNqNBv3mFre79XPnUNTRnSAmOL8k3VJf72K0FuOymJyXS8deYzkYqJZfQmNrxc+2aKmodMLCjkrrx9ZRQGCSgbg1JECS74YGGAbQFbAY6L9m5yUpeBf3ZTkGZJg5Jw3P9gncPDGcaJFO1kbVIec7L63C/q3U8lyFuhzkEaqXsz4u7ETKmVSQK9F6GyL0otxHUNlfVyltC7bU4MFGGdpyQom2rjRdjnW8TJ5V87I4z/K93oXeMErzRhNSrTaG0wieTJBd9KWiypU7XlarQxja9Y0BwaCOoDihmNn7Ni22/rjeiPDSgwqc9PuKKIpHgO+s8zC9aqy09loN9U0raQVitpSZMc7k5npGiDpl7aJ3C+l8A9LpJWQQk/nfXj40G0blKJxXlcOqxzJa7ccQ11T3zsVbWGvW2qrfkpZzky4VvOB8tNompPy7sjgYUiTHzkggP8tEslJe/4rCmdagw5+z+D0dMEbfgkKA+6hw+keoLCeHA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB6398.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: UrlzF9nCRUX71F9pnbrPJ9Xqj/xTGvEustcLkzqMkGAoNi6lyVTdJi+j8kAzjofCKLH1NxTUB3bvKfG7tw6gWvHSca5jcGl9drksUw5tgNimJFcS8/2gEvvhraJfUL/BktY8YL/UpnpXH6T1gI9LPwIYKORZhqUlL1g3wl6LATKZQMwF/Uj2Pby0xPw3YW2t1YhO6rIqD3FrijW4gPV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FZPFwecA07ZbW8FJC+DTGu8X+vT1433lvb8G/WCEWA5m/r7D6LYyaw+hQijAYkrHiXWmAetO9GlLhdL4hFPQtRG5p31IFuizzwO7CVPLTqto0V0RD1RognSajkaTRhxdyQJyQpz/S6lsjlfdpi8udZtUQ+9cbHZGJEaui+BMOtm3tz+PF/hPkIhKT37dIZhodE2I0RAWarJOkBXm84/5BN3dkslxVxbn+nsN1tW8Rro8+OAotN4JKFEGk9x4ZOkR0z1wltD5rxC0JnT/A29lkSAU1YIrMYKbtrfU2qE X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 782f40a1-db33-4e00-54da-08dc73f511f7 X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB6398.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 09:05:58.7054 (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: mYMua6HthxQQWn3FReyaHltBAVKlpESTVcV2G90rkhgSkS/BxjpxYfLLeoj1WEXg/rY3+zghPQoi3+k96BS4Cw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6102 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 with different target type. Signed-off-by: Yang Yang --- drivers/md/dm.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 25215b93c3cf..9dbddc214084 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_target *ti; /* * Use an on-stack bio for this, it's safe since we don't @@ -1574,10 +1575,21 @@ 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++) { + ti = dm_table_get_target(t, i); + __send_empty_flush_bios(t, ti, ci); + } + } else { + struct list_head *devices = dm_table_get_devices(t); + struct dm_dev_internal *dd; - __send_empty_flush_bios(t, ti, ci); + list_for_each_entry(dd, devices, list) { + struct list_head *targets = &dd->dm_dev->targets; + + list_for_each_entry(ti, targets, list) + __send_empty_flush_bios(t, ti, ci); + } } /* From patchwork Tue May 14 09:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13663885 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2087.outbound.protection.outlook.com [40.107.215.87]) (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 AEECD22EF3 for ; Tue, 14 May 2024 09:06:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.87 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677566; cv=fail; b=RLh5No6iHvxK9veeylv7yKh5fP5jpSlz4qK93Tow7kKzZuP/e+zkMAdVsxGz7AHnwFG9JDzc52NWpRNNdHfFvh0ocpfrDTdUSpsFXftzRvHWbfpxBsl+5aGBBQ98gt4ZpPjJG1jPhEOE+XuTkLd70ZVKYqhjFag7S3U8hrUdGzY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715677566; c=relaxed/simple; bh=pPWvRKMPkRY+EnBmIi6erbgSwiPgbkjhyxIFZjHSVZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=eq9bYidrwlAZgerX1ooRkdokL4zv5LNmnv9ukPy6hKuCAPZ0M8qf8hdmRwVKAjzDu/3FTqCpocpdQe0LpQw2hGo1CXyoRRRFrRJO/1Wr+BkSYTvvldDqgQyNBzcN2/jFR6vOzch8rPKtBkKT2OIewpPEuo3STCbUoU6dAtblkow= 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=AXvAd4ZG; arc=fail smtp.client-ip=40.107.215.87 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="AXvAd4ZG" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CW2x4MxQMIs+PDg68vEwqw8Bg1fF0EnMyNsmCVPIlOEwKSywmcpFsFSl7KF+XxUOVfyu8LhaQolDCA+8xcGIeXVdq6ENqhSfCTil+nIIJBTMTsZf6ugxMmsYJGX1tcxcreGoyvZgkdVgkZPSIG8LOPlGHtQjgfIWf8/IYjlnNOfOakliahKvMOSfIJQvQ+BMHEtq2BgYN1ZJhdRNJ/mSFWDTY/+bjw7nBEh+vLNW87q3eAbqf+Fu2BqPikcyL8GMg5GSHLaMaIR/TX9bZQE+zkFTalpEK6DqN193p7Q1dWl8XbtJpIwRU5t4fLkO50RxIsekE6aaHH+WMBgn54KIvA== 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=jvoAH+A8FMpA4W0P6A9TjL3sNrp5e4qDcMyEyQS8NFBSJwIDHItRpPr0TzuoOSOJk4z4kqfP1Han46RsIZ+m1dj4xFj/L27rNS+zOzZtqS65RNjoav+4dWZAK5QOCtTyfbpxk5DXGe6E84/pAu9vQmkmXjHXLhhf3rFvJCN/84+iwWko+rBzyiACjgkgEh0zLO+dKdl1y4LAbXYNeDJCkrKKwOtEfdJ3iaOUodKJSHOFphB1FAHn0lv+fXpYFLvQfRvGY96HILgky+zVKFC+1BmNOMO9sv/KUjmn10bjATvnMtJnt7qQ2x2du9UvWzgt3l8fzwzuijav2IYCy/yjDw== 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=AXvAd4ZGpOtxUO+2MCyFDJLy+xn41teGis1Qq0j3PpAJcNOzojAqUIimcvJAd3JOwrC+WGszlun8BZGjiuO5X2DccuefpAgINT0ZFxFUx40Q3tPi4y5eolGtH/4QfonqoCZLf3v33lFDUI799KSahDtgmH2flU27PZIVEh8JVxwsRtoOinoaM/wh97OdvxL7aLN5JskQtOiyU6IwzjN2bkDCJY3u8f4r0rljnV03wjP0UbmA0SFDdFYcTYoAw4jzqollSp1P5W7pNL1hYUeshmsMglA1r0KWUNZaUYEzrswf7tm5C8sN/8O7KfC6V+trow8A6+8LNKR/uoQWUrnyUQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) by PUZPR06MB6102.apcprd06.prod.outlook.com (2603:1096:301:112::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.55; Tue, 14 May 2024 09:06:01 +0000 Received: from SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e]) by SEYPR06MB6398.apcprd06.prod.outlook.com ([fe80::9784:d8bc:5eb5:b60e%6]) with mapi id 15.20.7544.052; Tue, 14 May 2024 09:06:01 +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 5/5] dm linear: enable flush optimization function Date: Tue, 14 May 2024 17:04:44 +0800 Message-Id: <20240514090445.2847-6-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240514090445.2847-1-yang.yang@vivo.com> References: <20240514090445.2847-1-yang.yang@vivo.com> X-ClientProxiedBy: SI1PR02CA0046.apcprd02.prod.outlook.com (2603:1096:4:1f5::14) To SEYPR06MB6398.apcprd06.prod.outlook.com (2603:1096:101:145::9) 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: SEYPR06MB6398:EE_|PUZPR06MB6102:EE_ X-MS-Office365-Filtering-Correlation-Id: 1761c51f-8dcc-4918-ec50-08dc73f513cc 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: s5sUsPhALM/Pkp7ol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nSWg/uGS7U4HuAWyBxjRN1ZESYXwJ3DZU6uKtm2YKtIW0QO9h0kTlp82yCNv9oMgIl2X/wAmnHxAKz3B7VWA01oBrJSQrKw8uka5X8D9cp1WaE/wGrRpBlg0IWZepibDCCrFWv8/SZgvDXtdL4gdGZZKCaHnT7+Bc2W8rjF1gpwDpM7fiUXDgmhT8yyoIC5s0Gpj+9z+nHuzijOdDbfcZXK/RiLNBbchMENDTsXBmvzc9PIxs3aafnKkwnMpmd7uZEzvUZlTC42t9vvjg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEYPR06MB6398.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: Dn/AN0mKnR+6oun4WZDZUyNnTKuaPzMeqWM6FOMwWY1IBV/p9Dy1WGRLnkK4gfmG35buEk6G14ZUFqyA42JYrIf+6E9BGJlJKjFiur/XWhckGc2TdQPCEOakCgzIRd39drDYFOtG/htM+enn2tDYCZrJC1OASQ1zBPcaCBiBkLzN/0g1JUs59XbRuNXbGnw0cse5U4lDshZj1coSQHaC5ytZEJ3E2AJ70qFs+9uUTuHm/fp+sgS2XItzEcH3CqPeqGDDmcVlQJEQfjWMjX+6HC/pLdJjasQzlFEi3GmejoQOq5/gZLIYe9u/BsgmuYylN1jA9938SPGxL3WQUcxNJq5pvO5sjpd3yM8+l1nG0J9WL1mNI+xJQrVLCWG9j+cJes4cnsLljB9GUYZ9yZJOfTKHmGOtUzPULEiFILvxuI7Z6DKVrVAgCI3HkHqhJSYw2UVnkPQQrG34KuUemyTSRAbDCKdJM5r0yJhDgfUBNQtTrPHKKgKWEkV9MZGNZpv927nxgEEZCxZUkRT3drCopdpI32GbvXCQ+aFVLX89Mest9qymbHkDzSC5O8ScV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-4918-ec50-08dc73f513cc X-MS-Exchange-CrossTenant-AuthSource: SEYPR06MB6398.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2024 09:06:01.7972 (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: w94iYCHefNR2n59gjE7vrXXZNA1JuKTJAAul1A71gTW3pATB2OtPz2zjQEMYNmGLj1P01DNfXytuwOXNjonROg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB6102 __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;