From nobody Mon Jun 13 16:43:31 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 2BF6E85BC70; Mon, 13 Jun 2022 16:43:34 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LMHSj34Xpz4mgv; Mon, 13 Jun 2022 16:43:33 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-lf1-x135.google.com with SMTP id a15so9759282lfb.9; Mon, 13 Jun 2022 09:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=fmut1ZvOsqT4cHhCZBBdIbVpZjEPOnjnQPKAZpHAJtM=; b=LDBQIFY7SW9ZwnfQWHfrLs50a2Jw21Lnzh8jxcEIa7ZgQxT8TueHDmvfDJvjF40Zrt xb6Heo0d41Uy848XRsICJMGbpJeUHhlOWBbgNh9neyARZ/3qnbM1dIjOm37I3HlOBb+P Hq72kI4prTIBKWQxwQ7Dm/6dISXPpGtuaca+r8PIeoTpIBloNy4b1ORtknB/wIy9J93q 1hlcCI8v/6mSzXkDdDe3rDUdItUCqx20StE7mj8cDWWWRmQi8H0bKjq+I4BEsfdjOE09 jiCw62FELhQaq+vElLMxlq1FZVP/C7GM8Qwq84kvgmfDNY7JUYR6ZHzKEGJzp8N8AIT5 yaSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=fmut1ZvOsqT4cHhCZBBdIbVpZjEPOnjnQPKAZpHAJtM=; b=Vrd8O1KzrxVs5vk02W5SUbczK/JPlo7t3YCCihs81aUzsp2uYhT79FZqxVd9KwTgf0 INBh+okWeCVROrX6mWFePlQ3M3HkmwF/w1Bs+Uwa4I58seWHJwjSN2i8xG6jwGT8KmtC DzUS1ktMgKseCefEUqEmzmTwH9Raf68hpXXZYZvCeV3DX9y77EbRKD5bjDwLbRtxq9yt TaJcIHLaP88Im5EPSu9ftVTcYb8g0io/Vd1FzkTn+LvyveCq0ePx6TMDj4fRKgNOwmKG +5V7KmPxswzEr/vs+YwcNXOmxQVFUBuSTn7iE2s4I3WFjEaFRg9rdNVQHJKhezQ90SWO +Wuw== X-Gm-Message-State: AJIora+o9zcDTgdggbEHw5C/lJX942eqCmY2KdK80U+E5ttEk+Q6bls8 3vGfoyl3HC7iDaOZ5NLFIaEL56ZBR3SznhGpNsB75neJ X-Google-Smtp-Source: AGRyM1sHHDw3fvFbco1QjACuF0SX9oV+ODBpeo5+6umIf3ljvGzi/LH4qhyFpX7xOQHl5+Q4iRUOqMuUXBJVqQ+qWEw= X-Received: by 2002:a05:6512:1150:b0:478:f60b:61d1 with SMTP id m16-20020a056512115000b00478f60b61d1mr449097lfg.8.1655138611835; Mon, 13 Jun 2022 09:43:31 -0700 (PDT) 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 Received: by 2002:aa6:c2d2:0:b0:1e6:e5ee:dbad with HTTP; Mon, 13 Jun 2022 09:43:31 -0700 (PDT) In-Reply-To: <202206131457.25DEvJDU044469@gitrepo.freebsd.org> References: <202206131457.25DEvJDU044469@gitrepo.freebsd.org> From: Mateusz Guzik Date: Mon, 13 Jun 2022 18:43:31 +0200 Message-ID: Subject: Re: git: 6468cd8e0ef9 - main - mount: add vnode usage per file system with mount -v To: Doug Ambrisko Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 4LMHSj34Xpz4mgv X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=LDBQIFY7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::135 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-3.36 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36:c]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[text/plain]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; TO_DN_SOME(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::135:from]; NEURAL_HAM_SHORT(-0.36)[-0.359]; MLMMJ_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim] X-ThisMailContainsUnwantedMimeParts: N 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. > 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 */ > -- Mateusz Guzik