Re: [PATCH v8 00/12] vfs: add O_CREAT|O_DIRECTORY to open*(2)
From: Jori Koolstra
Date: Sun Nov 22 2026 - 16:20:40 EST
Hi Christian,
> Op 18-11-2026 11:30 EST schreef Christian Brauner <brauner@xxxxxxxxxx>:
>
>
> On Sat, Oct 24, 2026 at 11:35:27PM +0200, Jori Koolstra wrote:
> > This series implements new semantics for the O_CREAT|O_DIRECTORY flag
> > combination for open*(2): perform a mkdir and open the resulting
> > directory; return a pinning fd (which mkdir does not).
>
> I've applied this to vfs-7.5.directory and folded a bunch of fixes into
> it. Each fixup is attached as a git note to the commit I folded it into
> so you can see what I massaged:
>
> git fetch https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git \
> +vfs-7.5.directory:refs/remotes/vfs/vfs-7.5.directory \
> +refs/notes/vfs-7.5.directory:refs/notes/vfs-7.5.directory
> git log --notes=vfs-7.5.directory v7.4-rc1..vfs/vfs-7.5.directory
>
> The biggest change is kernfs. kernfs_iop_mkdir() now just looks up the
> new node by name so the kernfs_syscall_ops change is gone and cgroup and
> resctrl aren't touched at all anymore.
>
> The kernfs patches are in vfs-7.5.kernfs as "kernfs: instantiate the
> dentry in kernfs_iop_mkdir()". I'll sent that out soon.
>
> I split out of 09/12, your kernfs_iattr_rwsem fix and the kernfs part of
> 11/12. vfs-7.5.directory is based on the first one.
>
> I dropped "vfs: move ->create check in lookup_open() to before
> try_break_deleg()". vfs_create_no_perm() does that check itself now.
>
> Let me know if I messed something up.
Thanks for pushing this along and taking a look.
I am a bit confused with the order of some of the fixups, but it does
not really matter since at the end it works out. But e.g. you first remove
the dir->i_op->create check from vfs_create(), then add it again in another
fixup, and then change the error code.
Overall, I agree with the changes. It does make more sense to do the
SB_I_NO_ATOMIC_MKDIR check in open_last_lookups() and that simplifies the
logic. Also, I like how you've split "kernfs: instantiate the dentry in
kernfs_iop_mkdir()" out. That is much better and allows Shakeel to continue
his stuff easier. I should have done so and not be lazy.
However, I am not sure that relying on holding the parent's i_rwsem is
sufficient for the atomicity that we are trying to provide. Afaict nothing
in the kernfs layer prevents you from removing a grandparent and a recursive
kernfs_remove() of an ancestor never touches the immediate parent's i_rwsem.
Also, returning -ESTALE, if you set LOOKUP_REVAL, can make open(O_CREAT|O_DIRECTORY)
return -ENOENT. Not sure if that is what you want.
I also see that "kernfs: hold kernfs_iattr_rwsem when initializing a new inode"
went to the kernfs tree, so that is fine too.
Best,
Jori.
PS. See you at FOSDEM...?