Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795021038; b=kMngCbqjIQXWpqtawOe06X1Ww2bY7TOI3tzNoZAQW7tdG0oilBGxClMdHTQ0YlsaibB4 giPzzazq4Xw44Lel07XKRGEllJ4sbvu91Hti0CURDXDbcXgbCTUw6OIkCGbGUAdMDb/I3 YfBnL8gaplm//rzhXuWkbUAi0LuYjN5IAAAnUutLa+E/SH20iLXOGQd+aAP7jEgiA3uv+ IwW42TjT2r+fgDKaC9gp9WI/feSs3O0Gzlo8FZ7kShOGgPRxtYabrXSTgunEvt3h0xHZ9 c34d9+/HCaM72AlU3nIWz7fsgUxIOEhUA7vLvC1Na/rfCxFsayge16OF3hanIKeEfow== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795021038; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=RtSYdjCD6zVr1v1CrcTc/XNY2eHuC9TfAnJm/hbQb0o=; b=wol/WAEdpHhR/xl8iyu0OiWzXpRlRb0E/VhA4pXoCT8fRry5AGUnVZVcO7YPg/49tStU k/QNx20uzKyXXIfLXImI4+RwrCmL7SawLkm49SvnQ7lck0lzfHOeRqjDpp8VW8ex9Gzul Z/augd1VcMJAanP5ymUoLnC/DUJZRsvkHfmfK5SPsOeqjRJbK2eI1SBzB3ox677y63Rgp LUI8FPZa3qDmdkR/T+R7H3XCQ4WjuDxGZfsfa5R8smt4aMti1NIg7HpKHpmLYLySF4AxJ 5fEg7NKBqilrQvWJ3Mnmog1zj6/5w8uFDvjl5cRMVXrxMXqmlpsAzHNDFJp7qwXaPiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=hz9rDQtV; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67C40606A32A; Wed, 18 Nov 2026 16:57:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=hz9rDQtV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C2591F000C4; Wed, 18 Nov 2026 16:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795021038; bh=RtSYdjCD6zVr1v1CrcTc/XNY2eHuC9TfAnJm/hbQb0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hz9rDQtVCvGG+z8AU9gL6P/0ApCxxP/xbkx9cnTHf9Tpn8OKN2ag43prJ43PnBU6O U9XakgC491dkbDr4Ew+LZimZlTkQrWteJBxchUkJ9K3zrz44aMJpF9zYO6AfNyimJz Bbr45aUqQO3kmN40EE6EM2v1oJGqi8H95nV5qHfo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dave Jiang , "Gregory Price (Meta)" , Miklos Szeredi , Sasha Levin , John Groves Subject: [PATCH 7.3 2165/2651] dax: add fsdev_dax_from_file() Date: Wed, 18 Nov 2026 15:56:45 +0100 Message-ID: <20261118150403.760768059@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150247.972732815@linuxfoundation.org> References: <20261118150247.972732815@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi [ Upstream commit c87dd99b6d0fe07e836c1593c03e8174029c66f4 ] If the file is a fsdev_dax open, take the dax_dev from the device inode's i_cdev. Return with a reference grabbed on the private dax inode. Make dax_dev_get() static again (internal to super.c for alloc_dax), export fsdev_dax_from_file() instead. This fix is in response to a Sashiko review, and some subsequent analysis. About the 'fixes' tag: this removes the export of dax_dev_get(), which was flawed, and replaces it with fsdev_dax_from_file(). It feels like the fixes tag makes sense for correcting an ABI error. Fixes: 2ae624d5a555d ("dax: export dax_dev_get()") Originally-by: John Groves Reviewed-by: Dave Jiang Reviewed-by: Gregory Price (Meta) Signed-off-by: Miklos Szeredi Signed-off-by: Sasha Levin --- drivers/dax/fsdev.c | 23 +++++++++++++++++++++++ drivers/dax/super.c | 3 +-- include/linux/dax.h | 3 ++- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/dax/fsdev.c b/drivers/dax/fsdev.c index 598604bf5ac5c..910665c1f4920 100644 --- a/drivers/dax/fsdev.c +++ b/drivers/dax/fsdev.c @@ -234,6 +234,29 @@ static const struct file_operations fsdev_fops = { .release = fsdev_release, }; +/** + * fsdev_dax_from_file - get dax_device from an open file + * @file: open device file + * + * Returns a dax_device pointer if @file refers to a fsdev_dax device. + * Otherwise return NULL. + * + * Caller must put_dax() the returned device when done. + */ +struct dax_device *fsdev_dax_from_file(struct file *file) +{ + struct dax_device *dax_dev; + + if (file->f_op != &fsdev_fops) + return NULL; + + dax_dev = inode_dax(file_inode(file)); + ihold(dax_inode(dax_dev)); + + return dax_dev; +} +EXPORT_SYMBOL_GPL(fsdev_dax_from_file); + /* * Acquire the dev_pagemap for probe: the static (pre-populated) one if * present, or a devm-allocated one for the dynamic case. Note that diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 210f4af479f0e..22ff364a5e34d 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -565,7 +565,7 @@ static int dax_set(struct inode *inode, void *data) return 0; } -struct dax_device *dax_dev_get(dev_t devt) +static struct dax_device *dax_dev_get(dev_t devt) { struct dax_device *dax_dev; struct inode *inode; @@ -588,7 +588,6 @@ struct dax_device *dax_dev_get(dev_t devt) return dax_dev; } -EXPORT_SYMBOL_GPL(dax_dev_get); struct dax_device *alloc_dax(void *private, const struct dax_operations *ops) { diff --git a/include/linux/dax.h b/include/linux/dax.h index fe6c3ded1b50f..2c9fc81f031b9 100644 --- a/include/linux/dax.h +++ b/include/linux/dax.h @@ -54,7 +54,6 @@ struct dax_device *alloc_dax(void *private, const struct dax_operations *ops); void *dax_holder(struct dax_device *dax_dev); void put_dax(struct dax_device *dax_dev); void kill_dax(struct dax_device *dax_dev); -struct dax_device *dax_dev_get(dev_t devt); void dax_write_cache(struct dax_device *dax_dev, bool wc); bool dax_write_cache_enabled(struct dax_device *dax_dev); bool dax_synchronous(struct dax_device *dax_dev); @@ -323,3 +322,5 @@ typedef int (*walk_hmem_fn)(struct device *dev, int target_nid, const struct resource *res); int walk_hmem_resources(struct device *dev, walk_hmem_fn fn); #endif + +struct dax_device *fsdev_dax_from_file(struct file *file); -- 2.53.0