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: 201504 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp449226dyb; Thu, 15 Feb 2024 06:49:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXZeyO6vd6hj/mkNUpxoNTYkHOMTJLG4LoI2KUcQonPcmVjwbgL4GOv4jO31P3cMQKRS/CZbeDRsDYBQinsC+9BhhGiSg== X-Google-Smtp-Source: AGHT+IGWl+vPGcLiKErP0IeDXaua3qx1XJsCX9YNx12nq5NTFgmhZPn9YI7IKqLo0rcFfI2ZG+8q X-Received: by 2002:a05:6808:f88:b0:3c0:3929:b0f3 with SMTP id o8-20020a0568080f8800b003c03929b0f3mr2394161oiw.38.1708008545492; Thu, 15 Feb 2024 06:49:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708008545; cv=pass; d=google.com; s=arc-20160816; b=CiYxLjHkXqshS4sowOa2b8QRBFhxotjXsuFR47k715evAdktz55yL52wpWueuHVR+x TSg/ZJqHsk6HaSN3qVYF4WsBFKS6lxyzctOAsfocQ7jLwejPhFESJ/qZOuVyjDQ9M/Bp feznWYFQ7y6sw40+3fNszoUviXe2BW1Vna/nNXlD6CdbiLwmLAk9qp7FA+FEn9/Uehom SgvO8MEX7xqclZ/ALlJ298oW8YdxHN7WiLki5j1qO/yOG80oNmAqU3H1GDTuqTOMXrEq hjFuXI5IJ2DwKFx2Emr9iU0F9fRU6hmpTY3mUmXJ5SF4qCsFz3dvvia0ZNW4F+TfJyOs Wmsw== 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=ym/AjxA3dY8nkclBW72WeTbsbmhWxX4/rRcYhBuexkc=; fh=GNeA/QZ7zQFhInUXedGuirIufvqkBvsPFrVhzF77X9E=; b=wOC6lGbXJSG8ZrtIqe0RcxLI2KYx8Uq3U80ucKypQwxKsuIdSePVQ410UUKVXSZHw+ ZPl44QvPZrKi9xacPVCS+s0cxW767Dmza26StB577UHCR945tGyfz7dHFSPJT5vb6c4V pHWbN53EHa9I9BjS7LtUla+xeLRfCxcCZSYttc6/tdHbFflDIPtj1GftrHbgEOn1ZKbr rmopVoln8vZndvagh/OIvy4ix9gZW6Y8EdYuvkH/DtWVo/JyXldS2a9K6p/iiGK0D5jv UBz7BizXtS8EkkzbE7gfYdHR8SYAgYYa7I0j3ASTPUtxcKkj4FcbKMdueN1EuAQ4E6x8 dxvA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=lJxsuurM; 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-67099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67099-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id pt14-20020a056214048e00b0068cdb0d8740si1552864qvb.376.2024.02.15.06.49.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:49:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=lJxsuurM; 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-67099-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67099-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 42BAA1C23942 for ; Thu, 15 Feb 2024 14:49:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 02EF81350C1; Thu, 15 Feb 2024 14:46:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="lJxsuurM" 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 BD4C2132470; Thu, 15 Feb 2024 14:46:40 +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=1708008403; cv=none; b=cO6foGmzsI5XvlGJusSqjR6nK3GP01aPU5jX8X2rqpDcacRE7F7M8fKR8GmioXxmmsvBqF2BiReN6MQEDOPOJ5pwigFwx7rHLpCwME+hUO/omzFzR7zQa56faiukuNfimPWJPDeSwRhhF9riDvgL6jRWPcuTXH2H1PyaxNQHoI0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708008403; c=relaxed/simple; bh=JafNy954LGAswGK3M3iYUpQrWP3IyrMlG3pf6B1HRm4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UwEBek/XxdZGS+CaKSfTxD9j1Q+5q2F8oeXew/n/S9pxmnQZsHdPFITsEQwMXUpvUJzCgNLB4L5tiHRmCmZnasccrnpozN/pRDfmmCNjonQrbwxijmR1Xma66pn3b9qncmC0bEKgzb6BtDkvnRpjpNYN6PvOcmDkiQBzxBNk0+w= 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=lJxsuurM; 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=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> 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: 1790976768486358451 X-GMAIL-MSGID: 1790976768486358451 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) {