From patchwork Wed Oct 30 09:49:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13856163 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 B06D247F69; Wed, 30 Oct 2024 09:50:00 +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=1730281802; cv=fail; b=lZqZ2JBU3xqyYjXQNEMlJPQxsl0Y1VXXLzs5Cgi0CNJgiUl2nSe4qhTmhRC0XbmOZHU0eLvCY0wNWp4JyEA8eF915Sbj94l416KNKo86PNMSO1PRJRaBBAIQOJrN87SyaGXTgjgT6JKUV8aHF9djV4YbpfkP53RAA5+J58NYsBg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730281802; c=relaxed/simple; bh=01KhSciHhDpqIB1/6U5BBDLB75C3JmBwAuju0Jwc1vs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=k63VvORrrYsclVCXrp663k+k9jGjloNnIJnRovdqosg/EDqyB4JOsJlPmLsy+tGcsW4aIiGRtVw4AXUNnlV1HnkCVOkYoslusvplbGTQcN2JbE7WgvNfeB6o826WjdF7cZGFrDndXaXUmZJ9YNglwvf3N8KQ8aQ9e3jpG1UEFD8= 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=PnlQWo4l; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=tiZ+bcfK; 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="PnlQWo4l"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="tiZ+bcfK" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U1fhbb021327; Wed, 30 Oct 2024 09:49:50 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=/CmkZMrTMQ9ALPs/Yfn/GrGBLtTKbirfOTt6rVEjLxY=; b= PnlQWo4lSC2hiXzrFaR04pu2EQqkRKJRYpeQuF8t6iTn2BAcMZK3JWBR5vi0/P7M FpEoJMt7oDWv21CIhaLs9RKG5dzZoNPChjyxUbxqnnGtyz9GdG/qsiveA+2lq0y5 S2E+f5LQdgIqBLgiDbQP+RWNS8iBKMASXgrhSyo8Xt/iOdQxdtsLbu1clqPUfhDB uM4d+RMFygY6sq0owYtew7Jw6EPkQwTsqIUyM5TVaic76DDpm4FrKdWjSgXVjYDO ee3idpzLgULpWn2oV8wqdKCUApQyJ11NoUpPKzupDPoP6iPD9Xltf6ZOIVzQxoKC ie+9F5zvT7hwMtC5Qy6nsg== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc8yka7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:49:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49U9C3jT011747; Wed, 30 Oct 2024 09:49:49 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2040.outbound.protection.outlook.com [104.47.73.40]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnadsyqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:49:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=P9pmnhsUvEMRoxW1AMrq5ddCzqNVD73x/UckunKDzWlAcGaoAtMVUgPfK/IyELhKs6lUzdO4qKGZ7my5fCiMwxWcND22gJygUhDg1hqIoEX5zDi/sYyTX8fj5xDymOsaeAH2zUVTCtilixy500oPD7jn4eHt4HN+LJVV49EKuyN06W5uzSm//GffC5HfrkPEyrAgD772QGat9MyKgxX5tRtAvVpJgK5ef4JpFgqQocLjLsV0Hro+1M5crwLsrOYyvIqTZv2qxYboKPhMvtGgA4ebS7Zm/XUwGaTUhu5O1YGvNyIck51ehf9KsXMtSCwzKsJH/jx6nGJYp7GN4Bo9wQ== 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=/CmkZMrTMQ9ALPs/Yfn/GrGBLtTKbirfOTt6rVEjLxY=; b=UP8C23zarQl7gRRoDaspdt9DRiaVa7XBWpYHWV89hoxIbm95QccuFf+hnjrm6TpDdWwEeS9dZ9iXwHYALASNZyRfklWjNHNGByRW8oCqH5z8q2RQvVRCS0CGmYBFHpz7GKlz1iHkFzbwsMNJiIv9CqNr+TtsTweZLHtpUNbymJ7O8PNAeVVoyKk9Or++Hrlmt/ZUCQkfNPe438fZVeZ0L0/IUhXBWqbTBRZPX/w7sOICrnJzRk7/aM5ytq7QGG06b159EB8xL2hXzc/ZF5eoN6Z9iRC48fZSR5K5nqE5kdUphokkl//RFk0maljXI9lmNcWZcMHus0E45VagCHPA3g== 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=/CmkZMrTMQ9ALPs/Yfn/GrGBLtTKbirfOTt6rVEjLxY=; b=tiZ+bcfKoQuhqNafaMwhmNPrnJtUp2vJA7NHSKWtYy4zQdTd8jmcvx5fpiPPlT9HrczssmrJ+iCIiBDyEPJa0qKq3V7Je/lsvvvQ/TR9OpAMKbmq8RdMxXn2xd+OI1NY4bMcu4Zwl08/YtigESmntGZ5QCCrqKB0XJO8OqzKlJs= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ2PR10MB7826.namprd10.prod.outlook.com (2603:10b6:a03:56b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 09:49:46 +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.8093.027; Wed, 30 Oct 2024 09:49:46 +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 v2 1/5] block: Add extra checks in blk_validate_atomic_write_limits() Date: Wed, 30 Oct 2024 09:49:08 +0000 Message-Id: <20241030094912.3960234-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241030094912.3960234-1-john.g.garry@oracle.com> References: <20241030094912.3960234-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P265CA0063.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::27) 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_|SJ2PR10MB7826:EE_ X-MS-Office365-Filtering-Correlation-Id: 072131bf-a184-403c-48cd-08dcf8c8301f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: UUIDsj7j/iLinfveKv6q5nWjPeqoBxNx57n8pXYxNodsrmPSQJSWX0TI0FoIEZk0wSqlqBdbetTc84NJ/koiC72WTWsDNC6rhTXg1VYkJrKoP71Pq5hJ2VCj3gPEXnT3XJS7y8z2cx7SHNCpQOVqb7bsXE5Hf4w6x707xmvYTCraRHUKvFF6evLC1ZsHzK0vWC1YJlb7zjdlvzRGMaSshSEK0t6IhWut/i9AHUh8aqmNouvsY8OduQzDMtUtsrV/D+OmAzC+G/LbLBy/28wbrOXLqgnFd9MxllcoYdSD0NunuAqWXqA10N4IHGNp9q+dia/BYXbZ9jmeYMbRgjyVQ8zRCyS2jaHvWsh901pCy4O3MkAsXyE4bUudQ2reuAe4a22uot6HI4hggItXwju77++2lpNcycGMA/DXATS+lbtRsbsJ0wVko3WOZjt9Uy70YtrA4mdD9Pf964qCdKryKDHZ6Vm9OaK1lGvMqp0ilH0App61vFdYniHcxKzKzYzzBRAlx364gDU3XDDQUQDl6p55rSxRsD2pF1KhHMyRaeflgFGWs5X8HYd7e7giAbnc2JhSvqoHfz8iZ8+bgZIQiCzrPA1ycJ3oX0YK2ZyG2lP0L4fDGCSTWxga4Q/Wxjgcg8mfF7urT/rJaiKsyI+GhXxwL/CEguCYlJaXRoBLfva7J6BCVh0Aripn2f8cNYjDMZI3U5CJhlAIp5o7RkIbjLd5rMAwZI5AShEEOF1r404LjaPreY5zo1AU6WKtTSemyu7Lm02pdsxAHl5rAjxh5ZrM68LDsGgQ+uXIgacU2I/Oaiq6KYFphmx/12HBjNHfigRLsgT3jpSNuwH2yDoLtizYkdrvPw5QRa/3bb+TUaa86WjvLRFICBrZJ8yCjkxKtNcbKxPCkH38f3o7GHELBHcMOa1KRnSzrZB52DecDuiehgq2yAsWTkB4eEF9FIWKDxQbEJ1BZHKLF+p8C09F8Rf6QWKsJlheM19UpD3aCg+lcDW+Uqb3w71sgJrhyQXdFXmSQvXFonSJ/33HRzIx9qt9+adk6FC63UsvQk3ESpYpczBAd9BvS4JwDjI+Rip4rholfQx89GKjMNIrCaIo8UtIMt/0qlEu/5aFcGcGrVP0D7BssIV6wuBTlCCbI0Drp3Rbu+K5fDqCF9KYkweSVis9n0Q1yJU7r0YrQkayHWm1e2I6ERlRgCLPo1xIufDKi1FvF5piWePjfnUq76myet07AQZPkM+z5sQ9QAtccG6lyl2dY1mlSnDWNAZUM6poHGhpkHTSNdSXd65s0qKGF/ASPEwBToicGAvje3K4iWyrLxpnb9fX0r/4+8J6X/q+ 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X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LYxbtTVRimBwuwWt/zgA5S2C3/FRBWu52WBTIjA5iUr+16xj0S98TOijsadw71Mk7k7f9972fBv3wPi4LvF7xu3VrQCkgQEyMo4R9egQc9eo3frIMoixYTUZMKxn7SW2qR9rBGV+L6xcLoDscpZpzrLkTC01KWzp0YQNBO10eE9Dk4u3Fq8ijgBrdPJThNfwDXRLBK/D9AjGdrrKYgFeiy+zntvoVPUcON0FZY7JQInmnG7mvyUejqM31+GIZgOJSBEKOkyJcg742wrdoLiTAi0RSVXLRzND9gLz1umU5iD1s45rC94ur4jvUKGw4L4xNIk5j45HZWXt+2YBGY5QQcu/XX2TO1kqikQqYQISftinVvStN90UD4bX8VI2Rjv55FqZQTL9mqBHgOU6NOXB4MsJFAq9Ctyc30zta/m4Z7l1vPpBlblRS+3ZRzfmWMW/trHMYtD32tvAngWdNUjGNvMQxtHir75iC4bZ5Ef+dzkmp17ZJTJjfTUY0cX237fOzWVHumK1Ns6umo/hkhr80hO6oyVE9QQaehkpJK4I9BMHl0ylxkm68RiLSoZ64SkAVDm1iyNm9VPrbKe1Lw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: RqrX9oe9KwSPAOZV+G2dWqZWGD8mmKvYWc859QC23lmFOyu/ZgAtavAOAuojFCiGbA8GqLLewofr4KV/TBeYWHKhyzWNflwccBD2DBL2dSzWbUB85rjvKFwF7786nIlpd6bHSgsjQwLbYtR9uqic550NPfevpLDZOg4v9StCtLrZS+73GWMYxAizxrO2ZtPKHSsKdV+L7DhbsK/71nv+wLK/eQ/j2G4XTtPnUn3midcA+R/a3NooxlNpdU4jIrOC4isPUvLRwcTlNEvkbFWZgjry3dN+50lE6y9IqJfRfZa62vx+8a3vN/p4rmrROko/Jjf6eopLQ87TZHmV0uU/3NTOVoxKAhYCo3BCzh2g+Z6TFpOZikip3MgF3EJrHpB4KXiFH2S+6dWKyGzeM6Mr4WrN2dJSKDApncXicnvhFzmbUWRhNF2q5jOJrBSd0F9o7hURXfoWV6hho0oILCBhJUbU0UKzeeqsD+zw2rjC1BgnixRhMkvrTe28nZ1AQ8H9onsANPTBgKknSVuDAEFMscsQ8rab/9FGDp6Ft5ZM0iY4x9ke5WHbcQvSSpGo40krNefm1DG7DEVyBIgWeDuH8zZP9VxZhs3o6wAJPRKF+40= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 072131bf-a184-403c-48cd-08dcf8c8301f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 09:49:46.6350 (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: aWwhX67tZRSdb9E1yNwXVJ8rxKdnCiw5yOpiXiL//FlFUO6aQq9nc1AdR1b2gLjBoVw4R71q/C+ltLp/L6EtFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7826 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_08,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300076 X-Proofpoint-GUID: lWQFthl6aUPzDfOdzuXHnxeHFzV24hp- X-Proofpoint-ORIG-GUID: lWQFthl6aUPzDfOdzuXHnxeHFzV24hp- 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. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- block/blk-settings.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index a446654ddee5..1642e65a6521 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -179,9 +179,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 Wed Oct 30 09:49:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13856165 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 4129F47F69; Wed, 30 Oct 2024 09:50:08 +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=1730281811; cv=fail; b=OxQ9ZxUg33ug/0FnWqqiKvAtUNUqNUbsJwQ0DkaFSMNuvQ456zoCS/k50ya0vqSi9ElUhFqZ82IFMeD07TBOZvIo2zjYC4vDs1Q3Fv2BjfyBL1Y7goVx3GAu9hmgxRmgiSSbtAtMdr4Hr/btylQYAZZg+a48oHonG+4VKpuNYJo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730281811; c=relaxed/simple; bh=51+tbdWrGK7GeJVebgMzh24fmAtgHv3IzADiVXhq/6s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=BLmzdkNaKCXLxBoLWv4s39rvTJuJG7q1iJjCFR6Q6bSsR4tPKfgTqhuPiBD6L3RfEGHQBE83G736f5nXGVsl1Yz8iA3xUhE/zOe3DWxdOYQDaJ6kwBL7WfyykCnbI7U6Nu76ekfkAQAy6O60cTLF2NSlAQaZZnLm7jChmVcf2VY= 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=QpIkn2XC; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Pzi5Lw1C; 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="QpIkn2XC"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Pzi5Lw1C" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U1gc4o022254; Wed, 30 Oct 2024 09:50:00 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=ATUqzNGRzjQO142Qvfv6ph6blGO5ahwog0aRbhCRv6A=; b= QpIkn2XCR5PlKCD4A+5EcbILVh5hJ+aj+fYFp0jOORxDeWndJXxLUuSOZF687if7 kq6Cma90u9nZW6Sl17//u6v/TavaB/6BJMDQJh0wp92whxjgYrlew7kJL5jD55CY 0l6ljgd/91K/8uknJb1xr+rwbAMJnEVrnWV+o3TDWj7ll6u2YH7wfSIL21yxYkhh oh0+HbxT4HTK85A0uTWXHUoDgQnLDkEzpHbNZVJu7g8y45rjA/blnvdGjf9P6m5z IPb7/8t+pCGdjiAnvlAwmW0Wk+wUwddZgRA4HlIsaqmeykMTkkGwMi6F3V6JHDZt /YHQgPe6k9kpeJIjn09IYw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc8ykaq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:49:59 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49U7TQrr011738; Wed, 30 Oct 2024 09:49:58 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnadsys9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:49:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KLEjPaFCWKvwRPIK4Hznws+BMJa7rFL+RodBgkZ/AM7fB6/5KlYoWjAdE9AD3eyEs8s6cBmDZmxEqPR1xkNzc8VH/0i6HsJWmH6rEgTs3ZjhWWo30MWbQ5GMt3ZRyNnUM4YQtls6wVMfOeo5zEu0w94hHsoe1guzXQ1YKfO/llgvozShBi+gTAtUtUkWR0hkwM59EJrYHGVMiCNA8ZV3KYnTCF6rb7jwithrMQNNz2sf8JTWkLoYSUEUjYuv2+UNYX/kV7KkZnVtUFnXs+dQ8SPdQwBV0dRBmqF7+aCdGynRmsqmw1pbMNtoA84+8nNs8J4g8NjRF3y1WxCyEwJfhg== 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=ATUqzNGRzjQO142Qvfv6ph6blGO5ahwog0aRbhCRv6A=; b=nyeDyy88SL3S0BEwFAiUgLbFRZ63JFrReFfJx51RJAM0kGo8dFel+2rXJX6QqopritKFHaRWn9PxdXxswyVg/ta2Y52mXymupdXr4f+nDZw4YftxBC/NoK/vGHXb352kVngOdb61S9Ku0Gz2nF7syWCTrj88Uj0orHjcstGIpZpCeik7S7iAbFDtFpLh+hqWuwG+ay4e6pJvNixeTniELyjNd1IMLoR/lC66sE1ClLP8zjR9F5lVFxSzbyXvjGCsodG1Rf72XjWP2dujhdHhZ0ZyHohAgghtSEerAIEOGJGsKgFm9M2qaeqeVEKXUvf3hfMAYPgojBR89joXDvTfVQ== 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=ATUqzNGRzjQO142Qvfv6ph6blGO5ahwog0aRbhCRv6A=; b=Pzi5Lw1CvCbBsoHNmnXQFYETk5qhI6tYsA3pxZe/tQFROh5UT4pHRoj8SDVPN+v++yRMA7ZLh+wp9B192P/nT1SV+aL+N/Sp5y3KmqSCtLNDMwQiGpIyd86czUVUEq83Gl1bDAvF8I/x5NjNITAWpdAOhBtTyfRNcqZjxSDt8zQ= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ2PR10MB7826.namprd10.prod.outlook.com (2603:10b6:a03:56b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 09:49:50 +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.8093.027; Wed, 30 Oct 2024 09:49:50 +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 v2 2/5] block: Support atomic writes limits for stacked devices Date: Wed, 30 Oct 2024 09:49:09 +0000 Message-Id: <20241030094912.3960234-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241030094912.3960234-1-john.g.garry@oracle.com> References: <20241030094912.3960234-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P265CA0049.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:60::13) 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_|SJ2PR10MB7826:EE_ X-MS-Office365-Filtering-Correlation-Id: f081622a-b285-4f08-3f77-08dcf8c8326d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: LPU0oEZiNb4Ntstq4ETtnhGkvK5vv2bHBqmQcjE/rwGwOUdW/UpBX8BmCzOVeR5Fhwot34PjivDTPG7rb1Dgzc/0RaYUU7KWk9cWfHDVMaJzMPtizIB6JVCZghlkSgau/4HRLkOwkkm9hvWRbRJY6y4vay7VO77GIct/7+2pkYllXwZahL2wC0HZ1LBDGJaAE7JT8CzqoaP879P1igTKCBmUcWHaaH9TMAs4vMYcKID268JZi80fvZUxZuR5lY/twYS4WAbpTa98h4qI6J8lkFMIat7mTlbTW0IxdgHpXSDiKG9HlhwdtsMhDdpDZT5+acuVAxzumPlIAX/dzw5h6GBXH/os942QA0Yw3kk5xrE8EVbhQBtl9Uh14MqyEFeNB8/p2PrM34QWUKYC1mUxSQ9zzoO5ZsGO5brL0RSYxzbUeOvvvAJ4yb5/70NSLqHarSDnu7GHYdnPgUv+SLjZvdloF3vWq4UAfhIMJv50GpT5EZ7IIV2RJQaEs4PuMa/VtU71vt/+T9DRfZcH9sonnlK2/FWwC4icwZxnN8wuOudEroK9z8UX36VxUvZc7NM8aNPMWtEiFKilGUgEZMiLywtC+6IMk4G0oiwrDm/b3VYS2KArz2qrY0UNptrfhLDPVuB7gRgYZfziit2Ab9Xw0d2O7SHrMV1h+0cQwXm2d6W08o/L1UN6Lniyo0eE9DVE2XM76lqagLn2okzVUglxBPMWlw2Q0HLofZS8BchCIDxcpUvb7cs7ODZl/1fLX6jJBGrnB4fszhLEXXHj5oibzMq80ksfWXoHQPlZdRBcTqPEjOb10vw7lUeVuZd67ta4EDfNvcKO76nMRVJGz9gUGulRJPcooqrhNX5DP0g4MmK9/6Vk4N+fdqLE4WHJNn2kBllgq5TYnm/AuZ4YaVAQZvzlOUTiERWcnnBrvsXqh2znIUq+m3xI4pX83bDj9+XDQ03Zu4X/YIqSR2xolmqvnz0YGEqMPHxcXULQ1CNZAKxTj/IGTr/lcm1mkm/9CwWFLcHg/dse6sAG3i2ZvbKPhsvHd4xip58kDVNoYx6nE31frvaLWJSQeg+SyNQBGm3x4sqCy7AtVr/gwlBD9OovGGv9/fveP+9Lf77WnnKwYJf87YCGhoNdP7Axh0NlH4J48G+Cqw04Xg9513p3n9WWpR5VX+4uetq+SoooHCA1FPPsB1JEeiEV84NIBxJH5CMDXOkaX3LWvuaOuFHTn5BxLgIAAynzkZ6rJGXUQkpJjSzxnqDyEJQNzkVxC1m8AdxPXaOE7Xawsj8azCdNeynfRq/Qd+EErKVjF2ygwwKVRl5YisVfh0fMyVWCUv+tQhGC 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zxgsTVEyhUDxxGpPAFNzQq5YbUT+qSScxDG20jrKp4FGITMPKcvzoJtacysA2Zf6JMRGmdQRun9MNrQdK81xP359N/Ls+8W2xOQBE34t7e39XLp3oHEKNotagKGkJuBugZePT9u6/RQj+yJcCxktA3rtMzbElFRlp713hmRN/P17xvLJotogzl3KFD1cHmzDh0Jap4h+qHjm1xscwMOVN9RzfcPrxrc4OXip8YMIAVTHtw0D4L+K2pEY5sgvKcTK1nBUWCgPaCUQprowqJbGeefqwvXm0Ca3CcPxkX3W9QyMTjVhl7bNf4zMaTifJV+i1eq3L4nA8Qv7HwOdiTGRt/605c4kPCJJdHCOOdpC0JaH/F07bmNbt0SxSKXTNkZzVvZq9asbl+/mvXuLbjNLQH4mCIT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sEm9gyeyhHKzmh0OlQzVL0sOl3PNFJC19e8REUQZapkiyjAkDf4moj1krBbx96F6uhvjq+FENv5jo+5qCp+vjaAK4iYMu5x8jF+hKN6Mj4jCRg3XUXkR54jgbtb1aVEinvQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: o5kMKObqikJxmJJEtTz7+OVLkqY+Xk/ogEsNeouefoyxwL/8+0OH96HTbdn5ESWMvOZh+/bJnwOkutsITjUbOlr8B6LtaJepqXOPjdz8NDUwxm7AxBzTwX0oeT3c21u/IXb6img1pHXtUShwatSK3drXNy0hgHhm8iq56OO2nqmyyzx9SpNJKH+ij9OidTGjc6hQV6vG37GHVodAvlho17SrUSprK9Wsk0LKT7tShx7PwtWn74IdO7ipyGGNaeUEfsYJA9cnp1VgiJ+yePGqTvu3/NPxD9iQqSMgCeQI3yiOYu+WgMat7du/eI1WQkoOcZi+6a2G3vpvFcZdGa0XAtmfMeD7NiMhhNfmUgeNYThW11wNiK90xaZluB0oyNUsH2RErjNBdU//WXjhC2Mwls/F3/VJ5sdTxJxjnG5HkorRgSI69bBcMLsM65FGm/IX7mOdCL2U4yqkzRsx5A4xC7MOJUhToub/o8IsnJ9IrSm0fExvY3te6EOuPM0nxChX6dFNaSM02YH/YwNQJPZrQPT3SN1KqyxwPlPbRHoLEsZFINAF7uE1iTkCpAtffFvdnuCW1qsXBHhhiXxcTp+fdjIjmDS7WX5zz7SWQJZs5TU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f081622a-b285-4f08-3f77-08dcf8c8326d X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 09:49:50.4824 (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: WlqnbvyIKzaVFlttVR5qQqIEcYD4XXf4l9GeR2pgz2I7sBZKVwDbJ1XYfsbRZOwh8uxKUb03hBpNJdiMeIV2+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7826 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_08,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300076 X-Proofpoint-GUID: yGaE37yuyipw5qlZeVyxNAyJwGlxyK0r X-Proofpoint-ORIG-GUID: yGaE37yuyipw5qlZeVyxNAyJwGlxyK0r 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. Signed-off-by: John Garry --- block/blk-settings.c | 89 ++++++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 4 ++ 2 files changed, 93 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 1642e65a6521..6a900ef86e5a 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -496,6 +496,93 @@ static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lb return sectors; } +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) { + /* We're not going to support different boundary sizes.. yet */ + if (t->atomic_write_hw_boundary != b->atomic_write_hw_boundary) + goto unsupported; + + /* Can't support this */ + if (t->atomic_write_hw_unit_min > b->atomic_write_hw_unit_max) + goto unsupported; + + /* Or this */ + if (t->atomic_write_hw_unit_max < b->atomic_write_hw_unit_min) + goto unsupported; + + 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; + } + + /* Check first bottom device limits */ + if (!b->atomic_write_hw_boundary) + goto check_unit; + /* + * 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) + goto unsupported; + else if (t->io_min > b->atomic_write_hw_boundary && + t->io_min % b->atomic_write_hw_boundary) + goto unsupported; + + t->atomic_write_hw_boundary = b->atomic_write_hw_boundary; + +check_unit: + 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; + } + + /* + * 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; + +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 +743,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 d0a52ed05e60..bcd78634f6f2 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 Wed Oct 30 09:49:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13856166 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 719361E32B3; Wed, 30 Oct 2024 09:50:12 +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=1730281814; cv=fail; b=BnmCfd0dPgF1q4iQFNb/9Wet2o31fLr1AkUZHPYYZ4uwzNac2nCiKXFWdhlS+WW2Q5pAPp1E2thpLiRs70sLPOW9ihw7aw19Ow/NwVWRhM9B9AV8a09oP4NHwmkQCmYKLw2McMVYl4r1iqkAtwRG0FxhPE6DfAovl8eXbC5xh/0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730281814; c=relaxed/simple; bh=JUx6i4OLcDLbtSqCsLxDX1UApTuAwuBQb3gIDTrL8W0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=KTwADNPjYznj8V+50zY7q6I1+L70FEFEZpNIVoOTact9q0n001XXniUjPsKBiEXcq3CxdvFgG7iRYzBF0db1xgUywzSviBZ6g/nSGrhO+tegT129JWnoyL0A6HxhBsxC71tv1VlaNnAlJIfP45Ee/S6VeYQ5qjwjLyK88ofmUTM= 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=SQccPWfy; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=uWPI5k88; 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="SQccPWfy"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="uWPI5k88" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U1fjs7009124; Wed, 30 Oct 2024 09:50:00 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=KPzur4AxfWZs5AO4+T4e5EtkO1yoPlQR6W8jWOZbvnA=; b= SQccPWfyMhXveIFQKR6AP30DAU03EzMAND/nWKi7iGXtgZ6avm0aiMN+XgGTyHL3 p2W74Odg5mHoG3PCEFE57p0OqowlsAk+ZvKJvPxRid4y06zlo4dX499QcXrFriPm N7a+pBNu3YsELzG2QhBbg9eIO3Ad+gfTsAm+2mt6diBGcrqp936DqOVc61jPR+Bl OWOw6qCdeuktseuL+9mol1Ee+cLCfKxXx/LvQDtCfuORdcoHcV8KXjkOwPqpORMO SmoXPZ29fesEwut7qh6OhsUhyaClhoWwamyiK3jPO7kuv06dlA2YFzxsT/HSFpfi oFOkKExklUgAAF0C6KP6mA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grdxqkg3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:50:00 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49U7TQrt011738; Wed, 30 Oct 2024 09:49:58 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnadsys9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:49:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=dC9/dzNQ6D+7lslJlyXYN7+NyNsa/rSWWn4xbe737iyxSz1NtDYNb3ET5/PlAFF29rvObzgUotCPaK7Ol4xTVtGYtWjpt2GZTAAcU8KScMOKNZAvbWb8LBBy2bf2FhoEF1MvwPEnCq76RaXdTSnB4ThDbewGPIUV40g8kgFCQzHJMkl6hCKvGZF3Y29J5ypMzFdGi1dcq2n6Tm4yBwBlXb2lzT0DE2980BZkXaQTnJCRw0uNGTWkdMlaO7nLWB5GlDNMW+zFL6e3jfTBLIgYJHCNIogaPlpicbFZaZ4SBvxuFJmErm13JrTD/HIbLWQ5s5MNutYlxIyFpxGSKAQ7YQ== 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=KPzur4AxfWZs5AO4+T4e5EtkO1yoPlQR6W8jWOZbvnA=; b=xNyxELY5AIIpiE2IU/JhGEyez2e+pocYhrCq/Qb+IGRHiO43xJnRWd3wbgMbadE8PMFF+kEvFlBUq6tGiMKg/aLkGG3jzgh+xrHlYgOO8jYG4yxWTnsQTN09tWXd6QYVQjjOXWtK+yMc3U2u/bqEbzB+IILhG3dNxIROrqrHAfxlUgLNRlWHatAN7IjNGqqbdoD88A8aYdPcGN3tpALKBoKYBPQqwk8eLHJbntE+Rh1tZloWMRWtFLNemNVp+hObYZhftzRBL7tC3fM56Nqx+XvvdqhcP3np+/nB/i1Smotu6vFIbNBkuPwFN6DHBs872c/duzQ6GYYVHScrTeeSUA== 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=KPzur4AxfWZs5AO4+T4e5EtkO1yoPlQR6W8jWOZbvnA=; b=uWPI5k88LWnnuKgJE6SzMz+hEcZTO70Im+4N5dMoBqPKXuZCRp+LER/h9NufSzm38PpMqoLcTK6XvOES3Y421ODrs4p6IK5yiRdzHpheS3rqAtgEJ6nj3NYxR+LjUXLBiSYGx0+PUoFQTLvUFFtvhatjB5qqu6SRQgvyN0fY+kk= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ2PR10MB7826.namprd10.prod.outlook.com (2603:10b6:a03:56b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 09:49:54 +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.8093.027; Wed, 30 Oct 2024 09:49:54 +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 v2 3/5] md/raid0: Atomic write support Date: Wed, 30 Oct 2024 09:49:10 +0000 Message-Id: <20241030094912.3960234-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241030094912.3960234-1-john.g.garry@oracle.com> References: <20241030094912.3960234-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0129.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2c6::20) 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_|SJ2PR10MB7826:EE_ X-MS-Office365-Filtering-Correlation-Id: 2614fcef-0beb-4bad-af04-08dcf8c834e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: 5XSvLWN608UsD0xcBaqR07/iN+D1pbks8vRB4CiNTuODXIMrOwxugL7z+72MC1pfac8Ca3PVxF3SvckDtvLc+ufARRa1Tmjk27/cleKVstxn/ZPXUegL/Tyua5K15zI5tcnUU0D2bMdL7jzo1os4D1/5GDpCFB+LAcmPHKlPK5V8WGgYYbg+90ZEfjzNmGk8ECYN2fxuFx9eELr1HIsOu1es3jjL0408xiSbJyIAcDQQ+G01s874TKhZho8e7fOxWObkonV9UlRzwGLG9tGll+ZdK0czsm+mWe8MOEdWipnHXXE7fGbm6vhH7ww0DoN0gSrMXmdXAooD5PfKFxZRHrtxC0p91lz3pWBR1rSON8vaxdXdvLjlQXG6kcbM8jR+Orzu3gzSIaTdBDrKQgMFLCis8c/J5oXJq+iz3ig3lvI17eJAjMoRLJ/auKVMEDc2/i/WNeb03DKwEtmVyX5qxTisWDImOfJpZtwju7WFvy7XoHMCRMixygWNVx3JbOycBsRRuhRhMZS9a7M7G+q/gRC6YFLZ+Yqb1bkDIpFxxLaSXFVBJ+INvgrakWb3fZ1lg3mU1ABlYy4UoSAuxxh4NnOltKN0Gjaxs2RxB39buHTqrX9bOGv1ivFQQdBRX2v5YJZiKBNMGQa1hdIQhJ18vx9hNhxX9W3lP9ydfOehCOgRNtho4Z7NJAQl3zPf8tR0UnoUNQLZWu8KY27mGsFJc3EBWkvgQJjB8TysyZ0rOnHtO4T/Cl4hN+PjtnF2kB6t+ZH4r8js2/MANPy8/2ZVyfwUNEvI0199liNfTZRXTDzk2S6rhQG1w45LF9XaDylr9KjDc64Yg7t8VBy8r+LgQ68YhfXO0SrVqLyEhhq5a2WdqkY70egSJM6s1jdaNjccP8JTe97xc6NzGYQMfiIg/eUF9VRdIsNLw+cwDi/wLyiOHe7UPRsdJSZEp7NP0CG52LyM4Jf9wuUf8h8T0BRJnXea9NrtaFnOzmhpEJY0VmTG2aEk2drKXWNeZDMv7TOX1hJAhSXO43YqXdjVAcu40hnMIMLOlwVWIG3tMgjr96YH1btLaVd0FF9x/kKBvOcd54NExV+3qkBUd+YZnCm2weYO6PiJe5MIpTwweCvEd7xOXXm6lmIEuYhW+I6HPpO6NUhXezx5JTjnbTumngoXkU6jeydbRxP7jeWsNKfjj0DiELLpD0QAHLOH+SMwYLGWh9TSaQ2PI1/qnKUA5hnP/zMyMBZQp7re3eCzZ05oV2IbpGbjxEXoKXWwvZ4FNvm0VVGiaKTgW+fbmz0X5fRfNAoynzBv9GWanEf9dR+RrYJZDU9Lkrj7jkt0SrOuXb1S 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bAR8I7vj6RAlOKm9s2w7B0NfNb/VGnr0GN2s/HO1bMX2p7wfqTUTHNQf5OwftljdVu+S1Ec8DgekMI9puCyfKh7W2bLssjQ1nnVxkaE8brIv0Mz3+QKKiM75MuwtoiyY8DULaWTO9rhI2rzvygDeXIwlRIg3cNWuaUwxC+PatUW4bLKI9eJ++3FK8ASKG/ETgIqebZ61VTM/zcPdh5Gb8ZwfGCn5BcixNpudwJVk1iP+i4KwcgW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w7G596tu7e2is6sgSwhmmm12tuUHchrGBVfNsu+9IOZmNA8p6q63ncj6QK90ZUo1moxav1JgXDtq3gkzNfv1+qWvjFqqaEuPEzuvxxED4wVic2gfywgfPY0WBWu3GsjvSXKw92QeexAXXjr3gl872OXl7PsvtT+ZnOwS+GpHKAsFZR6p2FjvhLwIJ9IbVV1F3GyBxVrtJMTIfyTI7Pn1v7QgoNgItevSV/ah6RQ/OUqXPQc6e/Ro2R/nZRinoURaEof8dhpkrJgiMwJPgnVd2kyqGSB4Du1td7eA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: msiQuwzTnR1NJT8izO9Kb7jxO74dvocvG/ic3Dma+txHJDNe7ydIQbYY/CPdfB65VZ1dDaZRPkoZS/LUDr4S2Plh5xvW80+9/oYAzlDR6iw9jas+e+3aYu7V3m43HkS0oYVRKCpWHt5AY6KT+dOAFVZQb3QZqtT1470u8PVHq9lCQ8Y2Kr8zbdNp9fGFNZqSxAfV6WR13ppVEkyvXINRrAOKl4waUyPbVF43k2bsRB9AzDzROXe13C4425tyPLMW9m+KFU5qntkTZPzyMau+A18IjiHVKhMbHeW/SCHcm/3IO952oJ3KGoqkvP7y4lTXfa5iCBEp301jSo9WD25QVA1CtBcu+LMf7ppxV0+33tULVOpPuT6oKqPsIJvTesFNlV6I88NqoSFWq1lPUsuatZtiWv4plAeyailjMJgyNwFYp6cIrhxU4l+JlzcosCxZPJbAYhts4Commj6BERuBxG9G6Jv+RjV1bsb5g24+5wyj2cGn/Mw/zd96ombsn+eXF1KpLMpI5ZS8yiy5K4vA6v21L7gk3xMuNMcxZjH6BSv732eX3B/VJ+1fjHlfoRWDz4GRFk2CvVgGky+Whx3u/dP3VhngiPB0nZK6lp3a778= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2614fcef-0beb-4bad-af04-08dcf8c834e3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 09:49:54.5363 (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: qK2JmUXBDYjpF6aeo9YGJ1XidNDQh9pa5Adfi4FEaCNx79IJC/et5QNBz+f5AOHx1L2KVMbr5ADK2yheybqq4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7826 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_08,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300076 X-Proofpoint-GUID: CgRjiMHR4o5sMtQtsJYelpXydNMuvynv X-Proofpoint-ORIG-GUID: CgRjiMHR4o5sMtQtsJYelpXydNMuvynv 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. 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 Wed Oct 30 09:49:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13856167 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 5CDAF47F69; Wed, 30 Oct 2024 09:52:14 +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=1730281936; cv=fail; b=WnSvZQtfK0OHIxmVSaPlj4+hRgrIJs8PB9CtxegQlkdoqymsiQsFuhN3W104OO5C0lYabTQN2YMgss3v+3opZMlAxDqKHKPe86WypFHQgTranu0M0yUNdVF9oANU32GxREVxIDqT9UysQSqbJL9PFN/W51POdH5xc6zy8dVMCw0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730281936; c=relaxed/simple; bh=q9CWA4mZK4QadNN4rv2hkgl7Dm3kao3I/60sa34mO60=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=suHsTfTW27bChzoL5VnD75z3OcrH0wd9xWTE8fKkZqnxAX4PnNioK4K2uVj6bmcpLeGxu8G9d/nzJwhxnmfAcyB5GoQVfFkn7oi2VnJLhIWhJV/sI+uXmSRTLK1TbSbIQ2CSk4mkF8vap/lnXuA3xWIVoDZf7WI2n7g4vcI5AOw= 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=K7dAG0kh; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=yxoRMgkD; 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="K7dAG0kh"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="yxoRMgkD" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U1fgvt009049; Wed, 30 Oct 2024 09:50:01 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=gvOBny839wNrSeq0rhAw2RAU63b/Fkl8E5af0+eZAO8=; b= K7dAG0kh+CFURpSAwSavUZWoAkvD11kSUgr455XU6/2HCMklopui8tYP+4STwESh N3OAdiLVDTYU7ObIRJvSn3f05axI2HzF/eZn+ZJCtlHlZteIPD8qCcYsZWAPlp4f HEfrFu0LwmRY97A6OYR4SUnvXSwnafnxrtoZwSU7zbRHva+F4LRFisdAByabXhxQ 3SDHVjIEDi6PX//RqH+ibmKZrepzz7EtYjSSF1dcKBJJvbq1IL47UHVy0PZe7Fhj 9LROOMu0Y0onZxeabqmS3wq7wpOKNEee13qTgz5jMhIZljaUi9hAFjW7SP8lmcAJ Mqtxa7rO3Tr8QiBp74IeXQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grdxqkg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:50:00 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49U8txtj004866; Wed, 30 Oct 2024 09:50:00 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42jb2vfsxf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:50:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=c5zqXDcfuWKbJHg12c1rYon4jfTnj9coFbxaMNvvM8hvTgv6VdwUfqUGTMFU1Pjd4+Q8ZZWR0T/haxYi73ASzB475RiGfaHrmBn9RVsk6GEXpfvj9cnMJyG+j7I374u9CpaFc+vdsxBbWFudf7XgORVP2N19DxGPtd8sKeuHReIRLTo0tP4J3yM9QtvQT9Npx6Jcgvyh+2rLlAuv6QIBm9c6Pz+svFrdsI4Hzhv9Dy3yllVswLUtWhVADCKzPeC17ApVLTiVV19MtRGnQrmZB/V8nWKqYLgEEWOL9NGqWvgRru7lzpe3JNjAjx63tIOdQVnx/gkAjngCcgqg8qKMvg== 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=gvOBny839wNrSeq0rhAw2RAU63b/Fkl8E5af0+eZAO8=; b=ykJ9zgckO893OrG34gMInPzZPP8dnXVqmodZpOTYQudBBTyoRoEukqlFcoM/19DH7DO19zfNB/EPTtMrcXZEiKwoalKgDkyySR16mCIk446bxJ3Qv2l/O5sgt5+st1YXNPNsZrMOPBQgm6dL+6p/ZLHrqyTMg32JrS8eH4ABgTdzYGf6QM2bQBNYZUQ4vrlaU/mcslvPwkiHRW7JqLmlprqX8IdyoDI8nryBuw8fa/FZkvH3lsaXbiy6rlqeKQimJuUqiQ6oQky7irppbI8K7GpPp4cge86cgD8hZtvFTAX/omzbOIyoF/sWiYUkGPXILeQ3RqawfXL6FMDFOJ890g== 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=gvOBny839wNrSeq0rhAw2RAU63b/Fkl8E5af0+eZAO8=; b=yxoRMgkDnSoSgYEqSJKmrZKB1jc7u5XcKh+hDKvSmacXQ9Jo3fL3RGAN/sCV6KO4k+CSS9SnNeV+gj+TS0rGH1LTDAnXPK4CKCKGvFJKAqUMH0IRBkECzb5Ak8d/DZ3cS7uQkZL6uoT7Vt67OH8QGW+6icbHNVAzfGHOcLz7pXQ= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ2PR10MB7826.namprd10.prod.outlook.com (2603:10b6:a03:56b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 09:49:57 +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.8093.027; Wed, 30 Oct 2024 09:49:57 +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 v2 4/5] md/raid1: Atomic write support Date: Wed, 30 Oct 2024 09:49:11 +0000 Message-Id: <20241030094912.3960234-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241030094912.3960234-1-john.g.garry@oracle.com> References: <20241030094912.3960234-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0057.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:2af::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_|SJ2PR10MB7826:EE_ X-MS-Office365-Filtering-Correlation-Id: 782c2605-7117-46a7-d7c7-08dcf8c83692 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: UZn8wC9y/cWVDYFJWrkLk/AzElRD4v/6GVMSNzrJu6853G3VJpeIv+Kuuy+w2sSPi937lFtQkqN2OpYy0ibWAY1OmI8dn8+UQa7XxlcwzMdBIdqDl4g8QmF7l8Y3slE1ISJlxc2dxjcSU2bBmvb7ByCzHesyLaucGFO0TzKUeqXR5GXecZh9RG3K/2Sj22LtyO5mAQNvOr7iVcedwe82u9jxW6a544QUjhwxpnF69+2F6UnAQvL4eOarfDSthkiaMgAt+L18qMirxDNjvYan5/ZevEZ1QkycxNqbf/TGUGBnWykbVlwYeLyClJb9GVs16SzvFf5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DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dmhIqKCVeRFEM9qCgWmcLpYcDrnikhKUONniN5IhKnC/sw4od6G16pjNTOVmbFUMFBpL7iHvcKhhdtTKkjcpc9vPL3dPMOrgFknOjV5/GljLBUgPa9eEK/VY8EHpF4WufhNeYykb9y/tnqqm2iycnr6JNWOBb9LMYY275aMzENQdkzNHu9e3a6Zfj6wM4m2/hk4UKz70iDtBiyqEHqrmy9eCu9f8kkWwHAfHC+rgE7k64huy0c4P5FLZUcU+ikpYGaFMr02YPvYaHVTmT6rT9Ka4H4/4c6DKNXGe7OkCr6DtSPFcBpNtUu0owLW5EtMOgIum6JQbkhthd7zbIqcNxXDza4aj5hs/NtAv4I6RH4pFu0p2LlQ6cTZroOYsbwdpReX4CL0FOTDjH8NTfbAGN2dmWkf+uIoRtvG0JlTHNYAqqfV4xjdPy2nK6nFUIOQhqjtjUcMUTA5W6srj1PwsGClbTrl9sn3RX5etA9Lja5XaYc0aLKYj6OJbW51nyr7vmrtXrg6CmMaINE41Q9do5WHXGrxK3HBijK7bO6MbJxFKshFHTyVxnSZFDS+N56XGNsmLQHnWrI824VnJmv1PozJOEfqk7cWVlCxq12+t5/EPk+/7Urh647fHYtVTZXS2vpuhXRnjnkCcRWIpqJWk9H+IRKxzdAl/6CTPzDWdf0bgyOiqFyHGstSX/mZLZhzf2z0AB4W2y19gTiDXZTFLVo+13+HM9618CSRz+c/177fruHX15StWBz5CX+SLhd2olqCWxxuaO9vnIbVTxuyA10OAdQ+2GWfzjTwPDTBrMPkEtrfmFNZB/cilxfkPiAjfxFEgcg6S3fOvs/RMOZaZrItGmuZ2e2b3RHYkzC0BJyrsJ+g4anNeKw9N7XiOrGAlQDrofoAHJDQ9M7hqx12G28xAa+3tT/wZ0DZ0Jt1JuX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q9kxES0l6mK1N01OO4HuaDgSHaxIqPoBptZwVCFBdt7nmAhD8FTrrbxiR3+hvIa0TMP0IRJ9ZBZ57D/OtVnSz8/nJRiYrFo8FLiIaYR4LTE1kK6nPor9uoncR9aWf01k5U2Fv+wLuDAg/V3VYYuML7nBmphe4AZs2V2njzTsPYsQLl4gHEkheXXv28VlHUFFJFx5cZHRK14lJjluW//YLNqoRw40Imzn+lvwdR4FkVIsGiukv6Q4z6HVODRbE9yPMALcWEJhbzATcSKXV0E+lTy+7La+3Aa07B1y4fww= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 782c2605-7117-46a7-d7c7-08dcf8c83692 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 09:49:57.4838 (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: LOeauPkfJP0Zu4bOA05swt9U1GENr4JRIUN0NYrpqcWcg/H+whtcFn+oejcf9FVF6WyqdA4Bp2psNLue4XdeGA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7826 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_08,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=999 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300076 X-Proofpoint-GUID: TDv-IA9scr6s_QwWAvwWQjou0uSf_I_x X-Proofpoint-ORIG-GUID: TDv-IA9scr6s_QwWAvwWQjou0uSf_I_x 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. Signed-off-by: John Garry --- drivers/md/raid1.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index a10018282629..b57f69e3e8a7 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1524,6 +1524,13 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, blocked_rdev = rdev; break; } + + if (is_bad && bio->bi_opf & REQ_ATOMIC) { + /* We just cannot atomically write this ... */ + error = -EFAULT; + goto err_handle; + } + if (is_bad && first_bad <= r1_bio->sector) { /* Cannot write here at all */ bad_sectors -= (r1_bio->sector - first_bad); @@ -3220,6 +3227,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 Wed Oct 30 09:49:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13856168 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 A1679199E89; Wed, 30 Oct 2024 09:52:15 +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=1730281937; cv=fail; b=lgF7I2uJWPF7G7uJgXHvEALVTKiYndg+GpOnW8x67UmwGtLno+9+SExhYNYdhrHYkBZhUf8JLcoyBIjqVATweRVE9lSKu8oGeb334SN9gy7eGqyT/ww9bNRp4WFc5GaAkejOC4d9bclWLD9m/Ewz2aig+Koef/N8sL1vSPOokps= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730281937; c=relaxed/simple; bh=VLa7wmMYxxFsc0wA/xGtjcLrr3VlrLn8ip4S++ojMVE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=h/bwcz5GaPgM4vUN6s9gLf+jR7jRLerP4bZBsUkWK8Vz+9azDVOgxseV0qOk8RJ2I1Advvm81f6j5HtkI8YNaM3NpAijJP8kCNfheCi0fxBmzVqLzejX/ftPbvp4/DHq9sMYasw9ak+ZezKvVe42nMazEzG1flMGaqEpvhcFvw4= 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=Dt0TrS6d; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MQYEioy1; 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="Dt0TrS6d"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MQYEioy1" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49U1fcrT021240; Wed, 30 Oct 2024 09:50:05 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=V6stwJwvLNvHT3vVDGp/GSQm/fuuX97C9la5hgyVBZs=; b= Dt0TrS6dMRPYlW0is+SAQfJUb2w8lJPwy2ZMv1UpjzmZZtaFpAfOHeqyylZMj9rD U3Gnqmle4h2hBxpPOKHlf/zVw08Qum3lzDzhJAIWWNRUqy0HwfGekX9aIIi2+t/H 4CR9+WBAprxX/gMcj7m7o0j7J1WKxZmb3iMBOoRjPmNU0osZkYFXrduhx7/+cAFX gOObut2SqFch1geLmv1yDxfn5OwrkCwj6mr1B0WYxrRwdxcmowT9WnU6TX/S4uo6 zOntCC+mhgPHbuKz6Jfku3Q9UEvlWqHXXNoZw2ZvEbleLZQM55XuxbXWsa5KlNO0 JHlCGEOy/5XeJMsmB8s34g== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc8ykb4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:50:05 +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 49U8dhBW010151; Wed, 30 Oct 2024 09:50:04 GMT Received: from nam04-mw2-obe.outbound.protection.outlook.com (mail-mw2nam04lp2172.outbound.protection.outlook.com [104.47.73.172]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42hn8y2xu5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Oct 2024 09:50:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZSSgcY0cLRek6WV3XDExHvVmAfRWZ7/scQqh+Pg91EbmrTjzLCX+14zUG1zC8Ee5Cgc5xLFLeaD4QIVaeXHe8W18EScdl63DFurqcG/ixkDn55eAfZzwjVvJEjHSJyMDS61MIYKkXoNvO7KtRz0xwLSlvrkEiGDPfm6O85fhFqgLaZgNjt06ZTWSO8vmOJEERqgVMBwHTSMR1MwzBH62z3xTz9RsuOohP6FYZas+ALUzydMKLIIkqnjjhau6fLNUheneHsiWnG8msdPVSZfXMNtZEJJzpYSB2S9zoJn0y4lEfEZLw003RxfzI2+PrsvLu4HGUmVXj/NuDQAuy7q9yw== 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=V6stwJwvLNvHT3vVDGp/GSQm/fuuX97C9la5hgyVBZs=; b=JNmukrcTSx8FIWdSOxQtmQezhx9ROp7YmUzMFxHqufd9QWvMSddx3m8YwPQmgNEPnXB+d3xubuIMsZq/Snmi2y7e5Zo9jRLC/R7i2H5mmBmTGW4TtukM2Oy5bvmIyVKNw9YQx4TGbhU7h7ghRGuS/BUteW5cdxdkrrwjwFL0ejaMGYeCvrX7G0EdYeXrM0HeSFgjxpTq+X8B8p4IywHHoucHA6KX9Xsh/iMwhK046V3+y4i8E3dkQZXlP9hVpb7Mxk7oeO2BLMK45VKgQe7D9NtwjBn3WHlHBmc1V99LWz3iTrAJKINlYtEBiP3dNFR+At0Q07xLS2fxW7ZqX7GhUw== 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=V6stwJwvLNvHT3vVDGp/GSQm/fuuX97C9la5hgyVBZs=; b=MQYEioy15Qf8TM8lToPoogBfIsax4pZ25eyXGTFNz2E1qScpXXAmwJtw/dcs37a/gg7g65NQUHxgA1ByWcfMyIRqIaU4XTIF+vz3L33A7abAiX5M5u5qkab1ZaW4y84JfodeRx3Gnos+/kaqAMcOltYKzF5rO+FQ0hldtJ5ktpE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ2PR10MB7826.namprd10.prod.outlook.com (2603:10b6:a03:56b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Wed, 30 Oct 2024 09:50:00 +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.8093.027; Wed, 30 Oct 2024 09:50:00 +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 v2 5/5] md/raid10: Atomic write support Date: Wed, 30 Oct 2024 09:49:12 +0000 Message-Id: <20241030094912.3960234-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241030094912.3960234-1-john.g.garry@oracle.com> References: <20241030094912.3960234-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO4P265CA0263.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:37c::12) 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_|SJ2PR10MB7826:EE_ X-MS-Office365-Filtering-Correlation-Id: baebffe1-f166-43ef-f321-08dcf8c83883 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: tTYQfpKPmd30DRGTRogtVGg/TASd7q2oaUXcqNhszcA5qumh1sU/SRDtT5djwoJ6wHzsg8uNkuKaRd4toSFCNfwvCaHrcnwCZVjqjSksX4lzi4gaG7BLVvhGYq802Ed2mGjAldPxUrLFeh+6dMjNRLM/cbHjvEqlR3EDi8Hgj8UI/4TxGBx0tj64mW2uPWNG3UJn02je33ShLdWF59BCLPK0UqZIzv6YcIDgwERhcTZA1mD//MbsTDnZAVcdLlvnftxxII0e5HBpke5mKa7lpSFIwP/NiucUofWtr4sO4TIFD4oXwnqYepdgsn2+m3VMKC1HP+fIWjWXV6SMIjo5DuI1lUMO5j19JsqikGndSxLoksoMM/ifdUdbI7+DUky+1OP8rxKssLCxeQHwxw5NTtVKEOVzm+OCeA5DAooM6uw2BKnlO2JoanDrIG46b52mmcFB1D6diaooGEXKdN0U9S43K2ob+UVgEzBLH997Huep/uEQc2js8YZ8nPEvCSQUJZkmdoTNGxUNS1KZ4NW/p9HRVmXUiCAPBfGIqqy3ygZjsWktZkzowzWxAuG1oAy9/TJrv7c2r72F2pIbTLHhkHYqWytHDLIxUhosyc6NRkO2PROUZXs8PSMDa7g8Shl+1RUqad0bDL/CbZyHh+HVUfIb6OMKUAEb+R3NYF66WAaX2tLP2YVWIz7OsWzjuFuOzg6dBrgznwasTkWq5FJ0EkFtB8sJBJMq/nRf0XoFuePgq2B4HGnO/HsNE6uKvokmZI7faX7/C0MNJKtMLyReXcrT6mEqEmOxuMy+ruAWI4ZtLViYKTHj7rTyxdyjcdZ9Sh7saiQj9tP1NUNc1fqduRh0MApkO7+qOl9D6XaGAvPg0fkG03R9q2w37cs1MNPm+eV3fomtqoQCzmgeHgcEb3LvuKkp7JSdQRv2UCqfF0MtRDWlcrSABGyufuA0B/34qK4edCHZ8lfajegfoqleJHXHOs4UiQL56OYCswCzrusJw2EPFhy+FIkXHmSPcA+BJii72MUyh/SIq1LLqjo8PThWr8dBSVVwOWEB9BRWZ9BpGaccmC+0pplMj4a4fER8AqfM3HVKJHokKLtke8rGQx/npAR45VbnQslCZr1hn0OxdQm+VQ9sqgkpeSjSUdFtpEoIAlH7atvfQ2h25+/CCuuuiF3qe5J0Mhsb/ouPSIExX/H4WoRJMLmAdpp8/7gAgy4E7HNQGnxJ49BfnZBZzMjDslF+64Q2NjjALnptWEcCqixQCcYi04NbDI3Z5e/eVhD53u8+EYJJN8fXAbKnLCsBIk5cNx1fz3WYITEiZ2E6BixSOFdWZ6Bq/2Cl7hR9 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S5RtWjb2bNvEA47jrFwSyBhmmnagEHnCGiRimOcgjiVCL1ODH4XWbHHw1S0yKZ97yIQ9Lr8JYCipnPSyyeGobUGvzcRtsV6o34/iIUhQupjY8Ha5VFw0LP9fmSU+We2D1zsLd4jc2SGVGK8RSljErfiAfO8ORgpY6Afx67wUvnD0hOLvKfkxLO8bUf07gOxHPaVMRDup4a7fcXBFFusQGN0XZ61nimjppoal1KYktFg2kp5VVOrvDPRnxWveryzEDodS+N5D3hGPtlUDyBNVU5cJCV+hfCDQRh/17RXksYvxmn+9Ygh1ac50bjNrq5ROr5BorS+ADnNNu8159nADy3yrhOzmMgFRpyNAQ3cPPAvryHlGfItgSaRD5sArpj/++J99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RU7kBcjK9UbuBzEWCXBuMrJ7zOrYxn7HgzFeXfHp/rIOtOfs56ey+AeYoLObzOf/KHFOS9TT3WDBFVTtsCjlvRFaHDVXldBWOUm8rQ/pfYKXP3QqUj3658QhqqKxEmslPJsdye8k1F/jw5AEnfUGHUkVpQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: gWN88D8j1xRJbo1cI9O0m9OzDanwm4fWRpQoTFNlwjaBp63cSk3Fkda00OufFjNuk2bHDL9Iy3osTqkih59WAncGaLFN8lcvUkv+No2jugLA6sv7iyZ3GhrjGFSPZuGiuvAT1IPYlGMtowGCdMMI6e6IDhDiq9eHRnc4vahpZ/lt/nDLzPRhTZcmv3Lt/rssyRlvs+AzAstOfxJWpk2i5MkslkiUP81jkdirEtdjD/+WEZi+/aqr3zWbvgnEAJ0EMzVGS+yvQGCSkIiS4zr98YLd2Trt9Sy6KG5jlaORlz5av5n/NbyIfLuQQnOL7uZ6FPz4oRnqBNSFpSvLMIX9OSRpsJF2FLLvsaVrMTp78t6G26xGBplXtNnsVKdGgWmupyc4XJFcLgJLklDaEc8siOuWbKaVQbScz+qf4RRyoIoJVm+2fZMG2lUnjQ35CD0YmbcnSF7FbTHz2XVnk4GSqM9EmQarIT92xN9KzE689ncHlO8fsrMaiU+blZrOgS/Z2fVnrOXIcTYm09Kp0OBaEHJtN1UGaIwhaXdaPUvnyNCVMMVxGcp0snGV3jT4ZvHPjUqAueYY/198fLCnmY6oVTnY8tO/KWPUOGFyn2gJMWM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: baebffe1-f166-43ef-f321-08dcf8c83883 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Oct 2024 09:50:00.7257 (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: HHtdtFSNrszvPBz9XL00T42SeT2uPH7wz4vsJ5d0CM3h5aG0NZiocX7ZInjEBWkTHuxiZXTfXqtgOP1QSiGZZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR10MB7826 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-30_08,2024-10-30_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 spamscore=0 phishscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410300076 X-Proofpoint-GUID: LFCBdzeNCmxy-AT3XoeTaCdmmbvJNQ_r X-Proofpoint-ORIG-GUID: LFCBdzeNCmxy-AT3XoeTaCdmmbvJNQ_r 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. Signed-off-by: John Garry --- drivers/md/raid10.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 9c56b27b754a..aacd8c3381f5 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1454,6 +1454,13 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio, is_bad = is_badblock(rdev, dev_sector, max_sectors, &first_bad, &bad_sectors); + + if (is_bad && bio->bi_opf & REQ_ATOMIC) { + /* We just cannot atomically write this ... */ + error = -EFAULT; + goto err_handle; + } + if (is_bad && first_bad <= dev_sector) { /* Cannot write here at all */ bad_sectors -= (dev_sector - first_bad); @@ -4029,6 +4036,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);