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: 13872185 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-raid@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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KfalD237YjOCPNYJYGQClKtpPzqQoB1be7Na/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