From patchwork Thu Feb 15 14:46:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13558533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E073C48BC4 for ; Thu, 15 Feb 2024 14:46:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E3908D0019; Thu, 15 Feb 2024 09:46:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06AEC8D0014; Thu, 15 Feb 2024 09:46:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DFF128D0019; Thu, 15 Feb 2024 09:46:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CD7618D0014 for ; Thu, 15 Feb 2024 09:46:42 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8BE0D160A14 for ; Thu, 15 Feb 2024 14:46:42 +0000 (UTC) X-FDA: 81794314644.12.E4B0634 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf04.hostedemail.com (Postfix) with ESMTP id 0FAD440017 for ; Thu, 15 Feb 2024 14:46:40 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=BnQ8gALW; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf04.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708008401; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=B4ilFMr2eFF794YdWWw0DjFvkMffunaWzt7kSkCawqA=; b=tZoNjEIydGKRvVTfi6GJImaJiOLmbstiNl0RM3pHluvnaRov49arJbuPFowvQDPY21Bycb saMhdMSVncM72qbzIlZTLjgP8bDf/YqroPVsA5FjtMjxVZqo8KJ241O/oRXTj6qnGjF/zM rv93ajp9fma5Fxtka30JCtWUw2JXMAo= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=BnQ8gALW; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf04.hostedemail.com: domain of mathieu.desnoyers@efficios.com designates 167.114.26.122 as permitted sender) smtp.mailfrom=mathieu.desnoyers@efficios.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708008401; a=rsa-sha256; cv=none; b=1yzz1RafBcmozWBD1b4M7oZUzqDUmf7LF75pNrxS9f6KP+NGSAP/y7o/vqbHOc527uJ0KO 6IqEnR4l/G94IreTnHI3jwKRhA1caOuIF5+D+l5/nXMyz5GSpAOXVs2MSFWDhROvamNfvO j9n9N8YPmNr5NpxjiJolMYLaO6Z3U6w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708008400; bh=ecUyvilxXmAuEa6CVYKrKIA8K8l2tVUUJHjpsI0Te00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnQ8gALWRG0w08WHE18FXz/gmkcBs+yrQ55MT0cKd97EICKIovqMo4kVDLrKcH8bh YQI6fZljO24zHkyqsBzPTcvX20Vmg1ap8c8Tut+BU0Ci57M0gEpwtLnH+URQUAtmmg 76+jmRJI3BJZlPVr+gtSamRkZubkS4p6ZAiRoPVMrfSWx4HichoBiZJGLDkgrUvm+H 3BOlrHqxHEUVhYGYgEgu5uP0I6z8XFlAkekIdXkSRk81RBemq+K4JJyRUPbB2q5zqA kStS73njuquarYVVqiJKuZr+R21XtlJhj0W1tdwj08C9j7a2ZkXN80Oc/GHeo+rxH5 /2vMn1vOE7jHg== 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 4TbHvN0F0TzZS6; Thu, 15 Feb 2024 09:46:40 -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: [PATCH v6 3/9] nvdimm/pmem: Treat alloc_dax() -EOPNOTSUPP failure as non-fatal Date: Thu, 15 Feb 2024 09:46:27 -0500 Message-Id: <20240215144633.96437-4-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> References: <20240215144633.96437-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0FAD440017 X-Stat-Signature: 48snsm7qpdauy6ah9pnacxp4d71jni6b X-HE-Tag: 1708008400-757329 X-HE-Meta: U2FsdGVkX19pdx7O7J5DH2qqg97Al4xtRYFT8i0OOeg1whnWVGZ18DfGBcG7mlG5QOWOGYRyvmb9eC82BUaMDNGi9WYO4j9NSF2N2S99+m5QcanYU1IganMR74PSXynfTRlEe775KwK73pbB+ncIB+ZAxDmuoFYq8frPQ+S7TV7qvdGfPgCCaAwpVlRbWo4J18GdoIGvEVpIjlDvSc528RFjvhs3FSnxZ1XhD6hBy+kCmiA0brvZexdJnw8TjhvxlPmhxXHAhNzBxzuZmhkF0GXY8AUiv2Tob/l0RbdIs5and2UpgyySGMbKvLHygt+tBPyIZFJ/yJp3hInxDCJFVyGGE46V0YWmpjEi+hcjmTSd7l0FKb7cWqfQMa8HVsLvO1rVO7ks16Nt4cDY1dDKBpaCO1n4KB/mMu+g7Wf/5ONeQb52wzRmsNGHD521mf7MJi7yzOCho2gwjJIL6CuckJ35WMBn2i0F/TcX7AlO2xNv5KTPr26lO89ryFygyO4Wd6e0LBVX4g45roLd1jO0hHRYq7a2zccdUnKFRkKxENIJ9+rPqR+kLjS7IYVG9Tm7LEkRoDsMcYuKKfOVBUW6sGKWBIqJhJeVUfvmeLqH/StZ4eIRIqgfUkyHysywfKFgdnzV6k3AveSNYTL0X3AVWDyXf0Xw49OzhZDvv56hVTIwrHfTSErDc1eTkOdWwwO1dVV6zqDY4d8jil70GpsCNoWXNdVFFt0wrxwZSlPipH/KheOhAsFybHMMWufavheyLZIbPArLeizCGxSZDY9MuQN/C35CH1CnRRClQ9XCtLTD9+zLlXHdJaAyfi9VQR0eQ5w4p5fOi1zjsFDEDSG2jeiid2unbmCijg4COn5R121GXcJNKD8t73rjZYZHNGM/sRYsrPoARhRwPlTIjXY3CVX7uXOILTx0/01NZg5R1cU67CyQNHUMo8YfS/vNaY5h9s5+HaDebfUMfM/BdMI VAEns7Nx TLysHQNVETzfyBVU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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. [ Based on commit "nvdimm/pmem: Fix leak on dax_add_host() failure". ] Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams 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 | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/nvdimm/pmem.c b/drivers/nvdimm/pmem.c index 9fe358090720..e9898457a7bd 100644 --- a/drivers/nvdimm/pmem.c +++ b/drivers/nvdimm/pmem.c @@ -560,17 +560,19 @@ static int pmem_attach_disk(struct device *dev, dax_dev = alloc_dax(pmem, &pmem_dax_ops); if (IS_ERR(dax_dev)) { rc = PTR_ERR(dax_dev); - goto out; + 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;