From patchwork Mon Nov 18 10:50:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13878395 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 3F6FE192B66; Mon, 18 Nov 2024 10:50:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927049; cv=fail; b=p0mRhSnLWyWyJKwLUkrgaYjFURyKQnTLL6yHyNtHgPTNFW3nYzQk6NbkKxdP9MlEOshDc74g/ec/boR7YRxpDCu2HWO+I9PFsr2BttDToPU6rqJs5MuiW/o5c7Twf1xKN0D0wdsSUpCVrGQAX01VcT3Dx43xGIaqoTdsRypaS9E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927049; c=relaxed/simple; bh=UMnwj0R4PWI2JDburXOCiqnxMZmMZSqzqS/+wnXsM9s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Xb/JXFORYi4uiN2kWBfHxWVfEwLNyv6Sh+XLHi4UDwi7omBYSmEZXpU0jc20Uf53oFoKoW5tVn07vb+dxJVYvnoVNNXXk8x7y89ahMjUQBWffQIpW9yTQnJdvHET/xgGp4AzrYRDlrOLpd3slRrKSl0JuI2RpLWJyZPtqaPj1nw= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=cS5EAKh0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ky8XG+5i; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="cS5EAKh0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ky8XG+5i" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QaXB004695; Mon, 18 Nov 2024 10:50:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=LKaQT1gAswVTR63fej5uKXIxRxLERAbzAeJy134X9HQ=; b= cS5EAKh06luJFHhRBAFR196VaMCuQGWNA81kjTqiELQwLsn5jTJXM6PByYgUSte+ doggdqBj1XnGURZYxSigFRfqDqL3hj8H5yZGwTppcWBnSpIsVrikE+XieArcIygg t6DHTlsIliHRfCxc5jZk+gxPFmLRO1CvmgxwM3MFzbH7kRnFNZ6u32Zqf7rGcF/c SdWIKSHKPwCsa/BsRiLOFMcmQjmzlJbC8TmaD5bujc7ZuJUzxOTtKIWcd7xqvPwz A3Mw6mjp0FK7pJlcQXT5b8z7lfCZJIYsnuKp4dKPRvDfObrLduHyhfXPOhGtPSKt dbXgMv9fLRriw1xECXdMeg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xkebtd1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:36 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8gFxF008934; Mon, 18 Nov 2024 10:50:35 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu75s8b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=elbYuMqxjE0I55jZF1gYZuoClfliw8jFPcTO7rfwUA+h2F8sq9ZzHToSA3s+coVfLYJVHPr3e7QCCc3dYma6cUVj7EPHE18BfO5GhqafegsG6X33CNL2sJ7thdeHtnvemt0h+SyGpQm7VSK1lCj3mzilj5XY5LXIkHywCNtbV0qynmkeXkpVQHPrlWbHzPwmpDEfpVos0z4MeKDHVZB39hmHfVD2QW/ip2fUp+SeXm3hEuJlOPgKe5BHbJE5wcRUoqI251kgge/9zliF/WpV3GdmUR+i/dFaN4/kZQ/Hybi+aezfLOPJ1Vw7hFGBCLxCl+1Q36EFk1erFcfzrJiaMA== 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=LKaQT1gAswVTR63fej5uKXIxRxLERAbzAeJy134X9HQ=; b=fvmQDNkjicuakg+gdqFOVpIpIVObmmBI8PLBY+UdTaYEqoZR0dl1Itfe5F9/AJ6TGjH0mVQNmNoiTH1t5yNOVV0ephFpd7AjvyVwoEzDjR6dQznHmy/BzQpx4zx2luQo9vCMzll1Cs0v2M7FD4YLrWxHoziGRMKwawiQPzNh5Uj4tBj9e0NF53kwJXolDKnT5fuo6BKrRQSbaeyX1GXDmUodkCPEAOhCky/FC0w8+uOP4NCGVBaUWLzbZmhgUcLmtg2KbJNO91ef1U8dJImnhWZvfaJFxm0GnIl7vYfK4l3g24Sff40//M/T0aSSTt4Ne4pkdywCvgjTXD5fENg9LQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LKaQT1gAswVTR63fej5uKXIxRxLERAbzAeJy134X9HQ=; b=ky8XG+5iXW0QlT10RG6rpbUsI1Z0pTI57oWmr0FUB8j6JKO4tgE+BvPAGS7hOuRB4xtVieKPBuHHtJd+9n/soNPHXWHExj8fz+bYG90kZt3jdT3Dy1yixPebyolsY/OSq1FdpLJyieXtwkVPttYwQg1rhOl/Q+q3tPBzFze9lvg= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6812.namprd10.prod.outlook.com (2603:10b6:610:14b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 10:50:32 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8158.019; Mon, 18 Nov 2024 10:50:32 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v5 1/5] block: Add extra checks in blk_validate_atomic_write_limits() Date: Mon, 18 Nov 2024 10:50:14 +0000 Message-Id: <20241118105018.1870052-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241118105018.1870052-1-john.g.garry@oracle.com> References: <20241118105018.1870052-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0006.namprd03.prod.outlook.com (2603:10b6:a03:33a::11) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) 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: DM6PR10MB4313:EE_|CH3PR10MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: fe35d1ba-c2e3-4def-f06c-08dd07bed330 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: kPvMG4d42HLZpJboT385w+kx3TXgI5YPkZaLwvVJ0hEEAyCddaxDI78AfARRp/Q/U3mQ390+o3ejjwb6MoKwqYvkumJuIZKp2udHVGyYuuQPfhORBjXxTIELuoyF2rsQd1yQv8gt/sxieFJ/+sBbbLpvhRzalcHLeEb3UvQlp/qaB7KWB5RCzOKm4lV5Nw11uJsoP5onFtCt7u+9Ag+rtjIMnPchWEcFEft2MOEjLuNc9xG9dyGRFhjurCCaNbVS44iCK0GdK3EXH/kxzdpLov1DK4pl+F8aLCCNHoWk+j5cpftz/5SPwW5xKIXeOR9K+vEXCPVyKvXxPmSFIy5lhPRLq0voonE0zSZVdnZ4f8LkFbzJr+XvpngCu8IesTlnNGTCB947/H00rmwiIumPZrp2ePCZjbDyPYeYKF/3F3FHBdb8G+R0S3uA/G7kWBdwoQ61znpKxSeh13Hl0eOoYnMVa/7OuZd3oRy1fJ98VCX/oPnFo4uwxVMMePIEmpoyMv+V383taZir1q5fzzA1tPuelWIcGHK8DbXgoSgTAV19So/qD7fx/zZq02xXkBPT8Ip6tPgdnoE3/8PJ3kJzLpkJHaMk8EKYEuRrSOQ56m/GJ6/Yne69m5uErG6SI4T5Z8BpGlTmCfSVmsvyyuOqb2yVhpDE3D3Efx3rQXCJ+tIfZidwmHauBZGLU6HhAFpYOqWUYW0HPaSR66WOJtGu0PK4gxJx13UphkeNyaFR2CPyaGueSvIDZuOQLH7sOlCr26kL6H6a/pT59P9NXm9kQhLtBjkxuPGshlyIYndiAv2DfM8TGE/UGbfvP24RuKP8DpvZa4NSOsaACadBff0UtKOBLkjt4rsVsrKk8oMSdlSV6xAL35y+W15GFySD3vLOxASyPZVMGAS9LGfuY8PsuZA9RkE+T7iaySAQOo24h3FHSkurMNtuupAeqar+043LwoydQGxrvTHex8aqIYbaQCpanXIpUt2GlUHm2uFcucRsgek11v34YBMO2zzUNKzpIU6/0bvR6vWsPlD4tEiBsrGncn1iQ8U91jXKGdpz5ve6QNOZsxTNa+YUnp7UaEQUy9nBuMVbr8GtohfIypXIexWtHQ+V7xBB//+CW2jh2llhU4u1f8tm8Tx8vX5aAnvoGf1fPXvprExth69mUOsazIffBpm5BI6oX8bi5qwB2SFkyXRNK5GRdkwxL0PDNlQutqbjLNdbqndVuYFUGk5ZG9tTjkgEAbh7iG7QV8p/zE5lijiTjNTqNAbn4riJOzHyUO+sRRfZuztRxn3TTAxbPi+We/9bHMrlINjAYTpXCjwgIiRRr+ELsDbECG7aUwvP X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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W7WQWvZby+8NdFWGSCp38cBPFXADuT87RKe5D5871njveJ8szJgu2NUdFP0rpIPpLE63+LJ+u+1nznlXPPiGgR6ETNG6gUBc80zZTJ6nR1PUqyfqjdLZlKRGI6GxEMug0AyTOGHlu2lQQAbw7QXzbPTeaZt+GUEGWsGsfJgiBjUfmvwNZ4lrAokoo= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe35d1ba-c2e3-4def-f06c-08dd07bed330 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 10:50:32.6225 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xIN+LNQBPD+kdnxRH8jbxcVthy4akZYWtvZEi1Gle1qSCbdNSGvLHcDlYecNhh5SUY+BIvKGWmv4N0BhmZM29w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-18_07,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180089 X-Proofpoint-GUID: CHbTWgA-YjoFpTpiyTERUFz8rowo1alX X-Proofpoint-ORIG-GUID: CHbTWgA-YjoFpTpiyTERUFz8rowo1alX It is so far expected that the limits passed are valid. In future atomic writes will be supported for stacked block devices, and calculating the limits there will be complicated, so add extra sanity checks to ensure that the values are always valid. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- block/blk-settings.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index f1d4dfdc37a7..cdfebbd5f571 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -178,9 +178,26 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim) if (!lim->atomic_write_hw_max) goto unsupported; + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_min))) + goto unsupported; + + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_max))) + goto unsupported; + + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_min > + lim->atomic_write_hw_unit_max)) + goto unsupported; + + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max > + lim->atomic_write_hw_max)) + goto unsupported; + boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT; if (boundary_sectors) { + if (WARN_ON_ONCE(lim->atomic_write_hw_max > + lim->atomic_write_hw_boundary)) + goto unsupported; /* * A feature of boundary support is that it disallows bios to * be merged which would result in a merged request which From patchwork Mon Nov 18 10:50:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13878396 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 62E912B2F2; Mon, 18 Nov 2024 10:50:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927051; cv=fail; b=iqUfjM+HfwbnHKQGIQfTcQNj2v6h2sW/9X9l2Us693QePWWjF5PNzPh6/5+y0AnNspM/xezDT6+tfd3t2oq+Fy7G+2NuezcqeqN0Mj9JuEsGv5ARh0AuoWXmYyfPtLBHzug4YUUJgNVCGMBHf6fNNBD2jk8j42qdk/XUupspdqg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927051; c=relaxed/simple; bh=f2ZqqeXBXBGTM9CGaIoBX1OhX0kz5YQhekx1Zonx1kc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=c21HI8wHTRcAkep80HPW2cXf2bCeb+kkI+3jWJ135UJ9bYdVxmikENJNSPtINk0/mEuVQYoveAAhxhDeaCSZgqq4EaT5CrdTLbvfOFVnZdvt7WxExwB+IUTjgRZ1LCgZ9PpiyY7+5kfh8trlxoaJafEoXJ+pmffkAXtHEtaBnVo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=EIdt3ZvQ; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=XhlO/9UW; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="EIdt3ZvQ"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="XhlO/9UW" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QX8T029728; Mon, 18 Nov 2024 10:50:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=pweaZNMe/5ZhhebwxA3K3X0/q+Ydlk9QOV6YOECUxBs=; b= EIdt3ZvQsoV/OYrBL2KDXzKclOGsb8mSca1ZwwAXsJwyV+4KNFEXkEKyFswIYCXR Jtnj+wzuByyVuA+sAXOr7SXOIJKmRw8PHDhQU012xDqyt69Lf3J6tPOEgbKt/eXz HUzd53YHUaypZd0xrGu+x7qY2Z8Me8N6GRLO1U+sXJwCW6SW31cKeeU7rSq1BN8n frS6z6IPc9t9CmxgrZhwjBBaXRY5D/7hzYQah6eJj26RLxDDRIyQoJUVu6+YQCN1 q93CLsK7ZAf7Y6QK5xDFrxkgLJotb06BA7ZipcDFfwgGc8P4HfYwg2DQtiAiR1E5 6zJto5AwtB30NHhu0i88jw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xkxstabc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:38 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIAmrbF036497; Mon, 18 Nov 2024 10:50:37 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2044.outbound.protection.outlook.com [104.47.73.44]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu6xtsw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dzeixHsLe780TD2mkWktfU638FbD721fxK2462e0bHsbVOp0GO/KPe9ORYiwt1omhfYA7k0OO0lb2D+MuRdqv9T4o7QoPvsXrUH2wn8HdtggnYJxbtSyO7LObd3HzuZ67Go28YIDNs/qPu6PeBbceDwlOZGh/E8xC7oZjTkScP/0X8PupKot+8FquahYyrqEe7JXoFB8bpWN/fZGafa0xN3VwtKA+iSrRd85cLjwt6E49uOrr3e04F2sGEzNUpdEfzIHa+bVtPjdcNNMsED4x4GBfAHHCZAPz1P1wUtO19tcIUxZr77Yl4Dh1R3qvD8+bQuuw5U/+/z88lzVdmfIvQ== 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=pweaZNMe/5ZhhebwxA3K3X0/q+Ydlk9QOV6YOECUxBs=; b=x3bw9cPw2mnuNGyOwUeseuaRoDlrFl8ryh0gMCBpBOelClq5sVF8BWEWk949m1aCU9EQWHhPU6XfzR9Rjqpa6YtRD8R8mTQFiXUdmIJHI7xT4un1xg2Kyp9I5RFO6+UMbMO9ZuB0JD5MyHVQzJ/cmusRHjsXDeiDxBsh0f+/zU6v7eLbsXpNRyDo5gvtBkmJqPcHd0Ded4O64ZNsVOP4WNzGu5brvrqe4+wVkP4FZxjKQ1K7ictoxE+qyfN1IhIw6oRIwLsdCLZkzUlPOqsIWJ/3cKas2HmEJMlXVMeBVjntIo2QlUv6O5/GuKeceMCdgZt22FNr7OcP/fWljFdWwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pweaZNMe/5ZhhebwxA3K3X0/q+Ydlk9QOV6YOECUxBs=; b=XhlO/9UWLabevVv0dTDufeE4h8t+AsBfLCu30stT7q5e1np+x2EZWOLhfJvTwbwUU6rPWFyIYqECj5ddaFt2YkcREV8M9i+6NgqEBxWYxbm66q8C55BotcjYxVz+lxQF8nfkRY57ny7RiRzAc9mQg7eHO7LbD8RL77Yy+Rs8Fb0= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6812.namprd10.prod.outlook.com (2603:10b6:610:14b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 10:50:35 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8158.019; Mon, 18 Nov 2024 10:50:34 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v5 2/5] block: Support atomic writes limits for stacked devices Date: Mon, 18 Nov 2024 10:50:15 +0000 Message-Id: <20241118105018.1870052-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241118105018.1870052-1-john.g.garry@oracle.com> References: <20241118105018.1870052-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0048.namprd03.prod.outlook.com (2603:10b6:a03:33e::23) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) 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: DM6PR10MB4313:EE_|CH3PR10MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: b854acf0-b705-4d5f-c50a-08dd07bed47f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: y9zCasS2jzONU4mh+zHcX9aOsI/ng46bahn0eQdZNMgvdk5PZMHc5PTkaO5OQcDbTauzHYmHTMNu3iS/J10tyi1W+jLqGVt/s7DgoKSdbQ8noQcX/yJb5KrkdDVcKwUIzLfPvzu4uaLlgmUlwuVrJGsDJ1r3ooshcjekPTsD2/gieXhwQ/x/1ugZR6OFuE6SeqjqlIg2wnk6XrS3r749ocH+PlCS0k73F6wmDD8fL8sALUWe2okOY6klx9qaVBehmUMbjYFT3Y35Iu0kRYQkZyn3k4oSp2IP2TRLphKvdRAGIUoNK1jPT0OctVbC2mFFLEKf07UyKOTH8gdhTDBIOnoaJn7tX/GZHLkK8eTvptvHCHIP1Ic3vDzle0VrRg8ebwOeJkrYTU6a69gCoX3D+nP9xPx1scyOUkyCW9azhY3eDEk/iK/FO753QQri/3bd/9KfeOEcgFf6ITveAhCXlcRRRwVUGYY52GgUWTnehhEkMQuMDuadYzKeoEIMYCZu/HgrJBo+tSBBc371iMru+u1Keix0gta2S0qyDL//xjUG8gbV9zZZ5qETfuWI/8OmmQhPm7+VVTEAyTqjHvRhTmRg+jzTR7BR9531iwkwWbdBlgirtufcT7/IoC1HhAr5kg/QwTa0GGgeQBMHfuKdzqwMcFg/3UdOeUZZ0ocksT83jg8hBeX9zdsOsG4HjhT/1U2hXiP5xS0EVrgWUCMH5/oDEUCXwcpGiMalB1gAvEtP/zME1AtQC2N2xxgLN3vaL3KXHJF0Im0CjQteHklJB3kr2UZ+rEOjWLvMTbRgfqh/dXI+0KcA9xRlcjYen68qv6mZmI5HRqbWWrOS48xleSIIPxkbRhZVmnfbiXNCTQ/NPqAMGaCkM5SpmDl5MuUL1hhAvQgePaZg7VCI4DlJ+TAlI86vIJPT4iIBCDiO1RoPMaLkG0pzLWrFwsXRLnsrJ/xnpnqrnxkv+Zp+SpRROKCSaIc942NtDvLEjpAMBAaqH7zL9PtoqNSd6rSKCRgu1qjGAqp0ugPpOabuwghz8MnJ0UwvRx96agyOABTl+BFAh64eYc9iRu1p3rWbH24PveDTApUo0wwFBdfA6v4xKb/vtUhUniZBThFkeqybv4aHWmRJwex+83CTye45Rz/LLlMyfJ20zmtB4oLGx0ZUW0jLyC68xUur6uKKYDGF9psI6Jc3+P3mnHu8v/TgDWogFpxfSET/rovzlgi02GAxgXlBswh8heBXkV6yq3Su3VHGij8fb/cMFNRPjiEw2s//yfezJ1jmf2t0eEzdRJ58yIRVfjxwaiHH9cr6NO8bM8TKVX1mBN5UsV8XBzv+7W13 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ob5vPel1H1kS/pnof+9t4Y79X+X85LLLMpOE8Cww63+rAeeRLz44xvh3k1f+Q+QivK57aOwkaSBK88HcYtY0FLImzjuleBujXzMYYf/3RKad4XbI5Yin1pZW7si+s8t1upooWqDRhuA831c5kfCI29G/4+83HI4vBF60P+JB1FJDENKlnDu5UDF+0HcLx6Ca+zzvlj26gl40pYVl48bQQb+MjLrVYrThFnGgEiZSsi5H+/byBwlpsmIOd/AtlAapPx6ao4u7cTw3rq/Wn2DAbO76+guYnEtDn0KoMLn4BFche5UOg7oP3Z9s1gq4q0I1eGd5vCoufIw1lElkHqkvxdxHlIBQO4KKD3f+S4Klp42sg4Exgu0epjDGYP2uZykRi8Kw83vg2Mx/QwiUmACWnh6yJjjAhfOw1AGmcZZ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IampD6UGmByvP0LbKqCfKaHWg4uPw8u0sicfCICWOi8EDDrFxtWbVsQzlNyRSrj7H+b/QFJsXyvQmJTJ+jZGM8gPMuEAWdEPWW1VNseE/ckPUFjHbIw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YPBqIZdGAzEBu7/kHZNUyCai3VilM1SpbKCU7weSWh0l/ozyblfBWYb/aMIYfntpnM/qoxrg+6Zi47QEmB1FBOVAesBwr2YdoavgJQOd+jkDkYucl+7a82kO8Oxtov8TJ0DueBWXrl0bcYLTStnOylL9wU5S/0sue6EMPfMiqZtUW7dfoB4E8VgGav+OD+4XmRr2zLeBD3P3P9fKXpzrfhgjGnNGxnzn6rcFz+zc4hqVdZumsC1rx8Oa+qCMR0Iq9Y4OvEyVEZW3OlDN29fTyZ3HDqcBZwx8QdrHQRhAAOIwrVL7Um5YpxbOf9C7+AJZfSAoZhE6VhQSMlMBD4pPzzQdLFXILsqGscSBMZ7/xnnw0NgZIvt0cq6+wqQpfKg7mEeIlkoYYmS3Hsz1qWKptL7eGcN/lfPpJ4JL15ISpkBJwoOI+7r4oQzkhbhFLnwsbGzcpQkicPHqH55yWKi5bkiWIJSbmc7OMA1KT0ZtFcxJdGi7qbjXU/eEKfJOFGPQbT9PlUKswxtF/1rHPunax2tUilwJ9RlZJNFETslIH+vIMhpAkV7anPYlaHP1gFiwnCpiM1BirxMSUw3bWKh/POS1GXHvG2Xo8HH8qpfHOtE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b854acf0-b705-4d5f-c50a-08dd07bed47f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 10:50:34.8602 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B+krvSGliTNodTbBQpLYBlaSZezHuWIEpGtByMvrmrkRXBkiGifHXte+HdsxPQ3pSezZLvLM39ABlRGe2ZWnJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-18_07,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180089 X-Proofpoint-GUID: 2C0LVAPW8chhQpaRcV0wBuMo1kcQiGHw X-Proofpoint-ORIG-GUID: 2C0LVAPW8chhQpaRcV0wBuMo1kcQiGHw Allow stacked devices to support atomic writes by aggregating the minimum capability of all bottom devices. Flag BLK_FEAT_ATOMIC_WRITES_STACKED is set for stacked devices which have been enabled to support atomic writes. Some things to note on the implementation: - For simplicity, all bottom devices must have same atomic write boundary value (if any) - The atomic write boundary must be a power-of-2 already, but this restriction could be relaxed. Furthermore, it is now required that the chunk sectors for a top device must be aligned with this boundary. - If a bottom device atomic write unit min/max are not aligned with the top device chunk sectors, the top device atomic write unit min/max are reduced to a value which works for the chunk sectors. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- block/blk-settings.c | 115 +++++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 4 ++ 2 files changed, 119 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index cdfebbd5f571..f7368c29424c 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -496,6 +496,119 @@ static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lb return sectors; } +/* Check if second and later bottom devices are compliant */ +static bool blk_stack_atomic_writes_tail(struct queue_limits *t, + struct queue_limits *b) +{ + /* We're not going to support different boundary sizes.. yet */ + if (t->atomic_write_hw_boundary != b->atomic_write_hw_boundary) + return false; + + /* Can't support this */ + if (t->atomic_write_hw_unit_min > b->atomic_write_hw_unit_max) + return false; + + /* Or this */ + if (t->atomic_write_hw_unit_max < b->atomic_write_hw_unit_min) + return false; + + t->atomic_write_hw_max = min(t->atomic_write_hw_max, + b->atomic_write_hw_max); + t->atomic_write_hw_unit_min = max(t->atomic_write_hw_unit_min, + b->atomic_write_hw_unit_min); + t->atomic_write_hw_unit_max = min(t->atomic_write_hw_unit_max, + b->atomic_write_hw_unit_max); + return true; +} + +/* Check for valid boundary of first bottom device */ +static bool blk_stack_atomic_writes_boundary_head(struct queue_limits *t, + struct queue_limits *b) +{ + /* + * Ensure atomic write boundary is aligned with chunk sectors. Stacked + * devices store chunk sectors in t->io_min. + */ + if (b->atomic_write_hw_boundary > t->io_min && + b->atomic_write_hw_boundary % t->io_min) + return false; + if (t->io_min > b->atomic_write_hw_boundary && + t->io_min % b->atomic_write_hw_boundary) + return false; + + t->atomic_write_hw_boundary = b->atomic_write_hw_boundary; + return true; +} + + +/* Check stacking of first bottom device */ +static bool blk_stack_atomic_writes_head(struct queue_limits *t, + struct queue_limits *b) +{ + if (b->atomic_write_hw_boundary && + !blk_stack_atomic_writes_boundary_head(t, b)) + return false; + + if (t->io_min <= SECTOR_SIZE) { + /* No chunk sectors, so use bottom device values directly */ + t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max; + t->atomic_write_hw_unit_min = b->atomic_write_hw_unit_min; + t->atomic_write_hw_max = b->atomic_write_hw_max; + return true; + } + + /* + * Find values for limits which work for chunk size. + * b->atomic_write_hw_unit_{min, max} may not be aligned with chunk + * size (t->io_min), as chunk size is not restricted to a power-of-2. + * So we need to find highest power-of-2 which works for the chunk + * size. + * As an example scenario, we could have b->unit_max = 16K and + * t->io_min = 24K. For this case, reduce t->unit_max to a value + * aligned with both limits, i.e. 8K in this example. + */ + t->atomic_write_hw_unit_max = b->atomic_write_hw_unit_max; + while (t->io_min % t->atomic_write_hw_unit_max) + t->atomic_write_hw_unit_max /= 2; + + t->atomic_write_hw_unit_min = min(b->atomic_write_hw_unit_min, + t->atomic_write_hw_unit_max); + t->atomic_write_hw_max = min(b->atomic_write_hw_max, t->io_min); + + return true; +} + +static void blk_stack_atomic_writes_limits(struct queue_limits *t, + struct queue_limits *b) +{ + if (!(t->features & BLK_FEAT_ATOMIC_WRITES_STACKED)) + goto unsupported; + + if (!b->atomic_write_unit_min) + goto unsupported; + + /* + * If atomic_write_hw_max is set, we have already stacked 1x bottom + * device, so check for compliance. + */ + if (t->atomic_write_hw_max) { + if (!blk_stack_atomic_writes_tail(t, b)) + goto unsupported; + return; + } + + if (!blk_stack_atomic_writes_head(t, b)) + goto unsupported; + return; + +unsupported: + t->atomic_write_hw_max = 0; + t->atomic_write_hw_unit_max = 0; + t->atomic_write_hw_unit_min = 0; + t->atomic_write_hw_boundary = 0; + t->features &= ~BLK_FEAT_ATOMIC_WRITES_STACKED; +} + /** * blk_stack_limits - adjust queue_limits for stacked devices * @t: the stacking driver limits (top device) @@ -656,6 +769,8 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->zone_write_granularity = 0; t->max_zone_append_sectors = 0; } + blk_stack_atomic_writes_limits(t, b); + return ret; } EXPORT_SYMBOL(blk_stack_limits); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index a1fd0ddce5cf..f4587355bd45 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -333,6 +333,10 @@ typedef unsigned int __bitwise blk_features_t; #define BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE \ ((__force blk_features_t)(1u << 15)) +/* stacked device can/does support atomic writes */ +#define BLK_FEAT_ATOMIC_WRITES_STACKED \ + ((__force blk_features_t)(1u << 16)) + /* * Flags automatically inherited when stacking limits. */ From patchwork Mon Nov 18 10:50:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13878397 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) (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 C33DF1974FA; Mon, 18 Nov 2024 10:50:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927052; cv=fail; b=FA1lvEcoeqv9tO73a/GD9orZDeTN4bprZ3u32zJAIDe+4SIVZmxA2USai0UbfyQYhHKk3LmWBUUQAu3btI0HzlGA3UPnPfKZ5kpzM4Fi++ZoMtkBRTVRy7QHtstPykAqWebG3DuHNMclbBx9/Hc9hQXV+ByhMqwnP8jWBY8w8K0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927052; c=relaxed/simple; bh=l8jWHfcLWmfiyOix9ULPk9fyb0xYOjtbPQAshuwY22E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=UfoLMSqcT9KsQkiDrF7yDUZPKJejy55+gaHdFx3+//07hzbh2omcMQ1nAtBWbYl7Ia1aXRU2itFGjScfkMB7MRxkoXMDLDOrAWJCcN3a3Pl1J3eRttu6U7CwHI7D1o197qlSoFBmCCSSlDM5d/2RbwKmLFZhxbifc5WvxW/FFlU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=UL7/vL1h; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Xsr92uL8; arc=fail smtp.client-ip=205.220.165.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="UL7/vL1h"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Xsr92uL8" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QZBG012271; Mon, 18 Nov 2024 10:50:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b= UL7/vL1hczD/9aKaDeSqykFR13uoCEkKF4myMIYfZO7rnp+RKFbumSS58P7/BV+u qeRXbsHhn2CpKBMvcNJwC5a0FWl2xCAQGLtUF9ZT7wCUPN3Akj/GxLRf630QN/PQ Cq9OfiMU1r64uVLave73gg42BOuaJ3CTL8+aJfl7PD0JJD9JYIQ5zyH40I156BlP qEjJvowyldRgkycYLaRDVVUD20eBZEZ3zCyjFOiLl0UPJ0ofhjbwEFdEX9WhQGGH /4WkNN5J2om91JFa4NM58RA19lfVKHwJiPLT/AeMH/P9jon4gCppOW+sAw+PCBqC /mxUBEFvkDeC+UvB8aEq/w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xk98jb6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:41 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8UTK3007762; Mon, 18 Nov 2024 10:50:39 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2177.outbound.protection.outlook.com [104.47.73.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu6wx72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eTp4mabZ0r0TCLpkx89NNAkSAwIaF85sj4RkE76wrhLtHngtcnO7V+fjYheL77OZEqcqqWMTQNZ/AXF4UCHTGvKa8B6a+lLN7U9Cya/UFfq1LLGz8sm0x3qt+x/IIKOmtr+uP9q7hQXWbespCMWtpPz6BgSSkVWxV2IhM7cuT5GfyAjCYHuRK5pggpwnSHtygm3kWg1oOI5uBSbwb+ZdQPMDWgA02sF8qwK4sWGS43Sh4OPPl7nR8Tvo8CC9Jh490gspc4dbWGvJn01PJFokRJCMpM0mh0APg+LyKsqVw284HIUDBfffUrummWEBlEXVRVtWBxRtxf3pIrFl4TcjNw== 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=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b=uqxcnCXmkkcAIiuaf3moS9RxkwHqUWJBC9+f8dpngElk1mjR+qtkqNEe4ETPXiHGoZhFPClMX3IEiRDYG4iV8iSdzabo7F9gLHcwkjUofQ71PU9UbECQqvktPiNxbPpdPpPIPJjHiGQD/pPBec+fMqNdIeaEBmhBrX0bY72NUpirn0g3hWeFnCeYe6kVPJ2/piYvv+Zx+u2BwhmuU5WN/nM4+FlGjNYgEvlRlL48vRWU3PmhzlNjmFxE5NfLauGt+HufPWuzA7h7iLBaXiUlYUfo/vNcg6J4XSZm7T5Z6Kjy3gDmWJW/6I8Bsl7e/1ELosp8hT0LtRmCwEEtqCKaxQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b=Xsr92uL8JEnxjM7dytiBwc8lcwFxhECMWdx7mcvtz11wN5AfKHIeo3cTNNvhbQJjSjm2Bu8iWUlaxk3T73iUmKh/8InVB7eXzbfheM6114VwdyFEIz9gHDR/94q3gCZynRSIIDGQcaQHy3w7amEw0LWCYhR5zV4iHZ8i6mBiB3g= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6812.namprd10.prod.outlook.com (2603:10b6:610:14b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 10:50:37 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8158.019; Mon, 18 Nov 2024 10:50:37 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v5 3/5] md/raid0: Atomic write support Date: Mon, 18 Nov 2024 10:50:16 +0000 Message-Id: <20241118105018.1870052-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241118105018.1870052-1-john.g.garry@oracle.com> References: <20241118105018.1870052-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0054.namprd03.prod.outlook.com (2603:10b6:a03:33e::29) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) 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: DM6PR10MB4313:EE_|CH3PR10MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ccf4d45-27f6-4bbf-5fee-08dd07bed5c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: SdG/mmF6M5S3JLvImhYVG1EacDt3aK7TBd4djXOOyB1/PfqvK8xIx75QV9PE6Dk9ZUsNmuRrr/E+aTMHzW0Uf3bO6UHcky/GCLWSfazdz3tE3kx+nbZo6QKDfkHlEkAHwlIsJ38xh8JXVrxbT62dG7O1ird4jg9NN5DLAyDWeDHQHmR1w/UzHCGmrwi9f259mVptml0sSrkswH4GbRryJwp3EfVeuxfopLJfScypn2QS+nTUaLQHiQiU5Xh7esog/fAjUVaDoR5MKp6mqgzg9e9OmWIiw2oxpzLw/7lYjFi4L8D9/xswERvLYHQc6R/J28cZCBh32S5emrCzFCFkmjWuN8CWeGtNsHeC3NqmLCEcZ1q1AInE1BQsR1iCiEHYim/XFtvzoByiqQ3ZjRUc84sNkr0K2qLxOQfVmdYNqWIs+mbXgJa3NaLtWWDgtw20C8A5b0UIxMEGCcCB+U3V+Io1FLUh8rOxluSPb5e1lwWqkyjFftajeVZqkzl71RJXd6YgdZAM7Ft/gsUj+e+MZV0GeH1hz7vEcb+k5jLesbVLVd113z/PUhGeaBSxbnIyZzdnfdLv87EdCLa3jtuyCkazvwJcTB6cCcmsuZf7/zk9gANbg29BoilNRSD3VlI/aeJ/BJQrvb84Kn4sFxN17SN2b59I5V2JJzuYCqN1KMDPD50l8s1pMN9vCEZMtK6r3vRVyXNjeq9SjFcw1WC3VPZq0zfE11fLNPVluXuppGgt0K3YolpdFjaVMgfHi1lbo4ozG27LYv3r+MIeATcICb/ZZ47WZ89Tlrg/39myf5QQ+pS5kovSatbRhctxiasYqJ9XTKkyEmDjWpRNkVi8ngynZbe+H4umXjqT2zl8dWx+lJRuWnq1a3ghQyIfBuJYqBlJv8FjwGStefZvLZrY1HdTLhSVBVxL1Q83NVS+FDWylusNKWFXn1CgqQWYCbJIFIweyKPpD7c/7+tRUJ6IKl9GuacPqrlkBg+9PtEifrt5eeqfaaQFwp8eaFNwtuQ1bxGurE9JRA8yFQGd4GHNAaNtuwrH106bBZ4PTBith6qWG4H+y+K62Dfku6gJP7v8VhqTcKqFbof5pEHL/+vOaBNH6cxkrmvnc7lwiPENKZclvDm7w0gTb1fmJyoe8FVl6kU8L3o5pzHGjeV7ZqDgVw+VHm1+J0JWF4MvFyKGMKguNJQymHVeJKKvM//LMEmhYV99bRLRu4cHGrSA9gEsGuFdOuhEfXAPsWA3WwMEeoGWiik1pjlNRBFL3/jo3/jyKKQ7vU0BYnuSc3CGtmla0AV4569j0cYVvBZePvDOS/jbdfdYAvwBRXc68KRE+Z6u X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-Ant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zfFAyJ/5Ld+OmAqLkbjktjQat+WZQdw5xYwiGVgZ9tTGeeOkeaKeqteWllqP0wI3rOcJ6pgtfcFX6QLhtq5ZrIMortMI8Ip8sYO9FXneS/Kudo9utNFCbCOY8R+VhtFhyxn06ML4Oy5rMeMAMJBIjUB8XN0Ze85crniTRWqgIkOEFORm6QOnP6I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3ccf4d45-27f6-4bbf-5fee-08dd07bed5c9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 10:50:36.9295 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IM8ajaIYNjfuQphTuEmZh8WN3BGEG2XrhL3iX9EnzTnWd+rRIzyStL/WXBURlHO8N3Hwm3s1wsYUiF2qp8CS7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-18_07,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180089 X-Proofpoint-ORIG-GUID: JYuxYXPFMeSAfiACg1UU5GQIIgibeduJ X-Proofpoint-GUID: JYuxYXPFMeSAfiACg1UU5GQIIgibeduJ Set BLK_FEAT_ATOMIC_WRITES_STACKED to enable atomic writes. All other stacked device request queue limits should automatically be set properly. With regards to atomic write max bytes limit, this will be set at hw_max_sectors and this is limited by the stripe width, which we want. Reviewed-by: Yu Kuai Signed-off-by: John Garry --- drivers/md/raid0.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index baaf5f8b80ae..7049ec7fb8eb 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -384,6 +384,7 @@ static int raid0_set_limits(struct mddev *mddev) lim.max_write_zeroes_sectors = mddev->chunk_sectors; lim.io_min = mddev->chunk_sectors << 9; lim.io_opt = lim.io_min * mddev->raid_disks; + lim.features |= BLK_FEAT_ATOMIC_WRITES_STACKED; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) { queue_limits_cancel_update(mddev->gendisk->queue); From patchwork Mon Nov 18 10:50:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13878399 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 AA0371991BB; Mon, 18 Nov 2024 10:50:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927059; cv=fail; b=scj6MhyIIQFcjFMz+uvaq0Y0OwdOPG4MsxEwStnubZvO4nKbwjJtmjjXBOfMvqmvlINoqlVfXxaNN8cRH4XZohJ95kakRDS3vHawJME5eyLaxkTjmLJSw/ZZm4LA+2RGZFuJXhbEVxmVZ4QCD16MHZlS3Cp6Q1QYBK12qX0XZeg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927059; c=relaxed/simple; bh=QCkgkCUDb/cm1thGqeYyHCY7Z2sUEXZreRdRGpFIIEo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=k0xiuGMiUGqrTMleDAK12YEXAP5gx0pMLeQ0sovMe1Xi82wxjbHmp9Lx9EjLaeVz+1NFmFsW3mePjeD1AlEzE94vKoPZ/toPR4ToVahAGuSrG7TUeJtj4lVWNNmP3ZI8lZHdM9yRA8JnvTjLS+ENSqngYES6Aj4ewAmFgeCdPZo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=ZpP7zf39; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=K5XEOEn3; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="ZpP7zf39"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="K5XEOEn3" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QaXG004695; Mon, 18 Nov 2024 10:50:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=Ayn8ndS6q+y5ybPwUu0Nft9UAxlsEsmFXmED9UfGcyo=; b= ZpP7zf39dwLyxcsTr84qcEtYh19tc/h+XQougcW/Xd4zIQRR/NLFsM0NviN40Ahn x1T7G5mQUV1Xqax7cA+/gtAY/zphxhHn1xovJ+QXQFhJTPCoWU9o+pJ6fMNm9SQL mnUB+ld74HIecILksm3meOpHcjzUwmnA+CSpNDzB+qsYEhzyyVvIz7MtO6e5zkjC L+CMmbOD3AouRVmQKabv27F2SmCuFOdwcC3pEs63LFaWG7VI6+dYehjvc2s2um+d 3dUM9SNtmf4k6Qo5vZW3S9kf6Gm25BeWc3Auif6PGEFuWxEEr9HAhBcX+BYjSn6h n0fYRTARAv1fuAjPULtNMQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xkebtd2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AIAZs8X008914; Mon, 18 Nov 2024 10:50:41 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2168.outbound.protection.outlook.com [104.47.73.168]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu75sb2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fQHDEI/Hxs+CGskTNM2Xgd6lMw70iQMbuN7KMIpZTBTl7OqMOcZfL0hQ2Gnh4YJnEo8CG7CsXbSI+1VXwVDpj8Z5GNYMw/Lv8nuPRHCDjZJdDC2zKgT3UPl2dTtREvP3fFQc5bzPLW/EhoO2d6AX1LtVij6VPDJR0V0KL8vTq/JG5MQH/JhZ3VHGwFp3lg5N7B55K9S7/in8T70AKns44gWjTeRg49ZKsr0BkH//Cv7RXmFjPasGykfEl3RoCtzZzgce3/rQGxe91fCEX5KtXQBZy5khwtRg9WEM7FYOSccYxvA3lqNZ6czzrDHDqwmdigNx9iOS6eK/+Yi8QMRsYw== 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=Ayn8ndS6q+y5ybPwUu0Nft9UAxlsEsmFXmED9UfGcyo=; b=A04WuwHkMFh8yTMCyzWISUNXWox679c+5YC1OFVoa9KMPJhOIcw6EkuxlqRPu3UxZVLz1kv1FFe4a6A8KdFw46jZ+JRbVy6tEnpbNgeGwqbqnatdo0PH+mMZgjSDw9Eh2uWHtks8wQ1yWnGEYLX2MCB2VF+mhM0Pxm2wA3toGglwAD8plBtTKLmoc1A8VKYFMEiqyAuqJyG8IKlJbU4y3nIsifUAZ6vNLuFYfuSny348sJVHU447jsKTQ9dDE8QSF3kcnes2SeJ58Zvrb8ByoOlQw/5/5j5HSY9kPdi/yhxEVwMeUNL2pY4pvzYCnQDi7ai3LcIZvY18Ni3jNkHgvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ayn8ndS6q+y5ybPwUu0Nft9UAxlsEsmFXmED9UfGcyo=; b=K5XEOEn3I0KoTgJlqbH6npntmSEGgzKDnwq7oqQAPXXU7PXe6A1H1cXQYu56qv1fWhZa3iGhoKhoayd4D7/6tca2lj0dR5wCN3sfffInzhr1ANmXO12RcOAcVtXTedV8H/91S/ioPfZbK2wmrdCIHZXinKQuCY9mce0LCJoccYU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6812.namprd10.prod.outlook.com (2603:10b6:610:14b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 10:50:39 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8158.019; Mon, 18 Nov 2024 10:50:39 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v5 4/5] md/raid1: Atomic write support Date: Mon, 18 Nov 2024 10:50:17 +0000 Message-Id: <20241118105018.1870052-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241118105018.1870052-1-john.g.garry@oracle.com> References: <20241118105018.1870052-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0260.namprd03.prod.outlook.com (2603:10b6:a03:3a0::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) 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: DM6PR10MB4313:EE_|CH3PR10MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c0f9e83-5306-4c71-49de-08dd07bed6ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|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SjvhUmwbyCYhaNMqXhGZsh2gc2MZAnEObTKufJFW66sBx+9ggp0AXefCVgV4mq9+M4KLN7s3IDv4zES4aZvNupC503O1A6QWeK5JiAXLldENHSSbCcAyjOyH2JpZ0gY3gVy0Yzrm9/z/371mYfJ9xQ6vARBhEF6jag6BcfpDEyuwbBQJhQ4r9IawO/iAiMBkEP3+pppuophSM3L9FoJe70Gkly9BTZZ6uPlKfku0pUO8FovGgtdCo3WgjGogRmS95RyYf50A7VRxl7K2jLH8slSoi5nLkfrKgB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0ZvMwwPcluL1XP2HzLS+1XwFtTPYDC3PE64W8zmzRxB0yM8bttItTUcLqr/9kt/1ilFTS9uLmPKJ3xLsWVi2P9TgTWhcHwnWikr0wGMn0qh2eX+4YeoqURBYZ8udNoqZY/iiWoArljdEhS4fRuxV8cBNItq4xXVFERUvLj5+Y4cPASjrnVvEZ3HpJAXIDOSWnqReUafwDrMBBkCa9dKbkedf9dYU7VkkRgI/PwZy5wV9RRCQE5gZQ+yyo81yQ/GuWiz/BpyYTz8Xu7Eze2TvtfONvLT5Fg/ejiQxlg/AdjfVRUeJhB7IF4X9NYIEzrksIDDr2ww05crjEOB40dDS2A5B1VEurQO6F9njO7C30Aq0VajiuJEcD/9NsVqqCIMo/3U2S4pKWMoBlEzt2hnyAPF5TIrPlQiqIblnBpUxSFA2Y14AusSjwXD6ldSgv/8v9UcuJKWSfXfTn68K/5NiDMpNds0QiZzglO3NJVpr6+qrEn4m6IWo0WlDVZkr6nGkeOsAddPDHvA69nCYIGknfgx6qdeVPdXQzvFxyf0/NnEobdBBnAc8c/OEvbnKXxa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ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: v31I6M3bUFygvUuQ/yfzl0X8wGH0VeACLofMCPNLgWsq3+ogFy8p3rNa7RYXCnMqz82fnx6jfxBh0b7LosRY+P8fzSyCK0UsSb+NWiKjQftChtL+3Vi8ZeUqc8l1rm6gNUo3gWBBqtn/EUKno9uvAubteIF7UNqRyR2ydN5qbxqyFI174N7+U2L02cWUf6DoMIuuV9va5iIM1WDNMk8gK6TohO1SzRPgyglWkiEr6g9d7XsUObySkspFG9PJhT++TfopcJqSYqEwCDhveWlMt7SR55zhQMzBGivTiRRUurOEzZC9OCT0v4E98BR9CtOPWvbjdLElBxtSHDrTectllxsYjigUARDUMHxHRohp1c4HHfIRmoJpB3g9+VnFa9IGQByNkOV6z04EJq4gYAnzjWlGeHTMBUXnbj+AM2QG6fOV77P4DRBkBrBZEbTR+6gljMUW0L1Oga9wVnvutjGeek9B2OpZVe/lGjoiHI0OAzeYaIi8eAKXKAwAfu4nGHZpqV33VKPlfBSo1o6x5lnu37EC8X9LDXK94eyudug/e6rLEVcPT4MS35OF2gqHK6IcG1vTJR1bK6AyVHk/mrenvcvKouJ05jXs4FbksVz9yh0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c0f9e83-5306-4c71-49de-08dd07bed6ea X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 10:50:38.9058 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lbdNenQanDXTBrnwHF1C9Mxte6/i2fRO+d823WNfNxfOwW32t1Ou0uHHymzkC6uM/YHWq+h5njjAQ3P07838vg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-18_07,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180089 X-Proofpoint-GUID: cGcadP6izNJdGH2W6nAq3-LR8xLupMVq X-Proofpoint-ORIG-GUID: cGcadP6izNJdGH2W6nAq3-LR8xLupMVq Set BLK_FEAT_ATOMIC_WRITES_STACKED to enable atomic writes. For an attempt to atomic write to a region which has bad blocks, error the write as we just cannot do this. It is unlikely to find devices which support atomic writes and bad blocks. Reviewed-by: Yu Kuai Signed-off-by: John Garry --- drivers/md/raid1.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a5adf08ee174..519c56f0ee3d 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1571,7 +1571,21 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, continue; } if (is_bad) { - int good_sectors = first_bad - r1_bio->sector; + int good_sectors; + + /* + * We cannot atomically write this, so just + * error in that case. It could be possible to + * atomically write other mirrors, but the + * complexity of supporting that is not worth + * the benefit. + */ + if (bio->bi_opf & REQ_ATOMIC) { + error = -EIO; + goto err_handle; + } + + good_sectors = first_bad - r1_bio->sector; if (good_sectors < max_sectors) max_sectors = good_sectors; } @@ -1657,7 +1671,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, mbio->bi_iter.bi_sector = (r1_bio->sector + rdev->data_offset); mbio->bi_end_io = raid1_end_write_request; - mbio->bi_opf = bio_op(bio) | (bio->bi_opf & (REQ_SYNC | REQ_FUA)); + mbio->bi_opf = bio_op(bio) | + (bio->bi_opf & (REQ_SYNC | REQ_FUA | REQ_ATOMIC)); if (test_bit(FailFast, &rdev->flags) && !test_bit(WriteMostly, &rdev->flags) && conf->raid_disks - mddev->degraded > 1) @@ -3224,6 +3239,7 @@ static int raid1_set_limits(struct mddev *mddev) md_init_stacking_limits(&lim); lim.max_write_zeroes_sectors = 0; + lim.features |= BLK_FEAT_ATOMIC_WRITES_STACKED; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) { queue_limits_cancel_update(mddev->gendisk->queue); From patchwork Mon Nov 18 10:50:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13878398 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 00FCD1990C7; Mon, 18 Nov 2024 10:50:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927055; cv=fail; b=DX6fermDn/l5CZAUzBRwHg/zZ/tAha3coK/2FQLzE9pO1gfVZbrVOBG4GPp6axBs0XvaoQaUpF9cRpUrUOB4bS+laDqTOUhyjfkvEAzppJm2NlrZSNpsFV7rB+onasCQplUXGVd8Nru3KoTUnxdIpA9Csv0HWBGBvb4/NXqMv9k= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731927055; c=relaxed/simple; bh=tGXd6v5fu75VTxyM9dYxDM9nikk6TaRYBXIb5eWiZmg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=ZbzYM6S9jbZ4gIszv/r7GlnM/+Tf+7rChIx4W5rzehe4HeDu4eTP9HmR5g4121I7kF9hNg6kCqWPVcil38y9Ve+5fYjONKrFEnxUjyZeo2EAlNfJajjN1es8ZoJHUKJ1bR2WDoy0eArTggbY1jBPDTzowyVaeFa0oQ41dXgJH0U= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=MRyP2r01; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kipA+OQz; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="MRyP2r01"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kipA+OQz" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8QVdg004562; Mon, 18 Nov 2024 10:50:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=DN/Y8o6XwNHIgExlg0S9MdUL/vLdc51DmXKFpsr315o=; b= MRyP2r01+AR9MyrUEwd0MEMjFt6Z9jZpbpis8jvXdoXbFAHpTHzBcgWtsc4X0DDm SbK3ji7SyuXdcQw3OU0bHgu85KmwGr0OgKxCmGeBjQKxTvud/eb/EnFRj7rPobtJ OyKjkN6hJl9om4Dw5XUn+1NT9uyV0dS+2q0o94LITHmV/d+Pn/ELZbCDHPi/9zHJ qMirrrumt6Th4ssiA+CaLXqBO19eQ6S1mqb6YzViB0zPI+OH89oPnTSKsBZJQPHE UN8TUgj3TUCvbeGrebkU01wG6KNB9jv2A6+ZiykKQPOxShO6f9pQ9//mc7/2ipq1 TLWXh+2DaliWj5eUZphmHg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42xkebtd2u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:45 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4AI8wtWt008976; Mon, 18 Nov 2024 10:50:44 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2041.outbound.protection.outlook.com [104.47.74.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42xhu75scd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Nov 2024 10:50:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=USCoQN4FQNkphEXFkK0OBwBdkzrnIQZYnvry96zOg+SxDmDm8wq6ACN1hL9yo3jG9KT10vAaZOZleg9J1dUTZ6rL63TV135wmSMzh9Dmk65G6lcWwcktEn8CvBcfO2AtOJDCB1Oup5xCj4+I7dHU5bd+DZwer+Z2IKgiMZWWQnylXi+qyjhwAaFwsMKJcJJ1uJeQZSVe15o65Wvx9RowhHt1LMLvDguN9iqRAqaCXlRW3P+eOc+1RAVN8iShAXdGallnPXaWsWwxbBwj6pb9j+H7ucFYjYOIK330bpKn5a0ZVnbTG3UPTboYIAQWH/UvcHOF5KNnJKnLx9Tvewc9OQ== 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=DN/Y8o6XwNHIgExlg0S9MdUL/vLdc51DmXKFpsr315o=; b=xAElU+HuW0UttrOFsNgwt5Bh/Af9knIkjRDDt32XTt8/y8+cdqBfZSJxUUlctLlDD3P44HR6620Zir5QxQ5ZhKpXNwzKkffTHtStYzHbetW7PhMG71M5POLzWJpYcXcSc6cCzCTspQLCOx79zhiS2Dkc9DEZKGMH/O1fKKtCfx6xsa1mWyAWtr9hcwlbBC4EARO/vlo7G7TyM0+2Dv+FB1krSmphQX8aXWevyxrAP1MPe7FmiPOFABLTEAHA7ym5CZB3NfdnfqzWAvkLr5zvLXxZcCLoJXk78oIjJFhMSxlWZRdEW34gF6n/yPBcbqVxzW1yvjOjwIPEkPtmTqlavQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DN/Y8o6XwNHIgExlg0S9MdUL/vLdc51DmXKFpsr315o=; b=kipA+OQztCG8ZLTO0LMoaf4iJTjYerKFR5tbQwICceEoD3STkXGPAffzWnmMxYKgfahi91EwkfOuZxQlqHB2/TW0KuJ8RV6ALNl2MEI21Z4KbDpEqQsRlm74QH+c0CzUBr177ETSLx+YtF8mEzqJ16MPSctLHOoK+w58ggtXktQ= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CH3PR10MB6812.namprd10.prod.outlook.com (2603:10b6:610:14b::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Mon, 18 Nov 2024 10:50:41 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8158.019; Mon, 18 Nov 2024 10:50:41 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, hch@lst.de Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, martin.petersen@oracle.com, John Garry Subject: [PATCH v5 5/5] md/raid10: Atomic write support Date: Mon, 18 Nov 2024 10:50:18 +0000 Message-Id: <20241118105018.1870052-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241118105018.1870052-1-john.g.garry@oracle.com> References: <20241118105018.1870052-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:a03:33a::14) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) 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: DM6PR10MB4313:EE_|CH3PR10MB6812:EE_ X-MS-Office365-Filtering-Correlation-Id: 2d0bdf96-7a2b-4ddc-f8f6-08dd07bed84a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: GYlXsUxFrUrUQcAy6Brzjji+/mS+uW0eyngpzi7OYYqfsYo3QoWsGYSelKEG/2fTULRMmj0D8u21hsCd4Tt2Nz6tWH6MEDmud2UKI9n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liO6DdTb0U+fiuDtPX5bjwLEQfK+kzNqjP1EKgl55efd/CrdtNHeqIQS19wMxKlc5892Y1EkqL6rV2k4PSMB7F+4OlAa5Dj4eOCQBqQwmdPatEa5oIlkMYET00vkZdqQcFKbFdCUAvPctXynC2+nms3bQI4CTXVI8f/2sxB+/8M1c6rDAGLeQqXnXNvn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r3EFm1ddRO/77g7eLpwQxGuzjH4qSpsSR/I246q4xCFVriB6e9LpR5lIiv+BctQ8BdHZ96k9I66P0YoQf4s++T1uDjBa97rRiCYuTWmVySHEiKstN9GaVr6GqUg8c1d1yS6DqUcwISbk1S6TIqFOzNH413FWSnu7/wIeSnOn1kYuNDfy7JyOf/MKVW51LVZdtOQ08LaOJKgXriblQnoTFsUFIyTSfGLyq2ZkWYFkzIcOCK4TzpPo9Uv4zDURS7FzAIW0DbU2xN6c2DDt9LFVoSxuJLgqqbAaucEAwozWG8Pb3ucm5yQyhntiSDX1+8eu1Gpn1BLOpydSQh2SQ/m6xPbggjcTTV8BkFPKZPTb5PyPBVhocq3cN4nyVCqu+EsmQjpNiimZ469vY+2ADXAhnXFmLqLmiJJX76Wc3tNtya51m36XqTmoZ3wrZTQiuKOoOacuayvNFkhNBLpuckQyph8h2r3kZeVeNeuIQXjuMb0yIZbnzGOMIt68y3dqHvYVrqX9AN4RP2s4LqsS6J7nJZPLY0Eueu6SHNZHtAiHumMh90NMcNlQHGDvu8dSOZ0VQkIFd+zx6UTv/Yn7skkfKET2byjR0VJvVtECEbivV0dp+48wCI63zUIvxrKI7ypp/VxIAas+HS4sq9ZE0Xa6taLTxK4tfhj9rIwhju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1sHKg5iNh+3jN91WzOhqy5jJiSBISe1uWfuzv2M/5j+Bs4i8fO8bJoIhi3vLWHSy4h+xMUPIjMGAj/5g5sUbPJUfYbwaCeMQa99ZAVVyvl/NfwPS1i++4C4X+KoRN49UpnYjajsAUYQosyATljngGm+HpssV3wjE57QJT847uY7AvIr7r6OEj7WwgWDoVwAqyRHwxymKlYAx4RlYfwkR6hCsDHFuzUN7NdEZqh82rFlCfk7osOqx3l4VptZGbIrp9In8rIZHVeNEjzOAnTFsL9CCly6IE1ncckQ9xaq+zar2m26LwWAgeZ1++AoKSuQzoPQ2R87H84YGfSLAOV2SS1AMPy6DMlqgGBRUAg36IFIzbU0Aw4oZm1hUbcWd1pxbQ3zkFjtE5zyNgB/kverRO5ac25/kQ7Jtn3Z7HBt8X4qH4N7r+9amH04zicLvQWuJNkHMFyiwq0uIBcNmHK9HP4Jf6znkw5bnuDy3m2EOL99rwdNvBTV7Yh0aFUyPDJamPYUIgP1lWonevtMPQsjV80UdTvxGTIWB9fINRPwEXgeRnVbacsc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d0bdf96-7a2b-4ddc-f8f6-08dd07bed84a X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2024 10:50:41.2100 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HTB3cUeGooK20Ar/g6SpwQaglggIXMibRq3S19OVoOgTNFQNwwKg4VpG6OAdTev1ROC/V+8OM/KuXUP3w4iafg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB6812 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-18_07,2024-11-14_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411180089 X-Proofpoint-GUID: 0tL893VX0PLGvXHW7OuKVfbMuM07Pm_2 X-Proofpoint-ORIG-GUID: 0tL893VX0PLGvXHW7OuKVfbMuM07Pm_2 Set BLK_FEAT_ATOMIC_WRITES_STACKED to enable atomic writes. For an attempt to atomic write to a region which has bad blocks, error the write as we just cannot do this. It is unlikely to find devices which support atomic writes and bad blocks. Reviewed-by: Yu Kuai Signed-off-by: John Garry --- drivers/md/raid10.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 8c7f5daa073a..f779d8225667 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1255,6 +1255,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, const enum req_op op = bio_op(bio); const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC; const blk_opf_t do_fua = bio->bi_opf & REQ_FUA; + const blk_opf_t do_atomic = bio->bi_opf & REQ_ATOMIC; unsigned long flags; struct r10conf *conf = mddev->private; struct md_rdev *rdev; @@ -1273,7 +1274,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, mbio->bi_iter.bi_sector = (r10_bio->devs[n_copy].addr + choose_data_offset(r10_bio, rdev)); mbio->bi_end_io = raid10_end_write_request; - mbio->bi_opf = op | do_sync | do_fua; + mbio->bi_opf = op | do_sync | do_fua | do_atomic; if (!replacement && test_bit(FailFast, &conf->mirrors[devnum].rdev->flags) && enough(conf, devnum)) @@ -1468,7 +1469,21 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, continue; } if (is_bad) { - int good_sectors = first_bad - dev_sector; + int good_sectors; + + /* + * We cannot atomically write this, so just + * error in that case. It could be possible to + * atomically write other mirrors, but the + * complexity of supporting that is not worth + * the benefit. + */ + if (bio->bi_opf & REQ_ATOMIC) { + error = -EIO; + goto err_handle; + } + + good_sectors = first_bad - dev_sector; if (good_sectors < max_sectors) max_sectors = good_sectors; } @@ -4025,6 +4040,7 @@ static int raid10_set_queue_limits(struct mddev *mddev) lim.max_write_zeroes_sectors = 0; lim.io_min = mddev->chunk_sectors << 9; lim.io_opt = lim.io_min * raid10_nr_stripes(conf); + lim.features |= BLK_FEAT_ATOMIC_WRITES_STACKED; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) { queue_limits_cancel_update(mddev->gendisk->queue);