From owner-svn-src-head@freebsd.org Tue Sep 3 14:06:41 2019 Return-Path: Delivered-To: svn-src-head@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 B9515DCC9A; Tue, 3 Sep 2019 14:06:36 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [96.47.72.132]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46N7zc1fDFz4Pjr; Tue, 3 Sep 2019 14:06:36 +0000 (UTC) (envelope-from yuripv@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 1452) id A45B51A8E9; Tue, 3 Sep 2019 14:06:12 +0000 (UTC) X-Original-To: yuripv@localmail.freebsd.org Delivered-To: yuripv@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id B57CFDFD8; Wed, 10 Apr 2019 13:02:37 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2610:1c1:1:6074::16:84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "freefall.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6345E6FB75; Wed, 10 Apr 2019 13:02:37 +0000 (UTC) (envelope-from owner-src-committers@freebsd.org) Received: by freefall.freebsd.org (Postfix, from userid 538) id 1F52DDFD6; Wed, 10 Apr 2019 13:02:37 +0000 (UTC) Delivered-To: src-committers@localmail.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client CN "mx1.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by freefall.freebsd.org (Postfix) with ESMTPS id D01C3DFD4 for ; Wed, 10 Apr 2019 13:02:33 +0000 (UTC) (envelope-from asomers@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 974DC6FB71; Wed, 10 Apr 2019 13:02:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6F76A22DF0; Wed, 10 Apr 2019 13:02:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3AD2XJ1012360; Wed, 10 Apr 2019 13:02:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3AD2XKg012359; Wed, 10 Apr 2019 13:02:33 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904101302.x3AD2XKg012359@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r346078 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 346078 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk X-Loop: FreeBSD.org Sender: owner-src-committers@freebsd.org X-Rspamd-Queue-Id: 6345E6FB75 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.95 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.997,0]; NEURAL_HAM_SHORT(-0.96)[-0.957,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] Status: O X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Date: Tue, 03 Sep 2019 14:06:41 -0000 X-Original-Date: Wed, 10 Apr 2019 13:02:33 +0000 (UTC) X-List-Received-Date: Tue, 03 Sep 2019 14:06:41 -0000 Author: asomers Date: Wed Apr 10 13:02:33 2019 New Revision: 346078 URL: https://svnweb.freebsd.org/changeset/base/346078 Log: fix cache_lookup's documentation cache_lookup's documentation got dislocated by r324378. Relocate and expand it. Reviewed by: jhb, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Modified: head/sys/kern/vfs_cache.c Modified: head/sys/kern/vfs_cache.c ============================================================================== --- head/sys/kern/vfs_cache.c Wed Apr 10 10:50:48 2019 (r346077) +++ head/sys/kern/vfs_cache.c Wed Apr 10 13:02:33 2019 (r346078) @@ -150,7 +150,7 @@ struct namecache_ts { * Names found by directory scans are retained in a cache * for future reference. It is managed LRU, so frequently * used names will hang around. Cache is indexed by hash value - * obtained from (vp, name) where vp refers to the directory + * obtained from (dvp, name) where dvp refers to the directory * containing name. * * If it is a "negative" entry, (i.e. for a name that is known NOT to @@ -1129,23 +1129,6 @@ cache_lookup_dot(struct vnode *dvp, struct vnode **vpp return (-1); } -/* - * Lookup an entry in the cache - * - * Lookup is called with dvp pointing to the directory to search, - * cnp pointing to the name of the entry being sought. If the lookup - * succeeds, the vnode is returned in *vpp, and a status of -1 is - * returned. If the lookup determines that the name does not exist - * (negative caching), a status of ENOENT is returned. If the lookup - * fails, a status of zero is returned. If the directory vnode is - * recycled out from under us due to a forced unmount, a status of - * ENOENT is returned. - * - * vpp is locked and ref'd on return. If we're looking up DOTDOT, dvp is - * unlocked. If we're looking up . an extra ref is taken, but the lock is - * not recursively acquired. - */ - static __noinline int cache_lookup_nomakeentry(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct timespec *tsp, int *ticksp) @@ -1229,6 +1212,42 @@ out_no_entry: return (0); } +/** + * Lookup a name in the name cache + * + * # Arguments + * + * - dvp: Parent directory in which to search. + * - vpp: Return argument. Will contain desired vnode on cache hit. + * - cnp: Parameters of the name search. The most interesting bits of + * the cn_flags field have the following meanings: + * - MAKEENTRY: If clear, free an entry from the cache rather than look + * it up. + * - ISDOTDOT: Must be set if and only if cn_nameptr == ".." + * - tsp: Return storage for cache timestamp. On a successful (positive + * or negative) lookup, tsp will be filled with any timespec that + * was stored when this cache entry was created. However, it will + * be clear for "." entries. + * - ticks: Return storage for alternate cache timestamp. On a successful + * (positive or negative) lookup, it will contain the ticks value + * that was current when the cache entry was created, unless cnp + * was ".". + * + * # Returns + * + * - -1: A positive cache hit. vpp will contain the desired vnode. + * - ENOENT: A negative cache hit, or dvp was recycled out from under us due + * to a forced unmount. vpp will not be modified. If the entry + * is a whiteout, then the ISWHITEOUT flag will be set in + * cnp->cn_flags. + * - 0: A cache miss. vpp will not be modified. + * + * # Locking + * + * On a cache hit, vpp will be returned locked and ref'd. If we're looking up + * .., dvp is unlocked. If we're looking up . an extra ref is taken, but the + * lock is not recursively acquired. + */ int cache_lookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, struct timespec *tsp, int *ticksp)