From patchwork Fri Feb 2 21:00:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 196036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp704052dyc; Fri, 2 Feb 2024 13:17:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQeeOs+CoiX5bbL3Nun0n1E+49mK/crCIbYmfEjsXxFp6Pe6Ce3ZAtuvNptgiUvGrGGj4u X-Received: by 2002:a17:90a:bc81:b0:295:fbbc:6daa with SMTP id x1-20020a17090abc8100b00295fbbc6daamr3420258pjr.19.1706908666810; Fri, 02 Feb 2024 13:17:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706908666; cv=pass; d=google.com; s=arc-20160816; b=DM8j3iRQxxvG3qa3mdxw7tw5TnUmpBxtQ54VZBgwRBYoQq+AKmYmBF8sIz4dorfWMS Y+JOZRyYEjpVe/Si3w7gUmy2oT8sN4qd0+yzZNCeNC7cQN0+9XBC9QYQsd7+Y5FURmA6 E+iTFQfY+wUH7SmTMtLiqJnNkgc3kSXe8WKwn7+7w4Ri0Cm69KrD5pTfjo66etJzb1LE PyifJ2aSzmiys0/cknhCBdz9vJajrmH6Riv1GGo7GbtMnP1pwTWUTmV/9tda5u/PiZn+ luzjb6Kfb+W2Cpt4x0EXYlqmrytur9I2VCDt0XMzERBDMI5y1deJ8uXeMMsoLZ1ezMxF xB1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=980dRtjhZ1sqASItbAJHswL4sSjsBCZ26JEnu08+RSE=; fh=79UYZkrPPID8ZNTbJBFHTT8oQDu9G21mRf2SbQfc2Yw=; b=sdaAr9kuirBz6AIFqNJaBT5k3h3WcLwhXjf8vBDnaNjPm+knoP8WilcggTsWjRM5kQ 2Fu+hIGRv7qH40wyl0aO4Ewz6+ZVoeOlTwvoBWieiSaPsEPYbDv5f9c4J/DlvpIQjCUc JAjf/0F1C2LQpCRiIuMiCTa1IhTetZv3TeXVIf/OigjjjlqAXm3VW1A/NwuhZ3h34Nri CU7bftyOxMydvyl5tuh5htJSKvx6e/lO/Pn3FTVXRb4133oj479ObxMaaJRcUn1anhgf u74Y19cHdIy/LOKB+1+dYsEkycEVj0IxD0lkgCvKRLtwG7OYrpCHAyV/APzZdHEvgp/T KR+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=SfD+9FBO; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-50574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50574-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com X-Forwarded-Encrypted: i=1; AJvYcCXsXm84kkdx2bOhEE0ovazprHPhqBTQ0Oe6MWx3rthGQSe7cY33Omb3DP4MLFQhbgE9R0CoTpoUts/K9iRqq9lQnZXfyg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w10-20020a17090aad4a00b00296426bc1a3si477980pjv.168.2024.02.02.13.17.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 13:17:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=SfD+9FBO; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-50574-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50574-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2F000B2685F for ; Fri, 2 Feb 2024 21:06:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5037136984; Fri, 2 Feb 2024 21:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="SfD+9FBO" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (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 A6C7081748; Fri, 2 Feb 2024 21:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706907631; cv=none; b=AdeRIdg022I5A1hFI3SlfG+qCwVMMzqJZBlD1a4bGF5XXkyXWS6ZmqUwime8eyyYUsV1uynPGTMgf0XSnbvWDXrx/LI0aXQXM0CVGvNMVmKcvAKFxmbXKG2TX9pybnAVUl6eoAw+l1y0kioxIF7Faq9RJfLNWrp5x6AOUU3dNxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706907631; c=relaxed/simple; bh=NdQ4OmFkV2+G2H8B4VkXTCxDeM+TIHeVIiPEQVlM7R8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jMWVzwu53yHgHWMSkZ5Ug8v4GT7ph7AtRbe+lUB4TU/3+7f4KdGGZyn2dkeyo3/vKw/TN9IIJLf8QJsmwbqreE8Sm1y8P+q+zBA+/Rrb6OkBzbLHtxXIkE9RKHBPBBATpwWVXwXIG+CMKvnZ7MJCk0M1abWvw/TN28iNIBeSOuw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=SfD+9FBO; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1706907627; bh=NdQ4OmFkV2+G2H8B4VkXTCxDeM+TIHeVIiPEQVlM7R8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SfD+9FBODsvL9YxlK1eefFmH2Hjg5R7Nm2c0c/fiMmV+KMkEfMgn8fwXWEqe567tr hitR0HdbXa8MBPzXdEQAfPlMmOwmhspx1tBJIONQneKlE9TwWJmkzfjXVdmBRroRoc tjILNBX/OBLmXaCizqF3wbdgWKaqsoQBmA0IBcR2qmBOEZHO6sI+lwpuXk3mpdXWn1 0wFeI3QK26ekNegrAv+Homtya3de6AuOl2OXBg83Pb+HUc1wnEG95Aq+dFPABMDzZX A4jobyF0SFA0vRkB0HcB8gGIiRsGKsSNiGhvGEQux2MIPMvpIBgiM+92vhzg7Pf3gh OJnjmBEQikO1Q== Received: from thinkos.internal.efficios.com (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TRSpg3hSPzX4Q; Fri, 2 Feb 2024 16:00:27 -0500 (EST) From: Mathieu Desnoyers To: Dan Williams , Arnd Bergmann , Dave Chinner Cc: linux-kernel@vger.kernel.org, Mathieu Desnoyers , Andrew Morton , Linus Torvalds , Vishal Verma , Dave Jiang , Matthew Wilcox , Russell King , linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-xfs@vger.kernel.org, dm-devel@lists.linux.dev, nvdimm@lists.linux.dev, linux-s390@vger.kernel.org, Alasdair Kergon , Mike Snitzer , Mikulas Patocka Subject: [RFC PATCH v4 02/12] nvdimm/pmem: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Fri, 2 Feb 2024 16:00:09 -0500 Message-Id: <20240202210019.88022-3-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240202210019.88022-1-mathieu.desnoyers@efficios.com> References: <20240202210019.88022-1-mathieu.desnoyers@efficios.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789823461889455270 X-GMAIL-MSGID: 1789823461889455270 In preparation for checking whether the architecture has data cache aliasing within alloc_dax(), modify the error handling of nvdimm/pmem pmem_attach_disk() to treat alloc_dax() -EOPNOTSUPP failure as non-fatal. For the transition, consider that alloc_dax() returning NULL is the same as returning -EOPNOTSUPP. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Cc: Alasdair Kergon Cc: Mike Snitzer Cc: Mikulas Patocka Cc: Andrew Morton Cc: Linus Torvalds Cc: Dan Williams Cc: Vishal Verma Cc: Dave Jiang Cc: Matthew Wilcox Cc: Arnd Bergmann Cc: Russell King Cc: linux-arch@vger.kernel.org Cc: linux-cxl@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-xfs@vger.kernel.org Cc: dm-devel@lists.linux.dev Cc: nvdimm@lists.linux.dev --- drivers/nvdimm/pmem.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9fe358090720..f1d9f5c6dbac 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -558,19 +558,21 @@ static int pmem_attach_disk(struct device *dev, disk->bb = &pmem->bb; dax_dev = alloc_dax(pmem, &pmem_dax_ops); - if (IS_ERR(dax_dev)) { - rc = PTR_ERR(dax_dev); - goto out; + if (IS_ERR_OR_NULL(dax_dev)) { + rc = IS_ERR(dax_dev) ? PTR_ERR(dax_dev) : -EOPNOTSUPP; + if (rc != -EOPNOTSUPP) + goto out; + } else { + set_dax_nocache(dax_dev); + set_dax_nomc(dax_dev); + if (is_nvdimm_sync(nd_region)) + set_dax_synchronous(dax_dev); + pmem->dax_dev = dax_dev; + rc = dax_add_host(dax_dev, disk); + if (rc) + goto out_cleanup_dax; + dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); } - set_dax_nocache(dax_dev); - set_dax_nomc(dax_dev); - if (is_nvdimm_sync(nd_region)) - set_dax_synchronous(dax_dev); - pmem->dax_dev = dax_dev; - rc = dax_add_host(dax_dev, disk); - if (rc) - goto out_cleanup_dax; - dax_write_cache(dax_dev, nvdimm_has_cache(nd_region)); rc = device_add_disk(dev, disk, pmem_attribute_groups); if (rc) goto out_remove_host;