From nobody Mon Jun 13 19:41:01 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 22FAF8595D9; Mon, 13 Jun 2022 19:41:09 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail2.ambrisko.com (mail2.ambrisko.com [70.91.206.91]) by mx1.freebsd.org (Postfix) with ESMTP id 4LMMPc4fP7z3wTM; Mon, 13 Jun 2022 19:41:08 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) IronPort-SDR: sFLGm8xwTxclm6wFRBRdKZSmw2yJF+qaffIvJJjH2Ig5sa8gPoVkeoRyUzvMiV3+Jm2ha8EBIO Q5h1Pna47SZ0BQXsqQKo4YaDytWizM5Zw= X-Ambrisko-Me: Yes IronPort-Data: A9a23:28e0kapyCgD8GkHPSzDbWnb9da5eBmLNZRIvgKrLsJaIsI4StFCzt garIBmGOauDZjOmKtpxb9nnpBsOvJ/SzYJgHAZu+ytgHn4T8seUXt7xwmUcn8+xwmwvaGo9s q3yUjRMRSwNZie0Si2Fa9ANkFEnvU22buulYAL7EnApLeNUYH9JZSNLw4bVsKYx6TSKK1/lV efJniHqEATNNwiYko4jw/nrRBtH5Jwesd6D17A0TagjUFT2zxH5AH+DTE0YwqaRf2VaIgK6b 76rILCR/2XF8g0rA9fjm7PxaEwRQbmUNg+L4pZUc/Hz2F4b+Hx0i+BhXBYfQR8/ZzGhltV70 tRWtpuYQAIjJKzXm+NbWB5de817FfAdoOGYfhBTtuTWlSUqaUDExvdhEVM3PqUX/+92BSdF8 vlwADkIZAqCnOGx6LyhR+RmnchlK9PkVKsEoHolxjbcCPc6XZ3ZWI3E/9JV1iw8wMdUEp72a 8cHLDFoaRHBfwYKIU0cTZs6mM+mnHTyeSZU7lWPqsIf72XNiQd21b3sLMGQYcaBAMBcn0Cwq HjL8m7iDlcdLtP39NYv2hpAncfUkDnlVZhIUrS9/ORrm16UgGcUDXUruZKAiaHRoiaDtxh3c iT4IwIi8vo/8lKFVN74U0HqqXKIpERFCdNVGfc78wKK4qPR6RyYHWsDCDVGbYV+5sMxQDUr0 H6Pns/oVWE36ezJESrF++fGty62NAgUMXQGOX0OQzwa7oSxu4o0lB/OEIpuSfbnkt3vFDjs6 DmWtyxi1a4LhMsG2vzjr1DKij6hvLbTSQsx6lmFV26p9FkgNoegbZap8lvcxf9FJpyYVVqG+ nMDnpHGvuwJCJiMkg2LQfkMTOzxvqfZaGWEjAc2TZc79jmr93qyRqxq4WlzdBVzL8IJWT71e 0uP6wlf04BeYSmxZqhtboPvV8lzlfr8Fc7oX+z/Z8ZVZsQjbxeO+SxjaBLC323pl0Rww6gzN Y3BKJStC2oXE6JuyHy/Qu0H0KQowWY1wmaKHcL3yBGu0Ly/Yn+JSOdYaALfMrhhtK7U8h/I9 9t/NteRz0QNWeLzVSDb7IoPIA1YNnM8H53395Rae7LROAZgA219Wfbdzal7I95+kr5Lm/2Su Hi4UFVZ01n4w3bALFzSOHxkbbruW7d5rG46bXF0ZAf0gyB7bNb99robers2YaIjpb5qwvNDR vUYf9mNX6ZUQTPd9jVBNZTwoeSOrvhwad5i68Z9XAUCQg== IronPort-HdrOrdr: A9a23:LnLZlK0cSWyyee98xBZ5oQqjBLIkLtp133Aq2lEZdPWaSK2lfu SV7ZMmPH7P+VIssR4b9exoVJPufZqYz+8S3WBzB8bGYOCFghrKEGgK1+KLqFDd8m/Fh4xgPM xbE5SWZuefMbBL5/yR3DWF Received: from server2.ambrisko.com (HELO internal.ambrisko.com) ([192.168.1.2]) by ironport2.ambrisko.com with ESMTP; 13 Jun 2022 11:34:35 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by internal.ambrisko.com (8.17.1/8.17.1) with ESMTPS id 25DJf1lB084035 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Mon, 13 Jun 2022 12:41:01 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) X-Authentication-Warning: internal.ambrisko.com: Host localhost [127.0.0.1] claimed to be ambrisko.com Received: (from ambrisko@localhost) by ambrisko.com (8.17.1/8.17.1/Submit) id 25DJf1KB084034; Mon, 13 Jun 2022 12:41:01 -0700 (PDT) (envelope-from ambrisko) Date: Mon, 13 Jun 2022 12:41:01 -0700 From: Doug Ambrisko To: Mateusz Guzik Cc: Doug Ambrisko , src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 6468cd8e0ef9 - main - mount: add vnode usage per file system with mount -v Message-ID: References: <202206131457.25DEvJDU044469@gitrepo.freebsd.org> List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4LMMPc4fP7z3wTM X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Mon, Jun 13, 2022 at 06:43:31PM +0200, Mateusz Guzik wrote: | On 6/13/22, Doug Ambrisko wrote: | > The branch main has been updated by ambrisko: | > | > URL: | > https://cgit.FreeBSD.org/src/commit/?id=6468cd8e0ef9d1d3331e9de26cd2be59bc778494 | > | > commit 6468cd8e0ef9d1d3331e9de26cd2be59bc778494 | > Author: Doug Ambrisko | > AuthorDate: 2022-06-13 14:56:38 +0000 | > Commit: Doug Ambrisko | > CommitDate: 2022-06-13 14:56:38 +0000 | > | > mount: add vnode usage per file system with mount -v | > | > This avoids the need to drop into the ddb to figure out vnode | > usage per file system. It helps to see if they are or are not | > being freed. Suggestion to report active vnode count was from | > kib@ | > | > Reviewed by: kib | > Differential Revision: https://reviews.freebsd.org/D35436 | > --- | > sbin/mount/mount.c | 7 +++++++ | > sys/kern/vfs_mount.c | 12 ++++++++++++ | > sys/sys/mount.h | 4 +++- | > 3 files changed, 22 insertions(+), 1 deletion(-) | > | > diff --git a/sbin/mount/mount.c b/sbin/mount/mount.c | > index 79d9d6cb0caf..bd3d0073c474 100644 | > --- a/sbin/mount/mount.c | > +++ b/sbin/mount/mount.c | > @@ -692,6 +692,13 @@ prmount(struct statfs *sfp) | > xo_emit("{D:, }{Lw:fsid}{:fsid}", fsidbuf); | > free(fsidbuf); | > } | > + if (sfp->f_nvnodelistsize != 0 || sfp->f_avnodecount != 0) { | > + xo_open_container("vnodes"); | > + xo_emit("{D:, | > }{Lwc:vnodes}{Lw:count}{w:count/%ju}{Lw:active}{:active/%ju}", | > + (uintmax_t)sfp->f_nvnodelistsize, | > + (uintmax_t)sfp->f_avnodecount); | > + xo_close_container("vnodes"); | > + } | > } | > xo_emit("{D:)}\n"); | > } | > diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c | > index 71a40fd97a9c..e3818b67e841 100644 | > --- a/sys/kern/vfs_mount.c | > +++ b/sys/kern/vfs_mount.c | > @@ -2610,6 +2610,8 @@ vfs_copyopt(struct vfsoptlist *opts, const char *name, | > void *dest, int len) | > int | > __vfs_statfs(struct mount *mp, struct statfs *sbp) | > { | > + struct vnode *vp; | > + uint32_t count; | > | > /* | > * Filesystems only fill in part of the structure for updates, we | > @@ -2624,6 +2626,16 @@ __vfs_statfs(struct mount *mp, struct statfs *sbp) | > sbp->f_version = STATFS_VERSION; | > sbp->f_namemax = NAME_MAX; | > sbp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK; | > + sbp->f_nvnodelistsize = mp->mnt_nvnodelistsize; | > + | > + count = 0; | > + MNT_ILOCK(mp); | > + TAILQ_FOREACH(vp, &mp->mnt_nvnodelist, v_nmntvnodes) { | > + if (vrefcnt(vp) > 0) /* racy but does not matter */ | > + count++; | > + } | > + MNT_IUNLOCK(mp); | > + sbp->f_avnodecount = count; | > | | libc uses statfs for dir walk (see gen/fts.c), most notably find | immediately runs into it. As such the linear scan by default is a | non-starter. | | I don't know if mount is the right place to dump this kind of info to | begin with, but even so, it should only happen with a dedicated flag. | | As statfs does not take any flags on its own, there is no way to | prevent it from doing the above walk. Perhaps a dedicated sysctl which | takes mount point id could do the walk instead, when asked. | | Short of making the walk optional I'm afraid this will have to be reverted. Just to be clear, this isn't breaking things but is not optimal for things that don't need this extra info. | > return (mp->mnt_op->vfs_statfs(mp, sbp)); | > } | > diff --git a/sys/sys/mount.h b/sys/sys/mount.h | > index 3383bfe8f431..edac64171f9a 100644 | > --- a/sys/sys/mount.h | > +++ b/sys/sys/mount.h | > @@ -91,7 +91,9 @@ struct statfs { | > uint64_t f_asyncwrites; /* count of async writes since mount */ | > uint64_t f_syncreads; /* count of sync reads since mount */ | > uint64_t f_asyncreads; /* count of async reads since mount */ | > - uint64_t f_spare[10]; /* unused spare */ | > + uint32_t f_nvnodelistsize; /* # of vnodes */ | > + uint32_t f_avnodecount; /* # of active vnodes */ | > + uint64_t f_spare[9]; /* unused spare */ | > uint32_t f_namemax; /* maximum filename length */ | > uid_t f_owner; /* user that mounted the filesystem */ | > fsid_t f_fsid; /* filesystem id */ | > Thanks, Doug A.