Page MenuHomeFreeBSD

vfs: add FAILIFEXISTS flag
ClosedPublic

Authored by mjg on Dec 27 2020, 10:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 29 2024, 2:22 AM
Unknown Object (File)
Dec 14 2023, 8:25 PM
Unknown Object (File)
Nov 12 2023, 2:07 AM
Unknown Object (File)
Sep 30 2023, 7:09 PM
Unknown Object (File)
Sep 22 2023, 10:08 AM
Unknown Object (File)
Sep 21 2023, 10:13 PM
Unknown Object (File)
Sep 2 2023, 4:11 AM
Unknown Object (File)
Sep 2 2023, 4:10 AM
Subscribers
None

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
rG FreeBSD src repository
Lint
Lint Not Applicable
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
4235

Why is this line needed ?

sys/kern/vfs_lookup.c
1310

This is a duplicate condition. Why adding it ?

1312

() != 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
4235

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

sys/kern/vfs_lookup.c
1310

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
1310

.. 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
1310

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.