From owner-dev-commits-src-all@freebsd.org Mon Jul 12 05:05:22 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5C487650C86; Mon, 12 Jul 2021 05:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GNWtB2D1vz3Jpr; Mon, 12 Jul 2021 05:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 30DA6FA9; Mon, 12 Jul 2021 05:05:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16C55MKA052605; Mon, 12 Jul 2021 05:05:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16C55MsG052604; Mon, 12 Jul 2021 05:05:22 GMT (envelope-from git) Date: Mon, 12 Jul 2021 05:05:22 GMT Message-Id: <202107120505.16C55MsG052604@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: 844aa31c6d87 - main - cache: add cache_enter_time_flags MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 844aa31c6d8785e7256a84d8ee7e8ae2362f9367 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2021 05:05:22 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=844aa31c6d8785e7256a84d8ee7e8ae2362f9367 commit 844aa31c6d8785e7256a84d8ee7e8ae2362f9367 Author: Mateusz Guzik AuthorDate: 2021-07-08 07:56:27 +0000 Commit: Mateusz Guzik CommitDate: 2021-07-12 05:03:14 +0000 cache: add cache_enter_time_flags --- sys/kern/vfs_cache.c | 24 ++++++++++++++++++++++++ sys/sys/vnode.h | 6 ++++++ 2 files changed, 30 insertions(+) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 5b978511db17..09f926d0cd31 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -2582,6 +2582,30 @@ out_unlock_free: return; } +/* + * A variant of the above accepting flags. + * + * - VFS_CACHE_DROPOLD -- if a conflicting entry is found, drop it. + * + * TODO: this routine is a hack. It blindly removes the old entry, even if it + * happens to match and it is doing it in an inefficient manner. It was added + * to accomodate NFS which runs into a case where the target for a given name + * may change from under it. Note this does nothing to solve the following + * race: 2 callers of cache_enter_time_flags pass a different target vnode for + * the same [dvp, cnp]. It may be argued that code doing this is broken. + */ +void +cache_enter_time_flags(struct vnode *dvp, struct vnode *vp, struct componentname *cnp, + struct timespec *tsp, struct timespec *dtsp, int flags) +{ + + MPASS((flags & ~(VFS_CACHE_DROPOLD)) == 0); + + if (flags & VFS_CACHE_DROPOLD) + cache_remove_cnp(dvp, cnp); + cache_enter_time(dvp, vp, cnp, tsp, dtsp); +} + static u_int cache_roundup_2(u_int val) { diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index ed5867b80754..64fb00c5845e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -641,6 +641,12 @@ int bnoreuselist(struct bufv *bufv, struct bufobj *bo, daddr_t startn, daddr_t endn); /* cache_* may belong in namei.h. */ void cache_changesize(u_long newhashsize); + +#define VFS_CACHE_DROPOLD 0x1 + +void cache_enter_time_flags(struct vnode *dvp, struct vnode *vp, + struct componentname *cnp, struct timespec *tsp, + struct timespec *dtsp, int flags); #define cache_enter(dvp, vp, cnp) \ cache_enter_time(dvp, vp, cnp, NULL, NULL) void cache_enter_time(struct vnode *dvp, struct vnode *vp,