Date: 28 Sep 1999 14:52:06 +0300 From: Ville-Pertti Keinonen <will@iki.fi> To: Ville-Pertti Keinonen <will@iki.fi> Cc: current@freebsd.org, culverk@culverk.student.umd.edu Subject: Re: just found this Message-ID: <86670v1cex.fsf@not.demophon.com> In-Reply-To: Ville-Pertti Keinonen's message of "28 Sep 1999 12:19:56 %2B0300" References: <Pine.BSF.4.10.9909272351370.327-100000@culverk.student.umd.edu.newsgate.clinet.fi> <867llb1k39.fsf@not.demophon.com.newsgate.clinet.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
Replying to myself... > Looking at the code, it would seem that the number of directories is > what's causing problems (one is created for each link). The directory > vnodes can't be thrown out because a name cache entry exists in each > one. All of the name cache entries point to the same vnode, which > can't be thrown out because it is open. My initial guess wasn't correct (I mis-read the program due to the lack of indentation) - huge amounts of memory actually are consumed by name cache entries, not just vnodes... Setting a limit for the number of entries in the name cache should be more acceptable if actual directory data blocks were cached more efficiently, which I believe has been implemented in -current by Matt Dillon, but it isn't enabled by default because of the wasteful use of entire memory pages. Even if making it the default were acceptable (IMHO it isn't) it still doesn't make fixing things easy because there is no longer a LRU policy for name cache entries, they are merely associated with vnodes. Balancing the sizes of multiple caches can get quite interesting. > This should actually be fixed by something I did as part of some > patches I played with earlier this year, avoiding the need to force > parent directories of vnodes to be kept in memory. I'll try to come > up with a version that works against -current and doesn't contain of > the other (experimental) features of the earlier patches. IIRC the > part required to allow parent vnodes to be reused is quite simple. This was trivial, and it did sort of help, but only to the extent that it made the DoS harder, requiring other programs to be run to increase the vnode allocation count first. It fixes another potential DoS attack (create a file, keep it open, create a huge number of directories, each with a link to the file, none of the directory vnodes can be deallocated), so I'll include it anyhow. It does have some negative impact on caching behavior so it probably isn't desirable until an improved vnode caching policy can be introduced. The changes (against -current, but should be trivially modifiable for 3.x) are: Index: vfs_cache.c =================================================================== RCS file: /m/cvs/freebsd/src/sys/kern/vfs_cache.c,v retrieving revision 1.40 diff -u -r1.40 vfs_cache.c --- vfs_cache.c 1999/08/28 00:46:23 1.40 +++ vfs_cache.c 1999/09/28 11:04:22 @@ -122,8 +122,6 @@ { LIST_REMOVE(ncp, nc_hash); LIST_REMOVE(ncp, nc_src); - if (LIST_EMPTY(&ncp->nc_dvp->v_cache_src)) - vdrop(ncp->nc_dvp); if (ncp->nc_vp) { TAILQ_REMOVE(&ncp->nc_vp->v_cache_dst, ncp, nc_dst); } else { @@ -292,8 +290,6 @@ bcopy(cnp->cn_nameptr, ncp->nc_name, ncp->nc_nlen); ncpp = NCHHASH(dvp, cnp); LIST_INSERT_HEAD(ncpp, ncp, nc_hash); - if (LIST_EMPTY(&dvp->v_cache_src)) - vhold(dvp); LIST_INSERT_HEAD(&dvp->v_cache_src, ncp, nc_src); if (vp) { TAILQ_INSERT_HEAD(&vp->v_cache_dst, ncp, nc_dst); Index: vfs_subr.c =================================================================== RCS file: /m/cvs/freebsd/src/sys/kern/vfs_subr.c,v retrieving revision 1.228 diff -u -r1.228 vfs_subr.c --- vfs_subr.c 1999/09/21 00:36:15 1.228 +++ vfs_subr.c 1999/09/28 11:04:33 @@ -523,10 +523,6 @@ TAILQ_REMOVE(&vnode_free_list, vp, v_freelist); TAILQ_INSERT_TAIL(&vnode_tmp_list, vp, v_freelist); continue; - } else if (LIST_FIRST(&vp->v_cache_src)) { - /* Don't recycle if active in the namecache */ - simple_unlock(&vp->v_interlock); - continue; } else { break; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86670v1cex.fsf>