From patchwork Fri Aug 30 08:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongpeng Yang X-Patchwork-Id: 13784533 Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010068.outbound.protection.outlook.com [52.101.128.68]) (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 CC1E81531C3 for ; Fri, 30 Aug 2024 08:19:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725005964; cv=fail; b=BaD0pJ5PZiTrsBNhrpsYLQDAb0cKAxhsLlnkF1gQT+8iHpGXcxkTbHsmoz/j9FFhoYyiUTcoqmNziXsHplARtDqfTID1DJLPRTmXtTA8GUStv8pl3gEcbkq6KmHjXtQbtgNH3oRvLrH1Y9y2QqSJF5dLzJVQ5m1VEjcAODcvO14= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725005964; c=relaxed/simple; bh=2BM6V3Re7VVbWERWNsJp3+pVooqoIfUswe/rSBVjxUg=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=piElveH/2yBqD93C95IgY9V9Db57f4clRD9BMXd/KBRGzB6/tS7NtEGQysEUZl63rqhAeRS61FG7JUUNjgX0jnWPIi39sIiX4CjpwrgcjhcMCSBBx3zrUrJpW8sFfnh8iKhvCMywGQAtHnzdiJ0/Q3cLPDAyEcJ291YShBLUcHU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com; spf=pass smtp.mailfrom=oppo.com; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b=DyKsr0Fe; arc=fail smtp.client-ip=52.101.128.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=oppo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oppo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=oppo.com header.i=@oppo.com header.b="DyKsr0Fe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LECj7XttqwuU6nITwg3pjMhpzV1NdXZIUT1Bg5527fSLy3ti712TU2zUmQPd+SyS6avuP2uMS9szRf3/rrzpu8kWL1x+BbBxBmMYNmRRuXC4mSemqmkvt9Xv/B2l7wJiQrYl6dlX7TfvlFh6xOUuET43jSWAtI8o+XnxSSLsRjPczFqXpsgFxD35hbztMwpau/yk1q6sQ9jucrFClHY4urWnW3sTq/5BbQa7dd1YrR2LmNio2+lElRK4ssc2gUzPjnIK6vC9uaN5ImTpDvFQnSYzXKwkVo2xYR2pahtR2vabDZZJa9AqD+VDTDFFB0IdARW8I98vvWLoaVnudqlOOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=OmCRlCE15wEQQnA+xdePGI7BQ4SMimrsiDyyD+cF2bM=; b=IUp3sQbQPQB28DrDKQXJQl11nnzX1+mUOZDANMFJCo/+w6WxjSUl/gYE4HkgCqJGlGXCVgSc3c7D63Sfdhe4GeU+oslYygeXvlRh9LIny5ut4tpJCFhrRKpqV4QLGVMK7XBDin6QLKg1fuCIgAKNtJoyT+qtnzwPFi6pEDX3eFOOkGwtTK5+16DTXHma1ORwBtyczC47e2ksU3g7CloAoi35u8T82DWSPlWpCWM3+Ugkri7Oi1JFQMDu/AJJw1+kpUfWod3v10e2KPs57/wr0/ctz8qMHcaWCgUwkirziLP76ZUt3uv3Utrtu7CToVjLnDDXBHESeIrLWIDHZr6xkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oppo.com; dmarc=pass action=none header.from=oppo.com; dkim=pass header.d=oppo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oppo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OmCRlCE15wEQQnA+xdePGI7BQ4SMimrsiDyyD+cF2bM=; b=DyKsr0Fe3D+RIXxsFacr8pAyEEAtkRBcke+yEj19BDJxr2RtblEy7JwDZRY+c+A8MeySn0kwCi/4ZvOwTHCkouV4AOMWarlCbQVJ1ePVPyKOclMPDrhomaTaU9x01PU5mkywxvhT21fUb1BHRzDWp0B1QvCxfMpl+RsNSVZtt/g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oppo.com; Received: from PSAPR02MB4727.apcprd02.prod.outlook.com (2603:1096:301:90::7) by SEZPR02MB7037.apcprd02.prod.outlook.com (2603:1096:101:19b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.20; Fri, 30 Aug 2024 08:19:18 +0000 Received: from PSAPR02MB4727.apcprd02.prod.outlook.com ([fe80::a138:e48f:965e:36f9]) by PSAPR02MB4727.apcprd02.prod.outlook.com ([fe80::a138:e48f:965e:36f9%6]) with mapi id 15.20.7897.027; Fri, 30 Aug 2024 08:19:18 +0000 From: Yongpeng Yang To: Jens Axboe Cc: linux-block@vger.kernel.org, Chao Yu , Yongpeng Yang Subject: [PATCH] block: eliminate unnecessary flush requests for bio with flush&fua Date: Fri, 30 Aug 2024 16:18:54 +0800 Message-Id: <20240830081854.487023-1-yangyongpeng1@oppo.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: SG2PR06CA0247.apcprd06.prod.outlook.com (2603:1096:4:ac::31) To PSAPR02MB4727.apcprd02.prod.outlook.com (2603:1096:301:90::7) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PSAPR02MB4727:EE_|SEZPR02MB7037:EE_ X-MS-Office365-Filtering-Correlation-Id: fffb6a66-bef1-4c8c-5aac-08dcc8cc713b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: WsU/iV/Tei2lyY9swqKM259zacl6LLs8QvU5nf2Vm67mGjp+Q2DSPmncoCLvYZ9jbJg+vNUo/UM2nCFp9Zi02rGYTa3hNUDF/eYfN1oAm7eZVS9uSyMDey15I+nnX2Aer+ktoqpdT+g3fQkMh2rUYnac7z8ie+ZpOlravBszweOTLj97vRRp+Iz6bCigPW8+aGsyAeNuXy2vrvnoOUbu6/8782XTrTyztvOXCiUH+FhAV9homqnnFUjFyi0/LgOR2CfSsmLlJE4iIR1D2IHsPPMWKT3uZLS2IvHWt5HDyjy36BRCWB9fXs7+n/mKrORNGFjwaMB0DhjKTmXwTOODHWl5PKDB7QISoKspFNrPkJCOXYi2EQCgbb5wBLd9pILZXkqV9+63/lWE7UWB7ZJWcqloQXv+aWB17toCcCe4OwI+GM8iX4iRgNB1gF62JrRi3lBiHzP7UqEFZnWmF3BUt+aTWsUcblxp+6fI0h5rzcVvJ1g/b2scp75lKGeFeTAyJN+a7CpLMZAxs0R+qK+JkZSz4ys5VldBfMb2XgFPsBC17Zd5QXRbiwh2n6r6ozVtfX4YnToTMPeDpXy7CXOXReBzQ3aJi1eNjyfWWbtgDmzy4G7Vn+I0fg3Dx130NgSFHz5FFVokD8DvbFwkUdx9V37MPE7w9+TlRbv0JMxTkEga9a15Bmp5Y0aYdM7vYK9dWqTc8NScaG1eiPZckvhrpTIKqGZrHvgEPSPkFSMBYeDZCqcDCbQwbn6slhiDlUsyQAGyA5ugOzO09W5U4jwxvIQ8gFOQN03qGyB1pPq1ff3xYt0fCAfXeqJ1SsJQdaZ1wE6OHu5TdtBLXmqJJDfKrPvNdVYCICJYVhckzfo5HBJZqeLYDreZPTI3srmC0YJeiZugnsly1SZHFoxSj9wUNlf9rc33fzUyDurkx7XfgAB9+RIoTEMNugDI/ip1vyI2ksZBr4Wd8h1jmhyK3bcQgRozuJKaFjiIa8hLBniXgBBq1HK++cFVMIgM06zDJbmXLgeElNm3KpYD67Xyhdgz/DsFwFyqLfzhn5uiPBm1OKZzp8XOoa3VRMptK4i38mhHwJnMjxs+xMve5Vpp7b/tFZiYKy/AEjRe+QBLB/img91hZtsMhYotAIK+22/+jds+en2Sih7gmbwbdChrffiyn/gzU0KJFpoxfZ0CUcTUTlhIWijavNcCNaKqLGU6RhLVknskAYhHuYyk0/riam8qwWzuMj2zaXJ99RrxwhwzSj/TvtJiPnjuudrueLzUXizW5cAigN1nv/Uk/n4qmdy6jXngk6b6Hq+onJ3mlXcu8wT9hjq+nezMXNyD64pAgVJXspS9dDCR15iGO8v1B9cpbnETFzDtDoM2rOdqzrYaEJ38TLibuQo+L5feomu04L/Un6MXcH67dU82fB6pKFA54A== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PSAPR02MB4727.apcprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1cVIyyQtqTadf3DHOPVqmHHRmJJIrujnzRacFi1vbn8QgEHCl6c+SDyvAPkPMg5VzkuqIDAbrHzOa7pxFZlRAoDu4vrPuP5fWQJVvdJv2Bnt9CTXLg9T03kHMGHLTMeqXB//aOe8lCoCopvxH5RJrnPwVrOS08IkjskQIN4NiVYe+g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vhGblQFhLBasSdlUaLBsEU44qQ7HEpDiJHkuCfB7WtcwVnNvjDcbxn2MJA+6DoV+zIQtmrZFRqbWqC19O6w1WNXkJuV9bElgmYzIofzEHfUSEdFYt4UHYK0EtLfY8FEqNWfVqxZUVc/mDqjpOcy2lezF3dHWsUTF8/pPMihAIXMlZFMMjevupMoEawWudJzPUkRgfNB+6afQxFHfRDkCIemM6hld8Nr5kMNeaCdz/XmY3LqOKCPYkhgANLWGUEp4NuGVEw9ghk042Y9lht/FsbqKvRN4qvW5wWkU7LAVcgVZmDk6jKswTTxl4Qj8kI/Yj5I0UHgkLCacV+Ms8wAoHqD7ya8UdFxWT4qXfLO4/TXW/w== X-OriginatorOrg: oppo.com X-MS-Exchange-CrossTenant-Network-Message-Id: fffb6a66-bef1-4c8c-5aac-08dcc8cc713b X-MS-Exchange-CrossTenant-AuthSource: PSAPR02MB4727.apcprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2024 08:19:18.0625 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f1905eb1-c353-41c5-9516-62b4a54b5ee6 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: luhRJbaOW89iK314auXWexsmnDNGoJtz/hxe2L5RPPEugVFTXy8oHYgYbbLqxbMiSNbyQAV7+N/snKaw8wZqtQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR02MB7037 The write bio is configured as follows: bio->bi_iter.bi_size = 4096, bio->bi_opf |= (REQ_SYNC | REQ_PREFLUSH | REQ_FUA), bio->bi_bdev: dm-0(dm-linear) with 1 slave device /dev/sda. submit_bio(bio), device-mapper will: Step 1. submit empty bio with (REQ_SYNC | REQ_PREFLUSH | REQ_FUA) flag to /dev/sda. Step 2. submit bio with (REQ_SYNC | REQ_FUA) flag to /dev/sda. The blk_insert_flush function will trigger sending a flush request to /dev/sda twice if the request queue does not support FUA. The second flush request is unnecessary. Signed-off-by: Yongpeng Yang --- block/blk-flush.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-flush.c b/block/blk-flush.c index a72e2a83d075..606a6a5ae089 100644 --- a/block/blk-flush.c +++ b/block/blk-flush.c @@ -445,6 +445,9 @@ bool blk_insert_flush(struct request *rq) fq->flush_data_in_flight++; spin_unlock_irq(&fq->mq_flush_lock); return false; + case REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH: + policy &= ~REQ_FSEQ_POSTFLUSH; + fallthrough; default: /* * Mark the request as part of a flush sequence and submit it