Home | History | Annotate | Download | only in pstat
History log of /src/usr.sbin/pstat/pstat.c
RevisionDateAuthorComments
 1.134  17-Feb-2022  hannken Add a marker VUSECOUNT_VGET to v_usecount that gets set whenever
vcache_vget() or vache_tryvget() succeeds.

Use it to rerun VOP_INACTIVE() if another thread ran a vget()..vrele()
cycle while we inactivated our last reference.
 1.133  27-Nov-2021  rillig usr.sbin: remove unnecessary CONSTCOND, lint no longer needs it

Since 2021-01-31, lint no longer requires a CONSTCOND comment in a
do-while-0 statement since this is a common code pattern, especially in
statement-like macros.

sed -i -E 's,} while \(/\* ?CONSTCOND ?\*/ ?0\),} while (0),' */*.[ch]
 1.132  12-Apr-2021  mrg fix a buffer size (off by one), and fix all the comments for the
3 other correctly sized buffers with the same comment/context.
 1.131  03-Oct-2020  christos Filter out the VUSECOUNT_GATE bit
 1.130  11-Dec-2019  ad Report on whether vnodes are MPSAFE. For diagnosing perf problems.
 1.129  01-Dec-2019  ad Update to match change in layout of vnode LRU lists.
 1.128  04-May-2017  sevan branches: 1.128.10;
Drop main() prototype.
 1.127  17-Apr-2017  hannken branches: 1.127.2;
Cleanup after mountlist iterator:
- remove now unused field mnt_list.
- rename mount_list to mountlist and make it local to vfs_mount.c.
- make mountlist_lock local to vfs_mount.c.

Change pstat.c to retrieve vnodes by lru lists.
 1.126  11-Jan-2017  hannken branches: 1.126.2;
Move vnode member v_mntvnodes as vi_mntvnodes to vnode_impl.h.

Add an ugly hack so pstat.c may still traverse the list.
 1.125  20-Apr-2015  riastradh branches: 1.125.2;
Cull unused vnode v_iflags: VI_LAYER, VI_LOCKSHARE.
 1.124  26-May-2014  dholland Don't check lfs flags on ffs vnodes.
 1.123  24-Mar-2014  hannken branches: 1.123.2;
- Make VI_XLOCK, VI_CLEAN and VI_LOCKSHARE private to kern/vfs_*.c.
- Make vwait() static.
- Add vdead_check() to check a vnode for being or becoming dead.

Discussed on tech-kern.

Welcome to 6.99.38
 1.122  24-Nov-2013  mlelstv Fix fallout from circleq->tailq transition.
 1.121  19-Oct-2013  christos fix unused variable warnings.
 1.120  10-Nov-2012  apb The number of active vnodes may grow in between the sysctl call
that figures out the size, and the sysctl call that fetches the data.

Previously, any growth at all would have resulted in this error message:

pstat: sysctl: KERN_VNODE: Cannot allocate memory

Now allow for growth of 100 vnodes, or 5%, or both. Growth in
excess of 2% or 6000 vnodes has been observed in practice. Also
ignore ENOMEM from the second sysctl call, in case the growth was
even more than we anticipated.
 1.119  04-Jun-2012  riastradh branches: 1.119.2;
Kill the IN_RENAME in-core inode flag in ufs and ext2fs.

Now that rename works we need not to wave this sort of voodoo at it.

ok dholland
 1.118  31-Aug-2011  joerg branches: 1.118.2;
Use __dead
 1.117  04-Jan-2011  wiz Fix memory leak in error case. Found by cppcheck.
 1.116  19-Nov-2009  enami Prevent sign extension when reading device number in ufs1 on disk inode
so that devname(3) correctly converts it to device filename.
 1.115  16-Sep-2009  mlelstv Distinguish between UFS1 and UFS2 inodes by reading the ufsmount structure,
the previous heuristic of comparing the size fields of inode and dinode
failed.
 1.114  18-Apr-2009  lukem Fix WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare)
 1.113  11-Mar-2009  mrg convert getfiles() to use KERN_FILE2 sysctl.

now it can survive "struct file" changing, as is upcoming.
 1.112  08-Mar-2009  ad Don't bother with file_t::f_iflags any more, as it's not used.
Noted by mrg@.
 1.111  28-Dec-2008  christos branches: 1.111.2;
consistently print dev_t's
 1.110  21-Jul-2008  lukem branches: 1.110.4;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.109  27-Feb-2008  ad branches: 1.109.4;
+#define _KERNEL
+#include <sys/types.h>
+#undef _KERNEL
 1.108  11-Feb-2008  dyoung branches: 1.108.2;
Do not #include <sys/device.h> from userland.
 1.107  11-Feb-2008  ad Don't decode union vnodes or f_usecount. XXX A lot of this belongs to gdb.
 1.106  24-Jan-2008  ad specfs changes for PR kern/37717 (raidclose() is no longer called on
shutdown). There are still problems with device access and a PR will be
filed.

- Kill checkalias(). Allow multiple vnodes to reference a single device.

- Don't play dangerous tricks with block vnodes to ensure that only one
vnode can describe a block device. Instead, prohibit concurrent opens of
block devices. As a bonus remove the unreliable code that prevents
multiple file system mounts on the same device. It's no longer needed.

- Track opens by vnode and by device. Issue cdev_close() when the last open
goes away, instead of abusing vnode::v_usecount to tell if the device is
open.
 1.105  28-Dec-2007  ad Remove reference to VI_XWANT - it will be gone soon.
 1.104  09-Dec-2007  dogcow Turns out we don't actually need to include <sys/namei.h>; since it causes
a compile error, away it goes.
 1.103  19-Nov-2007  ad TS_ASLEEP is gone.
 1.102  20-Oct-2007  briggs If we're printing totals, don't do all the work of allocating and
copying down the vnodes.
 1.101  10-Oct-2007  ad Merge from vmlocking:

- Split vnode::v_flag into three fields, depending on field locking.
- simple_lock -> kmutex in a few places.
- Fix some simple locking problems.
 1.100  17-Jul-2007  christos branches: 1.100.4;
Kill MFSNAMELEN
 1.99  04-Mar-2007  he Because this program has _KERNEL defined while including some files,
it now needs <stdbool.h> due to the arm ports. Longer-term, this
program probably ought to be converted so that it no longer needs
to define _KERNEL.
 1.98  06-Jan-2007  daniel Correctly retrieve information from an ext2fs inode's dinode. Fixes
PR 21302.

Ack by christos.
 1.97  28-Dec-2006  xtraeme More NQNFS fallout (hi yamt!).
 1.96  20-Oct-2006  reinoud branches: 1.96.2; 1.96.6;
Replace the LIST structure mp->mnt_vnodelist to a TAILQ structure since all
vnodes were synced and processed backwards. This meant that the last
accessed node was processed first and the earlierst last.

An extra benefit is the removal of the ugly hack from the Berkly days on
LFS.

In the proces, i've also replaced the various variations hand written loops
by the TAILQ_FOREACH() macro's.
 1.95  25-May-2006  christos Coverity CID 3377: Fix memory leak on error.
 1.94  17-Mar-2006  elad Fix off-by-one found by Coverity, CID 1485.
 1.93  17-Mar-2006  elad Fix off-by-one found by Coverity, CID 1486.
 1.92  11-Sep-2005  rpaulo Don't print swap information when reading from kernel dumps. Fixes PR
13418 by Andrew Doran <ad@netbsd.org>.
 1.91  02-Sep-2005  rpaulo de-__P() and use ANSI function declarations.
 1.90  19-Aug-2005  christos 64 bit inode changes
 1.89  30-May-2005  christos catch up with kernel's constification.
 1.88  18-Dec-2004  christos branches: 1.88.2; 1.88.4; 1.88.6;
Use the array of dtype names instead of hand-rolling our own.
 1.87  09-Dec-2004  matt When dumping the file entry, print the usecount and iflags too.
 1.86  22-Feb-2004  jdc Make pstat -f work on sparc by adjusting the offset of the buffer passed
to sysctl in getfiles().

XXX: Possibly the correct fix is to make sysctl() not return an array which
contains structs with different alignment constraints.
 1.85  20-Dec-2003  mrg support "-g" and "-m" as well as "-k" and "-h". swapctl & swaplist code
from Martin Weber, adapted for pstat by myself.
 1.84  20-Dec-2003  mrg add a "-h" (humanize_number(3)) option to swapctl(8) and pstat(8), from
Martin Weber in PR#23805.

ps: now we only need someone to do ls(1) :-)
 1.83  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.82  02-Apr-2003  fvdl Add support for UFS2. UFS2 is an enhanced FFS, adding support for
64 bit block pointers, extended attribute storage, and a few
other things.

This commit does not yet include the code to manipulate the extended
storage (for e.g. ACLs), this will be done later.

Originally written by Kirk McKusick and Network Associates Laboratories for
FreeBSD.
 1.81  11-Feb-2003  mrg revert previous
 1.80  10-Feb-2003  mrg no need for "pstat -T" to copyout() the entire vnode list , which can
take a Long Time on systems with large numbers of vnodes.
 1.79  02-Feb-2003  christos undo mallocvar.h change!
 1.78  01-Feb-2003  tron Include "sys/mallocvar.h" with "_KERNEL" defined in time to avoid
build failure because MALLOC_DECLARE() is not defined.
 1.77  20-Jan-2003  simonb Grrr. So much for my ability to use grep(1) effectively. Pointed out
by Stephen Degler in private mail.
 1.76  20-Jan-2003  simonb The Double-Semi-Colon Police.
 1.75  11-Dec-2002  christos don't use hand-rolled MNT_FLAGS
 1.74  06-Nov-2002  jdolecek constify structs, print also pipes for -f
 1.73  26-Sep-2002  agc <sys/map.h> is no more - don't try to include it.
 1.72  24-Feb-2002  enami For pstat -f and -t, make header align with actual data on LP64 system.
 1.71  23-Feb-2002  enami Make flag bit to character conversion table driven.
 1.70  22-Feb-2002  enami Don't use same character for different flags.
 1.69  22-Feb-2002  enami Use getprogname().
 1.68  22-Feb-2002  enami Always free memroy allocated by loadvnodes().
 1.67  22-Feb-2002  enami Forgot to fix header for union/layer vnode.
 1.66  22-Feb-2002  enami Borrow the macro PRWORD() from vmstat.c and use it. Also, calculate the
width of pointer using sizeof(void *) * 2 instead of using 8.
 1.65  22-Feb-2002  enami No need to use paren here. Actually, the usage was inconsistient through
this file.
 1.64  22-Feb-2002  enami - Fix indentation.
- Wrap long line.
- Kill unnecessary empty line.
 1.63  21-Feb-2002  enami - Print number of pages in the vnode.
- Recognize VEXECMAP bit in vnode flags.
- Recognize IN_SPACECOUNTED in inode flags.
 1.62  26-Oct-2001  lukem remove #include <ufs/ufs/quota.h> where it was just to appease
<ufs/ufs/inode.h>, since the latter now includes the former. leave the former
in source that obviously uses specific bits of it (for completeness.)
 1.61  09-Jul-2001  ad errx() prints the newline for you.
 1.60  05-Jun-2001  mrg don't #define _LKM to work around header lossage; it is no longer necessary.
 1.59  11-Feb-2001  enami Don't rely on the struct e_vnode since it isn't a part of KERN_VNODE sysctl
interface and it actually breaks pstat -v on an architecture on which
compiler emits padding between the struct's members.
 1.58  11-Feb-2001  enami Protect statement macro with do { ... } while(0).
 1.57  05-Jan-2001  lukem use %ll_ instead of the less standard %q_
 1.56  13-Dec-2000  enami Print address of lower vnode of layered fs vnode.
 1.55  13-Dec-2000  enami Use va.va_type instead of va.va_mode to determine if a nfs vnode is a
deivce node or not, since latter contains permission bits only.
 1.54  02-Nov-2000  tron Adapt to the new line discipline scheme.
 1.53  11-Oct-2000  is More format string cleanups by sommerfeld.
 1.52  12-Jun-2000  assar branches: 1.52.2;
update list of ufs inode, nfs inode flags and tty disciplines to
reality. also sort them in the obvious order.
 1.51  14-Apr-2000  simonb branches: 1.51.2;
Don't declare 'extern opt*' getopt variables.
 1.50  18-Nov-1999  enami - Sync mount options and vnode flags with reality.
- Use i_e2fs_rdev.
- Print per filesystem data only if an inode is associated to the vnode.
 1.49  18-Nov-1999  enami Cosmetic changes; fix indentation and usage of white spaces.
 1.48  18-Nov-1999  enami The field to print vnode tag isn't necessary so wide.
 1.47  10-Oct-1999  mrg add a (long) cast to previous fix like the other arguments.
 1.46  01-Oct-1999  soren Account for widening of the v_usecount member in struct vnode.
 1.45  04-Jul-1999  fvdl branches: 1.45.2;
Update for mount flag change.
 1.44  31-Jan-1999  mrg branches: 1.44.2;
discard setgid.
 1.43  26-Jun-1998  tv Fix hannken's fix: The correct way to keep pstat.c from looking for any
"opt_*.h" files is to set a flag that tells the header files not to look for
anything in the kernel compile directory, i.e. _LKM.

Just rearranging includes doesn't work because it'll just break again,
eventually, as more stuff is defopted.
 1.42  26-Jun-1998  hannken Make it compile again. Include <sys/socket.h> before setting _KERNEL.
Otherwise the chain pstat.c -> <sys/mount.h> -> <sys/socket.h> fails
with 'opt_compat_freebsd.h: No such file or directory' ...
 1.41  29-Mar-1998  mycroft Display the TS_DIALOUT flag.
 1.40  21-Mar-1998  mycroft Replace TS_WOPEN with t_wopen, per mail on tech-kern.
 1.39  01-Mar-1998  fvdl Merge with Lite2 + local changes
 1.38  20-Oct-1997  drochner The previous changes were not sufficient, we need more kvm reads.
 1.37  20-Oct-1997  drochner make compile after NFS (struct nfsnode) changes
 1.36  19-Oct-1997  mrg fix compile warnings on the alpha.
 1.35  18-Oct-1997  lukem deprecate register
 1.34  17-Oct-1997  lukem WARNSify
 1.33  17-Oct-1997  mrg merge lite-2
 1.32  13-Jul-1997  kleink Fix list_swap() argument order; from Dan Winship <danw@mit.edu> in PR bin/3856.
 1.31  12-Jun-1997  mrg bring mrg-vm-swap2 onto mainilne.
 1.30  12-Jun-1997  bouyer Make this compile again, and add support for ext2fs.
Also 2 ufs->ffs conversions in pstat.8.
 1.29  05-Jun-1997  mikel indicate more clearly that [Tfstv] options are mutually exclusive;
fixes PR misc/2655.
 1.28  28-May-1997  pk branches: 1.28.2;
Display VDIROP vnode flag (so we're congruent with the man page).
 1.27  23-Oct-1996  cgd recognize MNT_NOCOREDUMP and print the 'nocoredump' flag for file
systems which have MNT_NOCOREDUMP set.
 1.26  23-Oct-1996  cgd add support for recognizing a bunch of flags which are in <sys/mount.h>
but which were never added to pstat -v: UNION, ASYNC, DEFEXPORTED,
EXPORTANON, EXKERB. Also, sort according to the apparent local style
(order in mount.h, rather than alphabetical).
 1.25  03-Jun-1996  cgd fix session pointer field width: make it two characters wider.
(The alpha will use all 8 chars.)
NOTE: use of (addr & ~KERNBASE) is VERY bogus.
 1.24  03-Jun-1996  cgd warnx() already outputs newline; warnings for undefined symbols don't
need an extra one.
 1.23  31-May-1996  cgd add case for STRIPDISC to the tty discipline printing code, so that
ttys running Metricom Wireless IP have their discipline printed nicely.
 1.22  30-May-1996  mrg remove unnecessary test.
 1.21  30-May-1996  mrg oops. print pstat -t header.
 1.20  30-May-1996  mrg use new ttylist to get tty stats.
 1.19  02-May-1996  cgd branches: 1.19.4;
handle the VISTTY vnode flag with the same letter ('I') that BSDI used.
Update the documentation of the vnode flags so that it lists only (and all)
of the flags understood by the program. (The documentation is likely in need
of more cleanup.)
 1.18  30-Apr-1996  pk Don't get distracted into kernel space.
Understand MNT_ROOTFS flag.
 1.17  21-Feb-1996  cgd fix for new NFS include files. (checked with fvdl.)
 1.16  11-Jan-1996  thorpej New-style RCS ids.
 1.15  28-Nov-1995  jtc merge in changes from 1.1 release branch
 1.14  24-Aug-1995  ragge branches: 1.14.2;
Cleaned up an old #ifdef vax.
 1.13  22-Jun-1995  cgd specify precision, not minimum field width. pointed out by John Kohl
 1.12  18-Jun-1995  cgd don't assume f_fstypename is larger than MFSNAMELEN or is nul-terminated
 1.11  28-Mar-1995  jtc KERNEL -> _KERNEL
 1.10  02-Mar-1995  chopps dd support for mfc serial ports..
 1.9  18-Jan-1995  mycroft Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.
 1.8  15-Jan-1995  mycroft Add `-k' option, per Matt Green.
Put the description of the `-n' option in the table, where it belongs. Also,
fix the formatting of the table for consistency with the other man pages.
Document the BLOCKSIZE environment variable.
 1.7  04-Jan-1995  mycroft Make the usage string match the man page.
 1.6  31-Aug-1994  mycroft Update to match include files.
 1.5  22-Jun-1994  chopps update for amiga (should also enable hp300 specific stuff for them too).
from rhealey@kas.helios.mn.org (Rob Healey)
 1.4  13-Jun-1994  cgd undo local changes relating to new FS code
 1.3  16-May-1994  deraadt netbsd-ify & repair tty code
 1.2  13-May-1994  cgd clean up import. rcsids, notdef a bunch of things that don't yet work, etc.
generates a *lot* of warnings (from vnode.h) at compile time, but these
will go away "soon."
 1.1  13-May-1994  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  10-May-1995  mrg 4.4BSD-Lite2
 1.1.1.1  13-May-1994  cgd Pstat, from Lite
 1.14.2.1  01-Nov-1995  jtc complete ufs -> ffs change (From John Kohl; PR #1403)
 1.19.4.3  03-Jun-1996  cgd pull up from trunk:
>fix session pointer field width: make it two characters wider.
>(The alpha will use all 8 chars.)
 1.19.4.2  03-Jun-1996  cgd pull up from trunk:
>warnx() already outputs newline; warnings for undefined symbols don't
>need an extra one.
 1.19.4.1  02-Jun-1996  mrg pull up tty stats "bug fix".
 1.28.2.2  01-Jun-1997  mrg use swap(8)'s list_swap().
 1.28.2.1  28-May-1997  mrg file pstat.c was added on branch mrg-vm-swap2 on 1997-06-01 09:05:31 +0000
 1.44.2.2  19-Oct-2000  he Pull up revision 1.53 (via patch, requested by he):
Format string cleanup.
 1.44.2.1  10-Oct-1999  cgd pull up rev 1.46 from trunk (requested by mycroft):
Fix potential overflow of v_usecount and v_writecount (and panics
resulting from this) by widening them to `long'. Mostly affects
systems where maxvnodes>=32768.
 1.45.2.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.51.2.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.52.2.1  17-Oct-2000  tv Pullup usr.sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.88.6.1  27-Mar-2009  msaitoh Pull up following revision(s) (requested by mrg in ticket #2000):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.88.4.1  27-Mar-2009  msaitoh Pull up following revision(s) (requested by mrg in ticket #2000):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.88.2.1  20-Mar-2009  msaitoh Pull up following revision(s) (requested by mrg in ticket #2000):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.96.6.1  27-Mar-2009  msaitoh Pull up following revision(s) (requested by mrg in ticket #1289):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.96.2.2  18-Oct-2009  bouyer Pull up following revision(s) (requested by mlelstv in ticket #1360):
usr.sbin/pstat/pstat.c: revision 1.115
Distinguish between UFS1 and UFS2 inodes by reading the ufsmount structure,
the previous heuristic of comparing the size fields of inode and dinode
failed.
 1.96.2.1  20-Mar-2009  msaitoh Pull up following revision(s) (requested by mrg in ticket #1289):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.100.4.3  23-Mar-2008  matt sync with HEAD
 1.100.4.2  09-Jan-2008  matt sync with HEAD
 1.100.4.1  06-Nov-2007  matt sync with HEAD
 1.108.2.1  24-Mar-2008  keiichi sync with head.
 1.109.4.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.110.4.3  26-Sep-2009  snj Pull up following revision(s) (requested by mlelstv in ticket #1019):
usr.sbin/pstat/pstat.c: revision 1.115
Distinguish between UFS1 and UFS2 inodes by reading the ufsmount structure,
the previous heuristic of comparing the size fields of inode and dinode
failed.
 1.110.4.2  15-Mar-2009  snj branches: 1.110.4.2.4;
Pull up following revision(s) (requested by mrg in ticket #566):
usr.sbin/pstat/pstat.c: revision 1.113
convert getfiles() to use KERN_FILE2 sysctl.
now it can survive "struct file" changing, as is upcoming.
 1.110.4.1  15-Mar-2009  snj Pull up following revision(s) (requested by mrg in ticket #566):
sys/kern/init_sysctl.c: revision 1.157
sys/kern/kern_descrip.c: revision 1.187
usr.sbin/pstat/pstat.c: revision 1.112
Don't bother with file_t::f_iflags any more, as it's not used.
Noted by mrg@.
 1.110.4.2.4.1  21-Apr-2010  matt sync to netbsd-5
 1.111.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.118.2.3  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.118.2.2  16-Jan-2013  yamt sync with (a bit old) head
 1.118.2.1  30-Oct-2012  yamt sync with head
 1.119.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.119.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.123.2.1  10-Aug-2014  tls Rebase.
 1.125.2.2  26-Apr-2017  pgoyette Sync with HEAD
 1.125.2.1  20-Mar-2017  pgoyette Sync with HEAD
 1.126.2.1  21-Apr-2017  bouyer Sync with HEAD
 1.127.2.1  11-May-2017  pgoyette Sync with HEAD
 1.128.10.1  08-Apr-2020  martin Merge changes from current as of 20200406

RSS XML Feed