From patchwork Fri Nov 1 14:46: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: 13859499 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 13C351A4F19; Fri, 1 Nov 2024 14:47: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=1730472423; cv=fail; b=Ji2FhQcqXMSicmxkNQrnCKtI7PjUWDrDiXsSVn5mTZF2rPmIBeKAyXlMLTP99+274v2ZBHgeXTqwtYv09k5ZEevIKBZToOgk40UutQXz27EgXMs20eYPcGMsJV9AOnTJdAdMbjpuZ3qs/Sj3F71Lns2Noj1yM9yGScc8tarPmUg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730472423; c=relaxed/simple; bh=6rqAlZNfFZu3qwtF93jqtwZGNc8LOauF1Mcd4wzRASg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=DTH4Jupq77bf4P5TN0Sd/ifvSyC8/alx3UCdMVE7ugLthlb2MzkvtyyVxtrXopcp0EvYU30W92Kmy2WMgdDmQbIJznwSyrBZGq+HU1o23MB6HRrXLpnqlk/MggNHCILLiOsdmHjjvZZj6KASCC+Ke+cMAdZxFfXPf1T1KzT492M= 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=IvN5mnb8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=crkZWXZZ; 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="IvN5mnb8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="crkZWXZZ" 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 4A1Eik6s026630; Fri, 1 Nov 2024 14:46:43 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=hfR7HLmV4EHvDbqfmGBzg3KCs7rXKTa/060jOjb6rAE=; b= IvN5mnb8WchJAlt6ARfRmnM3DeUk4C1jxdSoj1J+G+/bw2M0iBqQCDOqybV8v+gx 9bJQ1gR5dAqJ4frjo7Go3j6r+S21ow9wuI1ouL3Wz+2Nv+AywypJqLxBHIQzqrfB 7FlWSt/V/yvQfFomouzo3DkrX5WEb2+bxxMZhSbc90Yun8oEIKAC077JqY56p6w4 BJdVCQRwHqorOV5S4mBNByzM0FiX6Jk3lbhxzDg+gAPoGxTGruVI21dHXr2MCUqf UZQ6xMlTZyxRyzMF8r+13bTdBOShfbCQObNkUGy/Xviq+PM5lc2/KBFhOtRVjl+1 D/aC7ECrVOZdWfWz9vG33A== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc94drn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:43 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4A1E15f4040458; Fri, 1 Nov 2024 14:46:42 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42hnat0pgm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qYPsjLzIqAfWOlJRffgo60fznLynxosf2YtVj+yCo8kYwx+F9B+2tOyPoxV3QIfXTGhWYLGA4WYwCmPwUG88qlTKPHzIo2ekNzgcBae8XCY2VlkXve2JUC9hGdiRQgDp2rMVlqMui9eBKjHqz2M7uITpaxDspHWc6rivp43FghYHJpsei2DQLWpy1oXPyDB7+651TiQ4IpDD60AXRvBRjvOFF9d2OOnWm5aUSSIkK0VxjB8Vcklhj3IR02EXZamWOFjw7lcxFaoHe4UETxCNaWn6tXXk4UB7u+z05sY89iuTqsROUwNbeMt2p/VtAE5HQ4dELpeFs6hIJnDDsg91eQ== 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=hfR7HLmV4EHvDbqfmGBzg3KCs7rXKTa/060jOjb6rAE=; b=KaloYh0ex2PTI4NmbmKc1vDOHks5VIY83nZFontSrXU1nGOlL14kbewwO0hm17sRC45POjgy1sr6TBy9SwcgT49R0V8mRzjyMxVtZjrt95e2uM8cN/86nb97GO2k2fnULCMrYQpPbd1R2Dnq+5hSbqFupI39sttESl8fU9DC5NjyilKnOWs15bSLpKfFJjT1b0Dhm5YN68JmmzYDm5qJ3ODdphwfTCmH/qnAVIOrjPkrWgoSBE5Qpx9R9LefvexKbAs+4zeYzxtAd7N82oyrYlUn+I2GAcQG2ka6KBrM7LujqNvzrh3tytTOoJNQDleJml3gLcd4e/JrOlXs2KkYPw== 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=hfR7HLmV4EHvDbqfmGBzg3KCs7rXKTa/060jOjb6rAE=; b=crkZWXZZIODXfMhC4F68OR9IQN/HChmp/Cb0UKKeMD/P4fxLx61oWMJEovHJXh2fabRnaciHNaKCmAtyK/3XJsxEY/kANg4fiBDC2wmw13n8VX7k8ca0OTobgZOgXj9Rtq95ad7EYUmRDZsMywZcbWy24Oq/xPeMEr9P/5xFHNY= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYYPR10MB7651.namprd10.prod.outlook.com (2603:10b6:930:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 14:46: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.8114.015; Fri, 1 Nov 2024 14:46:35 +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 v3 1/5] block: Add extra checks in blk_validate_atomic_write_limits() Date: Fri, 1 Nov 2024 14:46:12 +0000 Message-Id: <20241101144616.497602-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241101144616.497602-1-john.g.garry@oracle.com> References: <20241101144616.497602-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P265CA0408.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::36) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CYYPR10MB7651:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a490841-3956-40db-06ce-08dcfa83fc12 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: f5XfmNcRp1uyZ+qDmfz7YF99sUSwX1z3zefZ5SM5d8dAJs2pnMJkKqAWsJ/1aneae2kaYgIazatIf/a5Fz1DYXlPtycwtwWTzv500iCZF1uqCkOb6Z3C7CXB5AcdZCFUK3h2WhQyyPxelnzzv0QwZJcMFeKfDb/PtIQyzajBlQ92APgvvp4Jssc8Yr24gg39zCNGoGwITtrQWmBlbTPfjys8pJeOAXd4j0qc/xcp9emJYKLTX2fsIvX6RgKPSr5YY7/QKmLvS+x7iWt/us+A8f4z/krohVN0zOYG+F0RUrSS0tIwQzziHnyXbr9fOHkGLJ1EORfGewZL1gcf5Ha81aDciDc4b5oGcFDq2mpgDoaZKAvwDTbIOl12sKd4PPPJUOSJegbeXPOuplNk0alphC/6tlEWgc5HvoXTxSQBjtmOQ071Rb2zyUrpp3u3ia+X2qEqUmCAT4zX1Cnmq3uX/1PUz3AgFGdwVQivxjeSjUdJERFJ0dcU9KUmsVwc++HfB6UOkn4bExex2r8Z+/LMj2H+Bj8zndq9VAb0NlrgfoWSCK0GXeAyFT25elVnLxU6e4KCmu3wtz3QV9kTJ7zzLaoykdRD3SA0OVIAjK3P5NTfnt+bUVy0AFNgW1YN1pyivdQy+VexRbmuH7ZR3gX2F0XE2n3f0VS+DhTYtQJvNR5Jr5gRVmzyU2GElVEfDIzzUuV8D78QKYeU6WtX+raJDiqA7ed2s1mjQ/HEYpfeQuaE+xX3RvhpwklPOvCA/mGooYT8VU8ZQZLzFQApln2XRXJHjUVYGyvBP3I/Mh1yVHItb3LGyawE2mBCXNwA346PWynsW7L7Hv3dtpVxoosfImdewIdbp5R1lv2furcsJYpFTgc9IH6pk+VJTTYPig/CctgLJlrTSU6CoOb9QbzPVPcFqYgb37dxtVnYwXJKH/5qy5tEaQLZync//Yk6kjHVT9aOHIyZ/CsBKk4DwriDopErScfR7uACceVlD/e8EgH8ri0hOQ4Aguj15jg20SYr9/x5ooXZxmQ4l5rYElMl/hUoGJLlIT54mtyuxIfHQK0rbMDZS2l2mbTuHVrivl7Z5ui6+VmMCii67BLWwQ4D3jkitmPtQ3fW0FlzCIS6jnspc6pzPqaq0nPuz78jEysqPdawByOJlONY/L2N8oDk1/dYhDwoQ1se/YYGp0bKrpGgj6xp+8T3kqCntEZDcA6gsMHDk+zi4H53SpTwHvmHYnhgbPRAiy6n/5yqpsCGGzlQyW3/pKTZfNwMzuWCNn64olpOlYwTuBOqiBh7DXhLhkvGp3Jhpp2TAcj1x1VLkjy8I6uH+SBJD95Q1iqz3BZA 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-Message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y9OVeu1yvI2KTZtv0DbTKo5jABGLQzXP1ipNK63gGY5AZWveI4bgzGKJH444jBMyKA5axL/CCNWtV/kNSSEwRc5T+MNvUfKu+IihRVE4duHqjDcYodZlO6gLB5TVXN2xJX/Us93aSWPhMmzesBcCImUnOQmWCcj7hRr+0VRUObtlChV4DemZX1+A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a490841-3956-40db-06ce-08dcfa83fc12 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 14:46:35.8540 (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: LYK1RAPV5MpFV5s+DIeR5iRGqJwbE9GIr/Z8dh+Ur5AHVowWEvWbnfh3SlW/XeCO8AyB+MoX1XKYgKm6iDWGdA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7651 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-11-01_09,2024-11-01_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411010106 X-Proofpoint-GUID: CjkoruEekzmrQQxG6pqju2gmlT36X24M X-Proofpoint-ORIG-GUID: CjkoruEekzmrQQxG6pqju2gmlT36X24M 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 95fc39d09872..c5a753f980bf 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 Fri Nov 1 14:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13859497 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 5EFEC1A76BB; Fri, 1 Nov 2024 14:46:59 +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=1730472421; cv=fail; b=PuQHAPxSDX4h3US5J4PzaxAirMXM5rLpEFZ4e8FUFUyS6CHlr0kmZYRB2CDPgrMaoG7dQ06YKvgnwBrfWcfVkILqP/myf6Fo17yggSaYwF0v3NBjFPzihUoP/EFJQ4/ms2XVJqduCejAihgCnsP/5SAmtxabm1xbmcPFDgt7rjI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730472421; c=relaxed/simple; bh=FAbgQ3tcSp8cPuTuNe2Av54P+N6Aj6gd2ZYYLbQmgro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=kdfCwLdB9kOmLPz5Gna9h9X1XPYiWSnRDUJtCL8baQfSWFsKfKp187leQA2AW6lIHoc4ASEFbQNF8Kg9UdwbLCrbW55GLfTJADgjsBm9Gaco+XKpA4r6xImT60q/5AK2ndS5bFMHbZI69WkkklC1b0HBUu6+3ELH5QaPfBSAhJA= 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=YqP1q6kM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=CqC7fmcu; 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="YqP1q6kM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="CqC7fmcu" 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 4A1Eikps026591; Fri, 1 Nov 2024 14:46: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=Fjy46BWNOE57n3t8bwWyyuytGsqPwdI4Q6AqDAp5yu4=; b= YqP1q6kM9KcULTyQD4ygHas2FWru7XueRz9ptMrmZK2j51KUtzvNUzIaTzFV9ZTY xBHyZZQiXPp2BQ8Yz/Q/FexGSMUyKbzn07Y5SzrRwyG2+l5qtGCxDo2xHFjR8h5M HcBXRDMZppKrhH9gncOv03E4psa4nWLo6rVV3rVnSF6CyDsJYbT8ZvOCDthZZzG0 VMSo8Tccq+DjMX9C1+ySTlsECN8bbmPd7oa3gvbQgOX6P0WDTEjqkRBfQEDQd4Z6 s1Ao9Nl+Qv2rIUia9m8x8C4tN4hLKNemt/IH7mAA3GDzgqSFUu5R0cNlItP9p1iX AfFVvRS4zM+bNyl9BdYYDg== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grc94drr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:45 +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 4A1EJQUF035074; Fri, 1 Nov 2024 14:46:43 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hndbktt3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Pt3nJqYPR4IaGiswUyUEX5vfFCizQ9SLkQ+Za+MBEJg4ovMwWjYosw8F74tdvehdSqLTFADwVYiLos7o8T6cPWQjo7XybGLCNbgRsGLpD3hMIy3kiEuGAgeXNoRtdjTlnJ8iQu/Zo11q9YURCEZN2045L3UWIVl/cOp4Lk3N9u2fxKxr5pIj8H5sWANTcF4BU5zZG4mXiRBlNtsx1+N99UcwIK7Gno90sI3FA9ncNPYVCU7l4TQdh0cqUpqwTVuzwDNJUpt8EBdbEgDYv2TzOph/w4MFSwd68Pza2UjNnOeAjARc/TL/4B6vnCMH1xwow9Dm9ktMmwnH4Lk2ll35yg== 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=Fjy46BWNOE57n3t8bwWyyuytGsqPwdI4Q6AqDAp5yu4=; b=K/DMzv4g3Os9Ezd7WONb8ICBHK4V9ZRqpfED9KkgN2zhESGwJN9Z6lr+spgonjDdZQVVmcUEOmOSwOIxontjDZTfnRAK/JHMmSNRaAJa1qR7dl97S3BodufX9MCtnMQ1dwJtyqEsQRWSgFnhaDXsT+YInddobTUD/+zusEPKDKMBDLi9F+DqS2u5ulGlgqsztAHHy/2tdMWDk/FHcacjI8JcBz2HxdgbuJjBhZd0HHSE54BXZTJh03gp+Gprdyfow9cH+Al1wWciqA0ikh93wFdB9C3Pq1ujcmyhNg7O9i99o4GXZ2wuNUPMLVttIGbGDjnPcgGTgPGHlFWHv2qz5A== 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=Fjy46BWNOE57n3t8bwWyyuytGsqPwdI4Q6AqDAp5yu4=; b=CqC7fmcu9f328wT9qc2I73DIXxlZIez4O9ZiHxPhkIlfnyQlxq707BzLBc/RzpHwo+HOPVHQR/KYYG2aloAfQPjrZ3S/5zIYBbTE4bd194dbnGbFecO09CaEMx+uOH/R23TLlJLY04I3N8YIos/ZM3w3NueK5ZSRFmglIfMCFdI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYYPR10MB7651.namprd10.prod.outlook.com (2603:10b6:930:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 14:46: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.8114.015; Fri, 1 Nov 2024 14:46: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 v3 2/5] block: Support atomic writes limits for stacked devices Date: Fri, 1 Nov 2024 14:46:13 +0000 Message-Id: <20241101144616.497602-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241101144616.497602-1-john.g.garry@oracle.com> References: <20241101144616.497602-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN0PR02CA0032.namprd02.prod.outlook.com (2603:10b6:408:e5::7) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CYYPR10MB7651:EE_ X-MS-Office365-Filtering-Correlation-Id: 42b4e5c2-bffe-4bbe-0e70-08dcfa83fd16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: wv6pPjKscITGXR4YtuYkTN7I0DkR2tTObJoyA41mCTj7VdVjDgFb+zTTCOLuaeY8ADxk75W//ri3d61d47ho1zOtTGu4tiWhLSCZYePS5Wp8/DraYYRaG5d4EUy28HPt+NQhOu/OR3Y7gF5gUyfgnPbB/GxI+vcLe6tj7kY3XbU/Tg9RWqyFXcrQGU4sSdoLvKLFTNiftwrI6E19egSfCGk4vyVLFI+Uc4s6uIvrtb7q+Z47bGx55VK7ySTQmUuUeAxq5gJpF5oFY4blpKjGHkCU3RkHe8FskLkw1M786UX1Bbb7OBFZedri/LmIJvi7BGy6M0NcR/Be7B2rR6W21+xSEzU2i9X0kqEOv/oKh9M1q3tdRQvTeTFXg8cPF3Dht+CF0G7ZqGLWJZ8uHLThn/40WKVIEozjkO5/7555V2sfCagwPfLJoCJk1y7ylIkDTDS96EW3xVFd5OSzjKWPNgvLhfLwtscQtyGTr0q/oQqNeaKI8crUbvX/C/HFdJj7dVbZGLZzfVB2auDQrs7TcjGDPApkV8fFj63rBKtg6a6Qr9mUBsCSxSpaOn6N3GtvfmCHZa0PiG7zYSrybu1V6lkPpfUWSW54j07ct5dDt1iJ1DYo4NT7HMAIdX0ybjuuJcN7nSuNZSoylgNlgbZLO8ac0XNge6msn1bHDvEIx+A4bOnxlg9oL+xRY2NljItHRLVs+RThz4J3wBU6r1mCmrbu+VIdUug/kvMxD10lWMxuGbAS/rXppvIc/S2zs7CcUKwKCCwrb81khETS6Z5lTMO2UqXH3q9J7xuPOH0mHpIpCPodTH6+ehLC2jXFGNwwr0OjYB4vf1whBbi1kkurZSR/XSz/jFghnwag61nzG2+eH6AILrGw837DX0CakDSac670lVybOsn1ziOCBqcN4H59DGGNVoZrrEyPKocDzPycd6F5ii/x12Iv3n0uwL8HuA2FW85BitQHSsLnDxFYW6rP7ianxhLtPr5/+0u2ooApA1zFN9yy69M2AC5XKW6l71NU/MBLSiA26t2WQx5xDZcW0V+q92yIYJjzpKvgKuhjMlVGXF3ztEQMnEnGaRRzRERyhu1eVJoSZRLGkux564p6+YEEsLccZgGUlCjTKX7K/sBY3yqzFPDRPtIRSUb3x0x96yj3zqXiR8HYvjTXrjMZRvJB2rfO7lwWhzTXMI3HVQmpOP1m7bP9CnbYwxPFJgYF/JW1fsqryPRFeK3UuSbjlROp5yJzAZZoAFkSubagv5/ESDJyE39FIqmipHV6lT5EdTFVwa6J+4QHHNPpdqD0ZejdCNj9KfCF7WfrzJ50iprwYpKOJ685QlRxDTlI 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tCvB+bUQ7BdEgo5VWJ8V3wNLgMAhIIE1/Vj/3XQMbEDeW50yL3LnZHqJDVRlmNF4YnWUzjp4kSWxFRZrEIJY8K6XcY2FomFLPI7hYVlCA2W8iQC6lxkmq7EqvJyYThvY8Xz6wSC7Dqs0ot/AzFPwmFb5Z5q7RGZ7pWVtGsbBkqq1uRuRAUv8btEdbzXTPCHSVb+ORO+pDLqqLkJoZ4T+C5fwp7sN+Fdv9JFuZovilZ63d2QQPaHtzRzGiKZ5kBsLtU8/BwJXcUtzqcRz8ySgOHWCiGmtGLMzC4DbxA6glsUsNaLa6X+87puuDALFKkv6OeUoboFriCtMaW4mqx+BjiDbqQEgC4U2BSLpySfjmdla56pNItrWimULUvnx4ilcLmGiBRJHshQDhYb6gLwKnF8Lr7xOWm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SjHiCZ4ZpXPvT1nM22zrkwHmjGpQNigcosLqvY0aXfcI0bXKpKbqWBOvgdNheoSHDk864EhQZXYM8HeFk1oELjhqroYGTHWI5qGQ4yhVC/iTN5fuaRrV5WrMiBr81z/vUPU4xzA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0eMqvdpg4KWTjQLnMIaeX5D7Px3xa0wMlQZgZloMj0C7tT+xRxO0lVOKuQp7DtKW2lecobY/fxBTBqmLTbzevMF47pEsS40Mehvr0dp7jJe/DWgnvyPOKl5YH0Y08+t7AXbVdOKPWNIdMfDTjIBg2dOhyV8kxSeZ49207bPuiv/H26Tqrj/T3PeflTabUE6ModgKXXwblc4fcHJetm9YkZ4arWlLpLLmTPOlE1l/MTV/AtXoAhypou5yON8LdenqWtWyAzQyVS38StPXLLpVFFNKF7lQKWKnCz7966j9frzxtCoBwRoyPkS3vfIDCd5ZkolggpZKbBPfmxrGzhdtT+CpOwreE19Mm/9/mIRYx1kdXMeCRnx3nGcLzyOEolIHTcUhI0OeXh2UUDxJE2N32G6XZNnQsTcPE6SwbfbkxFqSZ3TgzUN9MJUHMv35WnmEotB7Bm3EFLAqaKLaugP7uJLgPUtqT6/BWErnpcYlfwsDVX7IF7uXKJoOQIjhDt8GST40FIXUFwsUevuwPz5k2AubSo+ipKEsePqqh71R7P8ypUA3Oe5tr96xLAEJ2kL8OrnPABDuJwlR2W/ebY1C92pIDznL0sJuS2L0tPe9Gtc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42b4e5c2-bffe-4bbe-0e70-08dcfa83fd16 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 14:46:37.4861 (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: KzssJzFyO3s8ylXQLIGCjNoDbQ/L/FmUIPW8JzpHQflAhvPImJj49JmK5OWZhTPzDeX/tU8lT2VZtcrD+9CxmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7651 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-11-01_09,2024-11-01_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411010106 X-Proofpoint-GUID: Dpb4SuZ-UD0OGpP2MqStUGTOyvqi969B X-Proofpoint-ORIG-GUID: Dpb4SuZ-UD0OGpP2MqStUGTOyvqi969B 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 Reviewed-by: Christoph Hellwig --- 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 c5a753f980bf..8d3a9a55462e 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 7bfc877e159e..272e7cd03297 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 Fri Nov 1 14:46: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: 13859498 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 B43A719DF53; Fri, 1 Nov 2024 14:47: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=1730472422; cv=fail; b=VRjMrn0YVGXW4vlIo4ycWH91RgWmMbLLU8or6H26t0mnTOvNHp6wfYmCV/ZrFvSy/DvV0DLAZBjOe6qJijVBiv7TeAb/xMedjIhjAXqFXHxS8cHElPSAB/nOq+kBZGO5arzDunqHu4tRoh0GvbSk2oFTFt/tJ3rNgnygfaXTWRw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730472422; c=relaxed/simple; bh=JUx6i4OLcDLbtSqCsLxDX1UApTuAwuBQb3gIDTrL8W0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=T1KSzQ6qo1Eqjo3zxbTW/4Iu1dhmFSY0VAANZDOQkYASsuNRyufua7hX+km/uolN50jUYyb2nx8+weiEPHzMk4TgKGv6gLq46kAtUgvM5EHuPy1XlK1CW+N9cgK2/xqJOHnUZRd+2Q7aq7XijYC2jAw1Z6l7YXNPqLVB0+PInDc= 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=XSXP18ON; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MOdSJxNW; 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="XSXP18ON"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MOdSJxNW" 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 4A1EibJg006582; Fri, 1 Nov 2024 14:46:47 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= XSXP18ONSI87wl7jM2i+vNh5UTmXaqZ1t5VaImQthLDK7u3XAVjUYKsHFmQrJKz8 YjDmtIq24s2otrBTaB+VY5b2B30+iIjoRtlAx8cjZlyrgtzNhgjqAFbMwlnuwIez DT0oXocoT3RuSvvKvjD5RI/TqmMwsjvN1s89te1T8zeEAE82aNCBeThxESNZV9BR 1bUq7jedXsa7GYl6JwesLJU54Jtk891jJVH0nF/MKz9+7v+dTGbR4U87NDrz+2Ig nSyPQoMdXFKdwJMSPeX90Jc4S0QHkqTL+IRqqSw0cHcRNLHN8tiO6ZMhsgyJUWHb GPQNONR15AiAVDcFLgmllA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grgwma5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:46 +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 4A1ClYJi011789; Fri, 1 Nov 2024 14:46:45 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnagmkpr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=doqWR9Ump7o1Le6rD3SA8NUeZVy6Ah3uxz7RKZ3rhrk2Opnwhg3/TPOQFBXXixAMwgwvLMbbnZJ9kSGZk2iVWoxx3OK6oAAoA8Hl+e1FhVcJ2csrIrhkCDrFm+ohMiyX8r3hr1cnz28ndHawZ3oW8ZAVrMsq+/2dWJknuzivyR1P8euJkESPDJ+3+y4haBv2zkuk0PHkuTqVkQ0F31VwSn2CnVupcB69vAZl7Nho3mqJVrWmg/AoQJruFQYs3/4kR3N7zzEdAVnuj6uRimXooI9m9EZzlxprjlXyf6yd6IAM8oP87AeTINlrhWh8r2JnF/HY46NVLhtN5BdUe6oBrw== 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=X+5q654IEk09ui1e2OCey44NKiplVZUbI68G6gFGM6zfRk3YhfBhuhX1zmkvp4IrtGYqW0ZykRTAXrBfxjlrYqePkSdnTxix1ihaH4JbtwuGMAwar3gBMJ9asZDdkiiQ4x8yfTsNJc817B7nu4T6tPjsMKqxBfyecvEkK8rdms3ej+Lt2RtSK1ON/Ow93Q8Jl26IKiJTSQg+xL4jxfQk77TJbOKtIl4Nlagj7ZAHfirC7imTDYIpHEmqmhDQUWkQO+YES8hh5m77o06ryOiEBNKa+mow201j9WekDl0STCPuwqiWK2wbvtMKu2IlkeHNPjfS6ZZe7pNZSAym/dziXQ== 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=MOdSJxNWT3TMe0p9f7P0DV5P+OuKCQbPeDm3a9jpQ57vokQ4zqrMR3I4WQoWZlyXU2el982wevIZWrBWmp2dbK+1iBFtJ92E2D4StWD3FaMBb5JeLoEZfse/cAYJQ40sLCbNpV1Y+v/YrCgkphU9zFp2pzQ9Pkn7K2vTb0Adg2I= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYYPR10MB7651.namprd10.prod.outlook.com (2603:10b6:930:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 14:46: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.8114.015; Fri, 1 Nov 2024 14:46: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 v3 3/5] md/raid0: Atomic write support Date: Fri, 1 Nov 2024 14:46:14 +0000 Message-Id: <20241101144616.497602-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241101144616.497602-1-john.g.garry@oracle.com> References: <20241101144616.497602-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN0PR10CA0027.namprd10.prod.outlook.com (2603:10b6:408:143::28) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CYYPR10MB7651:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a432842-e438-4ceb-5eed-08dcfa83fe0b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: p1pmYR7HxLem+vkQvf3V01KxtHW1ph6UUKVqt4GMvO3IUJ3H8TzyrQDQ1GMEf/kr677KEDW2GFdwt0Srb1uKfH7AE/m8nS9YC6+aqym3b27PV0m0SmdF8qWrAGMUSatMYoTAi+1325lv9jJmUR9rI2HN6NX5uALf1AOjjnoGUf9BF+U6RJBuf9852oiUowMUw3LrcR2sU14LWp1vwRaP7Rdyoq1gPgTgYVJe1bzXq1yKTM3KeFUtho1AE4b3kH+UmAh/vDHd//GmzEN665dlVKiDRkAGJ2pSEqdipdwOfyPFra34i9fPCopBg5W60NK6gpgdWiKqi3F+OijAylt6ZLzcFQ5PtT07eZWg263G1j/2F0H1s4eqMTnLoUUGzQ2qLLt1Pm+uVJxvhTzqPZBPyLjkztE1syUGY6bunDKxNMNoYsg6BdmRPXERrMNrwnX02RChVH/T+b/Rl8PCewh2zMswxOg4r278GU0HhTYGyG+fEook0G/0Yxv+C7VVNFkZWiaq4/wKhkQzjWT2IOR+LbWlDXIMqk7k447m1JlpTxGP+Xrj+4UT0hCCZxJO9jDZS4PrsusRVx96qFc16WjBzXB909yXwe40Zp7r106fI6h7VuJ06NfAEYDwHWQMO4OZBGhbpvtct5Djm7RGXbdp3+o5P9c7nFXtja5k8QVBmmfOmvF+sElfRTtE6Vn7u44Y2NZeAHSnmYfH/nNNLAivfk74r6QVtcbVF3o+K5k+3XWTw8zIdICHcoPzKg1ioeEal4Yw1s0WW+Z0ehDMcZX3kwyQ5719yCYqWTlt6DT7vUH75vfiiIMUJr5PJFkF0jqcMBnIUKLjQsBRv4t676bln9WkxZwCkiLnlxYF9+MxQQHLtqPEGjb5p6UtvJvGjUnVxRNEXLjIkJg3yR08oqrsb1xvc5BMrEykLjVckWc/lOWzqAUI23PbC0/xK4cab4m25KINS9ofn/RiRskYnba1/xpXOAQBSNOsDzTPlFajm+Sy1RoOFlqEhyVZfoN7NrNmvHliMoCuVTxBmCTvkHXQ2z5ZWBFbWLRZFtC+Heomx0JjO+iU8v6es4t9uvCkjAGrdatHRWdBer1+zeULI6gBDkXXXTAcBcgp811hXNYZFIHY8kn3gqHIGtjWA6shHb2h+z4tQEW0SWUVTdwi+oRo4mmvYbxWeZf6xcWQKadPEiX4GqK3zd7CNpT0vqMLaZr3TopaNwvHTqvjVNrSt/iKS3QPzo0leau5Wr9f79iVCFj2Wv3KMH6NbXjOpXa/r52C+tK8FRkknHDILpSuP08CDsYpcDUhp9unkcbp4dJRoqaKdPdAYDYgkkuy3nYOfYSz 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange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utz+SaB9ET6yT+CNCD50ygcvf90dzraj/DAZhq7VcahXPVPi0IvuPpYOLXrFa3a/5W+iVmL0p/Ze6PwS+dXT795pOTDBJLtR06pB1VIPNQssEMTQLPfuQH4rs1x4KQhqEcXHjcw/rZearXfJ1Z/YpJTIlbL02FhgRbxhjuZ17LAMEGnn2tTyBkrxz3TLPXmKj11Zhnn+FWct7DngziL63x6W+U= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a432842-e438-4ceb-5eed-08dcfa83fe0b X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 14:46:39.1415 (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: E55vT52wm/F/Xu//mwKf8C1CQN39y4nQ6u8GGalpz+HEfKAHvUbowC8pZ6quWHh+D5gcrK0QCD8MYnsNLtrfgA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7651 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-11-01_09,2024-11-01_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-2411010106 X-Proofpoint-ORIG-GUID: 1XoUxErWDnZqIrhX6Htxn7_cj2reDvei X-Proofpoint-GUID: 1XoUxErWDnZqIrhX6Htxn7_cj2reDvei 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 Reviewed-by: Yu Kuai --- 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 Fri Nov 1 14:46: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: 13859504 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 D16F019F485; Fri, 1 Nov 2024 14:49:02 +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=1730472544; cv=fail; b=fiptk4GOEn9+f7mAP3oZxwtKW9parGedDpF56MZv6WRmc8W+qxk/sFWODe8+U399ogO2M9qCo5EfaGSD2l356TYqA4wAmPf32Cbr0LPKx+u3UfGffsPMI/77tNzKyjWk5MSfF170pI/l2uCPs9HEdX2mfp/5/AYls2ygKPr5NvE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730472544; c=relaxed/simple; bh=IQJVg62Jh5W0T2x5maw5t1Kk/yhlFexGZCizSc7Mm9E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NDGDEOHJUjEewV6d4/UD3T9v2lDBMnE6+avDfDGIjRGIFURTIUIwJPms3jao7eJwk+VFPD+KovcSREAPNJslVtKHwQfx6Fdm5YOoHNa+q+7oduS1sWXO4o0Txar9xziJR4b8ndILYA7bupUv4EIP4+Dg5rYk9icy2o86x8W1CWg= 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=jCuDyvSM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gec9yFN3; 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="jCuDyvSM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gec9yFN3" 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 4A1EicsY006621; Fri, 1 Nov 2024 14:46:48 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=o1l+lAPFDeN21lD4Xw217uBRQPDczrwmG/QblhGbUs0=; b= jCuDyvSMoD4RMZpsE9WpbFfUYeHbEfgt2o200+J3XDhJyubGI47MuSg++RdAjfz+ EZhuxPC9yhutYLSFaiboMvCwFEd/JIkOrMoTYvotLYVfUl/6e6C2nAWRnuVYbQx6 iIBoDcMUX4yeIsD78C67ROVScaqCgi1rmb8f8AsggsMuAEOG/QR6r9QkWMSz0vgH GhAWcZZMTxrdfNB7niqusp+ozHgKQR/0DmeotdFWH98mz7Z+s1jZjE21DI4eYULZ YgxyDy3Vr4MdPGa97mEyr2zgDe9T2FrXdIQryf5K5bf19FareVNFHuqxkAbEJE/X DlgPzmVZebcq4gvEeNYh7Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grgwma5v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:47 +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 4A1EIMDN011808; Fri, 1 Nov 2024 14:46:46 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnagmkq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Bi8j3h40Z1sMt4u5MQt/IkGi1Ud8u8O+z76GTyQCFV2E42f+9NBykVK2EJeSedrvz8rKSpAcD0AOoTEUfMfNtGo/3lCoNTo0V8LAsODapYulDZklb5zEnvMvTU8XLciuj00B/XN8RvH+6z8ENAwciYvdEuF4j0/YvVFsqhJ9ur1SovzfOBo0Hs3N83CASiIWAJs3IBCwa5Hpls2mlezCjc8Vk5sicXohh9NyTTJrk7JC8TC5XwhuEco+Gp5Ul33VNENRjEDarL0tahNIu5qpXYKIWqyrJTfCNH2cmUxgFgQSBJKdNXJiFRMZCYwQmZvEJf9uk/wqitGmgi0FRmWjmA== 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=o1l+lAPFDeN21lD4Xw217uBRQPDczrwmG/QblhGbUs0=; b=hDrd77IxYr2LcX+wT5seAwRX2i7TlGs5NPvWMt22UrEV7p4Ek2yuXdS1fd0tmdZWHxxMOk9lJMBJWOg6Gr67LY9MuFLhFZrb3MCsLxrF//l8T3YEdDypLFqTNaNVnOQ5B3Yxxp4/WJsUZMx8I6imzP0EjOM8jPUlU+8oIoY9Ky6+IpLXyMii55wENmJD6+rOc8Wy3g+kmgYXDRVCKYnk1a92vb7H34Rex3CJnDuxw0E0FO3H0NWPrLmujNRWdEnCzS0r4vjyjDFrwhinIC3Nh9p2GCLVqfTpXSvDxw+VEpRovx3mDCLb8FgwtOWiCQjX4c14K6kDysBMNm7ZhpGkEA== 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=o1l+lAPFDeN21lD4Xw217uBRQPDczrwmG/QblhGbUs0=; b=gec9yFN35rvbhIwiJhVQjy2zF80k9wUWop75pP25VivJeeCzqKa7CNiLgXK/x2J6T1u/HRPEeBYHsX3LWAvjrJiSwTUIPt+5DdnJeerZTJxEqZg/P9+VRXhe4/2wA7S92RLmIYJAfS0AuA6VRPmCeM2/Xg5Zx4Y0RsG+Nzd8IYI= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYYPR10MB7651.namprd10.prod.outlook.com (2603:10b6:930:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 14:46:40 +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.8114.015; Fri, 1 Nov 2024 14:46:40 +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 v3 4/5] md/raid1: Atomic write support Date: Fri, 1 Nov 2024 14:46:15 +0000 Message-Id: <20241101144616.497602-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241101144616.497602-1-john.g.garry@oracle.com> References: <20241101144616.497602-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0055.namprd16.prod.outlook.com (2603:10b6:208:234::24) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CYYPR10MB7651:EE_ X-MS-Office365-Filtering-Correlation-Id: f2bc4f0a-cfec-4198-7418-08dcfa83fef7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info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fw8J3MFxQXlSSZjKtkCWRG/SY81xLc3RBwU/Wwv8alRF8Wd3YugnNm92eFPs7Lnrqx9tuz/6iLOe0x15emyqXdx6Scbcg8ehvR28+x/nccNWKI4wrePjw+KisLeYm+rtz4S2fKAHG/r33f4HkGIUwE6aNiXryCX+vzIT2RcuKyhpntxjK/uXO7HjKRmX4SgyEq+CBlT0p6yH6Y0ZLrrt94FXaLBdcGUmTD5bam1JrA3a6NX/VEMj5nU2ah6yc/0KLAoURvzTduMGB 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hFeGfFAqeqXmkn91ZHZMwzuqh4PCHCv12lHu9RifvEpu29jPCP3+cehlYt+yHszkOYE9hS+GXkCKoeekJ9nLygUhLYIIMgRGS0uU5uR9O3U31BY1KNKX720TSf+4agt9am5CA5NYsEKe9Hg+ccRChybxT23f6II8l9d9w+4m7MHVjszpSxvfhPNHdu0mVG53qT1DsNQtAiftnoaEH8FdRnFHjQCLY1tcsU3o5xQtJJ8hygNhFCsil5T6EZkhwAFoHDjX8jE1jQBCrPM+4E9B1d+hZ5HctGdp98iqFrykV0KfJp0Misg/UtFGYpoHBf820SdLBnIxCkI/XtfC3Qt9FJDqX1b+v5aJyqK3EQvR7Zi7UTuxfWkAqta8Ha0ERSeB+9maiyi2XCrYP8zJhcU919UHOF3cbvQMCNH1THN/sNIaEsjteKQqcoTlhnxtaamrAaXEUbZ1wcEB/HGnJS7pzxpWBNzeAHVcJLoj3sNQAsPq0tAzeVRJKoOOMjXPwKR2GHhJS1qStFjTQtNXnB0FnxiZUORI7oloiJ2j+7/OgOX4je+qFZwIFd5YnuNe9FDQTn+L05L3Bpoe3eYkzpB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Exchange-AntiSpam-ExternalHop-MessageData-0: IAh9NhYUUu2CDvdPCL0m9tuZN6jBFpPbDJBx0eFnIhI+pLirxdPEedmn3gP2csHhlSRBuK3rZY9fH8vU2Tf/pCz4O9AkrsC/gqtJypjlVB4afFHVLB6CzvlGp8vYRejhY71KPS/+YqQmO0f8sFympdPheSM+gZOpDc8wr0qFxfE7q0kWVm+L+c0bzRTHfzHJCy9gdHjsjo9TtGWf0qb0FXV+t4vvFFYS6l8UKTIyZMafpKDOwzCRj1Uzr4ohV3+mtXGH1cl/sr6aIIzNqEa1Gm5cuZGKUOqGfnd74thLRQNdG7I98bvIP/eVjyTciwRZoTp9Iep4LWD1DNPObPUODwq7s2pq1VuN/7GrrFfYMgXqhSniKjL05+fwDLMNrEwOiOcOLJGRWda/WbyimeVSPZKWDqis9L/jbMU73z0rRSOpgrn/J7nJCjPaToOmxEw1zsTIslZMGnJLDqLrSrZ7Iwy+x65ZeA4WeXMGjbRqbXuWWm7pKNfnInbF3TXUYajlQbOeZhFfQl3oJslq55YqM7/4ORdxVcDgDNWxOoExejLYg1Wwc3oiJLlo8mimD7o1ovqOacbtA2VowbGY9cuCR+qJLeQMra+fn3yh8Uv1fF0= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f2bc4f0a-cfec-4198-7418-08dcfa83fef7 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 14:46:40.6308 (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: anjoG3cnA+rE7vFD0NejtwSpgUf9TVcUKTznC7WkkrvITS4hxHYkAiW0upiU38mMtQS3+lT7zQxrbPs+VNc37g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7651 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-11-01_09,2024-11-01_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-2411010106 X-Proofpoint-ORIG-GUID: Wr-ZmRIvJk16jIcqF6d0cSDCsxAHZAQ9 X-Proofpoint-GUID: Wr-ZmRIvJk16jIcqF6d0cSDCsxAHZAQ9 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 7e023e9303c8..795bd0c7caff 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1547,7 +1547,15 @@ 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; + + if (bio->bi_opf & REQ_ATOMIC) { + /* We just cannot atomically write this ... */ + error = -EFAULT; + goto err_handle; + } + + good_sectors = first_bad - r1_bio->sector; if (good_sectors < max_sectors) max_sectors = good_sectors; } @@ -1654,7 +1662,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) @@ -3221,6 +3230,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 Fri Nov 1 14:46: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: 13859500 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 C3EC71AB53A; Fri, 1 Nov 2024 14:47:02 +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=1730472425; cv=fail; b=CvaH2zRe22wVUxVYHphW51NPUjLw46TON/HplnPENC/fdz3dp1Znv+Kl8hvZEmGVTbdAO7p6kgkuVKxGG8rIPArprPpH520txpcVxgc6XZ04aBmB2pu0kqhq6ToLzeMeQnSf0fa8VLNO1otCemEhw6JAz0kHe4Ip5WDS0ctWrz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730472425; c=relaxed/simple; bh=pbMXPOXi7nRnMiqjjelv/EzqNWA9gywI2WLOtlvGj6w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=tiThVAzMsFFiL//7+bq0GeNNoN+/L64FN9qD0joBzXXeaP9p6GD4iPAiUP5h7b8/b4CTWyygkuP/zbNAOp1vHW7pkkQL86sJ5TTOx+bTcgQCEuqhxnv8am+zCJWCdGljXBUxZXc1SId3EMR2I1MK57KpHBk1Ve3eP8c1OWQ1Wgo= 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=MW6FgCK4; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jkyqzmpX; 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="MW6FgCK4"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jkyqzmpX" 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 4A1EiVRi031856; Fri, 1 Nov 2024 14:46:49 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=LSDgn72u0eoeF14sBKQNt1j8FS+lvtYlccqCh3p60qc=; b= MW6FgCK4mgy8AeND8J5fnKjIfKvjPuV7KPypJhnRf95sTidOUt1X4AY15lrYIkB1 quAb3fPNcA47so8U8/NEd9m7QTOM/lnmPCcGZoWi1ACdKXJV70XEE4w8w/AK0Gq7 Q5Vpbofwt5/qLZjWS8XJrPqQpPutlD2MH22OviESEE5/c7+b0B57OuLzJKophsIp DfoamgmyOR5vobyDbAImr4SS5ERYcdODsBJwR6q3BCs7xeJIQ1PlnSxf8yXfEJAm yzpmjbMu8PgdNn7lJRuadF4wFJxJru7w5WpSnPEelsVcrXHKETypb2uOHVQ7FYXf /ZziQS1RcGeH40cdTfVw5Q== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42grgmmhsr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:49 +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 4A1DoEWC008495; Fri, 1 Nov 2024 14:46:48 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2175.outbound.protection.outlook.com [104.47.58.175]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42hnedjrp7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Nov 2024 14:46:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=TuhhUpZgVPq66TSv+qm20CoTOVhzMJUfl3HoUxxRfURLRgrlpzEb4M4Qd2EtJRqfHE3Y+EylCA2ZKxM9JhmFtss3PLiGSliUxNo6WAdCj4ZVJk8cUHiQRpH82dClu6ISOV734zlC5KiJQfQWPt2bn2KclPXd7s6F+ex9izFryWy0oyVQw+mBDCELCBYZXjrGb26yAFxbbCvNfylBsOC7K21bJFgpbTJslrWAhO3dBzMIQn2KjgQGGgYBGq9EdG89DrSHCW+CLWuPVzkmWdaCMKUYKP+jZfb8GbDQcMK/R9olQJTqlPpoliAeI3llTmNds6jCpA/y60vuvqhIVFoSOQ== 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=LSDgn72u0eoeF14sBKQNt1j8FS+lvtYlccqCh3p60qc=; b=E3UjuQfSOlc531YKtLl65xqgQ+ep8ikoX3RycuHbTEn3sgG1TYnMt7aFXDpFbW0tBtCYHZFYZ7loVSNXWaEFLTGuVmiMIv67xFw/t2vhLH2pBhFLLsvGQWFmM7GaBdbNFDWsUFUU+3B/47vSfp349k7mZak2NJ7ii7fBJkB70n0qgPJV8bG2D6/4wp7jBndJAki8YNr7PNMImPhEaawPLNTpOSuO2YA/LeJbLN9XjHqPNRU2TytPtCtDRVijsAT3ba3cGtmgs/sPpkCzrr1g7IBsDefZpGN5amNWPYF+B1wSNhWv+PNsq5cw4YAAKEE1N+dBghIfpMTRByuLrAc75A== 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=LSDgn72u0eoeF14sBKQNt1j8FS+lvtYlccqCh3p60qc=; b=jkyqzmpXzZKJ2IPLBOFQHdKwEfMt2Ay5wk++fuO+V2S8IEUyTWpN98Du/D4TzAd3z4X8xxuibLJUrceaqjL1wJDXoYeAHm334FW5bvnb20ELhHbVpyB+1bqjKLXOt76TCLeRFJXMesxIUUTjl2UzRbHM3qmkpiJS+4w32VyunEU= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYYPR10MB7651.namprd10.prod.outlook.com (2603:10b6:930:bc::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8093.32; Fri, 1 Nov 2024 14:46:42 +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.8114.015; Fri, 1 Nov 2024 14:46: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 v3 5/5] md/raid10: Atomic write support Date: Fri, 1 Nov 2024 14:46:16 +0000 Message-Id: <20241101144616.497602-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241101144616.497602-1-john.g.garry@oracle.com> References: <20241101144616.497602-1-john.g.garry@oracle.com> X-ClientProxiedBy: MN2PR16CA0051.namprd16.prod.outlook.com (2603:10b6:208:234::20) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-raid@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CYYPR10MB7651:EE_ X-MS-Office365-Filtering-Correlation-Id: ca92fb1b-628d-40b1-7224-08dcfa83ffb4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: Zmg3BDKShMatieuvV6co7ADpZjg67yGYS3z1lEk92ib5WvSHDVnVBKxVY0sEe6nHAmmBcMAUcxUVfQIfEkbmuINWQk04XaGYjDyhxt/m6McjALPZnQCx+YBcrBZKS2xr8LmqUB7aLsHoFMpJm4Np+fAWDrQsyNANl+C4+i52m5eHRReENXNIaG1IodTgUG6z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RA2lgi0i/g5vT2lNfhG1lVbR88wAtUUIHPVdxbtPw4C6j3ClzUH3AzxfeEyRWkuyKyyus04nev+fP3OASYQoDZ/ 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9tmE0qvkuKD3mFYNvey7l2O60bvTPRRI/vM9QL11EgOp3oTWZHx93hI6ts4fKNT6JouULN9EpnqfECi149zrjH9aMDaOi25b0vdx9Xh4fvR4C/voGU0C+VDyE6+jI4wiqY3bJHGX7uo7+R0x75XQTp2x6SLxzBShrFyA63a/tkhFUla+P2XbRDN6YuaIZJ1CpMKeRXftzHhh/6qFQjsDFYaSn9BEeB4OPWHGjR8ho6sXCsdsmJeziEum2s6YJ4QVNKXRl98p0V8IqQ5rb//J/7naz80wmjKno4v5imqNUtRe6hNv6zAa7PWtH65P9sNmXjEaLXTZAZquehpoo7zTjuyYhisRcmtHLgM56tLNDH/LZK/WfukfeHXY5XuidEfvbRBwAuRKv+IBtD2oGJOG97FhmnQVe6blSYaGIIpO09TpIG3FLRp3HUQ7qu5OrlOl5HhaXzU1vMRZ3K2cGmUvVCIxxoPivlCvndkyuV3Z9sVCYHyDTc1wct1e6IYxzUJuJsPcARBXMPUUriKIVh7xawPctHHPVNoxFq1m3WCL1B28pJHi4a+LfD9f7O92Bj415IlYQGVZi5MPoiZZN24b5PrYKbtvN3rcbltYfXPaWur8e1oZvEvwH7XJRjrFF6W/PYgdFp8wgQxNkF/4Ur7Fx9TJkvhRRIFyneISwAifCkc6kM27r2HRo5kh/BYMlPAiFtt/ywQBAIDYCeM4z9wu3I4VcwVLWpOppX5a4ljWHcyMwtO6XCR3cz//YfsXqxpQ6cadTqhM9Q7h3F8Bj1dXRMpFxYteWCLmwS6R5GF7e9idF2SFRA1pOZbjtL4LuSaBUPYnK+qjvhJS5Us8WkV6ndeI3YeD1BxzUwS85bkdRRoFfZfwqLd2m8qnY+03dYl+R7MO2m7djIc1KnAmsqtve+YqgSJVeG8bDHhvs7QWXc/HzzS24IU6Fe3V4akim5RzLcqqNa3T/fRMuwBK3bpN27+0kKDe4tgiIANNuPemhEOSWHRt0EDJsGsrvixDjLwUOy0Fhh0cJaQj+1+7exDDMLvkLvECNVtnMMkwO7R3bwc0uOTjr1RA2v15csE4JSAVohH4owPsOGrWD+aNY4RNi/07tWNg+P+qZSdTnU1sY7Cs9oWKFOhvrkEog6sj25qN263cTM0SnVPDRm/R+4nbOG05CtHIodTLo7r5s0Pm349wB2uyf0xMaXBpXfyLwRgh90zUHO7E8EwkrIztosqudLYejNU75eWZH7SXPyLdwgkOVOA6dzfBC9tRY2A9/9rxukRRYNGNwWAiJzw6y5WOAqKsOwRPlhJmoRsXqB4jxX8bwY2QKrax53CUWLKJ5Nts/kAZntp+s9gzGhnHH2cXbucSk7wg0es0YayuFroA4SUWKQAuPlizQXRFybntninIZsKpfpphkrBPyUZ3agfyGw94tDjpOYi/XseZNPNawMynAwXfdI0uGC7SOd/VrO6be/ambMPfuIdbxovomrYxPOGI97hTO1b1ijuqQH0ESdrUx1o1JHvuZS1PvDI+myzzKSgg61FAfHxWLTPWp+YmoDwItjmKQVLdrIiy2j8KUfO+y1X7CZAqqmYuizfferk6sDRC9sc82Hc/nBObGY1XQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: nKQE0KaCdwMFtUOlbQvolsZsGOIx/KDNKmtnViSOWsn5Z8crGds0GCOIYi6jRvzSgr0igDqYlY6RSYvgYi9+wQ5zkhewSorW2hyY+OkVrLU+Bm5aqi9EfE9kU7c1YPtUpeZkAOcTtAgv8MFIpgY/0fFXKBAXCdVGC7WS+Vwfytj/xEmz+ZnFaYTbdkVY2i4SI6ya/7wI0XgvwfTDtVaMqvF6E78v0bcBvJ/zI/05pb/4HcpjZZn4pLaQqTzLurm4z8FW6fBP8gD8yAHt1Jvw2VbO+iV6G6NnkrXOjm7n/4kI2sqN09jGlcYdNAnGhqbyYyS0S+55r3TxK+ymqbshJPfv0rwklKG4IhZ2SESFTLqG8kMus8N6CoYyOL/vJUrfQv3644PFRlW+UaFcXlc+4xZ+eljXuGVt+eu68edJV8Cd0LbFwjb1IEqtn+Y2n5+dYXuS6VAGBJmWfHK8uwvBLkjGIjCMg1U+/cZnoEhetg38Yot/BmMa4RKXJsCIHcR6H7GcUVbOaWr0bLCNLjgyyG9MyHliOT8BU9fUujAmoQBt4/+EtfrI+hldEN8uEZ8+6dEOM7iGDNgNkDd7vDfrShv1IPCDInb4e3rxruMCjfM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca92fb1b-628d-40b1-7224-08dcfa83ffb4 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Nov 2024 14:46:41.9074 (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: +NJtGO+v2d5Lzvl9bR6P+HuDV+4NiNnwAPMDaTX3QO9SBIS/YplvgofOGvQqBCAGdcYrqiuTg2sQQMcqlYmt8g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR10MB7651 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-11-01_09,2024-11-01_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 bulkscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411010106 X-Proofpoint-GUID: ATzUiT--DUwmxhgVyXPzOanwE1CQV_CZ X-Proofpoint-ORIG-GUID: ATzUiT--DUwmxhgVyXPzOanwE1CQV_CZ 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index ccd95459b192..55175ad55525 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)) @@ -1472,7 +1473,15 @@ 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; + + if (bio->bi_opf & REQ_ATOMIC) { + /* We just cannot atomically write this ... */ + error = -EFAULT; + goto err_handle; + } + + good_sectors = first_bad - dev_sector; if (good_sectors < max_sectors) max_sectors = good_sectors; } @@ -4029,6 +4038,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);