From patchwork Mon Feb 12 16:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13553518 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 1D71BC4829C for ; Mon, 12 Feb 2024 16:31:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A58B26B0081; Mon, 12 Feb 2024 11:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BCAC6B0083; Mon, 12 Feb 2024 11:31:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 836CA6B0087; Mon, 12 Feb 2024 11:31:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 706726B0083 for ; Mon, 12 Feb 2024 11:31:06 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 33AC4A19FA for ; Mon, 12 Feb 2024 16:31:06 +0000 (UTC) X-FDA: 81783691332.28.BA8E8A3 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf24.hostedemail.com (Postfix) with ESMTP id A6E7A18002E for ; Mon, 12 Feb 2024 16:31:04 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=EkF+I8nC; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.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=1707755464; 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=QQA/ij2WbJgdSDvBywiLol7C1tjSsVdtqkl4hy1jRqY=; b=WGCjKWDpJDTL62lpwZV6QsAz7LpePJiUWkW+pNJALkB+Riuj7Tz4nM4sK2Q+Kk8t1Mnn5N zZ2SO6yB+bv0Cgv716SBNcuZNfi/Us7Oik1GNXwY6HEGxri02jDEjkZcdPDEPthLnVRM8r ojOT8L/yaW+4c8mkR6e1lb1JOuqVY9E= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=EkF+I8nC; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf24.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=1707755464; a=rsa-sha256; cv=none; b=dTysWzoIpnVc3iCQ9Qk9OzpJgFD9wJj05DTmtMsEsNvAC5WxLMBPFuH6Z0Fhl4ooU5btj9 MXBKylLf800eFEVTwiPv04DtXZTWAKKNzfetSrSk/xyJRh7QATUgeq3IIaqpIANBb+pkCZ ttZgeVltjCrGA7cjkR1XcJB7E+7oGvU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1707755463; bh=q/9jEJfnqEQkc3MaRhsxgrh4+o9HVwSNE5hPfxrTXB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EkF+I8nCzGXwgsjLIO9z5hrj4YLXkG1Gy+qBhoGBPBzwMSQ2ngaByzqZ8MwMu7uYR HVuW3uAHo7KnmvGrg8FW5d8BZO/OcZAetn3pHPCIKXU3OWKZQrd1Gq04mjZpxP50jP v2sxs0xOImWi8VD0bUUiy+VYH/NlIQft+vc+QCvBV0VT3G9XLCd+o0JpXhqhRW8rT6 HOmpfq2rS2ZnfBh8TL+swhmVq8Py5ZEKkF6SvmeGs+vHNFDGloUyRXskUrpYkosMzK D8W0MOk5fYJK6ialW8Gs/5HZdIgZbPC1bGBNdK+vbFrB6x2RODeex/oO2dOq6vh+67 oMJWvt2aRlatw== 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 4TYVMC3L1TzXvQ; Mon, 12 Feb 2024 11:31:03 -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 Subject: [PATCH v5 1/8] dax: alloc_dax() return ERR_PTR(-EOPNOTSUPP) for CONFIG_DAX=n Date: Mon, 12 Feb 2024 11:30:54 -0500 Message-Id: <20240212163101.19614-2-mathieu.desnoyers@efficios.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> References: <20240212163101.19614-1-mathieu.desnoyers@efficios.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A6E7A18002E X-Stat-Signature: 4sprunsbrhxy45oyuo7e1mgphyrczpc1 X-Rspam-User: X-HE-Tag: 1707755464-642236 X-HE-Meta: U2FsdGVkX1+SrGV9bGpaafg8sI43VDI4EcTRmPCOm4yYG1NPTcWtajpXZkyrXcnlagCnDVA2Ryi5cbhIq+cY3NzurEeGUQ96NprlwJ/FEg6i7V5eT79zS5ByKbZLGPMGiZScW7HDNbguO6r+yPGhySWcFeM6mTShjCPloYc1iLrQQco2rde2ji84CqbARcC341ardCJE+dF0rN3SRdeQa8k6RKZEX5VRRSwvgAHNYw9bWlp0QNvJYKLhgbyZdqOF5U1imogS3mExxNAuXPTmvYRTDFaZPEO06MLdCKamtFdVDlQcLJjbvnFvuJijnClIKe+qEwhJzxZ3cxTMmmm1ZCiqjv3NnI25eg6L7IuWPXa7Jd9FQNV/jMfD0wZdm59tt5/ZsajhZS25arEk9ew/MdWXdJ+b13cjWxzo8bp+Dex0jAg5i6X2rfu48LIGgWQ77oQ1Mam7oozCnXFla/feQp+nexozq8t838eKu24Q51RKdsr7jSxPxL251469biDo9WPsDMY3HMtrSk4qViaA1WH8lSAl+oThZEOfQaJLDwMT9/R0rgyi45+ZOpysY1yAn0UGGxboasjjxxIS64BK74vQyaYMMqPQd4o2a+aUlSv/B1cWBTW8VEDBEgo5GJtU5uoGGRCzYMvbRWjfhQSKeXEqsi9VW4rU/Llg0Bo3J+Pg+ptkUNlbLuum3mQ89Eqys3okp1AH2B6QOjQs9r2SP0srCBoftXtUtqRGKEbvA7qpbc3WQ+9u3wb/Ni18uBC9MZ0anoUkkiaZXZJ1JRjguNKzhawReYZK3M0NP7b6CtreFFlam8EQy/+6vseQY7vFeG9CWJ+jAQteXJRsCLcfa1XIPuAeS2vI0d0Mgri0fJwGkPrC1XqwekAAL2Bi8EDtsOiADh2+nYjRanmhgAW0AKk/fKmg9nI6oHTl75B/n+M5aDGhMMxxKicSSJRB3oI7DiSfQTAEU7wEKVlNkvM UNlN9Zvw aY8i0w7R4993zI6Y= 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: Change the return value from NULL to PTR_ERR(-EOPNOTSUPP) for CONFIG_DAX=n to be consistent with the fact that CONFIG_DAX=y never returns NULL. This is done in preparation for using cpu_dcache_is_aliasing() in a following change which will properly support architectures which detect data cache aliasing at runtime. Fixes: d92576f1167c ("dax: does not work correctly with virtual aliasing caches") Signed-off-by: Mathieu Desnoyers Reviewed-by: Dan Williams 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/dax/super.c | 5 +++++ include/linux/dax.h | 6 +----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 0da9232ea175..205b888d45bf 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -319,6 +319,11 @@ EXPORT_SYMBOL_GPL(dax_alive); * that any fault handlers or operations that might have seen * dax_alive(), have completed. Any operations that start after * synchronize_srcu() has run will abort upon seeing !dax_alive(). + * + * Note, because alloc_dax() returns an ERR_PTR() on error, callers + * typically store its result into a local variable in order to check + * the result. Therefore, care must be taken to populate the struct + * device dax_dev field make sure the dax_dev is not leaked. */ void kill_dax(struct dax_device *dax_dev) { diff --git a/include/linux/dax.h b/include/linux/dax.h index b463502b16e1..df2d52b8a245 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -86,11 +86,7 @@ static inline void *dax_holder(struct dax_device *dax_dev) static inline struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) { - /* - * Callers should check IS_ENABLED(CONFIG_DAX) to know if this - * NULL is an error or expected. - */ - return NULL; + return ERR_PTR(-EOPNOTSUPP); } static inline void put_dax(struct dax_device *dax_dev) {