https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281749
--- Comment #46 from Mateusz Guzik <[email protected]> --- So I hacked up a reproducer. Kernel part: diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 65529bc195bb..539bffb6f312 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -513,6 +513,44 @@ SYSCTL_PROC(_debug, OID_AUTO, ftry_reclaim_vnode, sysctl_ftry_reclaim_vnode, "I", "Try to reclaim a vnode by its file descriptor"); +static int +sysctl_vtryrecycle(SYSCTL_HANDLER_ARGS) +{ + struct vnode *vp; + struct nameidata nd; + char *buf; + int error; + + if (req->newptr == NULL) + return (EINVAL); + if (req->newlen >= PATH_MAX) + return (E2BIG); + + buf = malloc(PATH_MAX, M_TEMP, M_WAITOK); + error = SYSCTL_IN(req, buf, req->newlen); + if (error != 0) + goto out; + + buf[req->newlen] = '\0'; + + NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf); + if ((error = namei(&nd)) != 0) + goto out; + vp = nd.ni_vp; + NDFREE_PNBUF(&nd); + vholdnz(vp); + vrele(vp); + + error = vtryrecycle(vp, false); +out: + free(buf, M_TEMP); + return (error); +} +SYSCTL_PROC(_debug, OID_AUTO, vtryrecycle, + CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_WR, NULL, 0, + sysctl_vtryrecycle, "A", "Try to recycle a vnode by its pathname"); + + /* Shift count for (uintptr_t)vp to initialize vp->v_hash. */ #define vnsz2log 8 #ifndef DEBUG_LOCKS userspace (pluggable into will-it-scale, but can be made standalone of course): # cat tests/reclaim.c #include <sys/sysctl.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <assert.h> char *testcase_description = "reclaim"; void testcase(unsigned long long *iterations, unsigned long nr) { char *tmpfile = getenv("TESTPATH"); if (nr == 0) { while (1) { int error = sysctlbyname("debug.vtryrecycle", NULL, 0, tmpfile, strlen(tmpfile) + 1); } } else { while (1) { int error = fchownat(AT_FDCWD, tmpfile, 0, 0, AT_SYMLINK_NOFOLLOW); if (error != 0) err(1, "fchownat"); (*iterations)++; } } } Then: mkdir -p /test/crap TESTPATH=/test/crap ./reclaim_processes -t 2 falls immediately: [11:20] lynx4:~/repos/will-it-scale # TESTPATH=/test/crap ./reclaim_processes -t 2 testcase:reclaim warmup reclaim_processes: fchownat: Bad file descriptor min:0 max:205 total:205 iow I have what's needed to figure it out, it is plausible I;ll hack it up over the weekend. -- You are receiving this mail because: You are the assignee for the bug.
