From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: David Reaver <me@davidreaver.com>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Christian Brauner <brauner@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org, cocci@inria.fr,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 0/6] debugfs: Replace dentry with an opaque handle in debugfs API
Date: Mon, 10 Feb 2025 08:08:19 +0100 [thread overview]
Message-ID: <2025021048-thieving-failing-7831@gregkh> (raw)
In-Reply-To: <20250210052039.144513-1-me@davidreaver.com>
On Sun, Feb 09, 2025 at 09:20:20PM -0800, David Reaver wrote:
> Overview
> ========
>
> This patch series replaces raw dentry pointers in the debugfs API with
> an opaque wrapper struct:
>
> struct debugfs_node {
> struct dentry dentry;
> };
>
> Intermediate commits rely on "#define debugfs_node dentry" to migrate
> debugfs users without breaking the build. The final commit introduces
> the struct and updates debugfs internals accordingly.
>
> Why an RFC?
> ===========
>
> This is a large change, and I expect a few iterations -- unless this
> entire approach is NACKed of course :) Any advice is appreciated, and
> I'm particularly looking for feedback on the following:
>
> 1. This change touches over 1100 files. Is that okay? I've been told it
> is because the patch series does "one thing", but it is a lot of
> files to touch across many systems.
>
> 2. The trickiest part of this migration is ensuring a declaration for
> struct debugfs_node is in scope so we don't get errors that it is
> being implicitly defined, especially as different kernel
> configurations change which headers are transitively included. See
> "#includes and #defines" below. I'm open to any other migration
> strategies.
>
> 3. This change is mostly automated with Coccinelle, but I'm really
> contorting Coccinelle to replace dentry with debugfs_node in
> different kinds of declarations. Any Coccinelle advice would be
> appreciated.
>
> Purpose/Background
> ==================
>
> debugfs currently relies on dentry to represent its filesystem
> hierarchy, and its API directly exposes dentry pointers to users. This
> tight coupling makes it difficult to modify debugfs internals. A dentry
> and inode should exist only when needed, rather than being persistently
> tied to debugfs. Some kernel developers have proposed using an opaque
> handle for debugfs nodes instead of dentry pointers [1][2][3].
>
> Replacing dentry with debugfs_node simplifies future migrations away
> from dentry. Additionally, a declaration with debugfs_node is more
> self-explanatory -- its purpose is immediately clear, unlike dentry,
> which requires further context to understand its role as a debugfs
> dentry.
First off, many thanks for attempting this, I didn't think it was ready
to even be attempted, so it's very nice to see this.
That being said, I agree with Al, we can't embed a dentry in a structure
like that as the lifecycles are going to get messy fast.
Also, your replacement of many of the dentry functions with wrappers
seems at bit odd, ideally you would just return a dentry from a call
like "debugfs_node_to_dentry()" and then let the caller do with it what
it wants to, that way you don't need to wrap everything.
And finally, I think that many of the places where you did have to
convert the code to save off a debugfs node instead of a dentry can be
removed entirely as a "lookup this file" can be used instead. I was
waiting for more conversions of that logic, removing the need to store
anything in a driver/subsystem first, before attempting to get rid of
the returned dentry pointer.
As an example of this, why not look at removing almost all of those
pointers in the relay code? Why is all of that being stored at all?
Oh, also, all of those forward declarations look really odd, something
feels wrong with needing that type of patch if we are doing things
right. Are you sure it was needed?
thanks,
greg k-h
next prev parent reply other threads:[~2025-02-10 7:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-10 5:20 [RFC PATCH 0/6] debugfs: Replace dentry with an opaque handle in debugfs API David Reaver
2025-02-10 5:20 ` [RFC PATCH 1/6] debugfs: Add temporary "#define debugfs_node dentry" directives David Reaver
2025-02-10 5:20 ` [RFC PATCH 2/6] debugfs: Add helper functions for debugfs_node encapsulation David Reaver
2025-02-10 5:20 ` [RFC PATCH 3/6] relay: Replace dentry with debugfs_node David Reaver
2025-02-10 5:20 ` [RFC PATCH 4/6] debugfs: Automated conversion from dentry to debugfs_node David Reaver
2025-02-10 5:20 ` [RFC PATCH 5/6] debugfs: Manual fixes for incomplete Coccinelle conversions David Reaver
2025-02-10 16:45 ` Steven Rostedt
2025-02-10 17:53 ` David Reaver
2025-02-10 5:20 ` [RFC PATCH 6/6] debugfs: Replace debugfs_node #define with struct wrapping dentry David Reaver
2025-02-10 5:58 ` Al Viro
2025-02-10 5:53 ` [RFC PATCH 0/6] debugfs: Replace dentry with an opaque handle in debugfs API Al Viro
2025-02-10 7:08 ` Greg Kroah-Hartman [this message]
2025-02-10 16:08 ` David Reaver
2025-02-10 16:53 ` Steven Rostedt
2025-02-10 17:00 ` Al Viro
2025-02-10 17:12 ` Steven Rostedt
2025-02-10 17:25 ` Steven Rostedt
2025-02-10 17:59 ` David Reaver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2025021048-thieving-failing-7831@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=brauner@kernel.org \
--cc=cocci@inria.fr \
--cc=dakr@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@davidreaver.com \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox