From owner-dev-commits-src-all@freebsd.org Sat Apr 10 06:02:03 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 5E6D05CF65A; Sat, 10 Apr 2021 06:02:03 +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 4FHPXW1TNTz4RFR; Sat, 10 Apr 2021 06:02:03 +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 137003A8B; Sat, 10 Apr 2021 06:02:03 +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 13A62222015136; Sat, 10 Apr 2021 06:02:02 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 13A622HI015135; Sat, 10 Apr 2021 06:02:02 GMT (envelope-from git) Date: Sat, 10 Apr 2021 06:02:02 GMT Message-Id: <202104100602.13A622HI015135@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: 378d492b2ed4 - stable/13 - cache: remove the largely obsolete general description 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 378d492b2ed420d09344fb32f52ea75b1e35ac1e 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: Sat, 10 Apr 2021 06:02:03 -0000 The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=378d492b2ed420d09344fb32f52ea75b1e35ac1e commit 378d492b2ed420d09344fb32f52ea75b1e35ac1e Author: Mateusz Guzik AuthorDate: 2021-02-05 23:16:55 +0000 Commit: Mateusz Guzik CommitDate: 2021-04-10 05:57:55 +0000 cache: remove the largely obsolete general description Examples of inconsistencies with the current state: - references LRU of all entries, removed years ago - references a non-existent lock (neglist) - claims negative entries have a NULL target It will be replaced with a more accurate and more informative description. In the meantime take it out so it stops misleading. (cherry picked from commit 2f8a844635312b0f25028a87459fdd2d2a1cbfd6) --- sys/kern/vfs_cache.c | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 50ec6face6ac..21eb436681fc 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -276,52 +276,6 @@ cache_ncp_invalidate(struct namecache *ncp) __predict_true((_nc_flag & (NCF_INVALID | NCF_WIP | NCF_WHITE)) == 0); \ }) -/* - * Name caching works as follows: - * - * 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 (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 - * exist) the vnode pointer will be NULL. - * - * Upon reaching the last segment of a path, if the reference - * is for DELETE, or NOCACHE is set (rewrite), and the - * name is located in the cache, it will be dropped. - * - * These locks are used (in the order in which they can be taken): - * NAME TYPE ROLE - * vnodelock mtx vnode lists and v_cache_dd field protection - * bucketlock mtx for access to given set of hash buckets - * neglist mtx negative entry LRU management - * - * It is legal to take multiple vnodelock and bucketlock locks. The locking - * order is lower address first. Both are recursive. - * - * "." lookups are lockless. - * - * ".." and vnode -> name lookups require vnodelock. - * - * name -> vnode lookup requires the relevant bucketlock to be held for reading. - * - * Insertions and removals of entries require involved vnodes and bucketlocks - * to be locked to provide safe operation against other threads modifying the - * cache. - * - * Some lookups result in removal of the found entry (e.g. getting rid of a - * negative entry with the intent to create a positive one), which poses a - * problem when multiple threads reach the state. Similarly, two different - * threads can purge two different vnodes and try to remove the same name. - * - * If the already held vnode lock is lower than the second required lock, we - * can just take the other lock. However, in the opposite case, this could - * deadlock. As such, this is resolved by trylocking and if that fails unlocking - * the first node, locking everything in order and revalidating the state. - */ - VFS_SMR_DECLARE; static SYSCTL_NODE(_vfs_cache, OID_AUTO, param, CTLFLAG_RW | CTLFLAG_MPSAFE, 0,