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: 199909 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp32449dyb; Mon, 12 Feb 2024 08:38:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IHnQ1VSZPtEgQsiqlMj6HFKsAappouqriD9Pi2j/eobMYEkd0LQy2tima1bPnho1R+8le3o X-Received: by 2002:a05:6402:1a45:b0:560:79a:11d5 with SMTP id bf5-20020a0564021a4500b00560079a11d5mr4634902edb.9.1707755880743; Mon, 12 Feb 2024 08:38:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707755880; cv=pass; d=google.com; s=arc-20160816; b=UdTZ4APUuowI/kUmcE01Dw0sArAc8tXq5nK+DzJMBiqz92bdUgDlzYH56qeiNOmphT aX3KxGdVh4H8rUnWptkW8hqrS8TEmveVLvaPhn4ATFrloslr5WMRp9RzUo23U8QJEV8U uHi2uXcjijxMpFKlUeXpTnlWEPmH3QEjt4SUkh87gWbhaSoGAa1Tu8POrSqYJh8Q4kEc kKMsX+AbFMrW4j5L0VFVc+erbXv5pTp4vtccSbc2OdDYeDE8uQx34VJdK/GYbynY+D3n Xm4sSnCss2LPiedj8mMiuGvmCf4oauY8HYp4IHNMojmuYY+xm07qFuIbvPgRP+coivZy 9piw== 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=QQA/ij2WbJgdSDvBywiLol7C1tjSsVdtqkl4hy1jRqY=; fh=+qTyzgcbD1WyVWJmmZ6LPgtDoaJEu0ONTVB7vZKQwUU=; b=hHNepGcywc5k/SJHrpQpi4zHkgBfg+WkhEYA24O5eKAM64mxg+8ftrKBDYJYBw8bDm QSlCQVAqO3l1PV+OhT7kmfLSOkKDqCvDz0Ne4tYjEOn/IiHmuLk1RHOiMdSezQdd6DTN RKoni0A0u/LOTFncj7oMhQYYxk/u1m+m4b9LEnai473X1GaRlabaO6YG03SPrYlTFqbk cPXlYYiZNlO/WOkoF/V+GPd6M9cRL1WngZX4EL04XRCJkH6JNIt46JbCxRiUPbxsm0Qk OM6XdLdD54FQkors2YbY3eY7nUaZ2ypRQg/P3N6AWC/MVm4LfabxSx5eAY4az//8ScG8 qYeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=EkF+I8nC; 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-61979-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61979-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com X-Forwarded-Encrypted: i=2; AJvYcCXEf1VZkI6rCOhF9Og+vSlKqGE/S+3bu7d9+r3DnF7Zijh0gaKVMSy4B1D1dlbdyY8FFm7MRSo2SOxOQ1Q9hjpHULjMpw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u20-20020aa7d894000000b00561557db288si2802714edq.386.2024.02.12.08.38.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 08:38:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61979-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=EkF+I8nC; 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-61979-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61979-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5994B1F2382D for ; Mon, 12 Feb 2024 16:38:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 574744F5F9; Mon, 12 Feb 2024 16:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="EkF+I8nC" 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 8C29B1EEE4; Mon, 12 Feb 2024 16:31:04 +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=1707755466; cv=none; b=ZmnFXibo/9C6ET7sfibz0iQi6q/irqsmP31nmBE4hcMtQR5vTo7eczGl1pJPmUZYgyuELL8QC5yjApnDVgq7AiHd8A0SuYNs2Fz+13A2br1xotMRm9ZwbDlyl88HKq3+hvi7p8vU+uQCyT3E6apWJTjMHsNeGfHvrYnmp68nE1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707755466; c=relaxed/simple; bh=q/9jEJfnqEQkc3MaRhsxgrh4+o9HVwSNE5hPfxrTXB8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Qk75W7L/IwH92HLTA7l4B8oF8sXHQ6JqgAH13nRgvaL1+PGKq8nXvdxWR+gI8e2yi8geswacm6uCrXLU5Cek6uvWs1ttnKSlBZJt86lEPGEeXuBLYvnpfs8LAXPUpGuPSzqsFF2gAd3JyjLZfQiRIglsvcaeLgdMNp7eGbW2/rw= 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=EkF+I8nC; 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=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> 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: 1790711830216840830 X-GMAIL-MSGID: 1790711830216840830 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) {