From patchwork Thu Jun 20 12:53:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13705389 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 75AB41B14FD; Thu, 20 Jun 2024 12:56:19 +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=1718888181; cv=fail; b=kBhJT+qoGEM/Q6HabJFTt2XgY8wgnVBspjBM2fQve8kS5x12DGa+kBm6ECujzFW39NoGcDuNG0hZbNyk+srORLhhx7aWzbYBSRKhvGgFVnj1TbgM0zUsiSXmjwW9sxRALgLIUkAkIEdKVI5ooYVj78uu1t3J0nU9NTXNLZR1HGw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718888181; c=relaxed/simple; bh=lqISxX5YEW/WeNeJDQSw1eC99xDJXb80NYGmqhZ9p5c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=iQ2dorIELyZYAbQ0N/i4vF8kW0AdSjyC2R1eu6aEGoWdIA0Tc0VS/x2E9Az9ym2jtSiHchoSrKZNqQ3NCEYCGVVLfYdnXcAQ6kQW8L7dW69AE5vCpseBGDeVfyGalz+18RMoCyhwapYQFmWm5nz7AAV2K5jV9tSiPNnn7PD11Z4= 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=e1AbHarY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=zEgXscnz; 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="e1AbHarY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="zEgXscnz" 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 45K5Fik1002321; Thu, 20 Jun 2024 12:54:43 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-type:content-transfer-encoding:mime-version; s= corp-2023-11-20; bh=CeXcO95RprRpKSW+3sToKcTkGBFVJhtusSrxlskOoZE=; b= e1AbHarY76DbR5zemdvNUoFUU5D6HTCfPdO+bmvWmMZUZIOEhtrcXlt0IFC0Qb6X wfthagKmN61ibUbTk6csgbz4LhHEfqfyPGazysoK+MVJgzL6uMsrYN4NrlezUkmv sY0z84Jzn0Tn9dIXOeb6OZ6s1HPrQ6qG/K7eoUTl74wqSVplxRWOx59pfPbMlS3W KO7OcdraihYD92EVsFIirtfGu//DwzCY2w4mHeoCPYHyM0rrmlBo2LkjLFip6oPR zh6iD6W1pumGzGxe9BZ/Y7wbEAn6YAHMZ+Q7BUqABSdXInsGCD3n0WvSgoqwq9r1 BxoZLHCxHRfgG24YDoq3tw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3yuj9r34ha-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jun 2024 12:54:42 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 45KC7uti032824; Thu, 20 Jun 2024 12:54:42 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam02lp2040.outbound.protection.outlook.com [104.47.56.40]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3ys1dae6nh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Jun 2024 12:54:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kku7jG3OpQ5oBSCk8mS2PI4gdLOJfdEayGL5F4ti+3BWGfZEETl7K4k/ay2jWnBinC5iOzafc90JMW3gBP5Z+CfgAqJf7UiJoI+sOt8TVhw5lk52ZnktVoZ1yoV1SXO2Ir2nOWRMOujw5POtbNEWwyEKJvZF2wTgJsVesNay2YmoyifKZ21CzUk1A84axwVN1S0xeKC1LrcPv5cr1cOgVbi3eYUYmBF3FUpSXisAIK1g4lhQeLZcaLVew80tgTLsBSVZyT59fmRXAcyrpYjDR0mDkH9nDu0ulOjtNzMwtHlcpcTpwiB3/Ol1rVr6jHiMiTEZ8umt6BF45/8vi1tsSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=CeXcO95RprRpKSW+3sToKcTkGBFVJhtusSrxlskOoZE=; b=B37tuutpy+kBlWIOEsXEwYxEzXDh9Ck5U0UOJz6Ts75LRQnTxM3vuZ0oPnrA8g/7qcVPAlYgUYycQHUb6PCN8IHVk3QfaqfDtsxaBJMwlzVpUKspPSDXpB6dMIM6dz4yO743Tmzi0N9PliSg7ChsMTeg10Z5mXQKpDO8UyKHCl3qMbvELZ35FL+kmf/Aqt/wQVIzqNtKLf03wqyf7RJYxSvhYzi0laVkzVaUk4uhZR4lCG07CDHC1rGF/j7lZJ3QCTKfktKlYstxaJ7iQpcs1/bUsYaZepUTLx2Q9WXY4yD26vRhuZYD5vU9TbxOjPhzmh3fhfyqOvHi4gWbD7AENQ== 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=CeXcO95RprRpKSW+3sToKcTkGBFVJhtusSrxlskOoZE=; b=zEgXscnz0krTwBbSznqUSL14IjNs1VKsIxMGdqcuJTC1DnQLQwsVKzr2pBLWyjPQg3G8U7wsTo/WEoLUgo/CdZtz6PfZxXDRRJ9cvftrzbXM90/Pp4K00g18ul06KiSzkEaLgfZKuv+k5bv2ARtRzJgtrwopjKyOiUX97blb5AE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by PH7PR10MB7695.namprd10.prod.outlook.com (2603:10b6:510:2e5::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.31; Thu, 20 Jun 2024 12:54:39 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%6]) with mapi id 15.20.7698.020; Thu, 20 Jun 2024 12:54:39 +0000 From: John Garry To: axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz Cc: djwong@kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, linux-scsi@vger.kernel.org, ojaswin@linux.ibm.com, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, io-uring@vger.kernel.org, nilay@linux.ibm.com, ritesh.list@gmail.com, willy@infradead.org, agk@redhat.com, snitzer@kernel.org, mpatocka@redhat.com, dm-devel@lists.linux.dev, hare@suse.de, Alan Adamson , John Garry Subject: [Patch v9 10/10] nvme: Atomic write support Date: Thu, 20 Jun 2024 12:53:59 +0000 Message-Id: <20240620125359.2684798-11-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20240620125359.2684798-1-john.g.garry@oracle.com> References: <20240620125359.2684798-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0303.namprd13.prod.outlook.com (2603:10b6:208:2c1::8) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|PH7PR10MB7695:EE_ X-MS-Office365-Filtering-Correlation-Id: 6cba38a3-da64-4c9b-ff1b-08dc91282529 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230037|376011|7416011|1800799021|366013|921017; X-Microsoft-Antispam-Message-Info: =?utf-8?q?YrZhW+2Q5OZBU4/1akC3F41E5r1pg4V?= =?utf-8?q?DtRP4PQmj9V0Z2R974hZD/5iCV4aYkEPtiFeCKHClS4/YYXmVQpFBtI5azBWoM3e8?= =?utf-8?q?VeXq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FXYR02St7BZturIwYLBtT9/7kif8KQGZADFswylNmL9VShvoRCPK?= =?utf-8?q?dd94HbCUiQHJYixZggWM427pQ1EOPzTSdmosPYpM27C9/BqG9Srrk5Er3VDA7Td+N?= =?utf-8?q?GozZ6t0pXElNmRZQe7A70UKfZEmWrzc5xFRIzHxg5A8pXERwHK4SY49IkAZ7Mh1UB?= =?utf-8?q?0oKMhniBcTyiuqxTKqB+fBvt4vtAs/ohKvIgkjXKzitvIUFkhhK5JLNVusOw/m20p?= =?utf-8?q?niVm+VJ1YM6hz9896b48cSVgth8ldIEWtjLXt24GdbA75TAVEa0VS+xfe8/Qj75x4?= =?utf-8?q?PXsNlSOqozCg9kP0VlGqWVIXB9W3NnPko02K3IKQa0sqBW1TTBWEJxX0=3D?= 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:(13230037)(376011)(7416011)(1800799021)(366013)(921017);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?xCwqRs30ucm4tUcKh6zJcQfPQHnZ?= =?utf-8?q?2R4kyNnYlpgTu56IDXudBPY1rXQtS1EW/QEur4v+gnV9erUy+kFe0cfD8kNXXi/By?= =?utf-8?q?68unK4tCG2hXh/pMXwaNFAXShsX5b4okeBI1u6h3tomP1mOgcuSChENGFseB5ztfl?= =?utf-8?q?84bIZOUSHMOvqOn4jlrttk5TqhUSQbV34YsRcYB7czTCaKOhJ5d5H65+4c9NU1rau?= =?utf-8?q?41zAYr4Delb7PFZOLq+9XDq53OfJkKJXEcaGKG5hukySxE/ldl2qbrYVNxJR6Yg4+?= =?utf-8?q?FAmkOQlLgHkMlDUVUZWu9xVBb7BcEICRjGQ4bHwQ0f4epGRlIUb+Ns1okW+Ser32b?= =?utf-8?q?MTPYG8qtN+X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FCDXEFUW7eOzmQ/Jt+JzxOhJQV5AtESYlpUITbk= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cba38a3-da64-4c9b-ff1b-08dc91282529 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Jun 2024 12:54:39.0004 (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: ThZraPXp9QLH9lUzfTz2C+sMxdaVhZcZ/Q9+wFsdXCVpDw/n7bkfa1SE0MVC4Aouo5iBwtVkMedvNpRB5fxA7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB7695 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-06-20_07,2024-06-20_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 suspectscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2405010000 definitions=main-2406200092 X-Proofpoint-GUID: mNS_5icj699YxJY16q4thhmq4cZy4-aS X-Proofpoint-ORIG-GUID: mNS_5icj699YxJY16q4thhmq4cZy4-aS From: Alan Adamson Add support to set block layer request_queue atomic write limits. The limits will be derived from either the namespace or controller atomic parameters. NVMe atomic-related parameters are grouped into "normal" and "power-fail" (or PF) class of parameter. For atomic write support, only PF parameters are of interest. The "normal" parameters are concerned with racing reads and writes (which also applies to PF). See NVM Command Set Specification Revision 1.0d section 2.1.4 for reference. Whether to use per namespace or controller atomic parameters is decided by NSFEAT bit 1 - see Figure 97: Identify – Identify Namespace Data Structure, NVM Command Set. NVMe namespaces may define an atomic boundary, whereby no atomic guarantees are provided for a write which straddles this per-lba space boundary. The block layer merging policy is such that no merges may occur in which the resultant request would straddle such a boundary. Unlike SCSI, NVMe specifies no granularity or alignment rules, apart from atomic boundary rule. In addition, again unlike SCSI, there is no dedicated atomic write command - a write which adheres to the atomic size limit and boundary is implicitly atomic. If NSFEAT bit 1 is set, the following parameters are of interest: - NAWUPF (Namespace Atomic Write Unit Power Fail) - NABSPF (Namespace Atomic Boundary Size Power Fail) - NABO (Namespace Atomic Boundary Offset) and we set request_queue limits as follows: - atomic_write_unit_max = rounddown_pow_of_two(NAWUPF) - atomic_write_max_bytes = NAWUPF - atomic_write_boundary = NABSPF If in the unlikely scenario that NABO is non-zero, then atomic writes will not be supported at all as dealing with this adds extra complexity. This policy may change in future. In all cases, atomic_write_unit_min is set to the logical block size. If NSFEAT bit 1 is unset, the following parameter is of interest: - AWUPF (Atomic Write Unit Power Fail) and we set request_queue limits as follows: - atomic_write_unit_max = rounddown_pow_of_two(AWUPF) - atomic_write_max_bytes = AWUPF - atomic_write_boundary = 0 A new function, nvme_valid_atomic_write(), is also called from submission path to verify that a request has been submitted to the driver will actually be executed atomically. As mentioned, there is no dedicated NVMe atomic write command (which may error for a command which exceeds the controller atomic write limits). Note on NABSPF: There seems to be some vagueness in the spec as to whether NABSPF applies for NSFEAT bit 1 being unset. Figure 97 does not explicitly mention NABSPF and how it is affected by bit 1. However Figure 4 does tell to check Figure 97 for info about per-namespace parameters, which NABSPF is, so it is implied. However currently nvme_update_disk_info() does check namespace parameter NABO regardless of this bit. Signed-off-by: Alan Adamson Reviewed-by: Keith Busch Reviewed-by: Martin K. Petersen jpg: total rewrite Signed-off-by: John Garry Reviewed-by: Keith Busch Reviewed-by: Hannes Reinecke Reviewed-by: Kanchan Joshi --- drivers/nvme/host/core.c | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index bf410d10b120..89ebfa89613e 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -927,6 +927,36 @@ static inline blk_status_t nvme_setup_write_zeroes(struct nvme_ns *ns, return BLK_STS_OK; } +/* + * NVMe does not support a dedicated command to issue an atomic write. A write + * which does adhere to the device atomic limits will silently be executed + * non-atomically. The request issuer should ensure that the write is within + * the queue atomic writes limits, but just validate this in case it is not. + */ +static bool nvme_valid_atomic_write(struct request *req) +{ + struct request_queue *q = req->q; + u32 boundary_bytes = queue_atomic_write_boundary_bytes(q); + + if (blk_rq_bytes(req) > queue_atomic_write_unit_max_bytes(q)) + return false; + + if (boundary_bytes) { + u64 mask = boundary_bytes - 1, imask = ~mask; + u64 start = blk_rq_pos(req) << SECTOR_SHIFT; + u64 end = start + blk_rq_bytes(req) - 1; + + /* If greater then must be crossing a boundary */ + if (blk_rq_bytes(req) > boundary_bytes) + return false; + + if ((start & imask) != (end & imask)) + return false; + } + + return true; +} + static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, struct request *req, struct nvme_command *cmnd, enum nvme_opcode op) @@ -942,6 +972,9 @@ static inline blk_status_t nvme_setup_rw(struct nvme_ns *ns, if (req->cmd_flags & REQ_RAHEAD) dsmgmt |= NVME_RW_DSM_FREQ_PREFETCH; + if (req->cmd_flags & REQ_ATOMIC && !nvme_valid_atomic_write(req)) + return BLK_STS_INVAL; + cmnd->rw.opcode = op; cmnd->rw.flags = 0; cmnd->rw.nsid = cpu_to_le32(ns->head->ns_id); @@ -1920,6 +1953,23 @@ static void nvme_configure_metadata(struct nvme_ctrl *ctrl, } } + +static void nvme_update_atomic_write_disk_info(struct nvme_ns *ns, + struct nvme_id_ns *id, struct queue_limits *lim, + u32 bs, u32 atomic_bs) +{ + unsigned int boundary = 0; + + if (id->nsfeat & NVME_NS_FEAT_ATOMICS && id->nawupf) { + if (le16_to_cpu(id->nabspf)) + boundary = (le16_to_cpu(id->nabspf) + 1) * bs; + } + lim->atomic_write_hw_max = atomic_bs; + 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); +} + static u32 nvme_max_drv_segments(struct nvme_ctrl *ctrl) { return ctrl->max_hw_sectors / (NVME_CTRL_PAGE_SIZE >> SECTOR_SHIFT) + 1; @@ -1966,6 +2016,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id, atomic_bs = (1 + le16_to_cpu(id->nawupf)) * bs; else atomic_bs = (1 + ns->ctrl->subsys->awupf) * bs; + + nvme_update_atomic_write_disk_info(ns, id, lim, bs, atomic_bs); } if (id->nsfeat & NVME_NS_FEAT_IO_OPT) {