Re: [RFC] "final" flag for a directory
David Sterba <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Aug 17, 2026 at 04:26:31PM +0200, Laurent Lyaudet wrote: > I had an idea about adding a boolean flag "final" on directories in an > advanced filesystem. > In the same way, the "final" keyword on a class in OOP can be added to > declare no subclass can exist, > the "final" boolean flag on a directory could be added to say that the > directory has no/must not have any subdirectory. Do you have an existing use case for that? > So here we see that 2 flags could be added: > - a configuration flag "must_be_final" forbidding to create a subdirectory, I see two possible semantics of that: - final, no subdirectories exist and new ones cannot be created - no new subdirectories can be created, but some may exist Also given how other attributes behave once set they can be unset. This is up to the user, and possibly a restricted operation. > - a status flag "is_final" telling that no subdirectory currently exists. When the filesystem tracks the number of subdirectories already, then it's an easy check. Otherwise a full search must be done, atomically wrt creating new subdirectories. > I think it may allow some small optimizations. > With a very limited search on the Internet, I found no similar thing before, > but I do assume that I'm not the first one to have this idea of > marking the pseudo-leaves of the filesystem tree. > Please, let me know if this should be discussed elsewhere. If fsdevel is not interested we can still discuss it on btrfs mailinglist. I've been collecting ideas for new file attributes (listed below), but not all are generic enough for other filesystems (e.g. nodatasum). The fileattr interface (wrapping the old flags and XFLAGs) has some spare bits and is on the VFS layer, this would be ideal but I don't know if it's viable if there would be just one filesystem. - noinline (reusing NOTAIL), nosymlink, nodatasum, nodefrag, noautodefrag, "new directory is subvolume" (reusing TOPDIR) Some of them may need an incompat bit so it would be better to add them all at once rather than one by one.