From patchwork Thu Feb 15 14:46:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Desnoyers X-Patchwork-Id: 13558532 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 14EFCC48BC4 for ; Thu, 15 Feb 2024 14:46:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7FED8D0017; Thu, 15 Feb 2024 09:46:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A07D68D0014; Thu, 15 Feb 2024 09:46:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85E338D0019; Thu, 15 Feb 2024 09:46:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 60D0E8D0014 for ; Thu, 15 Feb 2024 09:46:42 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 31A88411A6 for ; Thu, 15 Feb 2024 14:46:42 +0000 (UTC) X-FDA: 81794314644.16.D64DC54 Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) by imf03.hostedemail.com (Postfix) with ESMTP id 9138020003 for ; Thu, 15 Feb 2024 14:46:40 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=lJxsuurM; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf03.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=1708008400; 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=ym/AjxA3dY8nkclBW72WeTbsbmhWxX4/rRcYhBuexkc=; b=Y8Ws4hZKZRuDajefisT156BjlKPvDA59xRyaz4KFVxCFYF+lDX8dnJVUleEJfw1ZjEO9+a m0vxioN7XLcv/vlEGIzLPzbUzWdMk5Jn+/euxLmXwkO3qmIRyMv1bX+WIiRWjogytVu7sb rno0D703QOBaBQnmDN9v8ZyQPT8EZnc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=efficios.com header.s=smtpout1 header.b=lJxsuurM; dmarc=pass (policy=none) header.from=efficios.com; spf=pass (imf03.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=1708008400; a=rsa-sha256; cv=none; b=1lMvtDQbI+Ho4lWe+FfBG7u9EUlqWGcyXnxoTvn5uwg1vz06WPfcvFQyJAAEr4hFKT52AY oiiYwKYPiVaCyvt/MkXhHlnSaYK2B4mQKzBexyPo67aWmbEYvl6ymirB7Jrax3nHLp/dRA H+hNLsoPbXrszTdWkOUO3jOzSca5eaw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1708008399; bh=JafNy954LGAswGK3M3iYUpQrWP3IyrMlG3pf6B1HRm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJxsuurMOJq5+e74ZxcF+tIqPH0Qs+YhXRuSmvFSmLIGw0LXLL9OmA1TEc/hvC2zZ o91WMEukwLB1u4oCCHlgydXVguhQi11fEI6Vi8Ku08OyjSoiO2W2yeKDFGbjlSybRo grKnwo+y78PBVFCkNYKO8rAp12NTsmM88gHsKGJN+nzU5BYHEfglGxTm+PNhXBm4WX 1SH+QbvBu0shB1ITutjbBN/RvzwOVym/BdBANG0CF8gzUqRhhDPi+s7F1/D+ZD8taq b/ma0zxd+t86Hak1i/GDe5SYOKqW2uCqPPPfo+rNAEbyPVhQvm8B6Y94EIVbT9v+oc 6t/MP5Z/oCexQ== 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 4TbHvM4gxZzZS5; Thu, 15 Feb 2024 09:46:39 -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 v6 2/9] dax: alloc_dax() return ERR_PTR(-EOPNOTSUPP) for CONFIG_DAX=n Date: Thu, 15 Feb 2024 09:46:26 -0500 Message-Id: <20240215144633.96437-3-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-Rspamd-Queue-Id: 9138020003 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: ayagz8a49iznag5zzk6mc3mj8smfit6p X-HE-Tag: 1708008400-535367 X-HE-Meta: U2FsdGVkX1/fPhvcR6MSiWlWAvQZHdGrKHYlYr9AkYBg1ihJddgY5aEw93GLkxliZbZ1V6rNExb1W9sYkOTb8IGzezvo3YN3nZloEMcSnnZ7KdDoOHTHA6dOyEE9kp0EVPSK+fz6D2jA+lyAiEsmd8CQGxPwY+izsjA3G/abhs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1S9BOz01nCWHaMtsVhPqeSStsI79lUiz/U+FmIdseeAo8C62DFa3SHilaBoLxhvm0bth+dPBXGBzpzvDzITgzMOH5eKBO5It1ZhH144EsW2lM26qOvCGVwfYz1+1/rxSXYp7GXRt+Dxi61aGjw84Gvy2TxxRVWvpU5XBu6t28fTUsVTJuMfHR3Z2qDNUoRI7YvtmPzUnkxdCyXvhQ8h9Y6ZspHbW+QZ7g+ZyBeNkjeYd/5aqgZUy2gUpuWAOQWF/FF8rXZlXCU2PbgOB+HUefPBtnhkGI7GR7lOPAnAyGS/e0b1fJ/GInyEeB/XPkky7GOAhUXqzqxuFLatT5t2VbKFbMMHgsnQkW4fiHPA77BF9Ug/PSw== 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: 4e4ced93794a ("dax: Move mandatory ->zero_page_range() check in alloc_dax()") 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 e3ffe7c7f01d..9d3e3327af4c 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -88,11 +88,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) {