Page MenuHomeFreeBSD

vfs: add FAILIFEXISTS flag
ClosedPublic

Authored by mjg on Dec 27 2020, 10:40 PM.

Details

Summary

Both FreeBSD and Linux mkdir -p walk the tree up ignoring any EEXIST on the way and both are used a lot when building respective kernels.

This poses a problem as spurious locking avoidably interferes with concurrent getdirentries and calls on affected directories.

Work around the problem by adding FAILIFEXISTS flag. In case of lockless lookup this manages to avoid any work to begin with, there is no speed up for the locked case but perhaps this can be augmented later on.

For simplicity the only supported semantics are as used by mkdir.

Diff Detail

Repository
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mjg requested review of this revision.Dec 27 2020, 10:40 PM
mjg created this revision.
sys/kern/vfs_cache.c
4234

Why is this line needed ?

sys/kern/vfs_lookup.c
1309

This is a duplicate condition. Why adding it ?

1311

() != 0

sys/kern/vfs_syscalls.c
3791

I think this comment should be moved into the herald of the bad_eexist block.

sys/kern/vfs_cache.c
4234

So that the underlying can test that the entry is not found by the caller.

sys/kern/vfs_lookup.c
1309

duplicates what? hoisting the flag check above this would still require checking whether a vnode is found

mjg marked an inline comment as done.Dec 27 2020, 11:25 PM
mjg added inline comments.
sys/kern/vfs_lookup.c
1309

.. unless this was about the VDIR check, but it was already there and not added by me.

kib added inline comments.
sys/kern/vfs_lookup.c
1309

I am about v_type == VDIR. It is re-rechecked at the start of nameicap_tracker_add(). You can simple remove it there, you are re-arranging code anyway.

This revision is now accepted and ready to land.Dec 27 2020, 11:29 PM
This revision was automatically updated to reflect the committed changes.