From patchwork Tue Nov 12 12:42:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13872169 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 DA6F21CD1FA; Tue, 12 Nov 2024 12:43:37 +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=1731415419; cv=fail; b=Snvnp1Np9V4CMIgaNT+ZM9tEoKfg5AnGn/G1Uu3b9dh0eIVW+nc5+VVqqHdaCzjkS2+/HqznDGe5qtNlqiBBtre6Z2igF/NKLwCaBK7RPQTIdqvm2kQsezUfeoTkFmJ8DNh+GemS4KIwaDih9RXXb2hrIIL2FtjSbEIfj/2Dqb8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731415419; c=relaxed/simple; bh=pFzPiDhwgEb9Vm7aPcsLlta5qHsG3OBQRFG6wEuZ0a8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NbwvzE5tPJddU8JbgMBTLc6IKk7I6vCaGzlP5K1LN4pi6gBsClJuffZifAuAuBhCsm+gEEFDREHErM9Zz/lVmX5UKt5f6GPgiNmfpIcgYj5MhNrDNxvWF/tsYUCjZoa47hUuASOz1yihfZ73+xVtzBQ+ZVd/vfvytxpaOPlTEfE= 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=M+AbVPhj; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ppEhARDs; 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="M+AbVPhj"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ppEhARDs" 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 4ACCfjfV028740; Tue, 12 Nov 2024 12:43:10 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=G91Cv8J+yFqaKfxp43iRVW+0cERpGYd7+gOfd8Zelg8=; b= M+AbVPhj2NhhqTD2XcS2+DIN3hqPDniO8X7DSFxPZxx16/tZ1Ke+Uq5oNf0yw7NR Egc988Snk7HGXnlPhUf5C556IeZc2m+fdM04UtaYtBM0BGICa/6uMUbDOU4rG6JB ZclEfMQGEBYqIhHa/PIqUhvMOjMRBOCv+fP4zIfA38Q4NBrTKj+7lxpmrR3FTJKc BW+gCGDihYpGHzYqmzXGcTpSep5FWxsrRdpUpRNAa02DX3vapvjm1w7UOYG8auQZ U2MYzvBqUTN/J5eAiN3LPuWv1lwGnQYkbV3qeeP9PdzBCP6Iu/EUP5yGhOhOuMLh 1HyH97pewWF98384X6tarw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0n4v7uc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:10 +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 4ACCUS3G036106; Tue, 12 Nov 2024 12:43:09 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2047.outbound.protection.outlook.com [104.47.56.47]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 42sx67u7r0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=UQgkJ8xrVOWSPVUAl1iMA3v8WaHTWySmG2bx38qOJvSXnlIbPQ6NbHD4v2n7io6p0Ui6H3ZGx19g3IZhuypX8SfvMb4sgQDATJP1znSLdcj2r/Lj9IZkRGIQBcoRkOxGs8r1maBRl2natjmezF4VGuTiFSIsCLgp06JdZBggxghVKXVh2YEGqcHZynlBOZsEr1THe22yWv7gqxnFJDGc9NRxqPFYuu59eMKNJYE36Kr2BFPnrdU/BvhNSJP4xYjzVYb90PWTjHNzt6/ZHUcCsKF9aKaMxRfAu9NA73D3CHVE0ZqOqM02qmXnHLtL4isLkLvYlX/lIMQCVqQlfmdwng== 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=G91Cv8J+yFqaKfxp43iRVW+0cERpGYd7+gOfd8Zelg8=; b=gHn7Gw20NhNNxhuQYBwwsDLbHqbbsMkS0xns3cnd1PhqbVnL0RbA+OqwjAPGAqNcd6u8F5ot6sgK4Gx9lB8nIT+buGnznW5Ku07+x5OFfU7pyFhX1KvWSDj0BtNKetlJxJ+cGNBDpyTfS/ovCDXRvzPiSN1C2GyCxhID6TaYDzs5FskxPJdXfPm7/yyG4jrY/mBaV1GXrqyGEbYRvcVdUnnKvdoT0KqQKCYxfX15TlcBQQOPcGM4J1/a5UBScJYkLlSH6A3pepwrpqUAx9Xg6rE4jprWfqpNpaMa9/Q++TDxir6R+vJDR12V4lmesaqW5GxDOYVyrz7vqkXXa49n1Q== 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=G91Cv8J+yFqaKfxp43iRVW+0cERpGYd7+gOfd8Zelg8=; b=ppEhARDspIXF0WxoBlZeWJwNiVQIsoTaDBLCMsiGBFOsMPewVRVlHWpO8rRt3yQAugisYuY6tHvT8odhscn0chH/vG/pgQaixVTazgExUTMofBPS0IGsnuTQM+7GM2FYl9V0tqUbGsTkbp73VgubdL3f6KSbGs6rpqOLCycQYMk= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SA2PR10MB4809.namprd10.prod.outlook.com (2603:10b6:806:113::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.29; Tue, 12 Nov 2024 12:43:08 +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.8137.027; Tue, 12 Nov 2024 12:43:08 +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 v4 1/5] block: Add extra checks in blk_validate_atomic_write_limits() Date: Tue, 12 Nov 2024 12:42:52 +0000 Message-Id: <20241112124256.4106435-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241112124256.4106435-1-john.g.garry@oracle.com> References: <20241112124256.4106435-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0140.namprd13.prod.outlook.com (2603:10b6:a03:2c6::25) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SA2PR10MB4809:EE_ X-MS-Office365-Filtering-Correlation-Id: 5d5da35f-63eb-4148-2e6b-08dd03178f48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: V6Kf/1r/WtHjSsQKN1gvxi/AKaV4n09oErzyy+ro9R478yGSziNeKLKLpwIbKs8KkuA55QslZnh8b9o+zSec6eCO8mcwBdLdEiFsBUzz6r1y8q+5mEvLk+vAAanDkqrwGeBVaa9tFMa5+9dw1opzisz8FM/+b3Nncq/CSk+cyNnupF7a6f5sFpVpHx00bBSsBY2dTuk1pPzK4AETKeXBVz0ZL6tArvoeBX01uIt/7w8FXZnXCYtbsR36BeJAL+gui2vdUG/cImcng/5+rDLPR1LQp+4hLqJ55/U3Bk6YuP9EtXH20pXoeCKesojMy8GYKrzSRWS4ESWagQ2Po9LbJ/3iVCBwofLuy/hIuUgssLui/GiVeQJt75vTwQA9YZVZTqnybLqcLVgPrKXfw2O2PLb83cq3xFUiYspwrV7mCzz4wewyAwChR5ExMgU1+iB420lYyip5nYkEPHUJDkxIYJRKWycjg2ohY8N9B4jrXO864mQFhbFyrmkWz5GxbGE2BQkf7yQwgSUAoWoLHEAOKpM7dcRn9HRv+euRJptSEcFCEMdVbqskNI1JNErD31Gv2hnPB2mvyAQVXy/oui5Msi99JzH8LejYl2hYMaBdd3ehhKdqJxWBbyZnC3QuKt+0debXTB/Iu/CylEc/PW9ToeXCqUCbOCb6c/OkrReUJDZg3W7s9Y7Lr1bPFMMPsyRAytkO4UX6Htf53uazXR8jEtL1iyEBtw4RyG+nHLhbnO09H7mZIT/Mfu74unEOLePBkry92tfXLEd15danPzQq58iJZJX3k6jIZ8zxu22MpCdySML4QMnaoSIwhg6+YPMYi8Awq1eRUp+Z/vyv6ChQKC9Te0f4MyX31hkMJM098uA0BGSrdryULV61/h7hkrONiZG+d9ThhiaKS1oU2n7DQNW2MTEbWLj4Eae0n12c3VhiQs/IWF4lUH2oHkPN/836QeeyEIKIL6ETM3LS98skMDBkvLdWoR+JznydHzHk/2NVTI3C4vQjFT/23ich9qDANspPWMCfy4aYw8p9rJnZW10gzY/sAFANkWQuT7eqw8UGrGFQb0wRRse2l1KJLJzyPlY6V4xC7CPKZmVd0dVh/1BY+zVaV2LVI/FkX1lzmD+aYheAflshKN72XQbDH26hAX2QWBDKCq2EvD/niuefeInTQ+cu4MGuR6D/9GeZAZqVLuREOzNoFAgx24OAdWO0X69Zb3Akl91YihokienTADErGqxsltULczIx2gZjB6Q86CupnLszu0vl62awolnYn3ik6YMZXgfcIuex29EY5t5irruwqsod9tkQpRnXVW/sUCChKfmWHug6vZGoOeds 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)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 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falD237YjOCPNYJYGQClKtpPzqQoB1be7Na/ab+3CUOnJJxc8CQ9pSnFGaNmURSmLkfvv0KrsusXehk5W3j2Wgz4qEM5RO+UvWnH3ptowczJCD8FfEOLwYin1mDJXe4w+NUI26e6h4OfL8lFnl9UyFtYnaRyp4pTCWO7EDfOAqMwCdjyLHwnZpCShirhYjVhgQyVmRQQ4Xdiuz5M= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5d5da35f-63eb-4148-2e6b-08dd03178f48 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 12:43:08.0980 (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: hhPJocLvxRANfiqKh98mKczf/U8C0tKYQAKxpjC3G8hz6IlcN4YW5Ue+udoV7peFvHwCv004zRLIaUgBfEt14A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR10MB4809 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-12_05,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 mlxscore=0 bulkscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120102 X-Proofpoint-ORIG-GUID: Wjncz085CjqEPKF6vHXsuVD0cE_RaGfX X-Proofpoint-GUID: Wjncz085CjqEPKF6vHXsuVD0cE_RaGfX 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 7d6b296997c2..44e1148986b3 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -178,9 +178,26 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim) if (!lim->atomic_write_hw_max) goto unsupported; + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_min))) + goto unsupported; + + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_max))) + goto unsupported; + + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_min > + lim->atomic_write_hw_unit_max)) + goto unsupported; + + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max > + lim->atomic_write_hw_max)) + goto unsupported; + boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT; if (boundary_sectors) { + if (WARN_ON_ONCE(lim->atomic_write_hw_max > + lim->atomic_write_hw_boundary)) + goto unsupported; /* * A feature of boundary support is that it disallows bios to * be merged which would result in a merged request which From patchwork Tue Nov 12 12:42:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13872172 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 3A7881FA821; Tue, 12 Nov 2024 12:43:40 +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=1731415422; cv=fail; b=FWbelgKatieMTz2oP0HT/lpq570x2GSZSGNWf7b0++blMY+liRviZVDKl/LYYADS57VD0XDZOm4SbfxWIE8YeZ0HVGUj1NxbsJkPpSxlVFrOA2fLmeaCN1+a9xtoZLpkLdGUdwB/J1GqFcnbB+ELr/6uOAqpx4Du7q8qKAO27fE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731415422; c=relaxed/simple; bh=yIcWTxHekcb0WmkgMb7IksezlOOP8/ep6yBt4ONzNUU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=jYD0aQA6m9sbvp61dqCF7VdX0ZjZ2bnErNaK0LVtfWii4DitAgTG6Pe4Uvlu/p4p9EuVI3uiIkyFBibptWjKRH79dqQoxNwL2QKOqKMFrPirNAaaE567pL+7DqeqP4TJUUz4KowNS9kS4sIPy0fJdEKTJkTs5Dd1Y7opkt1JoNo= 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=Q0i1SRTq; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=wqxRSvMX; 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="Q0i1SRTq"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="wqxRSvMX" 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 4ACCfjgm028728; Tue, 12 Nov 2024 12:43:20 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=RN2e3hlFsTwOKqY1yBtlcCTHOQ8W+L/g/0MBuVh/mQA=; b= Q0i1SRTqx5A11NCq4gmTPw2CYiSd/AEdHNJo/0HEOOzDyGlnb01AFwnBxPzdUDFq zmT2KmnWiJr2Z1jZ7r/GJNCyTWlT66WW7eBsXVcVzAPbZXwPpIHSJP0F4oyCIFaK Bgk6VDaUk1bI0nHoiwvddaZb0CA17F+AYr3Ti857QEbS9feGQdVs6g+ogxEKs4LS jZ9Dox6ln9d3VYBFZaVDhxUC0yJReXdYyUslobkCywY6o8GKfyAFjkwiPM66fhy3 eF5kX67+rTEnhskyKqFZhHw1wg4GKQkWIO5OfMmcs9KwOv1AYWIdIPjdG8dNVTev UD3gkPIH3ni9jOXRsqEY1Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0n4v7uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:20 +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 4ACCX4GZ005677; Tue, 12 Nov 2024 12:43:18 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6825sj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cfih7K1QmFK6xlZ2pmVyzeE7m3iHn1NKTljGJFoYg9/kgGA6iNmpkGJN6O4iJ05+KLXe9RwXZNkLD0Sk9WxcclhV0oXF2FLHzZ/z84CD4bUeU5W1/TsZmCqHQxHOgFXfDKyWVuou/DqLINFGcmbwCFyQz8Yj5Er3oR22h6pg2BGPxBjZHytaxJDqVtM03I2o6eC2+8lVMkfNkrov802rOdNk9HfY7Xo0X8Cljs4maMLCj5prteTwGoTpe4O0YSge8D7heyatoxsaIx2J/mXf6OrlGeMBkmaA5PU2njJNkCO3fZpdbztTm5lf6fNzmOhPtNt4nVoIUMCmPcMFwL4bSg== 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=RN2e3hlFsTwOKqY1yBtlcCTHOQ8W+L/g/0MBuVh/mQA=; b=U7wlKi+HJVNrgtWSDQPxcjj0YIi+dSkKuHfeYQpdlJ/s8EX9TtDNomLhuXaxHHpH/hSBEMoBMjUEb7sUBrA200Lcy8PsiAkKsgCylTyrzyR8L4URDj6yRFDsl36DbloKqwcHukiNluUJJsTiXI9zlCwr9VrfxxGi4MmERA/8eIam1LUPo50HGcPrVQQmYb+hHpniA7d5d18hL4XyziAMofPwSCmgu7XtJtz35oW7qYghQCnR1OYBiPg7UxcOfu8bviSHT6vjihwnva/d5nIfX/m1n44kR8lAiRq/HdFffthx2k7KGqdebnvpHLx4usprzZ3cIEeP0+Gg7Cl7VimC4w== 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=RN2e3hlFsTwOKqY1yBtlcCTHOQ8W+L/g/0MBuVh/mQA=; b=wqxRSvMXB3vMcpfHsB+dwXEEAQ4SfynEUM6ltQQxF6nGHxtN08O2aROKeR20Nnc2AO93KHYkHZBLzZ5miqxEZubM9ky+rmF4DPZLWj7tvC0bRLEdDJIiCFnnatK8L8hA33UaTreXZ7i+7myf6mRbz9WACKJpyW+nL/Tr7yCRvg4= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYXPR10MB7974.namprd10.prod.outlook.com (2603:10b6:930:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Tue, 12 Nov 2024 12:43:10 +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.8137.027; Tue, 12 Nov 2024 12:43:10 +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 v4 2/5] block: Support atomic writes limits for stacked devices Date: Tue, 12 Nov 2024 12:42:53 +0000 Message-Id: <20241112124256.4106435-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241112124256.4106435-1-john.g.garry@oracle.com> References: <20241112124256.4106435-1-john.g.garry@oracle.com> X-ClientProxiedBy: SJ0PR13CA0146.namprd13.prod.outlook.com (2603:10b6:a03:2c6::31) 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_|CYXPR10MB7974:EE_ X-MS-Office365-Filtering-Correlation-Id: 3c664e08-f89a-47a2-9ee7-08dd03179070 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: QS1VrU7/6/EXDOZPyymmEuMCPah3Hz7w8Mq2VoIyXXHJr/MbpIrNILRSpYmxMA8tHrzHZwAFREMI61QBSP3UzD/hgIGoZV1JpzddAFifvX/PRe3TycJ0AwnJU26spyfJShZC5CVrAiX/LcrjOn8gpTP9qBORl17eTXZneGqQ2PbUja1AtZOIVm9Gm60/kO8tX3iqPFk5wyyJplaN2ZhS7PU+G/WcgQVSLOw+FCPCRAjLYkdtTNSqajkdmUvGEqbRjnd1zOwBwbIPmjoaJfhHtWiUfIDIQYh+V5KDbZyln89sJMVKW1pwrngDDGglIAiQzeQOww8ygw6KnUf0WkDQ5wLLbvShjhQbUa5aZLZdlDfK23DUZZn2TVkA3rFaOxw0G2a0ndqeshl+gByWbJAKqQMyyOe6cqipeFQ9h7NzTgQp0bJdgyQ6lNvmztjkFlJf3XiVatsquOaWallsSIT1WjucR0xFFMpg+yA2QRK5b9wgSNPfHrSA7RR8zFkb3zRQ25l/XPPjr/PkkO0f+PQO4VrdLGESxPQR/M9imIIKhTR0Heo59EGzU1YV/YfxNb0Y3NILgOnpL+kDlw5a4gCiScMExt08eQJT2ZE8k4mdj4j+OIfcpICRISKzv84rNDT+ILEMHNxUJFXDluxg7RgZXRYn2kc8PXnx2pNXonqJ0S02q4x4nis7YlEcx9AiwiNuKllSCwkHB9XCpe7eHzfWhnDXhkECV/K4rZYSZGow4HEzVrZQ5POgj8DvmYykXJRdLy58ZQpx7QQN1qOGVSgNAueJhZqk7VzASv/qwlDcTcMz+XdUi60kqy+dXda6Aybplp+T/31QJsGsLk+zctNtdrgFkcBGcjjyCIxOUc83XvVGKj0Xs4pN6OQwnAiFnCXS6I24sbjBgdeml3r9Ot2QkE+dqMCJRRf9+dEdKF5uL//mmMdHrLcx5YPWPbXTeSZS2VWe/VeleC43amWw784BucNzqeB8uFaA5SOrY6ctRkXAU+ON5OzdcUEAuiceHkxnS1aZe0ldFuYOAYdt6JRZkAeO1nzuvnOXsUv3eRc3hWFm+77vyCOhYOWmNmLPFp/X+vkaE/ZD0i3h/FXhV8WYepduDBojW0hV9xolrw7JHFZMEbzOpaywwI5Otsm+Vaf36I8ewjLMlivoIQA33MJ+MLZpye5Y+I56kA6WZGEQ0HGkTQnAm6K3OIr7qi2ERR3hvJYl45ZSK+qjNj9d0Qltg+HK1ajS45GoFN7YkvvKjY8355Hct6xs5N9bwDLaLZIhnTBGpQSoq/dyFiupnD5dbsHeJVXVtfHjxilXYo5xNTVO2KvQsWZ1XQT9w19EFcFG 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: rnFub/WOJ3zMYn3UFvC8Q0IuU5XMpmvANx7FnPZiQywHDKKtsI9Hh3SCpkYmSjbqMB2kdoNINpQ4hK2765IabIaCtB27OWhNQe2rmCjYz0YAv7pG7j7LNEjK2gPMlh8G/uBhc4NEmHknSOhOb0to3EGFeU78jdYwpAiIAAdbaVV9Zh56ICLyVqrH2CMnKZ0B/zu105wiONpDF4jutlQjvadhSb+qRgrW7QKwqPlYLar6srpMnEoguQQEs0iZ5izt/SlOu/Ocj+cRClQMTAR4REHxk92KkdBs7jcNiceOV0utK6XZspEC9PDohLAUrKm0ypkahImnZwXPMavBnJ0ecyZwzS4JHOry9uCY+pBsvihN7zHnQsdMx9R/4O/kWEu8BICMrd3mki8TQ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U3dq+OweTCTi7rWlhpLn1LGJOpiUzUqk5XZYsTZLnaH46KYVEVLIyI9r/YRo8DaP16mTtdNiCndKmzfBNsw1+PtcpMtruyqvDyjOsBuvA2MX4zdYep0ejWEKRSH+1Rf+5USRW7fDSTH4TpqYXSH3A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Cr2g8Kl/7K4cnQog9VzIJ7ZMwDZGRsclnIiYN2feLmD+MDWEy9wpnWLkrHJ+qnG87AyKGNBuw6cFyFiCnfLsia8GKW2QrYwiGze/CcGSEkFD0IqjVY5zaHETM4LAGFs6PMtXvSje8RpH+g0fl2Eh4H0jL5P6+BNiKXqc8p7/sPT2saPR0tYXwmZ9qeNu7OsSZd4wgrJ+iyH18o8yxigkGT/h4gnsGXNJ0hlyPvC52U5wEMIidYWVOIzd61jEklMYx+CPnLoHSxTRp3q3MPjw00AS9mJASJ7JcpUSWjXZCpN9Oui4s+0meHKmwK5yyobTu+cnrqMV5QDPVWqufdDYbvaUCs2z/UnURfevWCLbvUIpliWZ1ELVNmdoUh6aTE0aIluihBedctMmfyXV7nYqO4NPLsBmHhQz/kNcmgfQIvVL4W8Ae3wtQmWuLPjvaJ70Xl0iWXsudr/+vhi5mTGFxR3h9hiiAenuDoxNxJ7I4ZzgFUEYznt9BjzHFrAZmrJ6SYjkTo3V3Ga49KyDxdKBa+dLzHVd+1ofl4EURRU7xHaU7RqLcnWrPd/qKVrIT5GchnedBP/t5z6V708HG9QmZz0avrzj4Bqn4ay1Xzf0phg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c664e08-f89a-47a2-9ee7-08dd03179070 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 12:43:10.0353 (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: Lz+84SQRMjEQRt1PQmLwv3huin0E1spJVFQTrlzppwXdqnENBim4LJw2uH7rgVbQnjZj+n8ni4yhykL/wsDwgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7974 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-12_05,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120102 X-Proofpoint-ORIG-GUID: r7d1d73uWyZ9Tu1SvJKY2aBN6HIaf8Jl X-Proofpoint-GUID: r7d1d73uWyZ9Tu1SvJKY2aBN6HIaf8Jl Allow stacked devices to support atomic writes by aggregating the minimum capability of all bottom devices. Flag BLK_FEAT_ATOMIC_WRITES_STACKED is set for stacked devices which have been enabled to support atomic writes. Some things to note on the implementation: - For simplicity, all bottom devices must have same atomic write boundary value (if any) - The atomic write boundary must be a power-of-2 already, but this restriction could be relaxed. Furthermore, it is now required that the chunk sectors for a top device must be aligned with this boundary. - If a bottom device atomic write unit min/max are not aligned with the top device chunk sectors, the top device atomic write unit min/max are reduced to a value which works for the chunk sectors. Reviewed-by: Christoph Hellwig Signed-off-by: John Garry --- block/blk-settings.c | 115 +++++++++++++++++++++++++++++++++++++++++ include/linux/blkdev.h | 4 ++ 2 files changed, 119 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 44e1148986b3..e087e5d886ce 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -495,6 +495,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) @@ -655,6 +768,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 65f37ae70712..b9e5b00cd825 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 Tue Nov 12 12:42:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13872174 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 C456A1FA82E; Tue, 12 Nov 2024 12:44:32 +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=1731415474; cv=fail; b=Y9LcO43jmBoxbciLDHr1oGIuEYlyuy8jqybUnhvLuBPJHIVgRh8EECywMKijleX4kNfVFLGLFyn5NxJ/u74nWRqSnkjFqMho67C/wZGuuAUZrJ9NF5MWcz8tp5szUmlPacGJ+B2dgBN4X1S0ohTVtc5P65Fa594qVxErIMDpNJw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731415474; c=relaxed/simple; bh=l8jWHfcLWmfiyOix9ULPk9fyb0xYOjtbPQAshuwY22E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=o3f3WB3rQNCGfBR/BBd+IPkyeHDTPb17zVnEGOLwT1mr2duOFSmoAqeusu3/bWrKCfW9mhLy2E7adwOhgzspU+IyyMG1r2fwqStW3NWmWxe8FMeleZfCdx3cY2esO4fHW+6bEUt0/Lj7rSIPMoCvpZoU7qFNpmSCi1Qeun2GcKQ= 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=f7JYi5Gf; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=A5ftvaHJ; 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="f7JYi5Gf"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="A5ftvaHJ" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACCfiLH017452; Tue, 12 Nov 2024 12:43:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b= f7JYi5Gfn79OGOO1N0ofgbe/iAjnSfB0VUS5vy9doSQXKJrTZHPZ8/keUOXMBswq EbCOYGNWDnxb5jWMKEUrsZ2Z0owCegLp9IA0zhLN/liXoASAFD04d83nNxKCMg1S XcjiKpV4oocaxblsten30IZ428sPzyrxEBUdwA1PgKI3uQ989kJCMhQ97xrEEu9h gtuDmfJ0xDAyVZgVknAXswpgY6z6RDmKRP7swbqdjsTrmBclCfem983ihNWKJ8pN 4sMh24fMdbUdVzxWze05QGH8NqhbHo0Cnqg41dXOy5rJWvczOXXvFdD/yIXF+sMd QZSl677f1gWjgt4nhffFmw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0mbc8fu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:20 +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 4ACCX4Ga005677; Tue, 12 Nov 2024 12:43:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6825sj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=NEO5N+tJ+nctnVlK+7oypYV2h6qcaiBY2dDiBeWOWnDrAzpSMPFCqZ7BVIM6on+6UtU79hc1tLA87eRNTA3g+tDuQSHrFnnU+tS0vdcx8+YBGdN0xmyOUv0stytUY8pszDCjyCqd+dLyNgA23vkfzUPLFaUF5cn731c8oMqv8WqVMOa2akGzwkZZHigCkB4GogxMdty8SlFB44AGbdI5WuquMpVjChvmXxCB17cxHISMiuTeyQwSibFWb4cDkZEn7gCYAJKs1c0mnyVeAPVaNBOYsxMuAMpsVhaT+URU/IT3xAQfmO+AE/ld8Na4uWkdVlOIjQFRhn4lin4/BkSYFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b=tz9gilnOBkzvmpsdv2tqvMhqE2mYo3HvnYSBD36+LF67S2uDR/P/kovhwXEWPXDn801efxEbo6GkoatfO7kvQRZQZdIGy3fG26GxkQgjNPDrfkIcDYWCZw74jpjSy13La/L4v19H8Mp8nNTyM6Sr+a5N2s9tFRIfOpwKH5rjJqnqkgjEj7BSCVn1IiLT88wDQGW925LpfNmprXFJ+TFK/W/DMitN/1yC79CZZDh5G/9GoplqlQya/gb5j3+VoBqvzeNIjfvMns2QreWuZ+k7xZtGZtto4ULIuS4bX/v1173W6stYbSDs/Gvkv286TcA1Fz1l/WDDmfOFwp029E+PJA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H1sClM6+eh1zgJaFPbwdJ29io/dAbFTNuW/1IeGVBZU=; b=A5ftvaHJGNu6JmK2ae2l7sFDBjPsgd5ZY90QIhfidWlFXxEi20ukfVw4Lm7NNpxQRqWpUDq15Ly6suC8cq+xfqxwVYURNjF3LGpUl0iMev/u6L9TmXwchbr9iawSgQ9LHmX5KoUlGC3/scmLB3FVNmKy+zFuVqUZLfIRCF1gY+E= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYXPR10MB7974.namprd10.prod.outlook.com (2603:10b6:930:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Tue, 12 Nov 2024 12:43:12 +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.8137.027; Tue, 12 Nov 2024 12:43:12 +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 v4 3/5] md/raid0: Atomic write support Date: Tue, 12 Nov 2024 12:42:54 +0000 Message-Id: <20241112124256.4106435-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241112124256.4106435-1-john.g.garry@oracle.com> References: <20241112124256.4106435-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0026.namprd07.prod.outlook.com (2603:10b6:a02:bc::39) 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_|CYXPR10MB7974:EE_ X-MS-Office365-Filtering-Correlation-Id: 43ce4178-d3e3-451f-3f7b-08dd0317919c 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: t7DMIhg7UG12MCjkEL4WA6IIW1C2tcbPzyQfQk2dbJpVHzPX50A5RLpffM2oKl1DwnMbcWySe0602OwJwUvB69XwVGnPHRBvEUDzxofEjrD8VdepI67vTtMCA4o10AAqx0o56aIXpvuGvGtAT1UXvCW7sCT2ookFr7ScSAOfpVfeeYbYovK64zh8HcAusdK2GQhQsV2B1tMG/CJlrIIbl7DXbAp4SAYxPUS3fgm+i1Ui41N4WHsmuLOSUrfz1WRNn4Wjz2mtyAfHexqPzovwYOKWeFcP/29sISkT6CRaXTPYrTRtwY6uROVqePGvqSVrJ6c3Ji604zeGIxaRQ1rbIPnI7FGD63o4s/yMEZdKdkNy9LwiJy+a44+0psbBm4otQKpPXfYyVUxZR0AWrm19BqaibXupabetL3WcZJQX4/7xgGBT2sNxIUphPqoB6PBrUVCS4GLOYJFtzq2nz7WV2/krg8nENLuJMNy0fH/wRGW9YTYBWFvUj5KSU0hjy/uEo4zWi7cl6iLu6s3y8YhfFwBjskAipX8IQGOtFONHe+9SrXRIzrb5cQKPMubzn5dYD8bbbcTQkCDMfqtKrtimjzxFYD1F71+pQaLLDc2kEglm+Xp4WUMfFWFZMgaeg4mJXEtXfkH3jVYWjw4wyHesMCzyyoskhI36nQNbg3Sydj1Yfit0b1GdxwewkPgSvnPBN76fCK08TpUxGACiN1ZhfH6f5O0c6LzwCx7OMEnXUk5V/XNXaqQj+Ixf3x0jrClNbqLJArwtoBMO7rOLdrQT+gboGAGjY6wrejWUNc1st80uFJVofglHta1p5Urqi6KBt3AsmQWuATihTV6NpIbyaLLG1xSxqCge7AmdE0ISh8/wu+TTwIJHNvHbil6gGg7HYF3XhE+JA0n26YCIx4JPvsQmMpd0mfKF7fMYCLsYsCa84eA5TPZZFcljfWC7hbT9I6GiHTTw6x04TRzTFyF92abKXqSCsYj1PYbXg2Y9E2eMItFNybQQ5DhaLFTYd1qgifilBXXSriLKltn6vOvLToKR8Y5Ib7cYbCJBlTY9quh3ZH3poFMUWjx9idVMc0880pw6+UTKmuGw4IY7lw5KMRMmQGNd2RZ84L4Oxh3yUpSZIYB81aJjuLqthbYjujkqfoWs/Z5veYxkwEz7xvZa95PP18k24D2ACgGKjTD94DDEqIfR10a20fBSXSed7gmrT3r/NXtkXob0D+P53eg9HnrZp7QU0dkSd1AJAGvqqAlxFlRhTg+8ntZ0cOZqrlZCeabNxMJDrYQEUyldmGzLgfhgjEs9WxzdYnagmQjaj2G+rLtk0fYkrmwB3qNF1MT4 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-AntiSp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RRWx774tKryJJskxAlHFJmF4ZbC1NVIUIkMtJHW/oOwdfUrZtvsrUauEyBgUbLdtD0O+inThEEcho5ESi/AerxtV5LphRW3H+fL3V58IqpDlG7mlH093CmqUXaiNP64BLLYmjNLPJ3GJ9GzgINqAMI11I/8BpVRsFUWUGqTzdYjmz3vsi5w5kJdYWMkTqZGNAQnEA27LBbqqgCU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43ce4178-d3e3-451f-3f7b-08dd0317919c X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 12:43:11.9520 (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: KJKDypNWb+hDNkK3IsnaJsQtFBWLWlaYdibVM6q1Erk/8ri471G6FkGXAeKt7DPW0Vqx7wdJx/LrJ+mIPnkZhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7974 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-12_05,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120102 X-Proofpoint-GUID: gPXgOeXhFCeqKJGO470n9ayF1rLpxr2u X-Proofpoint-ORIG-GUID: gPXgOeXhFCeqKJGO470n9ayF1rLpxr2u Set BLK_FEAT_ATOMIC_WRITES_STACKED to enable atomic writes. All other stacked device request queue limits should automatically be set properly. With regards to atomic write max bytes limit, this will be set at hw_max_sectors and this is limited by the stripe width, which we want. Reviewed-by: Yu Kuai Signed-off-by: John Garry --- drivers/md/raid0.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index baaf5f8b80ae..7049ec7fb8eb 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c @@ -384,6 +384,7 @@ static int raid0_set_limits(struct mddev *mddev) lim.max_write_zeroes_sectors = mddev->chunk_sectors; lim.io_min = mddev->chunk_sectors << 9; lim.io_opt = lim.io_min * mddev->raid_disks; + lim.features |= BLK_FEAT_ATOMIC_WRITES_STACKED; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) { queue_limits_cancel_update(mddev->gendisk->queue); From patchwork Tue Nov 12 12:42:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13872171 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 C4D9A1F7792; Tue, 12 Nov 2024 12:43:38 +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=1731415420; cv=fail; b=iBAToblf1Cv6c4P9Km8suHTvsGacxpCix2mmT/Z8os0kHb8wdIVhFwRsNwGNemPlj87XRQtnHJHnlHcR3gccUYVt/Y9qs3dlaQhOpe3+PBNB+2HTBqycoeobG9zrsqN4f040yQzQDoJGvF8uzg+5j/j+j7kPKusmYyWJTaPRUFE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731415420; c=relaxed/simple; bh=vc1zd6xqSuDoOgpqU7t7YHAsIM8s/yREPcDQu5N7kvc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=pZxsYZWxonBy2rqeXK/iu2JlKsTSkz0o/Xp74FEXArlnkWSV5l1I9ShRJEnawO/bbAVf7dRYHsv0J6ToDf0MbmgAkWQLH3Zi/MV2gCf9he1D5u6CLwrWViE9ObMfXYDr90K1saX+GIaUuyjuQkeB8lCw87qjCvOtkMPxA6Fx624= 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=kCAduph8; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=z9RHnzSq; 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="kCAduph8"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="z9RHnzSq" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACCfjO5017463; Tue, 12 Nov 2024 12:43:21 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=oaRzKFZjn1tQC+YTnJoTkVX7wlS4OwXrz97b7bCItqE=; b= kCAduph8M6ozdWL3qMzzbKRlIFYAFId4dqYVCCBa+w2wWNapESf+8bQmM9/PyvCk K9za9y4LXjy12Pnl6dATYJlZVkuT7XrYgDcTonhGtO8UjDWfmjsnnXtGSFLWFWoq 1spBB726IXeTHTp3WWnyx5h9cCVW8iesU4qN7/JdkVm4VCJ+8Jd8Ap9T1GSuEh9c hu6VT/vJBS48/7sQ4HR6xA4hyNS1NOBQ2YKEeoXc9X65WlhGSlPixvt7gAUIJ6C3 JxSQKa2M21Kx4Wr/uIUYhNPC0cs7oUUFr7Ol64UWijFPPxYIweJ4D2Axj/O+ba5K hPiQDI4YLPVUq1QoW9MvOQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0mbc8fx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:21 +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 4ACCX4Gc005677; Tue, 12 Nov 2024 12:43:19 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6825sj-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Ospleb4Owlvx9QtXoi1AgIZhWpL+KZCLrXD9GXA8e1gDzqhVR75DKdWBK8TsvlFN1pr3eSbFZkEQlyHSE/tn0WaAGtC9xgoU8yykHK5tN5264Jss3vTQL45E0Igy1QaDxegJiBZwlpjj89BTPfV4VegGl6iZ3rJgxF25E+tMjJnRVLdtHc7JbtTuNQaU0Jrb8LQohxnyHifTEWdW+2FGzH1S2f6SCpLKtZDHEn3ZWPRk2IMYCyDYULtlT/L55FrbkqI/svPlFqfX39FK3clDcTADN5qbx/dS8O8xX0SX3LeWoysQ5k5+8jwVcIUwJLZ6MvAJ//8hEK+PE764C4z/Vg== 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=oaRzKFZjn1tQC+YTnJoTkVX7wlS4OwXrz97b7bCItqE=; b=emy8zKDHpJs8g6aqOdzdU7/OGAb5MuXsT1LvdjfWrTH3EYfXp5UU1HSWkiGgIn0o7DkhxRcp6Y3OGjhooFsBDCQ0LLbiTtYqTJc0ZlhyXVRdpJ+OA+YIerfeAmhEutCWndralillpiwSYkNc25+eThd2ahM8B9GpnIzdVrDHs8gvDWVEhnCbFuIzP+6iGHo3RdgUm/ugtxySdfJdgp5GUPlE5AD2xjxdlXouH898WhtLT+QYN9DrjFC7+DcRyd9U1YVT1Bd+3e0aLpm89STQTF+yewaW5cOAmRIgPyTJc10XudwprFLo/yLtkgLOnWjCOubYkC7ahOvCVAo0A3osmA== 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=oaRzKFZjn1tQC+YTnJoTkVX7wlS4OwXrz97b7bCItqE=; b=z9RHnzSqwIe6zU4NOYUNMuMAjAFiqf6nr4VWWXGBMnTqP8t1pAHkeltUw8nHwNqPQ9xn26b4GG+L00iYvih3rWRGzhJYWiWmcfC5T18ARDdfVk1txKHXcukpqToor4VAhJ5ycWjNRsVqyzkTbk7M5ZWLDTE97rzDh2cOO0RiI6o= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYXPR10MB7974.namprd10.prod.outlook.com (2603:10b6:930:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Tue, 12 Nov 2024 12:43:15 +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.8137.027; Tue, 12 Nov 2024 12:43:13 +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 v4 4/5] md/raid1: Atomic write support Date: Tue, 12 Nov 2024 12:42:55 +0000 Message-Id: <20241112124256.4106435-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241112124256.4106435-1-john.g.garry@oracle.com> References: <20241112124256.4106435-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN9PR03CA0450.namprd03.prod.outlook.com (2603:10b6:408:113::35) 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_|CYXPR10MB7974:EE_ X-MS-Office365-Filtering-Correlation-Id: 5ac977ff-eb07-496e-fce8-08dd03179266 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam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7RldHBmxHFcccMDr1DSb9nwzzBxgK4u3cWSmftOB0FQoVY6nUqhzLLWZHYJMzZPVds7obGkKjGiZloPcQBu2SxRawuyDTTtBSivF0gI4CI+mSRbdAgLa2nuxIRuKrqEMYfhmKFrKU/fNbGSFotuEkRrbUJLTzPDiiYVLW4m151OjSD7xzrudrjYMKAD4rS/TtTl2blSR9DJ3OFJ31IEYBEndwrNR5fI5eNoB39YWe+Lx90I0IaSdgJDfN5DigvDByN/M38Jza 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: y0mMU3x8p6u0ISZ9pXY8Ae0e+8zqNpPN7VnL1na1RffjKnGZ/HbwRXFP1Vd2IhP9hXU7P6HVr3tKyyhENAqPxEYD4pGFmqTK8modt6tpIzDhq6B1Pc26pvk89cdXxAt39hDuu6HpEFGHNTq8nkJ9d221nSg0/NhbUM7iSXxFiBVXFp9uemN5Kax6pxha0ug/qZ6XUzpyJJZ324qDcB8/84FVVAHKwwJkhV33uJwBW8pD1QhsHcH/aYdeov0sMA5iNc6SeX+MfdaCHu7BuCRI91YYxrgrhXMbCn0eNHgoqWECv/HKOOuV+whskW0WmyThOG0Fpaw9lGPSg0OH4tlEJodHl6shsNArFWcEnXKynsyOjEWpReYD4WqyIVnKyA5S1mB/S4Di8O4Q+JjcFlOlVe5pkT7dMgGm0Fo7WU1UU+oUV3KCauNGFv35pL2ZLjjo8/Op8Krb9Z0XQWuHUUysA44w/CMKoQqJD7BdKcYeAtukxYtFPM+Adm3VegpR4ojTRUDnbWrC3Cekx/CaXqUHXaOjLIDiyh1esKvSDo0v11TdfW10QquRFscphmFZV6MqtTB23EIgeFcmuBkKFPcipzo8dbi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-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: dPH0SQisurWxQhqVK3gYVZhIOluMAcbzlrbQBZTs3L7fLJgS3IAqlY/kAAl6kpugQGv5wiXJnoHZ3bMEyJCeD2HEGLfeD9hWwXX0X9bYKBbEzcTh3Zg14Pc71/B/hPPTHQd1q8kwMCEPrmF3dAD0jvUdirnQohZ/lVK2dwfEN05k5xEG7DAiixUs7iLhVocmAFpXWYPjJ+naPtt4JRbXZb/r7OyOyo6ILnM+hHUOulX6YKX4q8qunE1kcwIEeZ9ipgSzhQ/yZo+exebALWurroCFIlx0XYyAtgpSg1k9LB9N+E7gBG0WJ9SHO5ae9vf2TkDvcdug1Gcg9kTcSEa4snXC0+Ch5BXnpb1o/yFd/8DN6uyGQ4jt/UdQQTcoW1YBb0k2Z5I92gR5WFgGrMHRmDhbifTXTYHMdsE8aw7Ql2qgNUcEGgPo9CpMPd260IP9nyqtqz2hdNa1ANoUYpuy3pG/Zn0e7VPxuiq8rrFhl9Ac6InFp5BakIm/OjDp1aZBMV99hSFe4NA5UWgHJFXNawf6KFJ9AA3G/1Ztx/GopPD4IDrdiAsQlpv//taKbvwLGFtd9V5OrI18Z44km5DIHHQSHFwcGrMcOMNMGuqUwck= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5ac977ff-eb07-496e-fce8-08dd03179266 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 12:43:13.2743 (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: 1iU3qnNmD5VAaYJT/isdopuzxmabpLH5MhPrTw2L8pJcxPCu7xAjAK/2xh0d+SYRyQUvt/W/ASLeNliWTFulzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7974 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-12_05,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120102 X-Proofpoint-GUID: By9QGEQKJ-_UNziqKOkStnh2eTOzVxZC X-Proofpoint-ORIG-GUID: By9QGEQKJ-_UNziqKOkStnh2eTOzVxZC 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 a5adf08ee174..cd44b4bebf49 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c @@ -1571,7 +1571,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; } @@ -1657,7 +1665,8 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio, mbio->bi_iter.bi_sector = (r1_bio->sector + rdev->data_offset); mbio->bi_end_io = raid1_end_write_request; - mbio->bi_opf = bio_op(bio) | (bio->bi_opf & (REQ_SYNC | REQ_FUA)); + mbio->bi_opf = bio_op(bio) | + (bio->bi_opf & (REQ_SYNC | REQ_FUA | REQ_ATOMIC)); if (test_bit(FailFast, &rdev->flags) && !test_bit(WriteMostly, &rdev->flags) && conf->raid_disks - mddev->degraded > 1) @@ -3224,6 +3233,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 Tue Nov 12 12:42:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13872173 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 8232B1FA85F; Tue, 12 Nov 2024 12:43:42 +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=1731415424; cv=fail; b=d3hlFUchN8QCf7uTHg0DnGBmmc2l4UoJPpnHvJG20IWgTq1oCUZkJEVVy9t1omd1l17iOGGULp5V5nmG9LVp8tvOVJyuEQAaOMfMVWzh+v4y+5/dfmpwdeEQQ8HfLTqRZI9gNtGOxL0J8Nf/ZW5f0arN0lYQZFdLZqLxD7yvd/s= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731415424; c=relaxed/simple; bh=Xz9Z30ZTkfYi0F4uiVst9jahQNWzKKQNQ+COZh2wCK4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=Lb9snwmwASopyPM+iogWGYb3i9Obqkgl8NsBmfJQWWN1MjGsUXHUyfnGcorrSsoZpzuqjfgJadOIUrEzOl5uwgS7JmhN+tYrc9LjuDcrT32d5wC98sXP/yDKX6W+MeC5uRjl7q5Z9lncL5yWVSKxjoJOsp5RYEvWuPv6s4JDbhE= 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=gLq2cqow; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=yS52w/we; 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="gLq2cqow"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="yS52w/we" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4ACCfiIQ017443; Tue, 12 Nov 2024 12:43:22 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=eshDoH+qO7lGHZ9+7QXypbf1EQFLEYIUd8JIJNGaL00=; b= gLq2cqow/x/mOwvxLPT5s98/FGyXn2fJlWKQc6euHkQaZ3ygLOH/U3EkEyIIeqrE RkX9aifISotS4My0njVrdt4bAlnxXJOsPXHltbmM6XrhGgVND0koHjh/E3D9FRsL e4O8A9qSblPTcnA7vQ0RgML+NbUMbIHwVEYCAKmAU9s164EuplRmCs7wUHuScGHr Y3e4fabRD8yvy5hfaKdfLLT/8H2D0b5eY5a9w4tdpMSO83w8XW6KC2gFQwxDjmL6 gxaLUKRWMcdjXL18ZmmqF5L4/pEM3EKHi0MonKDiV7g5BCdZb66aKKYFNqCBQxiU 5KGAxOixQP2g1Thw8yjlaA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 42t0mbc8fy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:21 +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 4ACCX4Gd005677; Tue, 12 Nov 2024 12:43:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 42sx6825sj-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 12 Nov 2024 12:43:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FnkLPwz1M3lHMe9Prh9RnRK+7OvA2jE36HCUcogyL6rxSJeMLSUaKFWU/UccA8Cp1G52F4TaxVlCYaROyDhEiqMyyJ9N4kIUNPEpy8LW0vJVUOFwYx1ST55+MxSCZLF3k+MmDoyrRKQJvL/Tut5qaKGcSz9o7tCPkGgs/v3hERs+psIMch0r2WRq4kHZFqhpiusZB7u6E/iLKWLcWkit1lNt2rUK5yu1HJ/nf1MY21BSJmlBQD6q38nUz/NpUipxqVdsFclEwocDXw3HZf5B6Ky5mcBc5MRU+u3BTFvHMnyAU9n9QQGM5hKb6Iw36gy01oGbsvqvBswWg1OXFsJsFw== 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=eshDoH+qO7lGHZ9+7QXypbf1EQFLEYIUd8JIJNGaL00=; b=p1Y7W4axd/upBZA7FJWZWjACbmj75VwCKtsxsXbB3kPRwzDoo3+ehWY9jNIcW9FVtAHzZ8kwuWcgwmG6/h50femEDSXpmCalzOa6heNhYJF7uq/fpGIWmXt6RkjmrvT6x52qXcNhJI4ALbE4YYfCHtAgmhAh3RE72LUYmqT1MuvCqHPa6l7TCJMcS+i+UTeXsmYRAIThcDWvwedLVjoTwN5wEg7CyUXZenoFpe9zDzcyAsss3QCk0gRKsXbxxY788bqXFEWzq723x2a3TcPg5lo6COWy9d1lOxdjaod9L4u5BkVbWni7iXJa980IcVri2jh08hoqItdT7d5HORWbYQ== 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=eshDoH+qO7lGHZ9+7QXypbf1EQFLEYIUd8JIJNGaL00=; b=yS52w/weZ5EMRGwNHYkXbqyKAiOxEVDgYSimioJ42pwCoQ/5Kk1Uc53mxPcURzI7WIiGsUZbDatROq9/aA9Li+cK8noBcykJRLKgX/w11MxHI6uq3YOgodaWcUlg0AhqcF25cy44qSC5W1rjz+vt5x1Us46fbXMhErYBHnkDw0k= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CYXPR10MB7974.namprd10.prod.outlook.com (2603:10b6:930:da::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8137.27; Tue, 12 Nov 2024 12:43:15 +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.8137.027; Tue, 12 Nov 2024 12:43:15 +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 v4 5/5] md/raid10: Atomic write support Date: Tue, 12 Nov 2024 12:42:56 +0000 Message-Id: <20241112124256.4106435-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241112124256.4106435-1-john.g.garry@oracle.com> References: <20241112124256.4106435-1-john.g.garry@oracle.com> X-ClientProxiedBy: BN0PR04CA0028.namprd04.prod.outlook.com (2603:10b6:408:ee::33) 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_|CYXPR10MB7974:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a9ecf64-e6e4-4f42-2cc9-08dd0317933f 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: 3mD62HkxaW0RBTuQ3rpRBlqe4hClDiNDGPSGDHQrYGrUwVreajtwbw6S9UmbzZpliniKuW7Vp5BK9eSDUwNNd8nsg1e7TqWpbvz2P8s9g9liWXaPveJdTgPlBnLKGct/9QHDiPYZ4hXK1GpJBet9WKmBD8emST21B2l+BiboYE9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gxu0ML07/o3qzxmyvk2yRfJ/zlYj6tt54qtOIULW/uJWFcui2Y68BiLbwM/hnyyaer9xCEoi7wSXh035cPNCgu5ExjRzmnRwq 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: QAepNiDpqA4t0Et+r52ZRRz2sV3PfMputBG5LUlq6I/edRY9uYCwDcVePLpnK1m4vpBsLTjnPPdQ3pdEFa70VPkXYzBY13rwBOl5PCNmfE1c8Icqi//kwk7yOEhw0/+kQm42fzlUIHGHL0ROy+Hpl2IvZTJIdUI228P8JoP8l4XpGPmP5s6XhQNN9sweXbiQBnCYWlzQO6TXJ4m2FtYZ8JS8hzFEGIPbeUVo6S4mFYZgusl/ESk6hB6dhAIrvAeKqY/8nb0pMk6jB3vcFLRR8rK590LbJevELkxE8RSXpx1YhTj5DTiIE+X0uLTFLRkXiB1F8GtL9eUDf5Pu+vK9O5OnILwrc9XROYbk5EMMFKJQcNEe4/cVaijCdUy+Dg4JMVohg4oEm06SKt513tGzw1nRn7nQz8sU4CfYE7W8TvoYbVeagP+Qb4sTp4RoFUzSDfMQf2rKCAdp72ewD7R8llL2a5bRaQozYa0hbGy1NT4pJAEDYCFFtQFyCxOVyARN21zhodEeBdy2DILtrfL9tDc+G1/+XZE9L9lFC7tv1vHqS9z31JPPIlY2i98fArASBmN8/j9DkDX++d/skYYMbGsemQkGr4tU2aKrQKAhTJ6e7IUkgM4J24VUiUMpHx3OjgguXAtgYcwQ5435Imhg7dVLyM5AqoWKEdEEqzzVOfmiZpcS9AOKrV4ZgrDMOy/yOjOSLbD5zuTfrssBimgFVlW+9AR/rExV2vx5NUwjJE2ZYuU03UPmaFQ3GccpnH9/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w3fn1AdUaFo1oNnhPJt058uPIHfYZAJlGuJz1DFHsZwkgxr4fPv8ljjTgOAKdYDuxWc3CneSOG1LyssbEyKI5MHbsX0giLVRPKMxBvZH0/JwkGlodtmdqNuCG8IND4nWrTO5QWZdvdnEv0UELYIAr6QNiiwLLFj9w55RsmSrcLUJc2tJo6te85hVxrBv6zjFYaPfOdcCcMA6Xtscc5twomv1mmJivsJcJ1VasZpyMAfnL9dk6dFbcBbhZ3QoWxTmNQ4cFOdtNQXA2KPM938o0/EoXVmE+1KdG9Cg+4Vs4jFhfigAPuRQ1OXXRjxD5Zf2FRnV2sz6KDcX8Wb7JtRbG+2PiiuooOmOqHFUH4HjOmBxTwO+LsyKocQKSLat6L+rFVl7NrGHBDhLRy0kUmbAVuNwEf8JrW8iZ9o2zhFPxS0m597TVPfmwlcoY763xibUe/MmUc2oY1Vd9iJ6XNnQEZdQzCwn8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a9ecf64-e6e4-4f42-2cc9-08dd0317933f X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Nov 2024 12:43:14.7637 (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: 0AFqo4qwR7+4a6dnf7VDhC+wPWv/guAkqLlxR1FcloYpFud/NewfBe1tWcMNBb+FXlCIzLDpzYNPFz/DVp1EUA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYXPR10MB7974 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-11-12_05,2024-11-08_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 spamscore=0 adultscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2411120102 X-Proofpoint-GUID: PpDx4cTViuOKmE7w29141I0ZQ5RH0JON X-Proofpoint-ORIG-GUID: PpDx4cTViuOKmE7w29141I0ZQ5RH0JON 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 8c7f5daa073a..a3936a67e1e8 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c @@ -1255,6 +1255,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, const enum req_op op = bio_op(bio); const blk_opf_t do_sync = bio->bi_opf & REQ_SYNC; const blk_opf_t do_fua = bio->bi_opf & REQ_FUA; + const blk_opf_t do_atomic = bio->bi_opf & REQ_ATOMIC; unsigned long flags; struct r10conf *conf = mddev->private; struct md_rdev *rdev; @@ -1273,7 +1274,7 @@ static void raid10_write_one_disk(struct mddev *mddev, struct r10bio *r10_bio, mbio->bi_iter.bi_sector = (r10_bio->devs[n_copy].addr + choose_data_offset(r10_bio, rdev)); mbio->bi_end_io = raid10_end_write_request; - mbio->bi_opf = op | do_sync | do_fua; + mbio->bi_opf = op | do_sync | do_fua | do_atomic; if (!replacement && test_bit(FailFast, &conf->mirrors[devnum].rdev->flags) && enough(conf, devnum)) @@ -1468,7 +1469,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; } @@ -4025,6 +4034,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);