On Mon, 27 Jan 2025 22:08:29 -0800 Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote: > On Tue, Jan 21, 2025 at 07:36:34AM -0800, David Reaver wrote: > > This patch series creates a toy pseudo-filesystem built on top of kernfs in > > samples/kernfs/. > > Is that a good idea? kernfs and the interactions with the users of it > is a pretty convoluted mess. I'd much prefer people writing their > pseudo file systems to the VFS APIs over spreading kernfs usage further. I have to disagree with this. As someone that uses a pseudo file system to interact with my subsystem, I really don't want to have to know the intrinsics of the virtual file system layer just so I can interact via the file system. Not knowing how to do that properly was what got me in trouble with Linus is the first place. The VFS layer is best for developing file systems that are for storage. Like XFS, ext4, bcachefs, etc. And yes, if you are developing a new layout of storage, then you should know the VFS APIs. But pseudo file systems are a completely different beast. The files are not for storage, but for control of the kernel. They map to control objects. For tracefs, there's a "current_tracer". If you write "function" to it, it starts the function tracer. It has to maintain state, but only for the life of the boot, and not across boots. All of debugfs is the same way, and unfortunately, the kernel API for debugfs is wrong. It uses dentries as the handle to the files, which it should not be doing. dentry is a complex internal cache element within VFS, and I assumed that because debugfs used it, it was OK to use it as well, and that's where my arguments with Linus stemmed from. For people like myself that only need a way to have a control interface via the file system, kernfs appears to cover that. Maybe kernfs isn't implemented the way you like? If that's the case, we should fix that. But from my point of view, it would be really great if I can create a file system control interface without having to know anything about how VFS is implemented. BTW, I was going to work on converting debugfs over to kernfs if I ever got the chance (or mentor someone else to do it). Whether it's kernfs or something else, it would be really great to have a kernel abstraction layer that creates a pseudo file system without having to create a pseudo file system. debugfs was that, and became very popular, but it was done incorrectly. -- Steve