From patchwork Tue Sep 3 15:07:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 825853 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 698F62A1DC; Tue, 3 Sep 2024 15:08:44 +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=1725376126; cv=fail; b=h86+QsF6gJF7ZscVd8fefU00tC3ZqfFJpVS8CyzoLb/VAZQNkaiAVqwHlkKfL0ZwTjKN0s8/gAgShqxYIUn8oLgnHoPjWAhBLjE/Nt5/q2veLgZxOptzEVx5wotGG2Nh7QuO/y64YRyjYRX2IJpwdBDoPKZAEPI72gG89OlOGCc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376126; c=relaxed/simple; bh=uFUcIH1mxHbWtQ1NWzSW1d7YNITH2v3ky5rCBe3aUp8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=co/7Ej8BUD3BzKKTnC85C1Lym5B+xSbdOaCyGwBHA6QHkqwS4/KGovBV5cbuTm3SI01m91OvDk3IYEn9hGiCHqC6TIW2cJa2j2lQZIPCMJTp9CmgFQmmyFrPYgW1jWw1SarIolfc4huVQkoY/ClgQahP2DITw7c2a+rFOZL8v8Q= 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=DR5WOH3z; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=MKMYZ2B9; 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="DR5WOH3z"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="MKMYZ2B9" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483Eonsv016382; Tue, 3 Sep 2024 15:08:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=ZwuElY6cPraMbfOb4ODQTnyC6NGt8UEKPTW5tHUTjWo=; b= DR5WOH3zafDBpGh1hJUZ1QmqvBinvTwiLKb2OXAwlwrw1jSr2ie+OXEgweBKiwoe q/KRIO1hQgQ3OCgGiP+qKO0ySZEMsJh76dQELzwAg/lnXt/lhuOghFbO93/fATWg T5jjI0K1rMu8/2A+F33K3f0KTxGpq6bTg7FSrCme4MPLvrMO6De3j/wJYMuAQqyU OxAVaKzHcHR6+mA4D3hYNgnC7w6+EgPJ31azlulyxwKHSltp6SxvRfnj1lEzMAqF TYTbt3IizVoIu8GjDKmI8bdyJ5F7m6sytr6C2Ee67HEcYEnaNC8jZPCJXm9ZcU7t vLo9oOu/lWI46f1/LKMu9Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dvu794td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:22 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483Esjlp032636; Tue, 3 Sep 2024 15:08:21 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41bsm9151j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=A2lhPthW1F2kC5Ic4T++OuyDYWkcJ5qyMfx0SryFhk6zo7TSVrxvneJ8wlPhr5/p+0rnhPCGGZzhsAqFeNK33muyCRx1Q/7MhnEBXmvuyhpeF/661CBbhbdkmGy371YFKmLthyD+DNV3v6cCH1avdeERgR/lnKAv9ggpRrx4BeibKcx/bE3/Y+xUn6Ugg6J0i0ZeEu5Lwc2W1TrLzMKFaeR5JRGHxInErjsX/hLr1aB2RbBdc3kmH2OIYkzyL4y9ZP7qDmCpZrK8WhRtKeIHgAk+rLa/K/T9F2EnXTUEvJP9s2QLeWccOiRWoDUS3/vMQDHmoOo5UIh8drIhCYAjZQ== 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=ZwuElY6cPraMbfOb4ODQTnyC6NGt8UEKPTW5tHUTjWo=; b=sJbKTRU+EMP5+kuzotZGEjJl4ysOjAYWhmuQ27xqjbVlXAeS0gk8fSg+k8kKOAt7oqQ34sdQngVbf+fsdNCNH5HbdwrightwDzbROezWGkA7CMV9v1Mj0J9r1Nndt7ShJo3HZMxOR2tPUnnghK7sHdG4SP4vYdrOjrGNhPuUhn7OcRGH6G//d+OjM36YCq9Ig2Cf45r4iyaavMcz9nYMfmrzrvnfoYYROLi+FA/yQbjfseyFvq7YcPv6bc7dSmLUeeBB/hQ8enBS0P9Jnp/MoHpP2byZ4e0n44Q1gtUsQ9MflcHkYkg5GoJCpfZNxgZf2Yf3PcoTG+AA3U3iQbPJjg== 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=ZwuElY6cPraMbfOb4ODQTnyC6NGt8UEKPTW5tHUTjWo=; b=MKMYZ2B91A/4vYOuDjvg+WaI9OxDTyzKw1pM5lnQQae9M6gmuxC1N26ZeLLANH2q/Q09gsJoG8FM5oLXi4F4gsznTT0L9Q6zutdgGOdZyEAJ1hUTsVEIxSDt9OvG3Bf+IuWr2NRarGZ26N/iXVkLb7rDsfwBi+oWaP9gahpQ8CA= Received: from CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) by LV3PR10MB8105.namprd10.prod.outlook.com (2603:10b6:408:28d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 15:08:15 +0000 Received: from CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2]) by CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2%3]) with mapi id 15.20.7918.012; Tue, 3 Sep 2024 15:08:15 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, John Garry Subject: [PATCH RFC 1/4] block: Make bdev_can_atomic_write() robust against mis-aligned bdev size Date: Tue, 3 Sep 2024 15:07:45 +0000 Message-Id: <20240903150748.2179966-2-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240903150748.2179966-1-john.g.garry@oracle.com> References: <20240903150748.2179966-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR01CA0007.prod.exchangelabs.com (2603:10b6:a02:80::20) To CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4312:EE_|LV3PR10MB8105:EE_ X-MS-Office365-Filtering-Correlation-Id: bb6a53c5-dffe-4bf6-9f3e-08dccc2a3c6a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: QBec7ed/aap4nKeBTOLx4haXTP8brEqsX6hgzooRkos1JmyGtL+Bv6IS0LVf3oOjL1H/0TmzpxTyCHRJEiLya67aSwKuLjnx5Ppj0G5JzbLNBtBrJToV5bsO/NnSFgFn0NlIVuiBkI1ZyC6qvLRay9Q8vZxpC5YM0vTBr3veiGAswqAGIYnts7ax6uQuQFiALNJNGfn/ahVZIWMH5YSNgl0n1WCPvw5Bs6XpdZr9r8FsIFHzUmozOPzJH7J5tr7A5a8GgGZIz9A3HIgSrCKeZrZPwQWWuC5aY+KHJ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efront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4312.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /fHXPWuc77n5ZXtsZPq+n9R0eIQfwnFlFuDhVN5sSyjFev5p5IjvoXcqPtYhm/+cOAOSCKlKiT6At1ccQo/u721Kv/S9nao3N3wQUn36UuZ43r138e7YYd1zS6XaIU79q71ARdl92j0xF3QZlSF6hfnjF01/2KPwmvH/Ido6GVf8g3KmsmEf5ETu5pYh2ihleiFBGZdxyioBc17awl5c19837PiSZKKERsx6ykAuaVqUGxTPmT81TgUa3Ln/jWHhGHyctwTquGtwHDR2FzeDydmrXT+1K7I0s/1kIqowxAcVinwgoCjyg0brw5tW/15AChOu8OkWgH6iaZOp/27lEPT9hKmyFoo+19i7lqniShBzuByxCILNKFfIiiUOie6xCzibZ2CTGP5Rw9IgRby/IZeitJ613WbVtYOkALGBJ46EAIU74eAvNt3L2ZSQSgdIosGXWKzLYuZyazY14L2c6CjR4UiUUiyeSUXD64MPIHX279lDdDgToCXBoGkPVJ15Kk5nJsf7zllN2sVLd1/BTjhsXTCPhvx9A5cTTMvEc9H0xCVqKGmybuWwytiurfQJ/h6a1Adir86TZ5FsVn0gjXa4PdBnXoac4wbuLp+uIF89u5/rkAvxS4mjpqpIM36aEYm5vcNvafIEQ2BimZmpvaBSb9fDWDYl//XXIh3XmpiFnBlMLO4BijKG9yho/ZML/gcyyx2DiKtoFRbLusgj2RWjs5QrI2etYkpxm3mk6rQQwaQH6S4wHl2BUaw0E7O+dW7uyfNXrLGFrEywDiCu6ladhY3ul7I1/HWeIFh1LgVxQhKSHkcEopmAlXjgq5Tef2ZiFQdRJSjHMo/aPY11eGTlesQKy2OANnFkPtCNu/YWLSAVkxU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SSsIbrlpjHq1w30VeQ0DWTeXmiwOOS6v4tr8O6Epkxy0uHYrKFpLNX8rhmJ/489/YhqoQIdsuwOhmJ2yV9UZU+36tuIoJa8fRrQ1ITfVCE1FctpmVYGpFvp0eb4wNeKxJytxeCLacVP9TxbF2Q/S/2i76slRyssySBEhK8iINHE96WhD+sdbRqBLA6NK4xBG/KLNQ+FSS4kyMdrhzYDiNcseTygOYbWKyisvGMYW4lgXOAWzft1JjjRZdZY31dR8Hf1R4Evq2XThhFf0v6dGpZBiJxEOq7UFTZYKzeFQI0UheQnTHG0KZcBnP26SIOlHEIveeiUSwTV8PNnf8cRYMlrCgd2i6A= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb6a53c5-dffe-4bf6-9f3e-08dccc2a3c6a X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4312.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 15:08:15.5172 (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: aSmtSurPeDqbPh3gKXPp73Mry675ygLCsDgJK1z34NXxk3ZHkbEWmFFAakTIpILNnWF68W/TJ/HKZA1TXB0Iuw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8105 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_02,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030123 X-Proofpoint-ORIG-GUID: n7ACQSY4gxbBcpRgTfIodtD4ENouFjRx X-Proofpoint-GUID: n7ACQSY4gxbBcpRgTfIodtD4ENouFjRx For bdev file operations, a write will be truncated when trying to write past the end of the device. This could not be tolerated for an atomic write. Ensure that the size of the bdev matches max atomic write unit so that this truncation would never occur. Fixes: 9da3d1e912f3 ("block: Add core atomic write support") Signed-off-by: John Garry --- include/linux/blkdev.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index b7664d593486..af8434e391fa 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1662,6 +1662,9 @@ static inline bool bdev_can_atomic_write(struct block_device *bdev) if (!limits->atomic_write_unit_min) return false; + if (!IS_ALIGNED(bdev_nr_bytes(bdev), limits->atomic_write_unit_max)) + return false; + if (bdev_is_partition(bdev)) { sector_t bd_start_sect = bdev->bd_start_sect; unsigned int alignment = From patchwork Tue Sep 3 15:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 825223 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 6994617623A; Tue, 3 Sep 2024 15:08:44 +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=1725376127; cv=fail; b=aS8wO1w/5LbzmeaX/P6sZuuu/SsBGKgAGEGeRbsb/oo1xoM98pRuuiLOTl0pA02Y69ixrVW4GsZwst9mfVfZxWTOxkEeGO99x4zMAqBy9tNzYXGGk+hO0aQU/dkAexgSkJpsSpLDltt9yD0/qNSrjmCX6+ZumlGumK0VQahtyy0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376127; c=relaxed/simple; bh=fS3rovV3qIIbGZ/n8LdiGt/XBUJhlog66TshY1YkklQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=NQQUu9V1eQGOPh1uCW2Rat9w8wpChVmZN8etNGcyPQKGIa+XJiPvDTVOAdA7khUAPPsbTnpObbsBQcWwJZmScMuYImOickv63VCisX/jcZOCsp41OQ4sl1D0U9UWHv6GG2s5HLTz3PWxvzME+RgWg/F42xSm9gs5sgEpMJukNP4= 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=fND1rqhG; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=Um6TFlI1; 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="fND1rqhG"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="Um6TFlI1" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483EufpP016367; Tue, 3 Sep 2024 15:08:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=SdrjT84eVboeLkbGEN7I3Jq7kyAHgMQohJRPdaq+dUY=; b= fND1rqhG/KjT36vcuOemkgBHv7RYVdf79jP2lZ869VPGl7t+qVyG5lFySNjgKwMK al9b2oWjqPjsZE7DI1TBpEwXpNjhaE6vT+d6m1d6bAbklcLIpGK/a0T1HUMLmD7a +72HJBwd9msTY/VGvzfDMheGpt/ljP0XIYdym4TspjuonIvQR62a9vOAxUZGhPK2 AaWBfCk/laCWCf6a9nUkb3pg2/pdqoNIpTqqMY2d41h62YDET9ECGUAa8VK406aO rY+z/bLCx/47p5k8/bHgoteNVatewUWz2Z2iHFTlZHH7m7T4aeTQyZtLWwaiA7z7 P89dljJQs9JyL5h5MwkKuQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dvu794tn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:23 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483Esjlq032636; Tue, 3 Sep 2024 15:08:22 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41bsm9151j-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Z0QQeeq0pcFheASuxTN0B0M+wxxcVV9gWap0BDY721kjZbfpZrZU4jJS2WSti6I2cXK7ia0Y3rzgiZREV4UE+6oKg5xHYom2wZzDcEI5YwvWUZIjl7ixnBI0pbBWYXiNVWsBvr6JS49JL46WTtupwZWDSQ94LLNiLw7okXwcahS04d1z6i3NTHG2NmkBg7UH+SmlCwFsdJFVxdd4SOioxH7QCZzkRpTxls5D1gWyCWebd7EAwHl37ZtT3+0/majmA9QDSRNy0ccPjiHy0gBxQSebVk5IUjvO1h0Uvjp33KCmOS2wAcsI7t7xgGgSj6vs91puncT/IqFPOiSsW04alw== 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=SdrjT84eVboeLkbGEN7I3Jq7kyAHgMQohJRPdaq+dUY=; b=tddtmZQLBTXVCOuAwR7bUgq6AY1HJrZ4eQM4KXNGVFhvQufpEnfaSi9sZY4dha8aOA6Eow/ZtPCn0J3K+dM9TJwlRzBb3hE8Xk5+RA+CJA7fu1UGstUnWjk7cC7Eo7axp9DK6nDW4vEZ7hoMwKSqzoNXqNPHEh/OXNXYmGCAwUSzcj6iEOj36WUiaghu8gd+X84FJ9LHcjR4zU33ZjuDw42BnwZ96FyHFr3l9wAy2jjmYvJtIdNRkMBW30eZIQJOb03VfJ9D3zrVswcr/kYiPGXurjjuxe/DYQYdzih1LpafyqUsUX9TDq1/1f1zBcTpsktw504kOqMVrBKKB1XrOg== 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=SdrjT84eVboeLkbGEN7I3Jq7kyAHgMQohJRPdaq+dUY=; b=Um6TFlI12vBjb3IKVhKmrJUXKHoQP89hkqQomUmldTlb/rnN4Apiwam+SQp8+iUhDkGHYKcRvzSwEM29FRce+Yu0HCr3l+AK0z16kZp+LSXN123n5Vb3PtR4hkLxIbyMfVv4WIDnaK9a/vFQQYTQzPhqnH9IDBudge3T4HNIe5U= Received: from CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) by LV3PR10MB8105.namprd10.prod.outlook.com (2603:10b6:408:28d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 15:08:17 +0000 Received: from CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2]) by CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2%3]) with mapi id 15.20.7918.012; Tue, 3 Sep 2024 15:08:17 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, John Garry Subject: [PATCH RFC 2/4] block: Add BLK_FEAT_ATOMIC_WRITES flag Date: Tue, 3 Sep 2024 15:07:46 +0000 Message-Id: <20240903150748.2179966-3-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240903150748.2179966-1-john.g.garry@oracle.com> References: <20240903150748.2179966-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR06CA0055.namprd06.prod.outlook.com (2603:10b6:a03:14b::32) To CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4312:EE_|LV3PR10MB8105:EE_ X-MS-Office365-Filtering-Correlation-Id: 8b2a3d9b-82d7-43f8-f111-08dccc2a3d9a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: awf9bo+I670TtYQ5Gzf0X+eFurZKGxtXFJ9A41nctEFm4PCkcId8FicQLMNE2Q35vvHz6msbqajhpU+ZIk8/YVT1PP+YEHMeBN8Pr2FcWIGy0QIl/QthQ8ufyQ9L/ungWH//77RrYyzCP0d5zqdJpBXz+XZN7L0u3E6S00Z0MvNR+gFnHOQsedyge+kJH8IBJMirKLaix81BEE62sxtyZk2UixSbVtgr6yTJVy0WUigRKelosOcZIBucdRNpXh3/bFa9mTVUG9x+WJNxSXRLbzSv6xfgcLBwdReobw5O3nOpL6zEKpVk2Ef2LZuXbtMvMzPHGWwpxj36RPforXaMYSxp0CQQA2enEknajWdG5ntSrJ9sL2XQPudq+RWLBN0SSTE8dqY7r+IJoGsbeU/iikOBFB+IJR5w3cMDX27agmSB2nPYnNhr5w6BS/xrcBjin54SbhKWQyXs5hO6rkJvYeKNK9SWYvH4MqCW3ybqCDEtxNbcSTgFKCdRq2vhqBqmnsv1wyv0fuLzcDBPqkZp5WG0T93pX/IcgV+DEQNMkO0eUVMi69NH2j6jf+NNWrnW0kuuYfh2X4o1gnTcZfMzP+OlJRmWNYAmqL+9mXZuDqn+PwzpHSCxfS9K4w67inNhjIobu9Xkht7sknmyGrMDbxuGHd2L6A+ddlC2FdbzuDnd6o2K8i5C35kKIAcH2tvqIu3KwFko1XhVihW1DA3Z9Mj/HEhQOwsAJtdbSuIjl6aa7gBBhGCX21l3RKRxGc438VGIGpOG1XjbwQ1gl265X0NnRUmETgcMV+S1vXog3qweHBjwuh1fZvk7anrBC+oqk51UrzA2r7hoU0StDa9lB5QcnYIpLnSLsM/22Nglqht/C1CdjV2xIytW8MvXdgDJuoe677EG5zA7NYjSX5auNZ5VtiCzxyMsjeG1x6wwwJJmSf63UXARKChKeyP41CgGCc5SP8pS2+IkR+rJ2r26b6IzlcOkMDns254xxccmKPhvYxxIVZUxbG/mBNLEoTXwVF/BYjYuvViWrb8vRiv9Bjy2cI7o7NB+2Y8uuJp0EkSF5iJFxm+ztNLSMXr4F+EZ3O1nda/rdHFVtl5izoqg7JbiJlzBqoomeL8mmhRTdoeNbFKxoARSs/6TeA9CUFcJD0fLSpH9apXblahzXcN04zLQc/H1lsYi25hPPMtGMdgjP0RsS2OLZB3kgZAU7scSKMbiOJTts6pyGIxu1PFn8h9wEwIqbR25USxOm896sQBUfuLXuLwS9JQdUEsjoA3fH8lef307qnBLVfCWHZpRhtZmUXZqnAasLLbhio+ymNWcZBF/nfmcDje4XWn+UTcPb7huSf4iUtmmZJ5Q9GRVcA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4312.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F/y4pcc2+yGYxfprPNVJUZwkYfVr7mEd2zA4t/evgGyMMtBaz02jRpqu1XKH3Aa/ahfR5CpYVgc6aXCNS2F3K80zB3uKQIlqzSJs/b7YsQiR5P9eBKAs5xgk4gJKMPTopfjgjGuF6AOQAfpIt+S/yrkBrYUac2Yc5iT1NpJ8BVWBR3TW+PdjSmZ0keVfJSoj2eF1543oKV5WJPKjjenJct1DHQnmh1h6eOwzn+GGYshMLeYefbHfyClUpswvMMtfaKf0sx1/TatPbn0ON5E7h7TUfsQW7PE7/iLjdSwY4Um4IcbRaxZSmPq0LISl+IkHxUN25mwVYiNPYS71crXeuRf6IO8/PP4TGuY2ez85NWl0KnVEmAt/f7OKs+5Na2IlIl1zHs1XzyyvcPXLgHH9GeBjFf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pQzqTX5fwgRMo85Kzb3UBmv/5UUwWuiEURmyU/7PJuz1H6iBmzfMZx+dXh2Wgt4IuRhMX2g0u7H2S3K2ojlL89EvY9Yh3r69+pfXcYo9VKi6yI7kbark/KupXuAaGoKJb+TD/+w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qNLruL+PUdcRBqBqPFZCwtztdIrNgEUdeEZNDiDraCgjgttgymgaUy6H8LhsGz7+aTwAhQI3MOdaOicZ8Vc3eLFKowwocrA62f26KUMftDgPl6FuAgutexPfcLynocDFqAIuShcqpKxa6mnEH/wtkE2HnLM4s5OJNQGL7TXNjymv7drPQwsUfEkq0K0MfTrGrHCMHYZkP27KSRSXyPXQ4kbQg3yFCNuiEY9smAQh+naWV1VJKT9T2JROD//4mXdP6wC4ZRUIEtbS+0LrlLOIDDRQBfDKGLvpsFG3m4iEi3duQtMhLwQ/3BExRTULIqjQbi9u6yRQil3el76UxqJbpXu0yEcLxufHedO7ockjz7rfDhMyl2GzSH0YIV27TOXQN+xwgHCeto/oMOceofHA1kfeqtaSSpoquyAQ2JR8hdEN9mBKvf3/b4Kmqlc5BtGc6ERe5BDw0zDtSVtzNkgwXoCnRw2pseQxvB+dao3U3i5OhpBVwMCcgYCqltlvLkAWwoVpgm24lee2uMkomJQomOFousl94B0Oi4i6ECg0ebvUDplriqzFiyomn3hYrvXmMdeoxyPgYG0E8pioVQtkqxKCmNixCCqUnbCbzi1RU0w= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b2a3d9b-82d7-43f8-f111-08dccc2a3d9a X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4312.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 15:08:17.5400 (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: QR2fpq2T3caRVMwcaMac0+5VkWhnOLJeMc31j/WOge1PxNSVEvir4kFbwL4uTrFqoKPhncMyGCmCXdn580c9rg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8105 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_02,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030123 X-Proofpoint-ORIG-GUID: 97I50RQALv0vZkBTcVNwY_-h_lhNQ7OS X-Proofpoint-GUID: 97I50RQALv0vZkBTcVNwY_-h_lhNQ7OS For stacking devices, not all underlying bottom devices may support atomic writes, so a feature flag would be helpful in deciding whether the top device may support atomic writes. Furthermore, even if all bottom devices support atomic writes, a md/dm personality may not. Add flag BLK_FEAT_ATOMIC_WRITES to decide whether a block device supports atomic writes. Signed-off-by: John Garry Reviewed-by: Christoph Hellwig --- block/blk-settings.c | 3 ++- drivers/nvme/host/core.c | 3 +++ drivers/scsi/sd.c | 13 ++++++++++--- include/linux/blkdev.h | 3 +++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index cd8a8eabc9a5..036e67f73116 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -176,7 +176,7 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim) { unsigned int boundary_sectors; - if (!lim->atomic_write_hw_max) + if (!(lim->features & BLK_FEAT_ATOMIC_WRITES) || !lim->atomic_write_hw_max) goto unsupported; boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT; @@ -217,6 +217,7 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim) lim->atomic_write_boundary_sectors = 0; lim->atomic_write_unit_min = 0; lim->atomic_write_unit_max = 0; + lim->features &= ~BLK_FEAT_ATOMIC_WRITES; } /* diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 0dc8bcc664f2..c70d8e7602bf 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1975,6 +1975,7 @@ static void nvme_update_atomic_write_disk_info(struct nvme_ns *ns, lim->atomic_write_hw_boundary = boundary; lim->atomic_write_hw_unit_min = bs; lim->atomic_write_hw_unit_max = rounddown_pow_of_two(atomic_bs); + lim->features |= BLK_FEAT_ATOMIC_WRITES; } static u32 nvme_max_drv_segments(struct nvme_ctrl *ctrl) @@ -2025,6 +2026,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id, atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs; nvme_update_atomic_write_disk_info(ns, id, lim, bs, atomic_bs); + } else { + lim->features &= ~BLK_FEAT_ATOMIC_WRITES; } if (id->nsfeat & NVME_NS_FEAT_IO_OPT) { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9db86943d04c..aecd05165ee8 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -948,7 +948,7 @@ static void sd_config_atomic(struct scsi_disk *sdkp, struct queue_limits *lim) if ((!sdkp->max_atomic && !sdkp->max_atomic_with_boundary) || sdkp->protection_type == T10_PI_TYPE2_PROTECTION) - return; + goto out_unsupported; physical_block_size_sectors = sdkp->physical_block_size / sdkp->device->sector_size; @@ -988,15 +988,22 @@ static void sd_config_atomic(struct scsi_disk *sdkp, struct queue_limits *lim) if (sdkp->atomic_alignment > 1) { if (unit_min > 1 && unit_min % sdkp->atomic_alignment) - return; + goto out_unsupported; if (unit_max > 1 && unit_max % sdkp->atomic_alignment) - return; + goto out_unsupported; } lim->atomic_write_hw_max = max_atomic * logical_block_size; lim->atomic_write_hw_boundary = 0; lim->atomic_write_hw_unit_min = unit_min * logical_block_size; lim->atomic_write_hw_unit_max = unit_max * logical_block_size; + + lim->features |= BLK_FEAT_ATOMIC_WRITES; + return; + +out_unsupported: + lim->features &= ~BLK_FEAT_ATOMIC_WRITES; + return; } static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index af8434e391fa..c8c6a496a6ed 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -332,6 +332,9 @@ typedef unsigned int __bitwise blk_features_t; #define BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE \ ((__force blk_features_t)(1u << 15)) +/* device supports atomic writes */ +#define BLK_FEAT_ATOMIC_WRITES ((__force blk_features_t)(1u << 16)) + /* * Flags automatically inherited when stacking limits. */ From patchwork Tue Sep 3 15:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 825851 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 B1D32186E3D; Tue, 3 Sep 2024 15:10:46 +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=1725376248; cv=fail; b=IQtv+4lg6gDzhlVEo5OGRxLWtxYZNVgtb9dIF5SdEKRwvL5+l2t0ND5J9dxu3MxTBJ6URhqep8RUR5XZkwrvaMwX3bGaXCF0na8V229wBQ5VmpqjHESWanGowmKX5MQHMKaYZBz3lahoBUwE7pQonhaKSUlxZmO/QQyS8r+2PtA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376248; c=relaxed/simple; bh=11tgHcwd2vlspSsp3A1sW/deLKLzXwogOARn1ZZUDnQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=oWib9XpgIrcW4opGWMXMh42NenfITgZVIHRZsDBxE2fVVmrtjvuuOHnwXrlcAavmncmZicncXMAHjzB2rhTlNPp+GnmVrz1xqE4mXVEhBakYncD+gbc7jlSyw2+DY7JKuGWvgI3GFPUb0FqBJCJFMMwtJAGVk5FOZUva4HqwR04= 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=F1lTjpO0; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=xpolX4xM; 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="F1lTjpO0"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="xpolX4xM" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483EjAWB019498; Tue, 3 Sep 2024 15:08:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=/LVI0aImon/7Vc91T9r94DrdXJ2ycY8pPHSq4G7OYzc=; b= F1lTjpO0GWGYi0puPzifKyTGBgJs+wmN4/9iySR9IdZ1yaJC3rRI2as99jfqFmcx Ol4AwRLSnAfd/MyYuOCxIBv1VaaCs2uEm6B/NSadtPjxgtnOFqTDPbZAFhg+ZgME xTAaMXU7lFtPrAvz1+Mb4O2H3LNSu8GdoBqb12UIOff6fLjpo4gRzVDCm0MxroWm 3trzplwOt6pkFfi1gIBeWbWS2QBWGzyEpUDxJml/cBm/bRq14bilRMrsaWyYb4xo 6mYC1iDQxUYZflIpUDr8skpPASGzURsUS6VUc9c3PNB/EqE6fOcAZG0r163rLx9h 69wzVs5/uKmbEGp3ktBhvg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dvsa95wr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:24 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483Esjls032636; Tue, 3 Sep 2024 15:08:23 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41bsm9151j-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=a0VqXP1oegKz0N+ut7IIguJd1WrOK9UBmTW8Dxfn7xUWwj0oLsTWVNe8d+BLpH/gpVZhuFZxwfg8hsUKYZ4i3PpOiGseApp/xXHLCVkWLL/pAhFx9Uzk/lNiApJsBEsSCamxk+zbfWdxKbKvt4oSaP776l9bd5l+7WtWe5AjIdW+6sd0ZbZmPtW4vi/uIJDV09JJms1SS3paD1dCZswqk6ucGTDzaII8GdPyY5k3RxombC5frQKxMW7TkhFeaSxgsQ5b7J2niGTOYz0Fg5+YyvRCPZ9/xJXpSQQCCoUtHxAAey1m5pJ+Qt9YXX4FKjFB6LBHYMCVqXl3WzZhnXEcbg== 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=/LVI0aImon/7Vc91T9r94DrdXJ2ycY8pPHSq4G7OYzc=; b=omJesIFbugdm9bkiOSd1hPTv9ye9Z4VI7m7YN+Ov3633wuh2aGjwFJJquzMKUj5oKsK2MSOjHwDeTrwZNAyb/8zeaqjjU7xiC9zxlLbKWR32eO4LYBrXfaM/ICUJThm4GxXwSvknYhZ3cxLK5UIlIKrdafP8AvijCpIVYUMGZ118rG/r+VkxoK+I71nw+G5Nvbnj5wllc/tlTtdTcFeoK6SucGy6zrdFnpiet+XdX7yVdNcsyGLi9Hd7d8UVF+gA2Su2E1kHt4yfXLiKu7PbgPycWvsiiEC+vZtd/4tt2JNzzBCsGnefNS6F7XA2ftFU1V0tZjVg+RA2h5REaycFuA== 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=/LVI0aImon/7Vc91T9r94DrdXJ2ycY8pPHSq4G7OYzc=; b=xpolX4xMjlvuWS7h5ohjgtQJ41gpJOMkpJFz286VnRk4dwvbzdBkJpGNP5J8M50dpwvO3P615U9AYucc2QSAPeIOUzVXevuvRBnriH4YnTqp9wS6vBbHV2fwg+eVEBlQhq851Cfcl8I6K04wVk4ICjSoF5Zyj1bKa3tNxqsb3iA= Received: from CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) by LV3PR10MB8105.namprd10.prod.outlook.com (2603:10b6:408:28d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 15:08:20 +0000 Received: from CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2]) by CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2%3]) with mapi id 15.20.7918.012; Tue, 3 Sep 2024 15:08:19 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, John Garry Subject: [PATCH RFC 3/4] block: Support atomic writes limits for stacked devices Date: Tue, 3 Sep 2024 15:07:47 +0000 Message-Id: <20240903150748.2179966-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240903150748.2179966-1-john.g.garry@oracle.com> References: <20240903150748.2179966-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR07CA0041.namprd07.prod.outlook.com (2603:10b6:a03:60::18) To CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4312:EE_|LV3PR10MB8105:EE_ X-MS-Office365-Filtering-Correlation-Id: f74425ae-e542-419a-db15-08dccc2a3ee9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: 8UFYnnL9WoP6k/4XgN5b117vizrpy+KlYoOOJq3gTKlcX79mfj17bU3wSzxLX5ZRGjBaXhR2Muz3kMmgHJJZ+X98eQCw3hs11vmDG5UdpmGivkoIiMsOhQOrHUxFSAdXEpAG6Lz/W+A44eM1JBv/70KOryiRM6dl0p4v/6MKNPoVz8CO5Bv8zyljtkknAtnnpilGBrmzfi2Zi1eqU71LxrUbzn8Xse1Pve4Cgt0Sl36C4wy+YoxCaUZJHPlCogL4/I1LaNtASLKXWVDqwtP/HoDfXX7ZJullWQ0bnOdRJ0p+NtBZLrTfJ48ikI03Hxqwa20WYXwPxzBcd4xdlcxLSBOIieKiJz/FmWwlmS77Fr66P6a609TLljIlk7lBez4mTtcSrpNknYBznmvBEhTxZW3Im3BxecQWIXtsgDLrAPo8ZvaPwvmCgUeYdXuXBBRx9963I8YIOjRt2Cp8PxIpQBGexqtz4TOugSZaRU6zuUG3vbrLI6Texktp90e+HcU+VU7fb255M7dvSo52aT9OdWAP2LdOJnEd/AdCuPp4izywN/uNWjBJEvMbDPMHBlX2pYZk44tZqloaOB7dYTfpRAumSmYSagoQPTYvs1x/apqN9+ck/nDMhL2LzNgxJRJvsux5qdlDihbq03eCp9PbpMnSNEZ70hdECU3WXRhNRl07+cCh3fwe9zRiEc6Wb6LzfpkSqg9c5AqYfOAK3mAmzOY4wYCYA8BkPd9imTw3yRMA9S4nX70ptj4vADzWUQE3z0/ggUBf17qiGsEwv+NjIoVAhU945pgLQWRPPiTWFHPJo7t+D9miYMrvJ15XzELlDLE0x2HVqB6vrz8Y5Evl2RzfD4f9nJKZnmi34ie4ZUZkitO4ioWAYwzSYcz62w4oTrKLAM7l16kakJwHqkyr4Hwc3JD3+c9gVx+NUpdBBLMWFEGm+8oDBNy0l8lFXVlK1JfOuWUpP0RDMdPBotoJXE3oyTWHsc2KpwODhxZ+e7gremFioNEFIM1bkMh7j5wNl0f8B6LwLCgbBXsdzphUqd83r2CvINguENp9er0l+ecgzSfKBwxoFooOAzd9fqU/3NGzdaubmV6FM6s9o50j5bi2m6Ro/qqUP0ZjZheA2scd2iBXq28OJwjTESqStvOvfvFlW5IIcSjWAa4b7icZVzBQBk47gTqcvAHsPHm+RXFuotBpqxx4piO+5sbka60bYBcJ0tt1h5P5eW6gVgseu+UPKgFG0GHTizUX2Ok9H2vpHwoR8Y4INpxHNc6QzL8vJIE6pzlleRbiQj7PTVuhxzNUFN3GZ/7xbUIFd/FyITL7DS+J4hLdK1nRT+DITu5Gc7DIHXvF+bDjch6p3uRDkQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4312.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Xas9A3mMikl4H8DSfFePhIDu9v870wcKmAYjpkfkTHs+rUwbVPjGDqg+XBTNLcQ3Bh6BEPGkp/NDnXV7zJ0/nm2+cF36raFLhjmaYQntrs7I7iOuNpotMDgfI6m6VUmGr2dKB0btyaPBiWVwYfV+0JoDZY8qttHRwuz0hEiqS8mjNc1XBI4tj3vjUvVZ/8Sj5vONJ75KKNF8EmvrAr8eLbCp2I4SXspmAJiHSw0WVn+yUBbGQkN7pDSc3ZDmhVHZRu33pQjfbEfz1Fl8AEaPibICxDjWdBkCxOOVEvW9pjj5bokFmmROjvlr5VwF5uPG6lxDaVmZSflfW48zAMEyJ0SCq85xLKBC3G21TBmMMMRaCe0Br4ldG/xjdoDLo3r5PVfGHCOzETdyfTrxNOLxV+x6sQGE9irGc7t5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LqvwV9YhodBVGxwRh1e17vLXsDFL1LFKGqV9eVN6Ildu6CnkqtM0SbwzTLTPPOSBfRTj+lIRvQQn6ltMzBfGx3SBn09qZFAOPYCyF6f/MxdGkFZXetA== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: k9MrlXidbbFZw3j6TmdKUM8uUvsUyLenmzC09qQS2wn55w0LaTix3OfYvT+ZvwQwWVCeEBrtr2sYTFwbfCtckelHoymqvpTadlmXUhI1B4TtvuvbUta/fafCd/G6ufJpIxAP9PEJ2UQk+sE49kV68LGZpbAEJbscag9lDkcFy7rhyj30R4SzvVquaXQJZhPzhHdrp8f91CoK+q35J9jK3hfUrSqsCW6xWeTjR6vMJBjGlmCpfyHcEhp0JNwPxLZ4xAeFGo/K6hIB/lb2wNAlKRWvFvkvDXIxT57E05+H6uKokfz5d5/EzzBuOj0beFZz6xV/aoTslFHbK44d4R8nikn0FCuid+JhEWY8o0IBbOeZElz+T3taYv2gO/9U2KGsLkC8+hfAfsj/KVztvOBDZzoE01KS86xAkmUKN4rf1LJodpBGPWkAnSrhssWsOsiwAENQbWdZSFYc5sLwFXW1fKlDNLdrfVo/LVzPzZKvpqlMl6sDNabMulIIHL6Ru6Vy2If9kHWa75p/ec39MQdEIXb2WIlcot1+MUXi70Z6i2fPho2prOPRZGxDAfNB3qLrZSLptRDtRnfj5BkTRppsx1/bdgAVh0b/LU+bdG4Aj+E= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f74425ae-e542-419a-db15-08dccc2a3ee9 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4312.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 15:08:19.7447 (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: iRngSbvGmMtlyUNmpYmameulWTd7L2MV516ZTTdDTfobunVDf8QVq0EdGM6WdwzRGeYNcVkYyZtRLG+8xnZ/eA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8105 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_02,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030123 X-Proofpoint-ORIG-GUID: 4XdEdjXOtHF4mzndPd_i1fLKFeFpP2G- X-Proofpoint-GUID: 4XdEdjXOtHF4mzndPd_i1fLKFeFpP2G- Allow stacked devices to support atomic writes by aggregating the minimum capacility of all bottom devices. If a bottom device does not support atomic writes, then BLK_FEAT_ATOMIC_WRITES should be cleared for that device, and the top device then will also not support atomic writes. Signed-off-by: John Garry --- block/blk-settings.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/block/blk-settings.c b/block/blk-settings.c index 036e67f73116..aeb05fb24801 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -682,6 +682,25 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, t->zone_write_granularity = 0; t->max_zone_append_sectors = 0; } + if (!(b->features & BLK_FEAT_ATOMIC_WRITES)) { + 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; + } else if (t->features & BLK_FEAT_ATOMIC_WRITES) { + t->atomic_write_hw_max = min_not_zero(t->atomic_write_hw_max, + b->atomic_write_hw_max); + t->atomic_write_boundary_sectors = + min_not_zero(t->atomic_write_boundary_sectors, + b->atomic_write_boundary_sectors); + 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_not_zero(t->atomic_write_hw_unit_max, + b->atomic_write_hw_unit_max); + } + return ret; } EXPORT_SYMBOL(blk_stack_limits); From patchwork Tue Sep 3 15:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 825852 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 3298417BED2; Tue, 3 Sep 2024 15:08:44 +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=1725376129; cv=fail; b=JfsHoDgU14O2SVDKdaSjN3qYskUTsf87ERplSyo9Nr5PEwFtwpolRf3qlPMiCxIRoVCNf70AWYw7Jqi+iLLA/mB5yWeJ5iNzWpP3dOdUDlREimHmelQdHYfF0FZQsFEEuXLI4+K53uFq4Kdnl+tW2ICgbm0wYxo2KNsScXrQ8fw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725376129; c=relaxed/simple; bh=5d6UTCo/dvSVqS4AveHWhT5Y6r/yF3GCRdEl2EADCNo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=C0FTJV1EyozhKwmd4Vc5u3ExqeR28xlSM8/y8wpwbbzKYF7MxEr69pyrc8LpjfAPzangvn4VECR74oLHzMG6Hi/tQ5G4YcsDXEw760anOUwZGsCGJvQgeeL/qbLxsTABM+3StITG7Hk/FagKC0czfZxm6vGgdG7R5lhydX1/DZ4= 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=jeVEOEpa; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=t3EOAnxO; 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="jeVEOEpa"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="t3EOAnxO" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 483EpnXP019409; Tue, 3 Sep 2024 15:08:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :content-transfer-encoding:content-type:mime-version; s= corp-2023-11-20; bh=UthwDzQOFA6BxryT3tx6Ii3mvuOVPfZECAaSlktlY94=; b= jeVEOEpaNPD5vYnp5phJ1aOJenBTyWmlmIWZcvnMC1jSlBqHrOHDAF2HjDIaeu5P qnQQZ9nFV+Yi9yzH4oU1Nyu7m1srUK2LJJANLsbAfgWnv7OU7RgTExpIIbs5cMkA r8QC6VlcjWdAvJfgfM1nUgTdq+BnTdHX2/BPF1Zjv7f0uy1L8X4ixpschwsUSFbN IwqxmBXYKVsHYwCm3qT2Mdr3ApjzM9WqInR5UvFUokW2OqH3bt0vsUq/EM953r9R lZYIX3KqPZGS89bbYXOQh9tEtgEHcu7ogqKyyWXMVNxGCgg3TjK1xVZ7/mnpxung TzJATY4xyLC6YEE467M/Eg== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 41dvsa95wv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:25 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 483Esjlu032636; Tue, 3 Sep 2024 15:08:24 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2101.outbound.protection.outlook.com [104.47.58.101]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 41bsm9151j-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Sep 2024 15:08:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LY+mMCePdF/4EuxjEQvC5NmsjiG203UD8Tr5V+OsEc8HGxuD10Bre8MYR6CgMO3+rpbLuQSOKH1RIvTSo6ei3eXpSyjICTb9bUJzHTkImXd3iu4lmNVUZiCHe1EEpjjIhL7y7O/x4eY6rRVZ9e+3mHpycWmEb7tDaGLaCyTOoDCNx1He65lKEwU5wyV5NB90RVyFZVxBLtcI59sGiCZ7edagQBcGqjM3SG60IsLwerGA1ZOh3YPmHcNw/p0rDFhvPwMh+wz/hiwhTK4FHn2P7F06ypSa3oq7SFEOAPFTbDd6LfhcCJwXxMWSAMngUVn1OOdgXDMig3viM/y1CSlvkg== 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=UthwDzQOFA6BxryT3tx6Ii3mvuOVPfZECAaSlktlY94=; b=bakqoTKzXB8hdPlVS1tRq3uTieb7dSSSMwzfMyMVFZ67JQyWInSykpeRWDRVQE5maANp7B8pgaZZYiBy+dLHTUB1th/DJ43rht03EuUsnOWQR89/zKDSsy6fYyhoYUpth6450zL9Ximxbfz492Pju82IS4QD0uIwr520CYEN6tMQPM3+nAIUOiBaVwlHqF38XDbwy1hXGKNy3fG9ZnxGl/XzWYoSKaF4JJULZRNW/fLjdLaaIgBDt4Z+lf8vD3fi4tkoRO+qInznoMQ5P33XYLgV8AZUjLtlxRhN27jfYqDZiq5sfe4PQJvFfrd0+guFcLXrPECdogB8DJsD19opJQ== 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=UthwDzQOFA6BxryT3tx6Ii3mvuOVPfZECAaSlktlY94=; b=t3EOAnxOXxY1wWvj0ZXmi42eBcw/wNKyJMJTeLPlOeGOHbG9jgB4sNaALXl7HMWi999SzpxlFSBFLOM/SDhVUU3AvG/WPJbxkjw3ij8BH9gkkVye4qzqGXQAMMrXaVaMpOSadaH/cQC13sOzR3P2eQpDKMFzbAEFPaGVGCoDXzg= Received: from CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) by LV3PR10MB8105.namprd10.prod.outlook.com (2603:10b6:408:28d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7918.24; Tue, 3 Sep 2024 15:08:22 +0000 Received: from CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2]) by CH2PR10MB4312.namprd10.prod.outlook.com ([fe80::fd5e:682a:f1ac:d0a2%3]) with mapi id 15.20.7918.012; Tue, 3 Sep 2024 15:08:22 +0000 From: John Garry To: axboe@kernel.dk, song@kernel.org, yukuai3@huawei.com, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, James.Bottomley@HansenPartnership.com, martin.petersen@oracle.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, linux-nvme@lists.infradead.org, linux-scsi@vger.kernel.org, John Garry Subject: [PATCH RFC 4/4] md/raid0: Atomic write support Date: Tue, 3 Sep 2024 15:07:48 +0000 Message-Id: <20240903150748.2179966-5-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240903150748.2179966-1-john.g.garry@oracle.com> References: <20240903150748.2179966-1-john.g.garry@oracle.com> X-ClientProxiedBy: BYAPR06CA0071.namprd06.prod.outlook.com (2603:10b6:a03:14b::48) To CH2PR10MB4312.namprd10.prod.outlook.com (2603:10b6:610:7b::9) Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4312:EE_|LV3PR10MB8105:EE_ X-MS-Office365-Filtering-Correlation-Id: 25b12fa5-5c30-4bb0-87b1-08dccc2a4051 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014; X-Microsoft-Antispam-Message-Info: T7XG+GTQdtv3aLUXKCotubq0FHpKjftdir2myHwraHua0aw6YY9lb5EYeFt9wCBueuf9MPlCXKTnxIA4g2Gk6tSSHMsPW3ajm1m46E0atsEdy8Tb6gDwnFv7zw0gCzT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mrK+TAoxCzGyJFnilkH+43b0+3SntoNeNlplUNI0jwTP1MkuznhDmb56PoMiUSPvXof2JQ/X5r7TDztEVgcQchgCqDCCczRoBxv6/2lSLYtBByMPZ4zK8w/GCPxb2iQBG2dzvMEWY811ZcTC7A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH2PR10MB4312.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(7416014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TgvlS3KeerPbTUCidZNG6jI837+7rPBXhGfbBmvp4LP+SzD8DHCmBvTe8SJtISAnvftJbmPrzkqmku+nvd4JS5Sew7rFU6UZHd6DDxJKpe+3K9M6LMMbBU3UCG4zQNpFS6PaW+dafW1wgXApY6EBRJdGesgerTun4hc6I9Gt/olk+bOAt4CEPYZU8uemOQBgLYZCpFu1p/i1mgQj+lSz3RSC3tPQqfsuDmRBqAm+ISgp4OiC8OtFvtfxjPNQVoPNNmVzv6l/kEU1CMxCFzF+mxfwYFhfrTeq4wVzUW/UhLy5zqoItUnGfreuwGm4TXelcee53f/5Mgm5pu6Y2r1mrypkHRMjKupXvq+QedQKZv9FH0Ka2yMCaABkuBHozgZXnwL2HyUkhLjXjM7m/C9hivYx62O6jHAie/n4QZ1eExelfZJ87qg1Bzc/3Ae63UNBKXwMLW7lC8LPS2OZrBD1yK+0RrrcqE1FLXJNb8EOAoirA2yF18XVvgTD47Aimir0vJ94LuMdxAnYVRrWE1ohv/na26a6HH0/VBIdBBs+ztYpGi5Uk/j9FzIumg7I9J3QsVmi1QtM5ktSAwPVdwuomYcnWiaY100g0251ehf+JQSUsqSvd9oyo81sWQ/qU/ZFGZsTyR29BTKQQolo3pmLJ5cspo6VnHBxHWFwNkDwI9UF0xsIdQw2II1/3nqqcKOvUb6zygkIBdb5LCh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d7ijT4m41xfcYPq6jQ5ElqPWNfpafZkqDIH78uEt+U44ogbs4nWuuNzQhlZo348OTUS1euputLRJu+os7PmMcXr0SvrXFJUeItr7nFqohPsn652J/lOlQZN0tQi0n3drDMYpOJJVMXCOgSnuT4tCdaWAaiJpYc1bBtjO577OlJ5V29aBnKY0J6abecV2K8oZYHta4F+Ne1tUW9GaYByp2MKclTrJ72Xo39apgWkqa0FYyvm6Xg0AhN642kY1/yg3BIiiTQXBJGnAXaweW7ijaRQWEGSzYns88+NIjx+L0HiXWAwDaUzqB8QDKTMGDnfm5FmqdbhkGaK0K/Y0s6Uvh3vUxxwzngtuRAmFK/D6rSUpjvE19yO3ebyha2mV3L+caSqwrPLxoyX6MOYWVZ1bgeuFJiPIkIiEfGRy7Jp+KYYhOqjbNKk/t33w/LFjASQWmmJYaf1kIIEx3uxhqSK+Z+Uun6umXTa2g2Jp9SYKkJAOmClrcdU5oaNxNsj5QSWCpsIQjoYbY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25b12fa5-5c30-4bb0-87b1-08dccc2a4051 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4312.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Sep 2024 15:08:22.0988 (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: 1UfzozSGpOiygNytKphox7MIAbFXH/3NZEkteN8RzR76/88m4bQyIcoXZ/Hxu4aAYY9UA5Qszu2JHpucrVmc4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR10MB8105 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-03_02,2024-09-03_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 malwarescore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2407110000 definitions=main-2409030123 X-Proofpoint-ORIG-GUID: WHvyJUqQe7xwEPyJl5VpSJFxvOdLg2Hm X-Proofpoint-GUID: WHvyJUqQe7xwEPyJl5VpSJFxvOdLg2Hm Set BLK_FEAT_ATOMIC_WRITES 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. Atomic requests may not be split, so error an attempt to do so. It is noted that returning false from .make_request CB results in bio_io_error() being called for the bio, which results in BLK_STS_IOERR. This is not suitable for atomic writes, as BLK_STS_INVAL should be returned. Signed-off-by: John Garry --- drivers/md/raid0.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 32d587524778..caf1ecb55d11 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; err = mddev_stack_rdev_limits(mddev, &lim, MDDEV_STACK_INTEGRITY); if (err) { queue_limits_cancel_update(mddev->gendisk->queue); @@ -606,7 +607,12 @@ static bool raid0_make_request(struct mddev *mddev, struct bio *bio) : sector_div(sector, chunk_sects)); if (sectors < bio_sectors(bio)) { - struct bio *split = bio_split(bio, sectors, GFP_NOIO, + struct bio *split; + + if (bio->bi_opf & REQ_ATOMIC) + return false; + + split = bio_split(bio, sectors, GFP_NOIO, &mddev->bio_set); bio_chain(split, bio); raid0_map_submit_bio(mddev, bio);