vfs: prevent avoidable evictions on mkdir of existing directories
authormjg <mjg@FreeBSD.org>
Thu, 22 Oct 2020 19:28:12 +0000 (19:28 +0000)
committermjg <mjg@FreeBSD.org>
Thu, 22 Oct 2020 19:28:12 +0000 (19:28 +0000)
commit193170539e0aaf9c1686f5ff08caa21db4849074
tree248a65a8c626a5c68568a79649075a6ffaaacec1
parentb41aea587ed33bdae1a1895bae7630c7c1c29048
vfs: prevent avoidable evictions on mkdir of existing directories

mkdir -p /foo/bar/baz will mkdir each path component and ignore EEXIST.

The NOCACHE lookup will make the namecache unnecessarily evict the existing entry,
and then fallback to the fs lookup routine eventually leading namei to return an
error as the directory is already there.

For invocations like mkdir -p /usr/obj/usr/src/sys/GENERIC/modules this triggers
fallbacks to the slowpath for concurrently executing lookups.

Tested by: pho
Discussed with: kib
sys/kern/vfs_cache.c
sys/kern/vfs_subr.c
sys/kern/vfs_syscalls.c
sys/kern/vnode_if.src
sys/sys/namei.h
sys/sys/vnode.h