From ef23df13546811a49aeebb107dd17298bec8122e Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 13 Jan 2021 15:53:55 +0100 Subject: [PATCH] vfs: set NC_KEEPPOSENTRY alongside NOCACHE when creating a file Arguably the entire NOCACHE logic should get retired, in the meantime at least prevent the code from evicting existing entries. --- sys/kern/vfs_vnops.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index de5cd68501a..6c6727c7f37 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -240,8 +240,11 @@ restart: /* * Set NOCACHE to avoid flushing the cache when * rolling in many files at once. - */ - ndp->ni_cnd.cn_flags |= LOCKPARENT | NOCACHE; + * + * Set NC_KEEPPOSENTRY to keep positive entries if they already + * exist despite NOCACHE. + */ + ndp->ni_cnd.cn_flags |= LOCKPARENT | NOCACHE | NC_KEEPPOSENTRY; if ((fmode & O_EXCL) == 0 && (fmode & O_NOFOLLOW) == 0) ndp->ni_cnd.cn_flags |= FOLLOW; if ((vn_open_flags & VN_OPEN_INVFS) == 0)