From patchwork Thu May 16 08:03:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665798 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2048.outbound.protection.outlook.com [40.107.117.48]) (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 50EA86DCE3 for ; Thu, 16 May 2024 08:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846650; cv=fail; b=gaX2XlSAkBQVecyA/osp+CkdimiBO2j1bd0bJNHvfKXQYsXCAp6lwO9Jn+pnsLuoSEVLDbryW7VciLWmovjc7xnJkB5Qvt50S/pDjImk9dRFKYFi5zw2KHpBQI17sxMQ2KJQJl8u84HLSEG35wXApXAGBHtImZP9wag8tq6mSGM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846650; 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=aa7C5Fl1AASGwU/6nyyYGhhLtezEW1Y9irYDAPhrH7vMyvIGenFWO6yVkbLUnUgiepc4U2G/h/bviF4jmcD0/Uw/YF9mBXJr0+MiUD/eM8NMZl4xMjjpaecCMThmAPSOOLTFif9DG8nl644Em5PPquWMLdKKnjfDTXSEwy3eb/Q= 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=qdwBnQeQ; arc=fail smtp.client-ip=40.107.117.48 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="qdwBnQeQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZvdIORSGMKm/2JGQxGc9dE8JmsN2WOIRj3RO6HEbHVgFPoTJfjOIPgJjsXAf9V2gfSchF4q7fjLS6oLK8vbkJGuA7YuPV7i86KNeflLKiqKyl1k5x7ifrVYVBt+oM4NDig903Y2fkhtO0DQWmU2G/eIroWCmNIF06Y2UbugIXv8tViapwnQjtRqmTsz3ALUalyIC4sS8YWKS417EmzlETbtUyDPd4wAAqN0jotuBBk3FCUe4bheCCDgej/bn/yT5+erSSpjg8nFyp9EMh0eJBQFEHQ93y6839nWV2yhMw0dZCZ5HiO72INTSqlNX5xOp/8Yirek4HwtYdjgEzuGFcw== 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=X1EwJxnQs1bdXaYD1akNySvRwkh10JIe0gTkF83g2PMoTt8+EtnytWaqjTd8XZOuHnMfpj1ATrNBfHEJQFGiyRnB6hKhUVWNuhxOiqlac1qDpS983zHMZUvqOR2Se9pqfDwAx1KYvs+G/0bbtdlPQvMNfoDvTKeX5dHWKNVZxcflygkhQxDYW9fjCoWmDntTJ13gqet8v2WAn4B03Z9ZTPZ7EMdJBv94fbQISZWz7baU+Y4yExLakfwLoFN0oXzUgWbqbw83Ho7DhFvP68sq7VGtL6YLPzgQ0mBT9V64iOAnwIm/fFe9fszo50QEJxU7NkgqbtF690KkxHdylowNlg== 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=qdwBnQeQc23rfLvLJm88kdBZAUuuGf3w0vYB9S8B324zs+XjYfdcqLJYk88AH9EfvkwMXXwNkXm/vTNk5EJvUs+KsEFLLmfJqHhMTfCBtmEvVsrCQCtNFUnK+iZQYqidXdDz2k7yCYjiVk5F/2XuBt/y8kFJOevRQFnM9TY32FvM6wmo/cO21dX6Ah4jjNJvINkciPaCv8SLO2VbwewWt4l4ZayEjEJV+iapkJZ7h1JjpKIJBuWahUudfam43NSkfYK2EeU35Yk5rvyn84y4Kx0hW9FuzdeUDswbfUHu8e2JjMonSnqqvC+I90+XjdBFFxtK6/KSPf30HcRnJSiZmQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:06 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04: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 v4 1/5] dm: introduce flush_pass_around flag Date: Thu, 16 May 2024 16:03:14 +0800 Message-Id: <20240516080318.120231-2-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 9ff2380c-6319-4787-ebc2-08dc757ec1cf 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: Lk3WypqYDWHAEAXbTlLP9ukn8FZ/jMTX8aV30psr29JniM4MSuwkENsylIbZ7kKCWykutwplk6VzubHk+ioyUfNzaOYKkfPvIEkqrdZ+YN/fXdUEOy2jbUgyBxFaVioFgyESaSyYORhNUV6gxXs6UL1xvBJbJuF9JM4Mdo8Kd7xlYX3AoiEq1vEf2rM/PScoxtp5T5jonVQldAARhTEVqpwA3o2+Iy7yMqvi1lUhRaTIqp58h/VUgbc93ACUvUox74NiBTO3+EZnVHzu24So/RX+zbsbKIWUYS3EXyii+IkyoR4GJtF5H5u8BybBJawx4Bj8ITa2hiw+zviIu2Po8t6SvotXbMPb5yz4XN0tamE6u6JNbPlLdRcYry3j0cPo4yDNCSVdM0hvuucSwwAWJFZh8+4leXUVpLUBx4ZZWtgCZdtqMBXoM9/aZqmHzdIf9g6Dc7IMt4phgvWO0Xf0SqT4ArOsPFcIOBw8almIxsDCNjHVXkEtx1sP+riE4d/TnbV/rtcxVi+TWXTr1Cje0YTRKW5ssbD8xKpWoj1yyZxUyzYXSjkdhVDKdfzuXvDCUBxGMIU9O+LMIMHcCAZxvssGfDFehkdZ5BW7QMqMIWYxjZkLT9NZg2gx2+o61C9c1XGtbTBLQxcA+kZ67v2ES4Yyfc+77K9JjadygDCn4AY8L2IMqou/CRGuVAVgUeAHkp4H+Mcfd65gc9Bv9xsFGWjGdoP3Ih6F5V0U+KdkOfqhQ68dIwHlusrpjznnmNeTQvB7qbYZ5S+oTndFGVKqrpRhJSo47C+kSv7HiuN9ONP9kBanJvwmnqUipFOumt9prw9TROeCRneCLREPlDeEEQX2d3b76cW/KDZchwVaiazJpls8dENL40LsgoEkbO+pDhdp+x2tB5k7lL1ZgTZRkDTrMbaX8FNZovV2qkuLgZXiVBT+Rs9G+Cf5ajn777rfaH1OWx8hy/evGhKwmtLW77dtCcv/VJC6ine6VKNjq3qHJ55SfkZxA7W54C4jCDrRkX7lQ6sxLV9imTZtwSCQrH2oPNsPrWXqLDmWl+YQlvMp+iT3yWyNJ0/bZg5+WPYSRzoPKhYNX58CZRWg0uTnG4c5HJ6SpQlQcn9Le8MtDlav8Wzrs6BD+lg5MFRDGYUeIxy53oyAWnXAgL6rvMc5CdKMGX8vuKOJrNN/qP5+JZXiCdCp9kIThqDUeaTRA98GaJhwzA/gA8nR0z35LTyLB0d3yvdFYocSDlLyxmwadkMU17WeWooFIyhhExnpwyW4pBr9anWKJOW7qevlCF/7W/QNd4xjd2YBKKlbbE5FhLPLs1QGP9ifGBrxKqsR1inxq18ZvjLf5y6ZVZ0+V182Ww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X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diPnfd4VJKxdh+p25wxVbaXCl7g5IB73dGDv2V5iSmXPb2nf7E38Pru5P7CfxOntJ1ROHuo+P62ZjL2GW4SwEsa81pXzrCT7OSy2Fdh1AnFksYglqnNc/89q0+PdeOeowtgxykzrq9pmaAKwehIcSNsuYlzHqRqsr/tb9/KNrDpQrtdI5zB4nENTXotJJ859vt2WIYvHWyz83LSL92SFZmObfFD1jFTu92JdhwLOuY0gxGzpxnRMNwqUrLAo7B+gYnz7IRlr6ZqlMO5oZE12OC5NgTZa1U130eP/Fsti8MlYzXmilFVlZ5SuWiiaSafOh+FTS2s6EPQYuZQDPk6u8tYj3VuoGDakx/rf+oq2F9MlKhmQ/KxcztWmW+SUB+VLfErgBKBrLl3M4Iv3smEbQCj2n3O0KWnwWMyUIVpS1dbd8fTdxEkrJCFIlLirMMzEKUaxrBcU4wkLF3p9oo1wFlvXwLyvBRo99WW1+o64B1iw8QFE8uWOBQHXupPKAMPybx5Gmo0xZigTis8h3Pr7ySl7KGi6u+x+W8jhYS4JeQHGtwyT0Iqy9NrHrAwkItbjB1hxzihwuJ+CkAGGFK+8X0s3fSR7 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9ff2380c-6319-4787-ebc2-08dc757ec1cf X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:05.9398 (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: yayOpf+LkBvum35PH2m9v3mMdfqSGrbCj/549s66K7vix4QKt4faClkT1zrj8V+J4bPG8l2C1UZf+OkGcZp3RQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 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 08:03:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665799 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2048.outbound.protection.outlook.com [40.107.117.48]) (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 0F1251292F3 for ; Thu, 16 May 2024 08:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846652; cv=fail; b=OpFQms58Zt8u8RNS60RvYqHAjr4MhNf3YbuTlGQ+Y4Ge5PzKeQQtr8OKWbo0WTexF2ajN9GmTOulKyL/VnSQBZCbJUsOQjUEOLsVEfC+nQh/gf9Kbv4L2Tlo6K8aHSYeqAr7enu4C7v75a9wgSBVWL7zbJIo9nlx2VajfNClc2A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846652; c=relaxed/simple; bh=Dd2Ne+wYYQlf67SHMr3G51DSNztSqYbRu48pXFAFIJc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=MbBZzz8ZwVvmJO6IO/33gobw+uzeRvUVTQL2TispImcq0/eryDGO2tFhUnT0SlB04Jt6kOZXkoBwNdTauOPdbYUbeDyNI/MylqXTv8Oi39EDfWWc8EpybIAbw7M1pTNov2ifjzPb0PUvUy9JUc7IBJoqmZ8qvtFRJAUdEqH8vW4= 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=I8rciYIY; arc=fail smtp.client-ip=40.107.117.48 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="I8rciYIY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lqtGC6cM3RUAsKonEwvdk9UxBL7liSesnsVOSHsaKl0G30cLwIi6iENdpq+dN8QRSxZvl4jeaQ0vq81jlCjDLyp2iH5BCDlr00qRd8cVHAZz3iYdDvk1aqj/cybru38fozs1he7WZTtDH0viwEonnwUR3dbuzpHAoEIY8s7QAKxUi/YZrZ8SF+TFuLXwqxVUQ9cYrDwnfZoECxWyut9iwB4CElGDFjqWapC5H8RWi147yK0DjLaPfQdLRqqLBDIOfVkc7IItGLlaCVzVqFJ5sfmlrgZJhuWTobdN672eYfdTjVluwMF3DNnJNDLGQsZOZtgOUonF8Rdy9tB9oSqxdg== 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=BkmDZCeNY5XtEYH4GH/u8TNQHPE32bZjO6FY0M2jMFGYqIvBt7cZvnO1xp6vzNOdn2UulL/m5Re3Vjh0UA3rZ0e2vSAZg2WseVxdYnM5s8ZdYrJmzChqKQGxPLZWWFGZvfTzl/uP34ubOt7aG+5yBmvjD4KcyspKL0dLrBgeKix57qw4B9Wjjy/N7qZ4TvZLnbJ41NKRfCfXl9994CsyTk91w9A9BrvBlc0CKVZ9XT8T1MWsUhIlTkiMf1gOKa48LtDOPbKJpe5kmWlNGSIQ5Naa+xcdn9MSjsw8hl8Cf8S7ZKLQjlIn14hn+gF/gBlS9JCetXQnmEmgZ53UlB5+9A== 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=I8rciYIY/mCtXGfRV4qNlLGwQI7tzjHd1MHg3xtHdRomxN4Bdc+Kq3wwJZbocJa8jD7brZ4zz8wx9qyyvg/rPJZaBOqra2ZlP5ofoGPj7tHG0vbEFtYn5pDWxXMfzC7RyTE09IhgsL0wg9KtFJuBewIvEAr2Qbf3OUMxEFl9B5GY1nJjM4gznAxHCR2dvjryIxxXvr043mFqlo6EEGpLr6z+WGTHkzu35a16UCMyr2QfJjJj4hEDM0Ggvr8dJ46fHSMcg3tmCDVIujRwiHNrNnUIl2JM7We//V1Lx0Q9oHBnzygzOGpqsZtG3YgCE/TjAplmc5kbi3VQgdKruhO8EQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04: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 08:04: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 v4 2/5] dm: add __send_empty_flush_bios() helper Date: Thu, 16 May 2024 16:03:15 +0800 Message-Id: <20240516080318.120231-3-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ca4c8f2-ddd8-4f76-ddcb-08dc757ec345 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: G7D2cXRn8Id9QTO4f/3FIZITsY57g2pap/j6ByjzqLQYutJ3bClekVfrajeMlFZ4CPDBUkplKZV4S+qYzIJp844THlOGea2pCUXkuN2o4fiTbVfEyOzDD3PfSB7o6xBL704drq4V/tnfX/EeGbUvLKyF9NC2KN2NWunKxDvfKEoCXEJ9CPcYoCxCPbkRtl0G6KI+mIPOF7pq8xS24HKZq86dMCuMynPe1eJM0D9U+3yP6a6ChjylkcHfPamxQRWmZ6/z4KGR56BapOFVf2pDqGc6OasoWxVNlFoA0LlJXkPD8w0RW6w03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CL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4RRaSw4JvBuOZzLT9iHWltq3KEwRoI5TKJfVxa2x3gTKjVxS88GL1sbN7GwdXwKum1NMlt/bsf37MpDbFKcJppJMnHAloYTQD/0S9Q17P8Lp1WMllPROFbaBUuE5Kbt3+IuuZ1Bf6Gt3nvGpljSkhBh4gv4KrFRNxDFBX/xt+WaN/KUBwQq1azXr0Y/bRpCnFRglPn3BbMpAjICY4az6zdoeQ+SOnK1W7NP4AiJs3AYsuAZilXdbfKEwbfjKvzZPnBfXXFXeMRWzfYrxlIHWtManBdvt90V2I6ASJbpL2O1bXpi0AWvYS3Eh5UAFPKtKhbJ3oVEGwDtlvgqWUNilASSJYKFhDqqXvR86YB/s95sIjM1ySL9v0gWaaT1AEpnS25bAhbHtJIW8syUkxWJ7xE8ubTnnWnU7BB1N5AvEd0eh6fqzu7ZA0EKIfDGyCnwLwiXGXzhCMQM2eD8M46h0me7iJdsUIDIj8brHV+2WQHUH/LKMvbmIugT0I1oVpt6mLL92rp/VU/n6m/CysztI3IaY6mWux1dW3wsm6O4zj1q5aoqqbKuHTQFKAZXR7qXJ5qkoMicVPmAhAdXnDJW/9jqfKgRyI1EcgOcoeJWz4JzIm4EpzXOSlzFCa4kBO6mEbXBNkrVNBzidfgWtof3RFDOQkvDhwJSk4KfNsYvSxerKubWHA/vajPFd1Bmh2z7VmruJZxFDCo7EzoVTk5H8hpv+6jdnxAfASQZvBPDwC+9+Y+7ZrrsGsy6WtVgRpwVOmpCKw2s+1hkFECFouVmT0CBmQO5o7C/OUPhvDzpsFkJJrr0wL6DCoBEh2PIHWKsNd/QLNa1hpfmAkMljKGVMfFo7mqhq0rb4FaBUIqoR1hfDiPsFLswSyb2XJks0F65u5am6z+owKpFdmmUlzhYf40o/Y0sh0YSDGJfIUujpITwApO+e7kjaGDWV5e3F+nEq/IgB7gYUgXhEGqv9QSktaXA9LCBuQW62hdNSvwy5cZBQIoeNm8PHZjHaXbJkiyMZPTtg0Cl4YKZy04lOXqHaGwuc1yk02+W9EfKnZoTu3dBo22HNjeHaiDDxOUNSeIvG5E/kEH51UoTFnFwRKv43w/ygLc9noejLMtVYH5s6MOmnh5ypYXGSybLe4UucJKP7cJexbKWF0n5HXpd/Ec19csxJWgzVPTwqKnu81UapnDTOsmf5gidh7QHb7kDxE0SPdTHfWIEo91xKPhFlbj/crgYhYKaJ9PHP0SwbJWwXDtehwFMBvz8YQasrZuq1WtKCsennRnAOqeysFGkkOmEglr0UWoR4/zSCKFHOH4qGb0/DyzE+VPF4B0TPk14UzwaDO7BNcuPeQ15xZOuwkCwfBwwXlIcRkIzi2DhqXMtLeQ2+ciFED5dDqYURCIF84cLlmI5Y/vhUxtmENRxQk7uSJBW5eU+ipVy9PiLxD0rYA4ADbkXPHxiDvKbnXNqj/kTPTL8AWUMYY0/QRS7NiHoYYBA41x5xiwo5NNDWKIDo72lqan42TTXchH5mG3N/JkmAsBkg1lHUn4nHEQ1815RNlh9S6bh1iukiooauk0jIn2AjTSH2Te1KM2SY2sv6XTxv X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ca4c8f2-ddd8-4f76-ddcb-08dc757ec345 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:08.4038 (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: zYSe06esEtG9OasYnf3N/tRgFOdogdMsL8M9sIbJQAtl7vUZCW6xE59Fkm9YM7R3/zMAmZJ2/rdz83+xOo/o7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 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 08:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665800 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2048.outbound.protection.outlook.com [40.107.117.48]) (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 A61BD1311B1 for ; Thu, 16 May 2024 08:04:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.48 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846654; cv=fail; b=WGWy5y27ZwG3PsHZgY3gjlzpexEhaqLfOinz+qSYa7QaBWY0VkwzvttAsLyq5r4/s3U0leqdlZ11HvyjbJGd9hOAemJt/gYr9qqi72qGB5/pgA1l9K5Aa9+u9w4SpP52hQ5+zRwJlrs/lHEgti+gcQHkzRkw6r6q+orQNlgfGIM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846654; c=relaxed/simple; bh=geiOUcwvOQEWvSWzvmzuzbbdH8s7gm3NIqsdxOCEO4U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Gfgr6/BfYxsmL9U9gK6nOJrlZ8bLc3b2wu9Q3RJGeCUe5FviPOnUiu7/or+fpwq+GTlmUtPhXBh0fj4eC2G8zHPHx9W1Ly9kWjrj1PjqMhfzXiAiApxMa0DEgwI3VOVIci9Vqt9YlFrkrDJrGfdDXDTlpBWzkJt+jQ61Hcx1nWM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=QoB/nVXB; arc=fail smtp.client-ip=40.107.117.48 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="QoB/nVXB" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e9jAV9fKkfPvEznJn6kWn141AdDam40qObz94FYiQO3RR4rp05gbDHnfBFsVN8DjCFqwxbH6M6ydD8B4hImp4F3i56hO1Er4GX/ejpdMt6VSecl9SYnebCae1Qci8mJk5zuQ7+tnD94lfD5Eh+7hXUuQPKCAZe5a9RUTPktor4aQtWLZB9f19g/7WG0vcWh35ld9mIjviBDWn0O6zvttRcL/0vx7DTYNkXgniI5b9cNYp0KaUcJgATXYgfTuPYzWH95/LCwGkCxLAMuD6BhpQvb+g2Jr2BRXRS03ojjhffT0yVaWj2EJZ55IXb/WD1GEawT0huItbLZ5ybiRaogW6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lzCRbOJSPZPENWNCT94N4Qep991CBkBUtd0EM6pObP8=; b=Pyy2zyEaVGNu8Kl+Ke9wUVLo099Z/INu3UCrtjg+/m2U9wDaVHPJCdHm42YGjT5BfzrlLDUoNrOELFNMOuddQaKFHIIYhe1t5+pQ99Nfe57KsQw0voZuWo0kFSWd66LrhotUSuW50WsUrJmWXQ82bzCnoc4rZcaypmE/aCS0rHKSgacwoC5Aczatu/UbneOnuqsbNt/78Fzo4mzMBLKe9rypjlZkxL0jHl+qaVeimBuangHioOwY/0Pn0y+8ZDcqO3NzFliYk2AQln7R4IhjKB9hjlvdn83qtPD2UT8fO+lQLB2fZZjv8wRRH2hiAETsUQ9xFs13JvBujvMWTUIV6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lzCRbOJSPZPENWNCT94N4Qep991CBkBUtd0EM6pObP8=; b=QoB/nVXBQMa7lutNNyoUPZB/88hDQPho5NXEZxNZMWUbOUiFHHX67dIMygtUraVnsyS9Xl/IpsV0V/dKtWHE2jYAGyQ/9/GElfuRaMYnQmgb5ZrScqE8uBhy038qSG56zKpBm0B5Bu84UDrnj/fjUnjkqSan11LwOOK5dQ6Vp9v9bFcFdAJCEY5aZNCpKBqypvuVMz9QZkB9dfLPBxrZNkAtatG6rG2KRyerGQ+jwJOesjPFfvyzxWTwPeYVjk2WKpdNnmyqVETleilsh9JGxyTe650c6AAeRemITvsYnQsAY1LGnJZLW8icojsmwvVq/j4JRuKQIuwpQL+NaM22xg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:11 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04:11 +0000 From: Yang Yang To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Yang Yang Subject: [PATCH v4 3/5] dm: support retrieving struct dm_target from struct dm_dev Date: Thu, 16 May 2024 16:03:16 +0800 Message-Id: <20240516080318.120231-4-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: ae48b68c-8f66-4cee-4884-08dc757ec4e4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|376005|52116005|1800799015|366007|38350700005; X-Microsoft-Antispam-Message-Info: HzsAvWL2b8dg+ryAm5PvRzLbZsLRoKsR857oy6OonW9wvZT1FRX/WABH8rQ04Tj03TLr5NbT8cOTfJv715j3Za3J58DFLabGtgZ3fXy1EwBDE1IjWVfOpaWcv98lTh+g7OK6Ps+9EwOpB60zd/husDROpz1N4MUiAUfG5pyLA0jWeeWhksN/cLIvbimOhJIrXzNMHzFZU26a7z5heFneBt2s1FUW4Io1Crf+tE65WCPbQUvC1agyVBG7+RHVxnj5GO2hoc7+U/Q86FIoDLoOD0k2u+E5kwFbFkcrPMHQU9H1mc1+pXjhn0JsDQl+mP8ctcVUT2X5rB/Gtg+1MS/PFpN+1yXA2MmX80wxOb1OuUEEB0CSoQiN5UR7sLrfmk4LJdmDakX0m5YAXJ87aFSas4i74WJZJtJ/dYhNU8GlYqVGBvcPoOkk8Q+nnw3UdY3MjwZbkTkrJl+8SPTbKoTiNHhPUO4EmBaF71b97ZlK/MOnwZw3C9lXATfiddDYOF94pMr20PkYsf+xlAzzI6tSgF7SZY6b8jQND1uihIpuev/afYCMeuvxvB0+AIyBs6mT9ReehtIqoqQzH5uduRlxywx5Qy8Oab76pPjwin7D0rRiUlO6sPOK7eYYBAisvZcQ2iozKxDsCjMTpTatqZ0UG+7ioWMzyFN91k8g2Cn5l0s0nTFlhiiTI0c22C+5sVcbGiiyxBoi7FnrcVJ053djg5HGFpmmsikSecvJ8CGb0BjPjfP5sedqprkRJZA1ZAjE5OWmeVrzmj5FCuPQgOG3s2JS3HveKRsvQgBwg1lluG93nE5u//fIWM5wm8yyFbx/jHY01ST5//F/l/iZsaGG1oKWuB8STwFJRKFixXVILJwfl3ikZcijmwBvcUrROk75a/SNDglFvZEwMSzqFXHbbCG3B9uN9rppTLEkmyZ7sXgMXh/d4vUU45MYo/kHMGCS92uOUIsCIqoPWiBIi2Xyfbg0d9OgLA6XcUbdVbwAJFVeVEbr4RPx4C6+c/10qzo2heou91646aYokFcySefH+SUuw0zm4bPGKZwP4Anu915C18xjVhwjf0oY4NiedNMq2F5mh++QYl17cP6cfrKvtvW6PmiUM9Nzy9TdERvirU1ovc5Ua5zJHxj4QVoisvV2TaPUIFb73Ld/GdWr0UsoIW/HA9PZeckzaMzaprkxPd95KYlVAoMzK/ChW+fZfz4luucr75UC7DzshHLXf+4OjgFmsMwC4bwIyS4HCryLEKJ2EqiTvQXnD/wdSucdYatrvt0kZyfpyXomxUUKNvmgLmgRx7A/mIO9hgK3cLA//p1CcGr3josVscYM8yBxGk+k88YOg3eYG+PFaW1vbiGs1Q== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JI5hQhYJLt4jrmoUV7fplwiGtTRC+vBBsxBKrUA9AhKAcQVMCh1eSX+IC7U6b/LQTxGb+Qk9SDopGVnDzMYEcFIcM4o8K0JwI+gN3oXircBzheED4eIR+IxuHGB7YzXHFwB4K6q/VSqDs6LDYh46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SR34Jrbq0ItzbXDEn+lmFAObMXp0BvvAtx86ctz4+njrOBfEo9cE7RVCVV7t2dnUVVZT8CaI1dmKq5gpC9taXRGqvpmrcGtzsXXwuj4LAk6GC/7pTgWo0GEXAc21Tq9KatWePbnSshgol1+erC6RUEWWe8OZo2EB9SyEyVPyzQ1JWR3KDPb0CLhBZzfczHWJkx5xDIUeWLVpc94q/pm1rXxd8OIyKsHrjuuBsFc2rgQb1wDd02QCVjsqgiBXjbiw+6DU6UxMVPIg/J8pJswisFFwxiJ/54k1QyYfjNBkrFHdrJwGktWr/jKqwRxj2XWQsVi77YkkX7SwscvyCG0a7HbgXqvimz1YzcMwIQYyqv+AYv X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: ae48b68c-8f66-4cee-4884-08dc757ec4e4 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:11.1097 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0Kzg/4vYoqKQFIbY6x1kmUbPaOCegpT1tms0a74dDcIbZqcNMUm+SD5lmCWJjWkHFVBc8mirv099uWy9yDVDog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 Add a list to the struct dm_dev structure to store the associated targets. Signed-off-by: Yang Yang --- drivers/md/dm-table.c | 16 ++++++++++++++++ include/linux/device-mapper.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index bd68af10afed..4817ddb660c4 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -2134,6 +2134,13 @@ void dm_table_postsuspend_targets(struct dm_table *t) suspend_targets(t, POSTSUSPEND); } +static int dm_link_dev_to_target(struct dm_target *ti, struct dm_dev *dev, + sector_t start, sector_t len, void *data) +{ + dev->ti = ti; + return 0; +} + int dm_table_resume_targets(struct dm_table *t) { unsigned int i; @@ -2162,6 +2169,15 @@ int dm_table_resume_targets(struct dm_table *t) ti->type->resume(ti); } + if (t->flush_pass_around) { + for (i = 0; i < t->num_targets; i++) { + struct dm_target *ti = dm_table_get_target(t, i); + + if (ti->type->iterate_devices) + ti->type->iterate_devices(ti, dm_link_dev_to_target, NULL); + } + } + return 0; } diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 0893ff8c01b6..c6696f88bf66 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -169,6 +169,7 @@ struct dm_dev { struct dax_device *dax_dev; blk_mode_t mode; char name[16]; + struct dm_target *ti; }; /* From patchwork Thu May 16 08:03:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665801 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2077.outbound.protection.outlook.com [40.107.117.77]) (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 27FA01353FE for ; Thu, 16 May 2024 08:04:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.77 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846657; cv=fail; b=i4e57DTrGR28Cyc/Q+h4QqIhr4USxlvvYts7/Tu1OBVlbKdGMQcH7rSUw72+Et5vKdz5oZeJrDaYheQNpHbvWfgaYzvM7RSjzrDUYmXBJXz6ACZd3weQS/ostv+OSiniU1akhVyM/DKRnMJl72YFv+Wimi+G5OTyex2H3xn3I8Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846657; c=relaxed/simple; bh=Ka0RlUPOcraRrZGtj2xqynrRqvKUIqfl5gHglLt+BvI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=s1gciaVwq43bpKdM6yWScvr84sN+IY965EU9dUB+/3yGgCk0QpQ2El3vHepFae0Cu7cMC0SH8I/UB/0urPQUnn/mxVGIEvxkeEMOTxjYVZNnJQJ3IqSJc2oYnMiFkplBIv4MytvYUQ3RZzjn1i9TjyruiRV61sA13Kv3sHZHB/0= 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=VuHs++ep; arc=fail smtp.client-ip=40.107.117.77 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="VuHs++ep" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IeK1UKFCZk8WqQGk++D8O/mjhBWr/8XzSvee5/ceNu3kpJkrOo+M8WZxP1Tuq7PFXod+9zeU2M7JX7Rhi7iCqy3hPj95u1TIk1H8brXrlgflEGtDBQJStsVHPmJpoV0AxvjZ2Ifkr90j8NSSLilAoDxnngrc+GuQc1mpEeEC/JCHegoVrx4jMXqHidMgjtzCZCeXjjFJWYg/18nOT1//T1Tu9yeoiccclU0X9NjuafjDRkx5IWTMvNJsvVfsAg4RhRjm64SbhhOtltQ8qyePPARInt/OOFsScqJNmBPUqnB7ld/gg3DFSqNEPWYxFKOGmkQUc4QUFMdk4BGVbYgJGw== 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=kGBbD7FpmM/SQGdqstEr7tIDfoaZJrA7JrOZ5K5x8BTmrIc/Yx/8WT4kMvk3iukzoRbx/G26N5rEhGmN/1tubaPtYR7ZuMgxhp/DuaX938p4KD/a2EhNN/pyco3XpmBnAcPVCyyaJP524Tv+n+f3XDHHiLEz7qtxQygh8nSxkS3XYUbuJnLgK1v6dUJclRE4VCIzOTEutqOJ/9HXLccNVuq+Sa5/60gLK5Xa8awYtklESDuIeDTUgCBJZ2oX5QJT2E7zOQv4egMA0MrokQXqCDFkysdjeElQiyAf+vf/tytXIZJIty/JEOvROqfz9IQp02H7SI0ixX6LCSlMG3oB+Q== 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=VuHs++epf62mpRjBwVWA6S0JVCFSUS7NnT0FKh5EAeorLygHoLZSKJq6tt/c8UhyV6Lh/j0OV2n23YQ5pvZA+6BSv6U3sL003lbz0mPeL53bWxQV4BO31dryplb7/qAvsHzoUS3NZdZQwVAaW2idliOph6CVf0U5nvZd2H+KOwQBN1Nfn0R1gq07C9hp/kOnUEqBaLxR6l5lr2pByi2R+dFb6ont0o9RhZyuVZC3Gk9T4prOo8hAaBTUPgyxabRnwkz9Ah/YHXLOUv6gynGY1TAgA2bje+o5eiDwOsSsrBgyg7hfroLbi0MevWynXbUPCndMwhTEmRjymcgEXyF34w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:13 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04:13 +0000 From: Yang Yang To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Yang Yang Subject: [PATCH v4 4/5] dm: Avoid sending redundant empty flush bios to the same block device Date: Thu, 16 May 2024 16:03:17 +0800 Message-Id: <20240516080318.120231-5-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 6ed83c32-e6bf-4f77-8611-08dc757ec67e 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-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B6MSUE8E9Jh8ELYQY/WDSmDOt5zPEFypmG6C80SUHV3x271qJrB85Rzf06olPGsrLcI+EdXnv1UGMLKzcicIOkKXT/VoE/WCu53hb/YhiU7lQDUDydY0tF00hl6MRBfzST0k4Q9Is9G72R0V8gwtFOAvIlmCsvTd5e05zpaH7/zCB5W4XmhY+Hdg1n5r6LiFqVn4ofJgg97knwa5LSYLy9pDDkoEdlWh31whoPAjm9OKrFbBTXDg+I4IrWrJQUmiavLM6kpX3mIA08RGfFqYA7VewrXNCBEu71g== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYSPR06MB6411.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376005)(52116005)(1800799015)(366007)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KI/mL0AeTwWoy0nDbkTVNimcTYlcZCzqAHb/hZcR9/elYENcp5tWyBsGDKfrHk/ke9z9eqoVCuFh6lyXu9HIplzjYUR5djQO4/PkaKK9XTUd4uKqVf5D/hGAxdy6flGJ7+CfJElNZ5X3VtMTwcz8GXPfpwwXKe+9+u3dsnTHWj5VPbn0/Y+uDd1LyxJMHQSWifpiG6k7ypG16BNxGV1V293ICLg28ETO73iFHmTin25b1tUagWBvjkWv8YTa5jyiC6UEVqiu2VujB1WsfpEmMi+ne8OGMw51nHkM3BJ3tUhaAJsVdhFZ96EnobwKA5rEq3MkysZlQeZsnIbWwaALaNUYlUAWbvtLNgUo8wDr/xWbvrZdudGCSj6X07hCULhowzV75JMFz/H2xWrOO0kYr5+Qpp1OGmuJMdgsfCV2GKatKng8KQKwA7DImaNW5XPJ+vbq7c1tjubITLO/P5w3nwyXnZ4oDnmrAEkZh51uaPNjXLl7aOStN+YJXkK8ZDfJK09c4uCw5MrcxY4MYoDS+u7diwgGQDXJrBYdp1Sn23xV0FYCSwLT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-Id: 6ed83c32-e6bf-4f77-8611-08dc757ec67e X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:13.7946 (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: BeI8ubqFgMmQgk3sx0uObkAM5DLSuUeWSr6zRd/matPnYRh57OfKCW54NCLxsb3d9I21+5M3wyMqmrwsEi0X+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 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 08:03:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YangYang X-Patchwork-Id: 13665802 X-Patchwork-Delegate: snitzer@redhat.com Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2053.outbound.protection.outlook.com [40.107.117.53]) (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 8B927136E00 for ; Thu, 16 May 2024 08:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846661; cv=fail; b=k3x8ZeDh3ZLTrgnGtRg7h6J6UAaUXT2of63N2zt7UrSPvRS+ohlKWWVGvDt3rd5dvyB1Jc+QToEIkt5dp/JGzL1TA2ivhpUFWMQ38aY8O8Nv2p36Tg5p3o9vsYwF+anFvWCmvJQs4ryP+S58f+gZoYmZ+Cab+Nlwx8ilpMn1a40= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846661; c=relaxed/simple; bh=pPWvRKMPkRY+EnBmIi6erbgSwiPgbkjhyxIFZjHSVZs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=rLPsZxHAhcZ5RYNxgHSIRhhyWC93H6njQQNedoTy6eRs0Mw2igBAuPPiUew+RNqwVO0iXDhZOBzifqA5v/2LFzeNj3wlF+c1qS2RvwwK+nAKSaqP66DhjyBC6wn00BMcz2Yiv+G6nz5JEK2d4rWFtUfmmD5mYaMAhqdoRCRvS3Q= 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=absooTII; arc=fail smtp.client-ip=40.107.117.53 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="absooTII" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fB/EIIjjfzZO4ty8LKsbhdnRSdPIVk3rGOFs/rLW1FduF3bYNY3t2jbf/meyo8BpDRC6EqY3CZOr94jZvbbwOrEZzNcNiYA+u99XtR51FwO18soZZe8nhq+vrBODi2o0yzSlJ+MS+AoObt+EjsYI/QeTOWk6Gcy6Bihb8k2rpaFNRcclEyFtaizUmLdCHzpntXP443+OI3DJNaMtTj6UAzxx1Jyn8wfQyrfT/0Db8iOJocr4T7QlwpFnbcgsuwOFqt75T9r2ItLhfhEjwrVoS1tluap96rcMtjzyhFTDGU5rf6rP99yis3SvS08Z1buAnW6UaQyx8e99Rqf+WqZhxg== 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=Z9edaEbcmojDorLpEGwqQL0tWUQzUOLXvVy9/b97LyOWBF1KhRyJIdFtggu+/FrQ/aBfPUodSZZaYx1QgpUvkINbmD6KenP90iZxi3GPGdB8WBzjPvLhvBS2mtXm3XVR6jRzQTgHN0Ydqnh6SH6hvNrVuUhOP5/ynnXEOKKzyzl5bqlQDrtCt8oxEtxMMXtlUexz3WHWMAxriWoh5XLY9VsCo+TtPgr7o31IAAIJTCK2tTuizDiPLyN0Ef43IEI+l0O/3VKnzYV5r7pVEK+idgdw9oYTZjpXZJ1Ctl893DzrF6sfCwkmlsyjweplTRsq24Fn1BbA3szRTscrxHUiVQ== 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=absooTIIXCxYJ0fMnPKFY9JhxZJVFGdELYOOE+3jxZZ5Ws/n14gLqWk3RpX0G+hOQj/E8tWNsxt69MFrypyRHPlVDoPh/PKIRRrdxZa9qJIZGMXrtvchdYg2KbVmGPKNc4GXftaooPSMyO+AguKUxbt1eEYBX+1lsBQIHwUnc6rI55dgDdj6gqQp9veJCIxUCjGAAkbbN2/xClmwuSmdwxOs62nl9bYNXy5yiAgw66mFhvCFeGyywlfVTmYGBwY7ri0ZJ7AAP2wclkzW/PmOmgX2iDhOS8YSvWcR2UzXSbHh3xcZsep5jZvGE/PB1tCDOsrLlvf+f6l9CQkpBIcj9w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) by SEYPR06MB6830.apcprd06.prod.outlook.com (2603:1096:101:1b3::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.28; Thu, 16 May 2024 08:04:16 +0000 Received: from TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee]) by TYSPR06MB6411.apcprd06.prod.outlook.com ([fe80::8e76:5af3:e027:ccee%3]) with mapi id 15.20.7587.025; Thu, 16 May 2024 08:04:16 +0000 From: Yang Yang To: Alasdair Kergon , Mike Snitzer , Mikulas Patocka , dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Yang Yang Subject: [PATCH v4 5/5] dm linear: enable flush optimization function Date: Thu, 16 May 2024 16:03:18 +0800 Message-Id: <20240516080318.120231-6-yang.yang@vivo.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240516080318.120231-1-yang.yang@vivo.com> References: <20240516080318.120231-1-yang.yang@vivo.com> X-ClientProxiedBy: TYCPR01CA0201.jpnprd01.prod.outlook.com (2603:1096:405:7a::18) To TYSPR06MB6411.apcprd06.prod.outlook.com (2603:1096:400:42a::11) Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYSPR06MB6411:EE_|SEYPR06MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 0195cbde-feed-43a7-6de7-08dc757ec856 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: cqxVHo0QwXfE7osLUCtTdtxDHSc0FxQWrpc50lTCvysa4FMF0jOuJ9CWZ0pjYp94sLaowN0nUu4EWGgRm3Gunj2WS5eELA6XqlCbMJgl9twfC6+e64m61+zlzAf+pun73SeCu/Zg7FB7/T83+07KxstuhepeD9w0tQIPL1zfdaHJSBmhWfSGEoNu+CmZJB86fNPVSNZnfjB/3NDzox4hZiAMkwndvPf6dmn/zlPjV4GM3OccmWtWrFyxKoiObYkSJHRbCn8PqZ4o4tLmgWhcoYQ7EBFx38rB2bvX/kclTVQweaSU4w6of9XCplimeUjA9Ga9n9j7FLwAGMy5x2qD5f7VRgQnucVK8hj/u/5gOwoZEbdKM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YSPR06MB6411.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: ff1Ok/aSWDmc/oKgX6Z3mRiweLDSvA6plgEAAb29iB5iom9oNQjUR1BK7cx5iFL67oKIEq8/6Xp4UJuWTVPRbHu+OPzS1cB7uWPh+pya4n6jdikqEadYZ3oW9EZo6eCGOG7zjeLwW/qZKQpUcVrtkbV84Dc5YnYyok0sEVcM1nmvDBFLpB3E1tbP2bGVMHeJwFgnHqXZUGQrnZtyHHJ1gqxgKo/JEPjN0ecCtW4LrQgOBNXDJtCmVX8x6oqwCxcwZMYu9pGfybeFuKf0cmG7Fp+y/J7S0FP50lePsRKHbuQeqzW1G2N64HFHESDUXR/LucZQBIKZEZSqq7lADYc8oerEg82c0YccY4WRihwP2D3iSCU+10UjlATGNPh8foOIRe7zk1UqxInhJJSlQ6Rp/8muOMyufWrke/EiutaHfw4rhlYqsAwYCSqQr10PrGvYhHFrH8Tn67c/CyrkZNC36qBXwr1Byoa86IcZcxZUJJuO3pItd7YYbMHwZHMiWvS5Kvz9kZg8ifCzUzFwPLD2GqSjn9z+dGW/DOUd8LqSC6EyKY1MSGDnrPIv3nVVBCHAwfa2wERWkIE/sWbw9VgLDOD9AbzcaVPR8DPC8XMHL163HKNMIsklKsYAf1oeFwmi5kW/obfu6hjLel/w+CQc6M2QMXntdWeRUoi5sH1cM40tgda7ehpT0/EfoP+/PLLg4OvceQ9b+7YFJ4e8JQQ6IRUDFdfp9zxiA3+Jk2dUCHEBtd8N7cjdXomiGP7VQA8Qh6fD1eXIgr/gaPspiqmw4RkTVpaqDyva/BcOZi+WN7+YC3UlmtsuSuNez4KfSgNtTFVfHNZ9UfSbwH8hbjExb48TIXpZ64pZZOoUKKE/+Og+mP5t+M0m75tLeVMrDe43A1RKy2NLWnufnnr+pqnqcJ3SKr9EsAn2XKeF0epB4AAhAhUbhX6ZaHbo5V+wvlaCnYgI0plRAOrutWeA247RY4mcbg/AFTMjHbOhAJTiwm4Gt4GPh/xfTvJzXCXJDN7uokutezN+TAWOp0RufjRX0I3Zs8Z6y4of8SKUjXydZ9UVm5KS9P8Bf6cr1Slh/3UdwiBjbt1UVXBmAD2rh5bnuno8oRCzYPjPPcugUDJC920hM1C/Xrbialf0i4Y/U/LCOtonTGvVBMHe+skOTYiiNqe/EKy8CFjgj0DWlCEYGFIU36kGiowGKrHmi9YWW41FyF1q0/H4J59XIUeZUBciGtqp7bYOGSPWxnVCu+8a1DWH4ZQWeLP1BIcQbfAYaOPgQTdkPuvhZd/O6vZ6OVpCSZhfupnkKoYSOrGsSSr/VIgZNqPuRblDmXP1r36rlhyh8izijhkpcnKpfhDQ+VV6CTE7q4f9hXnYd+V5BXqKlRHpYdkEnHpIOnSEME7QvvP6ESnGyIZEQQzq+sv+2iUq0zgxusFPItTRrMcXWoF+eognL7VryO3X27YbUQOB6+rkWEwC8qbov+m6d0UG0Kd0k1gYZsSn0wf6nShC8FjFPnbRyHYAhk8FoH0vd6l1oKmHhRrojbrK+TSSgK9mo11+TKU3YS65vjpppQz+vmORWQwRcl6DAZDMJh/NzCbfLoPd X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0195cbde-feed-43a7-6de7-08dc757ec856 X-MS-Exchange-CrossTenant-AuthSource: TYSPR06MB6411.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 May 2024 08:04:16.8848 (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: 17Flpdv/WdRoZqeKbMIT1x4mzmd7/yA7QNnJXSezCuNfpimZO6BBt9Q20Qt9u/OMqqMDdYroyb4dcS4X2MuzJQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB6830 __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;