CVS commit: src/sys/miscfs/procfs
Module Name:src Committed By: hannken Date: Thu Apr 13 09:54:18 UTC 2017 Modified Files: src/sys/miscfs/procfs: procfs_linux.c Log Message: Switch procfs_domounts() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/miscfs/procfs/procfs_linux.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/procfs/procfs_linux.c diff -u src/sys/miscfs/procfs/procfs_linux.c:1.72 src/sys/miscfs/procfs/procfs_linux.c:1.73 --- src/sys/miscfs/procfs/procfs_linux.c:1.72 Mon Mar 28 17:23:47 2016 +++ src/sys/miscfs/procfs/procfs_linux.c Thu Apr 13 09:54:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $ */ +/* $NetBSD: procfs_linux.c,v 1.73 2017/04/13 09:54:18 hannken Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.72 2016/03/28 17:23:47 mlelstv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: procfs_linux.c,v 1.73 2017/04/13 09:54:18 hannken Exp $"); #include #include @@ -603,26 +603,22 @@ procfs_domounts(struct lwp *curl, struct { char *bf, *mtab = NULL; size_t mtabsz = 0; - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; int error = 0, root = 0; struct cwdinfo *cwdi = curl->l_proc->p_cwdi; bf = malloc(LBFSZ, M_TEMP, M_WAITOK); - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { struct statvfs sfs; - if (vfs_busy(mp, )) - continue; - if ((error = dostatvfs(mp, , curl, MNT_WAIT, 0)) == 0) root |= procfs_format_sfs(, , bf, LBFSZ, , curl, 0); - - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); /* * If we are inside a chroot that is not itself a mount point,
CVS commit: src/sys/gdbscripts
Module Name:src Committed By: hannken Date: Thu Apr 13 09:52:18 UTC 2017 Modified Files: src/sys/gdbscripts: vchain Log Message: Change command mountdump to evaluate mountlist_entry. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/gdbscripts/vchain Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/gdbscripts/vchain diff -u src/sys/gdbscripts/vchain:1.8 src/sys/gdbscripts/vchain:1.9 --- src/sys/gdbscripts/vchain:1.8 Wed Dec 14 15:48:55 2016 +++ src/sys/gdbscripts/vchain Thu Apr 13 09:52:18 2017 @@ -1,4 +1,4 @@ -# $NetBSD: vchain,v 1.8 2016/12/14 15:48:55 hannken Exp $ +# $NetBSD: vchain,v 1.9 2017/04/13 09:52:18 hannken Exp $ # @(#)vchain 8.1 (Berkeley) 6/10/93 # @@ -53,14 +53,18 @@ print vnode chains for all mount points end define mountdump - set $mp=mountlist.tqh_first - while ($mp) - printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \ - $mp->mnt_stat->f_mntfromname, $mp->mnt_stat->f_mntonname, \ - $mp->mnt_op->vfs_name, $mp, $mp->mnt_data - set $mp=$mp->mnt_list.tqe_next - if ((const void *)$mp == (const void *)) - set $mp = 0 + set $me=mount_list.tqh_first + while ($me) + if ($me->me_type == ME_MOUNT) + set $mp = $me->me_mount + printf "%s on %s type %s, (mp 0x%x, privdata 0x%x)\n", \ + $mp->mnt_stat->f_mntfromname, \ + $mp->mnt_stat->f_mntonname, \ + $mp->mnt_op->vfs_name, $mp, $mp->mnt_data + end + set $me=$me->me_list.tqe_next + if ((const void *)$me == (const void *)_list) + set $me = 0 end end end
CVS commit: src/sys/compat/netbsd32
Module Name:src Committed By: hannken Date: Thu Apr 13 09:46:59 UTC 2017 Modified Files: src/sys/compat/netbsd32: netbsd32_compat_20.c Log Message: Switch compat_20_netbsd32_getfsstat() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/sys/compat/netbsd32/netbsd32_compat_20.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/netbsd32/netbsd32_compat_20.c diff -u src/sys/compat/netbsd32/netbsd32_compat_20.c:1.35 src/sys/compat/netbsd32/netbsd32_compat_20.c:1.36 --- src/sys/compat/netbsd32/netbsd32_compat_20.c:1.35 Tue Mar 28 18:44:04 2017 +++ src/sys/compat/netbsd32/netbsd32_compat_20.c Thu Apr 13 09:46:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_compat_20.c,v 1.35 2017/03/28 18:44:04 chs Exp $ */ +/* $NetBSD: netbsd32_compat_20.c,v 1.36 2017/04/13 09:46:59 hannken Exp $ */ /* * Copyright (c) 1998, 2001 Matthew R. Green @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.35 2017/03/28 18:44:04 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_20.c,v 1.36 2017/04/13 09:46:59 hannken Exp $"); #include #include @@ -85,7 +85,8 @@ compat_20_netbsd32_getfsstat(struct lwp } */ int root = 0; struct proc *p = l->l_proc; - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; struct statvfs *sb; struct netbsd32_statfs sb32; void *sfsp; @@ -95,32 +96,24 @@ compat_20_netbsd32_getfsstat(struct lwp sb = STATVFSBUF_GET(); maxcount = SCARG(uap, bufsize) / sizeof(struct netbsd32_statfs); sfsp = SCARG_P32(uap, buf); - mutex_enter(_lock); + mountlist_iterator_init(); count = 0; - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + while ((mp = mountlist_iterator_next(iter)) != NULL) { if (sfsp && count < maxcount) { error = dostatvfs(mp, sb, l, SCARG(uap, flags), 0); if (error) { -vfs_unbusy(mp, false, ); error = 0; continue; } compat_20_netbsd32_from_statvfs(sb, ); error = copyout(, sfsp, sizeof(sb32)); - if (error) { -vfs_unbusy(mp, false, NULL); + if (error) goto out; - } sfsp = (char *)sfsp + sizeof(sb32); root |= strcmp(sb->f_mntonname, "/") == 0; } count++; - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); if (root == 0 && p->p_cwdi->cwdi_rdir) { /* @@ -144,6 +137,7 @@ compat_20_netbsd32_getfsstat(struct lwp else *retval = count; out: + mountlist_iterator_destroy(iter); STATVFSBUF_PUT(sb); return error; }
CVS commit: src/sys/compat/ndis
Module Name:src Committed By: hannken Date: Thu Apr 13 09:44:48 UTC 2017 Modified Files: src/sys/compat/ndis: subr_ndis.c Log Message: Switch NdisOpenFile() to mountlist iterator. XXX: Do we need a function or variable to retrieve the root mount or NULL? To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/compat/ndis/subr_ndis.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ndis/subr_ndis.c diff -u src/sys/compat/ndis/subr_ndis.c:1.28 src/sys/compat/ndis/subr_ndis.c:1.29 --- src/sys/compat/ndis/subr_ndis.c:1.28 Tue Mar 25 16:23:58 2014 +++ src/sys/compat/ndis/subr_ndis.c Thu Apr 13 09:44:48 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_ndis.c,v 1.28 2014/03/25 16:23:58 christos Exp $ */ +/* $NetBSD: subr_ndis.c,v 1.29 2017/04/13 09:44:48 hannken Exp $ */ /*- * Copyright (c) 2003 @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ndis.c,v 1.67.2.7 2005/03/31 21:50:11 wpaul Exp $"); #endif #ifdef __NetBSD__ -__KERNEL_RCSID(0, "$NetBSD: subr_ndis.c,v 1.28 2014/03/25 16:23:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_ndis.c,v 1.29 2017/04/13 09:44:48 hannken Exp $"); #endif /* @@ -3042,6 +3042,8 @@ NdisOpenFile(ndis_status *status, ndis_h char *path; linker_file_t head, lf; void *kldstart, *kldend; + mount_iterator_t *iter; + struct mount *mp; ndis_unicode_to_ascii(filename->us_buf, filename->us_len, ); @@ -3094,7 +3096,10 @@ NdisOpenFile(ndis_status *status, ndis_h return; } - if (TAILQ_EMPTY()) { + mountlist_iterator_init(); + mp = mountlist_iterator_next(iter); + mountlist_iterator_destroy(iter); + if (mp == NULL) { ExFreePool(fh); *status = NDIS_STATUS_FILE_NOT_FOUND; printf("NDIS: could not find file %s in linker list\n",
CVS commit: src/sys/compat/common
Module Name:src Committed By: hannken Date: Thu Apr 13 09:41:28 UTC 2017 Modified Files: src/sys/compat/common: vfs_syscalls_20.c Log Message: Switch compat_20_sys_getfsstat() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/compat/common/vfs_syscalls_20.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/common/vfs_syscalls_20.c diff -u src/sys/compat/common/vfs_syscalls_20.c:1.39 src/sys/compat/common/vfs_syscalls_20.c:1.40 --- src/sys/compat/common/vfs_syscalls_20.c:1.39 Fri Jul 24 13:02:52 2015 +++ src/sys/compat/common/vfs_syscalls_20.c Thu Apr 13 09:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls_20.c,v 1.39 2015/07/24 13:02:52 maxv Exp $ */ +/* $NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.39 2015/07/24 13:02:52 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls_20.c,v 1.40 2017/04/13 09:41:28 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -203,7 +203,8 @@ compat_20_sys_getfsstat(struct lwp *l, c syscallarg(int) flags; } */ int root = 0; - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; struct statvfs *sbuf; struct statfs12 *sfsp; size_t count, maxcount; @@ -212,30 +213,21 @@ compat_20_sys_getfsstat(struct lwp *l, c sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK); maxcount = (size_t)SCARG(uap, bufsize) / sizeof(struct statfs12); sfsp = SCARG(uap, buf); - mutex_enter(_lock); count = 0; - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { if (sfsp && count < maxcount) { error = dostatvfs(mp, sbuf, l, SCARG(uap, flags), 0); - if (error) { -vfs_unbusy(mp, false, ); + if (error) continue; - } error = vfs2fs(sfsp, sbuf); - if (error) { -vfs_unbusy(mp, false, NULL); + if (error) goto out; - } sfsp++; root |= strcmp(sbuf->f_mntonname, "/") == 0; } count++; - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); if (root == 0 && l->l_proc->p_cwdi->cwdi_rdir) { /* * fake a root entry @@ -252,6 +244,7 @@ compat_20_sys_getfsstat(struct lwp *l, c else *retval = count; out: + mountlist_iterator_destroy(iter); free(sbuf, M_TEMP); return error; }
CVS commit: src/sys/compat/ultrix
Module Name:src Committed By: hannken Date: Thu Apr 13 09:18:18 UTC 2017 Modified Files: src/sys/compat/ultrix: ultrix_fs.c Log Message: Switch ultrix_sys_getmnt() to mountlist iterator. Really skip "start" items instead of a useless loop. Compile tested only. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/compat/ultrix/ultrix_fs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/ultrix/ultrix_fs.c diff -u src/sys/compat/ultrix/ultrix_fs.c:1.56 src/sys/compat/ultrix/ultrix_fs.c:1.57 --- src/sys/compat/ultrix/ultrix_fs.c:1.56 Fri Oct 23 19:40:11 2015 +++ src/sys/compat/ultrix/ultrix_fs.c Thu Apr 13 09:18:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ultrix_fs.c,v 1.56 2015/10/23 19:40:11 maxv Exp $ */ +/* $NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $ */ /* * Copyright (c) 1995, 1997 Jonathan Stone @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.56 2015/10/23 19:40:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ultrix_fs.c,v 1.57 2017/04/13 09:18:18 hannken Exp $"); #include #include @@ -206,9 +206,10 @@ make_ultrix_mntent(struct statvfs *sp, s int ultrix_sys_getmnt(struct lwp *l, const struct ultrix_sys_getmnt_args *uap, register_t *retval) { - struct mount *mp, *nmp; + struct mount *mp; struct statvfs *sp; struct ultrix_fs_data *sfsp; + mount_iterator_t *iter; char *path; int mntflags; int skip; @@ -216,7 +217,6 @@ ultrix_sys_getmnt(struct lwp *l, const s long count, maxcount; int error; - nmp = NULL; /* XXX keep gcc quiet */ path = NULL; error = 0; maxcount = SCARG(uap, bufsize) / sizeof(struct ultrix_fs_data); @@ -237,6 +237,7 @@ ultrix_sys_getmnt(struct lwp *l, const s if ((error = copyinstr(SCARG(uap, path), path, MAXPATHLEN, NULL)) != 0) goto bad; + skip = 0; maxcount = 1; } else { /* @@ -247,20 +248,14 @@ ultrix_sys_getmnt(struct lwp *l, const s if ((error = copyin((void *)SCARG(uap, start), , sizeof(*SCARG(uap, start != 0) goto bad; - mutex_enter(_lock); - for (skip = start, mp = TAILQ_FIRST(); - mp != NULL && skip-- > 0; - mp = TAILQ_NEXT(mp, mnt_list)) - continue; - mutex_exit(_lock); + skip = start; } - mutex_enter(_lock); - for (count = 0, mp = TAILQ_FIRST(); - mp != NULL && count < maxcount; mp = nmp) { - if (vfs_busy(mp, )) { + count = 0; + mountlist_iterator_init(); + while (count < maxcount && (mp = mountlist_iterator_next(iter))) { + if (skip-- > 0) continue; - } if (sfsp != NULL) { struct ultrix_fs_data tem; sp = >mnt_stat; @@ -281,16 +276,13 @@ ultrix_sys_getmnt(struct lwp *l, const s make_ultrix_mntent(sp, ); if ((error = copyout((void *), sfsp, sizeof(tem))) != 0) { - vfs_unbusy(mp, false, NULL); goto bad; } sfsp++; count++; } } - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); if (sfsp != NULL && count > maxcount) *retval = maxcount; @@ -298,6 +290,7 @@ ultrix_sys_getmnt(struct lwp *l, const s *retval = count; bad: + mountlist_iterator_destroy(iter); if (path) free(path, M_TEMP); return error;
CVS commit: src/sys/compat/osf1
Module Name:src Committed By: hannken Date: Thu Apr 13 09:17:55 UTC 2017 Modified Files: src/sys/compat/osf1: osf1_mount.c Log Message: Switch osf1_sys_getfsstat() to mountlist iterator. Compile tested only. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/compat/osf1/osf1_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/compat/osf1/osf1_mount.c diff -u src/sys/compat/osf1/osf1_mount.c:1.53 src/sys/compat/osf1/osf1_mount.c:1.54 --- src/sys/compat/osf1/osf1_mount.c:1.53 Fri Oct 23 19:40:11 2015 +++ src/sys/compat/osf1/osf1_mount.c Thu Apr 13 09:17:55 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: osf1_mount.c,v 1.53 2015/10/23 19:40:11 maxv Exp $ */ +/* $NetBSD: osf1_mount.c,v 1.54 2017/04/13 09:17:55 hannken Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.53 2015/10/23 19:40:11 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: osf1_mount.c,v 1.54 2017/04/13 09:17:55 hannken Exp $"); #include #include @@ -132,7 +132,8 @@ osf1_sys_fstatfs(struct lwp *l, const st int osf1_sys_getfsstat(struct lwp *l, const struct osf1_sys_getfsstat_args *uap, register_t *retval) { - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; struct statvfs *sp; struct osf1_statfs osfs; char *osf_sfsp; @@ -143,13 +144,9 @@ osf1_sys_getfsstat(struct lwp *l, const maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs); osf_sfsp = (void *)SCARG(uap, buf); - mutex_enter(_lock); - for (count = 0, mp = TAILQ_FIRST(); - mp != NULL; - mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + mountlist_iterator_init(); + count = 0; + while ((mp = mountlist_iterator_next(iter)) != NULL) { if (osf_sfsp && count < maxcount) { sp = >mnt_stat; /* @@ -164,16 +161,15 @@ osf1_sys_getfsstat(struct lwp *l, const osf1_cvt_statfs_from_native(sp, ); if ((error = copyout(, osf_sfsp, sizeof (struct osf1_statfs { - vfs_unbusy(mp, false, NULL); + mountlist_iterator_destroy(iter); return (error); } osf_sfsp += sizeof (struct osf1_statfs); } } count++; - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); if (osf_sfsp && count > maxcount) *retval = maxcount; else
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Apr 12 10:35:10 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c Log Message: Switch vfs_getvfs(), dounmount() and vfs_mountroot() to mountlist iterator. Add a helper to retrieve a mount with "highest generation < arg" and use it from vfs_unmount_forceone() and vfs_unmountall1(). To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.52 src/sys/kern/vfs_mount.c:1.53 --- src/sys/kern/vfs_mount.c:1.52 Tue Apr 11 07:46:37 2017 +++ src/sys/kern/vfs_mount.c Wed Apr 12 10:35:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.53 2017/04/12 10:35:10 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.53 2017/04/12 10:35:10 hannken Exp $"); #include #include @@ -234,11 +234,9 @@ vfs_getnewfsid(struct mount *mp) ++xxxfs_mntid; tfsid.__fsid_val[0] = makedev(mtype & 0xff, xxxfs_mntid); tfsid.__fsid_val[1] = mtype; - if (!TAILQ_EMPTY()) { - while (vfs_getvfs()) { - tfsid.__fsid_val[0]++; - xxxfs_mntid++; - } + while (vfs_getvfs()) { + tfsid.__fsid_val[0]++; + xxxfs_mntid++; } mp->mnt_stat.f_fsidx.__fsid_val[0] = tfsid.__fsid_val[0]; mp->mnt_stat.f_fsid = mp->mnt_stat.f_fsidx.__fsid_val[0]; @@ -253,17 +251,18 @@ vfs_getnewfsid(struct mount *mp) struct mount * vfs_getvfs(fsid_t *fsid) { + mount_iterator_t *iter; struct mount *mp; - mutex_enter(_lock); - TAILQ_FOREACH(mp, , mnt_list) { + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { if (mp->mnt_stat.f_fsidx.__fsid_val[0] == fsid->__fsid_val[0] && mp->mnt_stat.f_fsidx.__fsid_val[1] == fsid->__fsid_val[1]) { - mutex_exit(_lock); - return (mp); + mountlist_iterator_destroy(iter); + return mp; } } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); return NULL; } @@ -832,6 +831,7 @@ err_unmounted: int dounmount(struct mount *mp, int flags, struct lwp *l) { + mount_iterator_t *iter; struct mount *cmp; vnode_t *coveredvp; int error, async, used_syncer, used_extattr; @@ -845,14 +845,14 @@ dounmount(struct mount *mp, int flags, s /* * No unmount below layered mounts. */ - mutex_enter(_lock); - TAILQ_FOREACH(cmp, , mnt_list) { + mountlist_iterator_init(); + while ((cmp = mountlist_iterator_next(iter)) != NULL) { if (cmp->mnt_lower == mp) { - mutex_exit(_lock); + mountlist_iterator_destroy(iter); return EBUSY; } } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); /* * XXX Freeze syncer. Must do this before locking the @@ -983,38 +983,57 @@ vfs_unmount_print(struct mount *mp, cons mp->mnt_stat.f_fstypename); } -bool -vfs_unmount_forceone(struct lwp *l) +/* + * Return the mount with the highest generation less than "gen". + */ +static struct mount * +vfs_unmount_next(uint64_t gen) { + mount_iterator_t *iter; struct mount *mp, *nmp; - int error; nmp = NULL; - TAILQ_FOREACH_REVERSE(mp, , mntlist, mnt_list) { - if (nmp == NULL || mp->mnt_gen > nmp->mnt_gen) { + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { + if ((nmp == NULL || mp->mnt_gen > nmp->mnt_gen) && + mp->mnt_gen < gen) { + if (nmp != NULL) +vfs_destroy(nmp); nmp = mp; + atomic_inc_uint(>mnt_refcnt); } } - if (nmp == NULL) { + mountlist_iterator_destroy(iter); + + return nmp; +} + +bool +vfs_unmount_forceone(struct lwp *l) +{ + struct mount *mp; + int error; + + mp = vfs_unmount_next(mountgen); + if (mp == NULL) { return false; } #ifdef DEBUG printf("forcefully unmounting %s (%s)...\n", - nmp->mnt_stat.f_mntonname, nmp->mnt_stat.f_mntfromname); + mp->mnt_stat.f_mntonname, mp->mnt_stat.f_mntfromname); #endif - atomic_inc_uint(>mnt_refcnt); - if ((error = dounmount(nmp, MNT_FORCE, l)) == 0) { - vfs_unmount_print(nmp, "forcefully "); + if ((error = dounmount(mp, MNT_FORCE, l)) == 0) { + vfs_unmount_print(mp, "forcefully "); return true; } else { - vfs_destroy(nmp); + vfs_destroy(mp); } #ifdef DEBUG printf("forceful unmount of %s failed with error %d\n", - nmp->mnt_stat.f_mntonname, error); + mp->mnt_stat.f_mntonname, error); #endif return false; @@ -1023,17 +1042,23 @@ vfs_unmount_forceone(struct lwp *l) bool vfs_unmountall1(struct lwp *l, bool force, bool verbose) { - struct mount *mp, *nmp; + struct mount *mp; bool any_error = false, progress = false; + uint64_t gen; int error; - TAILQ_FOREACH_REVERSE_SAFE(mp, , mntlist, mnt_list, nmp) { + gen = mountgen; + for (;;) { + mp =
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Apr 12 10:30:02 UTC 2017 Modified Files: src/sys/kern: kern_veriexec.c Log Message: Switch veriexec_dump() and veriexec_flush() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/kern/kern_veriexec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_veriexec.c diff -u src/sys/kern/kern_veriexec.c:1.11 src/sys/kern/kern_veriexec.c:1.12 --- src/sys/kern/kern_veriexec.c:1.11 Tue Aug 4 12:44:04 2015 +++ src/sys/kern/kern_veriexec.c Wed Apr 12 10:30:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $ */ +/* $NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $ */ /*- * Copyright (c) 2005, 2006 Elad Efrat@@ -29,7 +29,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.11 2015/08/04 12:44:04 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_veriexec.c,v 1.12 2017/04/12 10:30:02 hannken Exp $"); #include "opt_veriexec.h" @@ -1363,20 +1363,15 @@ veriexec_file_dump(struct veriexec_file_ int veriexec_dump(struct lwp *l, prop_array_t rarray) { - struct mount *mp, *nmp; - - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - /* If it fails, the file-system is [being] unmounted. */ - if (vfs_busy(mp, ) != 0) - continue; + mount_iterator_t *iter; + struct mount *mp; + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { fileassoc_table_run(mp, veriexec_hook, (fileassoc_cb_t)veriexec_file_dump, rarray); - - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); return (0); } @@ -1384,24 +1379,19 @@ veriexec_dump(struct lwp *l, prop_array_ int veriexec_flush(struct lwp *l) { - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; int error = 0; - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { int lerror; - /* If it fails, the file-system is [being] unmounted. */ - if (vfs_busy(mp, ) != 0) - continue; - lerror = veriexec_table_delete(l, mp); if (lerror && lerror != ENOENT) error = lerror; - - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); return (error); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Apr 12 10:28:39 UTC 2017 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Switch do_sys_sync() and do_sys_getvfsstat() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.509 -r1.510 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.509 src/sys/kern/vfs_syscalls.c:1.510 --- src/sys/kern/vfs_syscalls.c:1.509 Tue Mar 7 11:54:16 2017 +++ src/sys/kern/vfs_syscalls.c Wed Apr 12 10:28:39 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.510 2017/04/12 10:28:39 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.510 2017/04/12 10:28:39 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -641,14 +641,12 @@ struct ctldebug debug0 = { "syncprt", void do_sys_sync(struct lwp *l) { - struct mount *mp, *nmp; + mount_iterator_t *iter; + struct mount *mp; int asyncflag; - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { fstrans_start(mp, FSTRANS_SHARED); mutex_enter(>mnt_updating); if ((mp->mnt_flag & MNT_RDONLY) == 0) { @@ -660,9 +658,8 @@ do_sys_sync(struct lwp *l) } mutex_exit(>mnt_updating); fstrans_done(mp); - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); #ifdef DEBUG if (syncprt) vfs_bufstats(); @@ -1251,39 +1248,32 @@ do_sys_getvfsstat(struct lwp *l, void *s register_t *retval) { int root = 0; + mount_iterator_t *iter; struct proc *p = l->l_proc; - struct mount *mp, *nmp; + struct mount *mp; struct statvfs *sb; size_t count, maxcount; int error = 0; sb = STATVFSBUF_GET(); maxcount = bufsize / entry_sz; - mutex_enter(_lock); count = 0; - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { if (sfsp && count < maxcount) { error = dostatvfs(mp, sb, l, flags, 0); if (error) { -vfs_unbusy(mp, false, ); error = 0; continue; } error = copyfn(sb, sfsp, entry_sz); - if (error) { -vfs_unbusy(mp, false, NULL); + if (error) goto out; - } sfsp = (char *)sfsp + entry_sz; root |= strcmp(sb->f_mntonname, "/") == 0; } count++; - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); if (root == 0 && p->p_cwdi->cwdi_rdir) { /* @@ -1305,6 +1295,7 @@ do_sys_getvfsstat(struct lwp *l, void *s else *retval = count; out: + mountlist_iterator_destroy(iter); STATVFSBUF_PUT(sb); return error; }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Apr 12 10:26:33 UTC 2017 Modified Files: src/sys/kern: vfs_subr.c Log Message: Switch vfs_vnode_lock_print() and printlockedvnodes() to _mountlist_next(). Switch sched_sync() and sysctl_kern_vnode() to mountlist iterator. To generate a diff of this commit: cvs rdiff -u -r1.461 -r1.462 src/sys/kern/vfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.461 src/sys/kern/vfs_subr.c:1.462 --- src/sys/kern/vfs_subr.c:1.461 Fri Mar 31 08:38:14 2017 +++ src/sys/kern/vfs_subr.c Wed Apr 12 10:26:33 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.461 2017/03/31 08:38:14 msaitoh Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.462 2017/04/12 10:26:33 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.461 2017/03/31 08:38:14 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.462 2017/04/12 10:26:33 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -759,9 +759,10 @@ lazy_sync_vnode(struct vnode *vp) void sched_sync(void *arg) { + mount_iterator_t *iter; synclist_t *slp; struct vnode *vp; - struct mount *mp, *nmp; + struct mount *mp; time_t starttime; bool synced; @@ -773,23 +774,19 @@ sched_sync(void *arg) /* * Sync mounts whose dirty time has expired. */ - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { if ((mp->mnt_iflag & IMNT_ONWORKLIST) == 0 || mp->mnt_synclist_slot != syncer_delayno) { -nmp = TAILQ_NEXT(mp, mnt_list); continue; } mp->mnt_synclist_slot = sync_delay_slot(sync_delay(mp)); - if (vfs_busy(mp, )) -continue; if (fstrans_start_nowait(mp, FSTRANS_SHARED) == 0) { VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred); fstrans_done(mp); } - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); mutex_enter(_data_lock); @@ -967,8 +964,9 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) { char *where = oldp; size_t *sizep = oldlenp; - struct mount *mp, *nmp; + struct mount *mp; vnode_t *vp, vbuf; + mount_iterator_t *iter; struct vnode_iterator *marker; char *bp = where; char *ewhere; @@ -988,17 +986,14 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) ewhere = where + *sizep; sysctl_unlock(); - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + mountlist_iterator_init(); + while ((mp = mountlist_iterator_next(iter)) != NULL) { vfs_vnode_iterator_init(mp, ); while ((vp = vfs_vnode_iterator_next(marker, NULL, NULL))) { if (bp + VPTRSZ + VNODESZ > ewhere) { vrele(vp); vfs_vnode_iterator_destroy(marker); -vfs_unbusy(mp, false, NULL); +mountlist_iterator_destroy(iter); sysctl_relock(); *sizep = bp - where; return (ENOMEM); @@ -1008,7 +1003,7 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) (error = copyout(, bp + VPTRSZ, VNODESZ))) { vrele(vp); vfs_vnode_iterator_destroy(marker); -vfs_unbusy(mp, false, NULL); +mountlist_iterator_destroy(iter); sysctl_relock(); return (error); } @@ -1016,9 +1011,8 @@ sysctl_kern_vnode(SYSCTLFN_ARGS) bp += VPTRSZ + VNODESZ; } vfs_vnode_iterator_destroy(marker); - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); + mountlist_iterator_destroy(iter); sysctl_relock(); *sizep = bp - where; @@ -1549,7 +1543,7 @@ vfs_vnode_lock_print(void *vlock, int fu struct mount *mp; vnode_impl_t *vip; - TAILQ_FOREACH(mp, , mnt_list) { + for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp)) { TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) { if (>vi_lock != vlock) continue; @@ -1656,25 +1650,18 @@ void printlockedvnodes(void); void printlockedvnodes(void) { - struct mount *mp, *nmp; + struct mount *mp; vnode_t *vp; vnode_impl_t *vip; printf("Locked vnodes\n"); - mutex_enter(_lock); - for (mp = TAILQ_FIRST(); mp != NULL; mp = nmp) { - if (vfs_busy(mp, )) { - continue; - } + for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp)) { TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) { vp = VIMPL_TO_VNODE(vip); if (VOP_ISLOCKED(vp)) vprint(NULL, vp); } - mutex_enter(_lock); - vfs_unbusy(mp, false, ); } - mutex_exit(_lock); } #endif /* DDB || DEBUGPRINT */
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Apr 12 10:23:35 UTC 2017 Modified Files: src/sys/kern: vfs_trans.c Log Message: Switch fstrans_dump() to _mountlist_next(). To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.40 src/sys/kern/vfs_trans.c:1.41 --- src/sys/kern/vfs_trans.c:1.40 Thu Mar 30 09:13:01 2017 +++ src/sys/kern/vfs_trans.c Wed Apr 12 10:23:35 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.41 2017/04/12 10:23:35 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.41 2017/04/12 10:23:35 hannken Exp $"); /* * File system transaction operations. @@ -871,7 +871,7 @@ fstrans_dump(int full) fstrans_print_lwp(p, l, full == 1); printf("Fstrans state by mount:\n"); - TAILQ_FOREACH(mp, , mnt_list) + for (mp = _mountlist_next(NULL); mp; mp = _mountlist_next(mp)) fstrans_print_mount(mp, full == 1); } #endif /* defined(DDB) */
CVS commit: src/sys/miscfs
Module Name:src Committed By: hannken Date: Tue Apr 11 07:51:37 UTC 2017 Modified Files: src/sys/miscfs/genfs: layer.h layer_vfsops.c src/sys/miscfs/nullfs: null.h null_vfsops.c src/sys/miscfs/overlay: overlay.h overlay_vfsops.c src/sys/miscfs/umapfs: umap.h umap_vfsops.c Log Message: Field "layerm_vfs" of "struct layer_mount" got superseded by "mnt_lower". Adapt consumers and remove the now unused field. Ride 7.99.68 To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/miscfs/genfs/layer.h cvs rdiff -u -r1.48 -r1.49 src/sys/miscfs/genfs/layer_vfsops.c cvs rdiff -u -r1.19 -r1.20 src/sys/miscfs/nullfs/null.h cvs rdiff -u -r1.93 -r1.94 src/sys/miscfs/nullfs/null_vfsops.c cvs rdiff -u -r1.8 -r1.9 src/sys/miscfs/overlay/overlay.h cvs rdiff -u -r1.66 -r1.67 src/sys/miscfs/overlay/overlay_vfsops.c cvs rdiff -u -r1.16 -r1.17 src/sys/miscfs/umapfs/umap.h cvs rdiff -u -r1.98 -r1.99 src/sys/miscfs/umapfs/umap_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/layer.h diff -u src/sys/miscfs/genfs/layer.h:1.16 src/sys/miscfs/genfs/layer.h:1.17 --- src/sys/miscfs/genfs/layer.h:1.16 Wed May 28 10:51:20 2014 +++ src/sys/miscfs/genfs/layer.h Tue Apr 11 07:51:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer.h,v 1.16 2014/05/28 10:51:20 hannken Exp $ */ +/* $NetBSD: layer.h,v 1.17 2017/04/11 07:51:37 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -79,7 +79,6 @@ struct layer_args { #ifdef _KERNEL struct layer_mount { - struct mount *layerm_vfs; struct vnode *layerm_rootvp; /* Ref to root layer_node */ u_int layerm_flags; /* mount point layer flags */ u_int layerm_size; /* size of fs's struct node */ Index: src/sys/miscfs/genfs/layer_vfsops.c diff -u src/sys/miscfs/genfs/layer_vfsops.c:1.48 src/sys/miscfs/genfs/layer_vfsops.c:1.49 --- src/sys/miscfs/genfs/layer_vfsops.c:1.48 Thu Mar 30 09:16:52 2017 +++ src/sys/miscfs/genfs/layer_vfsops.c Tue Apr 11 07:51:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vfsops.c,v 1.48 2017/03/30 09:16:52 hannken Exp $ */ +/* $NetBSD: layer_vfsops.c,v 1.49 2017/04/11 07:51:37 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.48 2017/03/30 09:16:52 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vfsops.c,v 1.49 2017/04/11 07:51:37 hannken Exp $"); #include #include @@ -127,7 +127,7 @@ layerfs_start(struct mount *mp, int flag { #ifdef notyet - return VFS_START(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, flags); + return VFS_START(mp->mnt_lower, flags); #else return 0; #endif @@ -156,7 +156,7 @@ int layerfs_quotactl(struct mount *mp, struct quotactl_args *args) { - return VFS_QUOTACTL(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, args); + return VFS_QUOTACTL(mp->mnt_lower, args); } int @@ -169,7 +169,7 @@ layerfs_statvfs(struct mount *mp, struct if (sbuf == NULL) { return ENOMEM; } - error = VFS_STATVFS(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, sbuf); + error = VFS_STATVFS(mp->mnt_lower, sbuf); if (error) { goto done; } @@ -249,7 +249,7 @@ layerfs_vget(struct mount *mp, ino_t ino struct vnode *vp; int error; - error = VFS_VGET(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, ino, ); + error = VFS_VGET(mp->mnt_lower, ino, ); if (error) { *vpp = NULL; return error; @@ -276,7 +276,7 @@ layerfs_fhtovp(struct mount *mp, struct struct vnode *vp; int error; - error = VFS_FHTOVP(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, fidp, ); + error = VFS_FHTOVP(mp->mnt_lower, fidp, ); if (error) { *vpp = NULL; return error; @@ -381,12 +381,12 @@ int layerfs_renamelock_enter(struct mount *mp) { - return VFS_RENAMELOCK_ENTER(MOUNTTOLAYERMOUNT(mp)->layerm_vfs); + return VFS_RENAMELOCK_ENTER(mp->mnt_lower); } void layerfs_renamelock_exit(struct mount *mp) { - VFS_RENAMELOCK_EXIT(MOUNTTOLAYERMOUNT(mp)->layerm_vfs); + VFS_RENAMELOCK_EXIT(mp->mnt_lower); } Index: src/sys/miscfs/nullfs/null.h diff -u src/sys/miscfs/nullfs/null.h:1.19 src/sys/miscfs/nullfs/null.h:1.20 --- src/sys/miscfs/nullfs/null.h:1.19 Fri Jul 2 03:16:01 2010 +++ src/sys/miscfs/nullfs/null.h Tue Apr 11 07:51:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: null.h,v 1.19 2010/07/02 03:16:01 rmind Exp $ */ +/* $NetBSD: null.h,v 1.20 2017/04/11 07:51:37 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -83,7 +83,6 @@ struct null_args { struct null_mount { struct layer_mount lm; /* generic layerfs mount stuff */ }; -#define nullm_vfs lm.layerm_vfs #define nullm_rootvp lm.layerm_rootvp #define nullm_export lm.layerm_export #define nullm_flags lm.layerm_flags Index: src/sys/miscfs/nullfs/null_vfsops.c diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.93 src/sys/miscfs/nullfs/null_vfsops.c:1.94 ---
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Tue Apr 11 07:46:38 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c src/sys/sys: mount.h Log Message: Add an iterator over the currently mounted file systems. Ride 7.99.68 To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.221 -r1.222 src/sys/sys/mount.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.51 src/sys/kern/vfs_mount.c:1.52 --- src/sys/kern/vfs_mount.c:1.51 Thu Mar 30 09:13:01 2017 +++ src/sys/kern/vfs_mount.c Tue Apr 11 07:46:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.52 2017/04/11 07:46:37 hannken Exp $"); #include #include @@ -94,6 +94,22 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c, #include #include +enum mountlist_type { + ME_MOUNT, + ME_MARKER +}; +struct mountlist_entry { + TAILQ_ENTRY(mountlist_entry) me_list; /* Mount list. */ + struct mount *me_mount; /* Actual mount if ME_MOUNT, + current mount else. */ + enum mountlist_type me_type; /* Mount or marker. */ +}; +struct mount_iterator { + struct mountlist_entry mi_entry; +}; + +static TAILQ_HEAD(mountlist, mountlist_entry) mount_list; + static struct vnode *vfs_vnode_iterator_next1(struct vnode_iterator *, bool (*)(void *, struct vnode *), void *, bool); @@ -119,6 +135,7 @@ void vfs_mount_sysinit(void) { + TAILQ_INIT(_list); TAILQ_INIT(); mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); @@ -769,9 +786,7 @@ mount_domount(struct lwp *l, vnode_t **v cache_purge(vp); mp->mnt_iflag &= ~IMNT_WANTRDWR; - mutex_enter(_lock); - TAILQ_INSERT_TAIL(, mp, mnt_list); - mutex_exit(_lock); + mountlist_append(mp); if ((mp->mnt_flag & (MNT_RDONLY | MNT_ASYNC)) == 0) vfs_syncer_add_to_worklist(mp); vp->v_mountedhere = mp; @@ -931,9 +946,7 @@ dounmount(struct mount *mp, int flags, s coveredvp->v_mountedhere = NULL; VOP_UNLOCK(coveredvp); } - mutex_enter(_lock); - TAILQ_REMOVE(, mp, mnt_list); - mutex_exit(_lock); + mountlist_remove(mp); if (TAILQ_FIRST(>mnt_vnodelist) != NULL) panic("unmount: dangling vnode"); if (used_syncer) @@ -1439,10 +1452,156 @@ makefstype(const char *type) return rv; } +static struct mountlist_entry * +mountlist_alloc(enum mountlist_type type, struct mount *mp) +{ + struct mountlist_entry *me; + + me = kmem_zalloc(sizeof(*me), KM_SLEEP); + me->me_mount = mp; + me->me_type = type; + + return me; +} + +static void +mountlist_free(struct mountlist_entry *me) +{ + + kmem_free(me, sizeof(*me)); +} + +void +mountlist_iterator_init(mount_iterator_t **mip) +{ + struct mountlist_entry *me; + + me = mountlist_alloc(ME_MARKER, NULL); + mutex_enter(_lock); + TAILQ_INSERT_HEAD(_list, me, me_list); + mutex_exit(_lock); + *mip = (mount_iterator_t *)me; +} + +void +mountlist_iterator_destroy(mount_iterator_t *mi) +{ + struct mountlist_entry *marker = >mi_entry; + + if (marker->me_mount != NULL) + vfs_unbusy(marker->me_mount, false, NULL); + + mutex_enter(_lock); + TAILQ_REMOVE(_list, marker, me_list); + mutex_exit(_lock); + + mountlist_free(marker); + +} + +/* + * Return the next mount or NULL for this iterator. + * Mark it busy on success. + */ +struct mount * +mountlist_iterator_next(mount_iterator_t *mi) +{ + struct mountlist_entry *me, *marker = >mi_entry; + struct mount *mp; + + if (marker->me_mount != NULL) { + vfs_unbusy(marker->me_mount, false, NULL); + marker->me_mount = NULL; + } + + mutex_enter(_lock); + for (;;) { + KASSERT(marker->me_type == ME_MARKER); + + me = TAILQ_NEXT(marker, me_list); + if (me == NULL) { + /* End of list: keep marker and return. */ + mutex_exit(_lock); + return NULL; + } + TAILQ_REMOVE(_list, marker, me_list); + TAILQ_INSERT_AFTER(_list, me, marker, me_list); + + /* Skip other markers. */ + if (me->me_type != ME_MOUNT) + continue; + + /* Take an initial reference for vfs_busy() below. */ + mp = me->me_mount; + KASSERT(mp != NULL); + atomic_inc_uint(>mnt_refcnt); + mutex_exit(_lock); + + /* Try to mark this mount busy and return on success. */ + if (vfs_busy(mp, NULL) == 0) { + vfs_destroy(mp); + marker->me_mount = mp; + return mp; + } + vfs_destroy(mp); + mutex_enter(_lock); + } +} + +/* + * Attach new mount to the end of the mount list. + */ void mountlist_append(struct mount *mp) { + struct mountlist_entry *me; + + me = mountlist_alloc(ME_MOUNT, mp); mutex_enter(_lock); + TAILQ_INSERT_TAIL(_list, me, me_list); TAILQ_INSERT_TAIL(, mp,
CVS commit: src/sys/fs/v7fs
Module Name:src Committed By: hannken Date: Sat Apr 8 08:51:02 UTC 2017 Modified Files: src/sys/fs/v7fs: v7fs_vnops.c Log Message: Update mtime when updating file size. PR kern/51762 (mtime not updated by open(O_TRUNC)) To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/fs/v7fs/v7fs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/v7fs/v7fs_vnops.c diff -u src/sys/fs/v7fs/v7fs_vnops.c:1.22 src/sys/fs/v7fs/v7fs_vnops.c:1.23 --- src/sys/fs/v7fs/v7fs_vnops.c:1.22 Sat Aug 20 12:37:08 2016 +++ src/sys/fs/v7fs/v7fs_vnops.c Sat Apr 8 08:51:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: v7fs_vnops.c,v 1.22 2016/08/20 12:37:08 hannken Exp $ */ +/* $NetBSD: v7fs_vnops.c,v 1.23 2017/04/08 08:51:02 hannken Exp $ */ /*- * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.22 2016/08/20 12:37:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: v7fs_vnops.c,v 1.23 2017/04/08 08:51:02 hannken Exp $"); #if defined _KERNEL_OPT #include "opt_v7fs.h" #endif @@ -499,8 +499,11 @@ v7fs_setattr(void *v) /* File size change. */ if ((vap->va_size != VNOVAL) && (vp->v_type == VREG)) { error = v7fs_datablock_size_change(fs, vap->va_size, inode); - if (error == 0) + if (error == 0) { uvm_vnp_setsize(vp, vap->va_size); + v7node->update_mtime = true; + v7node->update_ctime = true; + } } uid_t uid = inode->uid; gid_t gid = inode->gid;
CVS commit: src/sys/fs/puffs
Module Name:src Committed By: hannken Date: Sat Apr 8 08:49:44 UTC 2017 Modified Files: src/sys/fs/puffs: puffs_vnops.c Log Message: Update mtime when updating file size. PR kern/51762 (mtime not updated by open(O_TRUNC)) To generate a diff of this commit: cvs rdiff -u -r1.207 -r1.208 src/sys/fs/puffs/puffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/puffs/puffs_vnops.c diff -u src/sys/fs/puffs/puffs_vnops.c:1.207 src/sys/fs/puffs/puffs_vnops.c:1.208 --- src/sys/fs/puffs/puffs_vnops.c:1.207 Thu Apr 6 00:02:19 2017 +++ src/sys/fs/puffs/puffs_vnops.c Sat Apr 8 08:49:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: puffs_vnops.c,v 1.207 2017/04/06 00:02:19 christos Exp $ */ +/* $NetBSD: puffs_vnops.c,v 1.208 2017/04/08 08:49:44 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.207 2017/04/06 00:02:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.208 2017/04/08 08:49:44 hannken Exp $"); #include #include @@ -1252,6 +1252,7 @@ dosetattr(struct vnode *vp, struct vattr pn->pn_serversize = vap->va_size; if (flags & SETATTR_CHSIZE) uvm_vnp_setsize(vp, vap->va_size); + puffs_updatenode(pn, PUFFS_UPDATECTIME | PUFFS_UPDATEMTIME, 0); } return 0;
CVS commit: src/sys/coda
Module Name:src Committed By: hannken Date: Tue Apr 4 07:36:38 UTC 2017 Modified Files: src/sys/coda: coda_vfsops.c Log Message: Use spec_node_lookup_by_dev() and spec_node_getmountedfs() to retrieve a mount by device. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/sys/coda/coda_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/coda/coda_vfsops.c diff -u src/sys/coda/coda_vfsops.c:1.85 src/sys/coda/coda_vfsops.c:1.86 --- src/sys/coda/coda_vfsops.c:1.85 Fri Feb 17 08:31:23 2017 +++ src/sys/coda/coda_vfsops.c Tue Apr 4 07:36:38 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: coda_vfsops.c,v 1.85 2017/02/17 08:31:23 hannken Exp $ */ +/* $NetBSD: coda_vfsops.c,v 1.86 2017/04/04 07:36:38 hannken Exp $ */ /* * @@ -45,7 +45,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.85 2017/02/17 08:31:23 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: coda_vfsops.c,v 1.86 2017/04/04 07:36:38 hannken Exp $"); #include #include @@ -624,23 +624,20 @@ getNewVnode(struct vnode **vpp) NULL, NULL); } -#include -#include -/* get the mount structure corresponding to a given device. Assume - * device corresponds to a UFS. Return NULL if no device is found. +/* Get the mount structure corresponding to a given device. + * Return NULL if no device is found or the device is not mounted. */ struct mount *devtomp(dev_t dev) { struct mount *mp; +struct vnode *vp; -mutex_enter(_lock); -TAILQ_FOREACH(mp, , mnt_list) { - if ((!strcmp(mp->mnt_op->vfs_name, MOUNT_UFS)) && - ((VFSTOUFS(mp))->um_dev == (dev_t) dev)) { - /* mount corresponds to UFS and the device matches one we want */ - break; - } +if (spec_node_lookup_by_dev(VBLK, dev, ) == 0) { + mp = spec_node_getmountedfs(vp); + vrele(vp); +} else { + mp = NULL; } -mutex_exit(_lock); + return mp; }
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Mar 30 09:16:53 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c src/sys/miscfs/genfs: genfs_vnops.c layer_extern.h layer_vfsops.c layer_vnops.c src/sys/miscfs/nullfs: null_vnops.c src/sys/miscfs/overlay: overlay_vnops.c src/sys/miscfs/umapfs: umap_vnops.c src/sys/sys: param.h vnode.h vnode_impl.h Log Message: Locking a layer vnode is racy as it may become reclaimed before calling the operation on the lower vnode. Replace vi_lock with a rw_obj and change layered file systems to share the lock with the lower vnode. Layered file systems now use genfs_lock()/_unlock/_islocked(). Welcome to 7.99.67 To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.193 -r1.194 src/sys/miscfs/genfs/genfs_vnops.c cvs rdiff -u -r1.38 -r1.39 src/sys/miscfs/genfs/layer_extern.h cvs rdiff -u -r1.47 -r1.48 src/sys/miscfs/genfs/layer_vfsops.c cvs rdiff -u -r1.60 -r1.61 src/sys/miscfs/genfs/layer_vnops.c cvs rdiff -u -r1.40 -r1.41 src/sys/miscfs/nullfs/null_vnops.c cvs rdiff -u -r1.22 -r1.23 src/sys/miscfs/overlay/overlay_vnops.c cvs rdiff -u -r1.58 -r1.59 src/sys/miscfs/umapfs/umap_vnops.c cvs rdiff -u -r1.533 -r1.534 src/sys/sys/param.h cvs rdiff -u -r1.274 -r1.275 src/sys/sys/vnode.h cvs rdiff -u -r1.12 -r1.13 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.80 src/sys/kern/vfs_vnode.c:1.81 --- src/sys/kern/vfs_vnode.c:1.80 Thu Mar 30 09:15:51 2017 +++ src/sys/kern/vfs_vnode.c Thu Mar 30 09:16:52 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.81 2017/03/30 09:16:52 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.81 2017/03/30 09:16:52 hannken Exp $"); #include #include @@ -416,6 +416,21 @@ vnis_marker(vnode_t *vp) } /* + * Set vnode to share another vnodes lock. + */ +void +vshare_lock(vnode_t *vp, vnode_t *src_vp) +{ + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); + vnode_impl_t *src_vip = VNODE_TO_VIMPL(src_vp); + krwlock_t *oldlock = vip->vi_lock; + + rw_obj_hold(src_vip->vi_lock); + vip->vi_lock = src_vip->vi_lock; + rw_obj_free(oldlock); +} + +/* * Return the lru list this node should be on. */ static vnodelst_t * @@ -1066,7 +1081,7 @@ vcache_alloc(void) vip = pool_cache_get(vcache_pool, PR_WAITOK); memset(vip, 0, sizeof(*vip)); - rw_init(>vi_lock); + vip->vi_lock = rw_obj_alloc(); /* SLIST_INIT(>vi_hash); */ /* LIST_INIT(>vi_nclist); */ /* LIST_INIT(>vi_dnclist); */ @@ -1128,7 +1143,7 @@ vcache_free(vnode_impl_t *vip) if (vp->v_type == VBLK || vp->v_type == VCHR) spec_node_destroy(vp); - rw_destroy(>vi_lock); + rw_obj_free(vip->vi_lock); uvm_obj_destroy(>v_uobj, true); cv_destroy(>v_cv); pool_cache_put(vcache_pool, vip); Index: src/sys/miscfs/genfs/genfs_vnops.c diff -u src/sys/miscfs/genfs/genfs_vnops.c:1.193 src/sys/miscfs/genfs/genfs_vnops.c:1.194 --- src/sys/miscfs/genfs/genfs_vnops.c:1.193 Wed Jan 11 09:08:59 2017 +++ src/sys/miscfs/genfs/genfs_vnops.c Thu Mar 30 09:16:52 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 hannken Exp $ */ +/* $NetBSD: genfs_vnops.c,v 1.194 2017/03/30 09:16:52 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.193 2017/01/11 09:08:59 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vnops.c,v 1.194 2017/03/30 09:16:52 hannken Exp $"); #include #include @@ -295,7 +295,7 @@ genfs_deadlock(void *v) op = (ISSET(flags, LK_EXCLUSIVE) ? RW_WRITER : RW_READER); if (ISSET(flags, LK_NOWAIT)) { - if (! rw_tryenter(>vi_lock, op)) + if (! rw_tryenter(vip->vi_lock, op)) return EBUSY; if (mutex_tryenter(vp->v_interlock)) { error = vdead_check(vp, VDEAD_NOWAIT); @@ -305,25 +305,25 @@ genfs_deadlock(void *v) } else error = EBUSY; if (error) - rw_exit(>vi_lock); + rw_exit(vip->vi_lock); return error; } - rw_enter(>vi_lock, op); + rw_enter(vip->vi_lock, op); mutex_enter(vp->v_interlock); error = vdead_check(vp, VDEAD_NOWAIT); if (error == EBUSY) { - rw_exit(>vi_lock); + rw_exit(vip->vi_lock); error = vdead_check(vp, 0); KASSERT(error == ENOENT); mutex_exit(vp->v_interlock); - rw_enter(>vi_lock, op); + rw_enter(vip->vi_lock, op); mutex_enter(vp->v_interlock); } KASSERT(error == ENOENT); mutex_exit(vp->v_interlock); if (! ISSET(flags, LK_RETRY)) { - rw_exit(>vi_lock); + rw_exit(vip->vi_lock); return ENOENT; } return 0; @@ -341,7 +341,7 @@
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Mar 30 09:15:51 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change the operations vector before changing the mount. Vnode operations enter the mount before using the vector. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.79 src/sys/kern/vfs_vnode.c:1.80 --- src/sys/kern/vfs_vnode.c:1.79 Thu Mar 30 09:14:59 2017 +++ src/sys/kern/vfs_vnode.c Thu Mar 30 09:15:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.80 2017/03/30 09:15:51 hannken Exp $"); #include #include @@ -1556,11 +1556,6 @@ vcache_reclaim(vnode_t *vp) /* Purge name cache. */ cache_purge(vp); - /* Move to dead mount. */ - vp->v_vflag &= ~VV_ROOT; - atomic_inc_uint(_rootmount->mnt_refcnt); - vfs_insmntque(vp, dead_rootmount); - /* Remove from vnode cache. */ hash = vcache_hash(>vi_key); mutex_enter(_lock); @@ -1578,9 +1573,19 @@ vcache_reclaim(vnode_t *vp) VSTATE_CHANGE(vp, VS_RECLAIMING, VS_RECLAIMED); vp->v_tag = VT_NON; KNOTE(>v_klist, NOTE_REVOKE); + mutex_exit(vp->v_interlock); - fstrans_done(mp); + /* + * Move to dead mount. Must be after changing the operations + * vector as vnode operations enter the mount before using the + * operations vector. See sys/kern/vnode_if.c. + */ + vp->v_vflag &= ~VV_ROOT; + atomic_inc_uint(_rootmount->mnt_refcnt); + vfs_insmntque(vp, dead_rootmount); + mutex_enter(vp->v_interlock); + fstrans_done(mp); KASSERT((vp->v_iflag & VI_ONWORKLST) == 0); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Mar 30 09:14:59 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change vrelel() to defer the test for a reclaimed vnode until we hold both the interlock and the vnode lock. Add a common operation to deallocate a vnode in state LOADING. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.78 src/sys/kern/vfs_vnode.c:1.79 --- src/sys/kern/vfs_vnode.c:1.78 Thu Mar 30 09:14:08 2017 +++ src/sys/kern/vfs_vnode.c Thu Mar 30 09:14:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.79 2017/03/30 09:14:59 hannken Exp $"); #include #include @@ -212,6 +212,7 @@ static pool_cache_t vcache_pool; static void lru_requeue(vnode_t *, vnodelst_t *); static vnodelst_t * lru_which(vnode_t *); static vnode_impl_t * vcache_alloc(void); +static void vcache_dealloc(vnode_impl_t *); static void vcache_free(vnode_impl_t *); static void vcache_init(void); static void vcache_reinit(void); @@ -662,6 +663,8 @@ vtryrele(vnode_t *vp) static void vrelel(vnode_t *vp, int flags) { + const bool async = ((flags & VRELEL_ASYNC_RELE) != 0); + const bool force = ((flags & VRELEL_FORCE_RELE) != 0); bool recycle, defer; int error; @@ -692,62 +695,48 @@ vrelel(vnode_t *vp, int flags) #endif /* - * If not clean, deactivate the vnode, but preserve - * our reference across the call to VOP_INACTIVE(). + * First try to get the vnode locked for VOP_INACTIVE(). + * Defer vnode release to vdrain_thread if caller requests + * it explicitly, is the pagedaemon or the lock failed. */ - if (VSTATE_GET(vp) != VS_RECLAIMED) { - recycle = false; - + if ((curlwp == uvm.pagedaemon_lwp) || async) { + defer = true; + } else { + mutex_exit(vp->v_interlock); + error = vn_lock(vp, + LK_EXCLUSIVE | LK_RETRY | (force ? 0 : LK_NOWAIT)); + defer = (error != 0); + mutex_enter(vp->v_interlock); + } + KASSERT(mutex_owned(vp->v_interlock)); + KASSERT(! (force && defer)); + if (defer) { /* - * XXX This ugly block can be largely eliminated if - * locking is pushed down into the file systems. - * - * Defer vnode release to vdrain_thread if caller - * requests it explicitly or is the pagedaemon. + * Defer reclaim to the kthread; it's not safe to + * clean it here. We donate it our last reference. */ - if ((curlwp == uvm.pagedaemon_lwp) || - (flags & VRELEL_ASYNC_RELE) != 0) { - defer = true; - } else if ((flags & VRELEL_FORCE_RELE) != 0) { - /* - * We have to try harder. - */ - mutex_exit(vp->v_interlock); - error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); - KASSERTMSG((error == 0), "vn_lock failed: %d", error); - mutex_enter(vp->v_interlock); - defer = false; - } else { - /* If we can't acquire the lock, then defer. */ - mutex_exit(vp->v_interlock); - error = vn_lock(vp, - LK_EXCLUSIVE | LK_RETRY | LK_NOWAIT); - defer = (error != 0); - mutex_enter(vp->v_interlock); - } - - KASSERT(mutex_owned(vp->v_interlock)); - KASSERT(! ((flags & VRELEL_FORCE_RELE) != 0 && defer)); + lru_requeue(vp, _vrele_list); + mutex_exit(vp->v_interlock); + return; + } - if (defer) { - /* - * Defer reclaim to the kthread; it's not safe to - * clean it here. We donate it our last reference. - */ - lru_requeue(vp, _vrele_list); - mutex_exit(vp->v_interlock); - return; - } + /* + * If the node got another reference while we + * released the interlock, don't try to inactivate it yet. + */ + if (__predict_false(vtryrele(vp))) { + VOP_UNLOCK(vp); + mutex_exit(vp->v_interlock); + return; + } - /* - * If the node got another reference while we - * released the interlock, don't try to inactivate it yet. - */ - if (__predict_false(vtryrele(vp))) { - VOP_UNLOCK(vp); - mutex_exit(vp->v_interlock); - return; - } + /* + * If not clean, deactivate the vnode, but preserve + * our reference across the call to VOP_INACTIVE(). + */ + if (VSTATE_GET(vp) == VS_RECLAIMED) { + VOP_UNLOCK(vp); + } else { VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED); mutex_exit(vp->v_interlock); @@ -759,6 +748,7 @@ vrelel(vnode_t *vp, int flags) * * Note that VOP_INACTIVE() will drop the vnode lock. */ + recycle = false; VOP_INACTIVE(vp, ); if (recycle) { /* vcache_reclaim() below will drop the lock. */ @@ -1097,6 +1087,26 @@ vcache_alloc(void) } /* + * Deallocate a vcache node in state VS_LOADING. +
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Mar 30 09:14:08 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Add flag VRELEL_FORCE_RELE to vrelel() to force release and use it from vdrain_vrele() and vrele_flush() to prevent a possible live lock from vrele_flush(). To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.77 src/sys/kern/vfs_vnode.c:1.78 --- src/sys/kern/vfs_vnode.c:1.77 Thu Mar 30 09:12:21 2017 +++ src/sys/kern/vfs_vnode.c Thu Mar 30 09:14:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.78 2017/03/30 09:14:08 hannken Exp $"); #include #include @@ -184,6 +184,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, /* Flags to vrelel. */ #define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */ +#define VRELEL_FORCE_RELE 0x0002 /* Must always succeed. */ u_int numvnodes __cacheline_aligned; @@ -482,7 +483,8 @@ vrele_flush(struct mount *mp) TAILQ_INSERT_TAIL(vip->vi_lrulisthd, vip, vi_lrulist); mutex_exit(_lock); - vrele(VIMPL_TO_VNODE(vip)); + mutex_enter(VIMPL_TO_VNODE(vip)->v_interlock); + vrelel(VIMPL_TO_VNODE(vip), VRELEL_FORCE_RELE); mutex_enter(_lock); } @@ -523,8 +525,10 @@ vdrain_remove(vnode_t *vp) mutex_exit(_lock); if (vcache_vget(vp) == 0) { - if (!vrecycle(vp)) - vrele(vp); + if (!vrecycle(vp)) { + mutex_enter(vp->v_interlock); + vrelel(vp, VRELEL_FORCE_RELE); + } } fstrans_done(mp); @@ -561,7 +565,7 @@ vdrain_vrele(vnode_t *vp) mutex_exit(_lock); mutex_enter(vp->v_interlock); - vrelel(vp, 0); + vrelel(vp, VRELEL_FORCE_RELE); fstrans_done(mp); mutex_enter(_lock); @@ -704,7 +708,7 @@ vrelel(vnode_t *vp, int flags) if ((curlwp == uvm.pagedaemon_lwp) || (flags & VRELEL_ASYNC_RELE) != 0) { defer = true; - } else if (curlwp == vdrain_lwp) { + } else if ((flags & VRELEL_FORCE_RELE) != 0) { /* * We have to try harder. */ @@ -723,7 +727,7 @@ vrelel(vnode_t *vp, int flags) } KASSERT(mutex_owned(vp->v_interlock)); - KASSERT(! (curlwp == vdrain_lwp && defer)); + KASSERT(! ((flags & VRELEL_FORCE_RELE) != 0 && defer)); if (defer) { /*
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Mar 30 09:13:37 UTC 2017 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Lock the vnode before changing its writecount. To generate a diff of this commit: cvs rdiff -u -r1.194 -r1.195 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.194 src/sys/kern/vfs_vnops.c:1.195 --- src/sys/kern/vfs_vnops.c:1.194 Wed Mar 1 10:43:37 2017 +++ src/sys/kern/vfs_vnops.c Thu Mar 30 09:13:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $"); #include "veriexec.h" @@ -376,13 +376,13 @@ vn_close(struct vnode *vp, int flags, ka { int error; + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (flags & FWRITE) { mutex_enter(vp->v_interlock); KASSERT(vp->v_writecount > 0); vp->v_writecount--; mutex_exit(vp->v_interlock); } - vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VOP_CLOSE(vp, flags, cred); vput(vp); return (error);
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Mar 30 09:13:01 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c vfs_trans.c src/sys/miscfs/nullfs: null_vfsops.c src/sys/miscfs/overlay: overlay_vfsops.c src/sys/miscfs/umapfs: umap_vfsops.c Log Message: Change _fstrans_start() to allocate per lwp info for layered file systems to get a reference on the mount. Set mnt_lower on successfull mount only. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.39 -r1.40 src/sys/kern/vfs_trans.c cvs rdiff -u -r1.92 -r1.93 src/sys/miscfs/nullfs/null_vfsops.c cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/overlay/overlay_vfsops.c cvs rdiff -u -r1.97 -r1.98 src/sys/miscfs/umapfs/umap_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.50 src/sys/kern/vfs_mount.c:1.51 --- src/sys/kern/vfs_mount.c:1.50 Mon Mar 6 10:11:21 2017 +++ src/sys/kern/vfs_mount.c Thu Mar 30 09:13:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.51 2017/03/30 09:13:01 hannken Exp $"); #include #include @@ -711,6 +711,12 @@ mount_domount(struct lwp *l, vnode_t **v return ENOMEM; } + if ((error = fstrans_mount(mp)) != 0) { + vfs_unbusy(mp, false, NULL); + vfs_destroy(mp); + return error; + } + mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred); /* @@ -728,12 +734,6 @@ mount_domount(struct lwp *l, vnode_t **v if (error != 0) goto err_unmounted; - if (mp->mnt_lower == NULL) { - error = fstrans_mount(mp); - if (error) - goto err_mounted; - } - /* * Validate and prepare the mount point. */ Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.39 src/sys/kern/vfs_trans.c:1.40 --- src/sys/kern/vfs_trans.c:1.39 Mon Mar 6 10:11:21 2017 +++ src/sys/kern/vfs_trans.c Thu Mar 30 09:13:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.40 2017/03/30 09:13:01 hannken Exp $"); /* * File system transaction operations. @@ -329,15 +329,26 @@ int _fstrans_start(struct mount *mp, enum fstrans_lock_type lock_type, int wait) { int s; + struct mount *lmp; struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; - if ((mp = fstrans_normalize_mount(mp)) == NULL) + if ((lmp = fstrans_normalize_mount(mp)) == NULL) return 0; ASSERT_SLEEPABLE(); - if ((fli = fstrans_get_lwp_info(mp, true)) == NULL) + /* + * Allocate per lwp info for layered file systems to + * get a reference to the mount. No need to increment + * the reference counter here. + */ + for (lmp = mp; lmp->mnt_lower; lmp = lmp->mnt_lower) { + fli = fstrans_get_lwp_info(lmp, true); + KASSERT(fli != NULL); + } + + if ((fli = fstrans_get_lwp_info(lmp, true)) == NULL) return 0; if (fli->fli_trans_cnt > 0) { @@ -348,7 +359,7 @@ _fstrans_start(struct mount *mp, enum fs } s = pserialize_read_enter(); - fmi = mp->mnt_transinfo; + fmi = lmp->mnt_transinfo; if (__predict_true(grant_lock(fmi->fmi_state, lock_type))) { fli->fli_trans_cnt = 1; fli->fli_lock_type = lock_type; @@ -383,9 +394,8 @@ fstrans_done(struct mount *mp) if ((mp = fstrans_normalize_mount(mp)) == NULL) return; - if ((fli = fstrans_get_lwp_info(mp, true)) == NULL) - return; - + fli = fstrans_get_lwp_info(mp, false); + KASSERT(fli != NULL); KASSERT(fli->fli_trans_cnt > 0); if (fli->fli_trans_cnt > 1) { Index: src/sys/miscfs/nullfs/null_vfsops.c diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.92 src/sys/miscfs/nullfs/null_vfsops.c:1.93 --- src/sys/miscfs/nullfs/null_vfsops.c:1.92 Mon Mar 6 10:10:07 2017 +++ src/sys/miscfs/nullfs/null_vfsops.c Thu Mar 30 09:13:01 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $ */ +/* $NetBSD: null_vfsops.c,v 1.93 2017/03/30 09:13:01 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.93 2017/03/30 09:13:01 hannken Exp $"); #include #include @@ -170,13 +170,15 @@ nullfs_mount(struct mount *mp, const cha vn_lock(vp, LK_EXCLUSIVE |
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Mar 30 09:12:22 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c src/sys/miscfs/genfs: genfs_io.c genfs_vfsops.c Log Message: Change last users of FSTRANS_LAZY to FSTRANS_SHARED and change genfs_suspendctl() to move from FSTRANS_NORMAL to FSTRANS_SUSPENDED and vice versa. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.65 -r1.66 src/sys/miscfs/genfs/genfs_io.c cvs rdiff -u -r1.4 -r1.5 src/sys/miscfs/genfs/genfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.76 src/sys/kern/vfs_vnode.c:1.77 --- src/sys/kern/vfs_vnode.c:1.76 Mon Mar 6 10:07:52 2017 +++ src/sys/kern/vfs_vnode.c Thu Mar 30 09:12:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.77 2017/03/30 09:12:21 hannken Exp $"); #include #include @@ -543,7 +543,7 @@ vdrain_vrele(vnode_t *vp) KASSERT(mutex_owned(_lock)); mp = vp->v_mount; - if (fstrans_start_nowait(mp, FSTRANS_LAZY) != 0) + if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0) return; /* @@ -1518,7 +1518,7 @@ vcache_reclaim(vnode_t *vp) vip->vi_key.vk_key = temp_key; mutex_exit(_lock); - fstrans_start(mp, FSTRANS_LAZY); + fstrans_start(mp, FSTRANS_SHARED); /* * Clean out any cached data associated with the vnode. Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.65 src/sys/miscfs/genfs/genfs_io.c:1.66 --- src/sys/miscfs/genfs/genfs_io.c:1.65 Thu Mar 9 10:10:02 2017 +++ src/sys/miscfs/genfs/genfs_io.c Thu Mar 30 09:12:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.66 2017/03/30 09:12:21 hannken Exp $"); #include #include @@ -890,7 +890,7 @@ retry: if (pagedaemon) { /* Pagedaemon must not sleep here. */ trans_mp = vp->v_mount; - error = fstrans_start_nowait(trans_mp, FSTRANS_LAZY); + error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED); if (error) { mutex_exit(slock); return error; @@ -903,7 +903,7 @@ retry: */ mutex_exit(slock); trans_mp = vp->v_mount; - fstrans_start(trans_mp, FSTRANS_LAZY); + fstrans_start(trans_mp, FSTRANS_SHARED); if (vp->v_mount != trans_mp) { fstrans_done(trans_mp); trans_mp = NULL; Index: src/sys/miscfs/genfs/genfs_vfsops.c diff -u src/sys/miscfs/genfs/genfs_vfsops.c:1.4 src/sys/miscfs/genfs/genfs_vfsops.c:1.5 --- src/sys/miscfs/genfs/genfs_vfsops.c:1.4 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/genfs/genfs_vfsops.c Thu Mar 30 09:12:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_vfsops.c,v 1.4 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -27,7 +27,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.4 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_vfsops.c,v 1.5 2017/03/30 09:12:21 hannken Exp $"); #include #include @@ -75,26 +75,18 @@ genfs_renamelock_exit(struct mount *mp) int genfs_suspendctl(struct mount *mp, int cmd) { - int error; - int error2 __diagused; + int error __diagused; if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) return EOPNOTSUPP; switch (cmd) { case SUSPEND_SUSPEND: - if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDING)) != 0) - return error; - if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDED)) != 0) { - error2 = fstrans_setstate(mp, FSTRANS_NORMAL); - KASSERT(error2 == 0); - return error; - } - return 0; + return fstrans_setstate(mp, FSTRANS_SUSPENDED); case SUSPEND_RESUME: - error2 = fstrans_setstate(mp, FSTRANS_NORMAL); - KASSERT(error2 == 0); + error = fstrans_setstate(mp, FSTRANS_NORMAL); + KASSERT(error == 0); return 0; default:
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:11:45 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_lookup.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ufs/ufs_lookup.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_lookup.c diff -u src/sys/ufs/ufs/ufs_lookup.c:1.145 src/sys/ufs/ufs/ufs_lookup.c:1.146 --- src/sys/ufs/ufs/ufs_lookup.c:1.145 Fri Apr 29 02:38:19 2016 +++ src/sys/ufs/ufs/ufs_lookup.c Thu Mar 30 09:11:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $ */ +/* $NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $ */ /* * Copyright (c) 1989, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.145 2016/04/29 02:38:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c,v 1.146 2017/03/30 09:11:45 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ffs.h" @@ -54,7 +54,6 @@ __KERNEL_RCSID(0, "$NetBSD: ufs_lookup.c #include #include #include -#include #include #include @@ -376,8 +375,6 @@ ufs_lookup(void *v) cnp->cn_flags |= ISWHITEOUT; } - fstrans_start(vdp->v_mount, FSTRANS_SHARED); - /* * Suppress search for slots unless creating * file and at end of pathname, in which case @@ -695,7 +692,6 @@ found: error = 0; out: - fstrans_done(vdp->v_mount); return error; }
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:11:12 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_rename.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/miscfs/genfs/genfs_rename.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_rename.c diff -u src/sys/miscfs/genfs/genfs_rename.c:1.2 src/sys/miscfs/genfs/genfs_rename.c:1.3 --- src/sys/miscfs/genfs/genfs_rename.c:1.2 Thu Feb 6 10:57:12 2014 +++ src/sys/miscfs/genfs/genfs_rename.c Thu Mar 30 09:11:12 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $ */ +/* $NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $ */ /*- * Copyright (c) 2012 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.2 2014/02/06 10:57:12 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.3 2017/03/30 09:11:12 hannken Exp $"); #include #include @@ -45,7 +45,6 @@ __KERNEL_RCSID(0, "$NetBSD: genfs_rename #include #include #include -#include #include #include @@ -177,7 +176,6 @@ genfs_insane_rename(void *v, struct componentname *fcnp = ap->a_fcnp; struct vnode *tdvp = ap->a_tdvp; struct vnode *tvp = ap->a_tvp; - struct mount *mp = fdvp->v_mount; struct componentname *tcnp = ap->a_tcnp; kauth_cred_t cred; int error; @@ -196,8 +194,6 @@ genfs_insane_rename(void *v, KASSERT(fdvp->v_type == VDIR); KASSERT(tdvp->v_type == VDIR); - fstrans_start(mp, FSTRANS_SHARED); - cred = fcnp->cn_cred; /* @@ -232,8 +228,6 @@ genfs_insane_rename(void *v, vrele(fdvp); vrele(tdvp); - fstrans_done(mp); - return error; }
CVS commit: src/sys/ufs/chfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:10:47 UTC 2017 Modified Files: src/sys/ufs/chfs: chfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/chfs/chfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/chfs/chfs_vnops.c diff -u src/sys/ufs/chfs/chfs_vnops.c:1.29 src/sys/ufs/chfs/chfs_vnops.c:1.30 --- src/sys/ufs/chfs/chfs_vnops.c:1.29 Sat Aug 20 12:37:09 2016 +++ src/sys/ufs/chfs/chfs_vnops.c Thu Mar 30 09:10:46 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: chfs_vnops.c,v 1.29 2016/08/20 12:37:09 hannken Exp $ */ +/* $NetBSD: chfs_vnops.c,v 1.30 2017/03/30 09:10:46 hannken Exp $ */ /*- * Copyright (c) 2010 Department of Software Engineering, @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "chfs.h" @@ -653,8 +652,6 @@ chfs_read(void *v) if (uio->uio_resid == 0) return (0); - fstrans_start(vp->v_mount, FSTRANS_SHARED); - if (uio->uio_offset >= ip->size) goto out; @@ -737,7 +734,6 @@ out: ip->iflag |= IN_ACCESS; if ((ap->a_ioflag & IO_SYNC) == IO_SYNC) { if (error) { -fstrans_done(vp->v_mount); return error; } error = chfs_update(vp, NULL, NULL, UPDATE_WAIT); @@ -745,7 +741,6 @@ out: } dbg("[END]\n"); - fstrans_done(vp->v_mount); return (error); } @@ -833,8 +828,6 @@ chfs_write(void *v) if (uio->uio_resid == 0) return (0); - fstrans_start(vp->v_mount, FSTRANS_SHARED); - flags = ioflag & IO_SYNC ? B_SYNC : 0; async = vp->v_mount->mnt_flag & MNT_ASYNC; origoff = uio->uio_offset; @@ -1003,7 +996,6 @@ out: KASSERT(vp->v_size == ip->size); - fstrans_done(vp->v_mount); mutex_enter(>chm_lock_mountfields); error = chfs_write_flash_vnode(chmp, ip, ALLOC_NORMAL);
CVS commit: src/sys/ufs/lfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:10:08 UTC 2017 Modified Files: src/sys/ufs/lfs: lfs_pages.c lfs_vnops.c ulfs_bmap.c ulfs_inode.c ulfs_lookup.c ulfs_quota2.c ulfs_readwrite.c ulfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). Add fstrans_start()/fstrans_done() to lfs_putpages(). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/ufs/lfs/lfs_pages.c cvs rdiff -u -r1.306 -r1.307 src/sys/ufs/lfs/lfs_vnops.c cvs rdiff -u -r1.8 -r1.9 src/sys/ufs/lfs/ulfs_bmap.c cvs rdiff -u -r1.16 -r1.17 src/sys/ufs/lfs/ulfs_inode.c cvs rdiff -u -r1.39 -r1.40 src/sys/ufs/lfs/ulfs_lookup.c cvs rdiff -u -r1.29 -r1.30 src/sys/ufs/lfs/ulfs_quota2.c cvs rdiff -u -r1.22 -r1.23 src/sys/ufs/lfs/ulfs_readwrite.c cvs rdiff -u -r1.45 -r1.46 src/sys/ufs/lfs/ulfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/lfs/lfs_pages.c diff -u src/sys/ufs/lfs/lfs_pages.c:1.9 src/sys/ufs/lfs/lfs_pages.c:1.10 --- src/sys/ufs/lfs/lfs_pages.c:1.9 Tue Oct 4 16:46:20 2016 +++ src/sys/ufs/lfs/lfs_pages.c Thu Mar 30 09:10:08 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $ */ +/* $NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.9 2016/10/04 16:46:20 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_pages.c,v 1.10 2017/03/30 09:10:08 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -466,6 +466,7 @@ lfs_putpages(void *v) bool seglocked, sync, pagedaemon, reclaim; struct vm_page *pg, *busypg; UVMHIST_FUNC("lfs_putpages"); UVMHIST_CALLED(ubchist); + struct mount *trans_mp; int oreclaim = 0; int donewriting = 0; #ifdef DEBUG @@ -478,6 +479,7 @@ lfs_putpages(void *v) sync = (ap->a_flags & PGO_SYNCIO) != 0; reclaim = (ap->a_flags & PGO_RECLAIM) != 0; pagedaemon = (curlwp == uvm.pagedaemon_lwp); + trans_mp = NULL; KASSERT(mutex_owned(vp->v_interlock)); @@ -487,6 +489,7 @@ lfs_putpages(void *v) return 0; } +retry: /* * If there are no pages, don't do anything. */ @@ -497,6 +500,8 @@ lfs_putpages(void *v) vp->v_iflag &= ~VI_WRMAPDIRTY; vn_syncer_remove_from_worklist(vp); } + if (trans_mp) + fstrans_done(trans_mp); mutex_exit(vp->v_interlock); /* Remove us from paging queue, if we were on it */ @@ -587,6 +592,33 @@ lfs_putpages(void *v) return r; } + if (trans_mp /* && (ap->a_flags & PGO_CLEANIT) != 0 */) { + if (pagedaemon) { + /* Pagedaemon must not sleep here. */ + trans_mp = vp->v_mount; + error = fstrans_start_nowait(trans_mp, FSTRANS_SHARED); + if (error) { +mutex_exit(vp->v_interlock); +return error; + } + } else { + /* + * Cannot use vdeadcheck() here as this operation + * usually gets used from VOP_RECLAIM(). Test for + * change of v_mount instead and retry on change. + */ + mutex_exit(vp->v_interlock); + trans_mp = vp->v_mount; + fstrans_start(trans_mp, FSTRANS_SHARED); + if (vp->v_mount != trans_mp) { +fstrans_done(trans_mp); +trans_mp = NULL; + } + } + mutex_enter(vp->v_interlock); + goto retry; + } + /* Set PGO_BUSYFAIL to avoid deadlocks */ ap->a_flags |= PGO_BUSYFAIL; @@ -607,7 +639,8 @@ lfs_putpages(void *v) if (r < 0) { /* Pages are busy with another process */ mutex_exit(vp->v_interlock); - return EDEADLK; + error = EDEADLK; + goto out; } if (r > 0) /* Some pages are dirty */ break; @@ -624,7 +657,8 @@ lfs_putpages(void *v) ip->i_lfs_iflags &= ~LFSI_NO_GOP_WRITE; if (r != EDEADLK) { KASSERT(!mutex_owned(vp->v_interlock)); - return r; + error = r; + goto out; } /* One of the pages was busy. Start over. */ @@ -662,7 +696,8 @@ lfs_putpages(void *v) mutex_exit(_lock); preempt(); KASSERT(!mutex_owned(vp->v_interlock)); - return EWOULDBLOCK; + error = EWOULDBLOCK; + goto out; } /* @@ -724,7 +759,7 @@ lfs_putpages(void *v) error = lfs_seglock(fs, SEGM_PROT | (sync ? SEGM_SYNC : 0)); if (error != 0) { KASSERT(!mutex_owned(vp->v_interlock)); - return error; + goto out; } mutex_enter(vp->v_interlock); lfs_acquire_finfo(fs, ip->i_number, ip->i_gen); @@ -851,7 +886,7 @@ lfs_putpages(void *v) */ if (seglocked) { KASSERT(!mutex_owned(vp->v_interlock)); - return error; + goto out; } /* Clean up FIP and send it to disk. */ @@ -892,6 +927,10 @@ lfs_putpages(void *v) } mutex_exit(vp->v_interlock); } + +out:; + if (trans_mp) + fstrans_done(trans_mp); KASSERT(!mutex_owned(vp->v_interlock)); return error; } Index: src/sys/ufs/lfs/lfs_vnops.c diff -u src/sys/ufs/lfs/lfs_vnops.c:1.306 src/sys/ufs/lfs/lfs_vnops.c:1.307 ---
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Thu Mar 30 09:09:26 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_vnops.c Log Message: Protect tmpfs_getpages() against reclaiming vnodes. To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/sys/fs/tmpfs/tmpfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_vnops.c diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 src/sys/fs/tmpfs/tmpfs_vnops.c:1.130 --- src/sys/fs/tmpfs/tmpfs_vnops.c:1.129 Wed Jan 11 12:12:32 2017 +++ src/sys/fs/tmpfs/tmpfs_vnops.c Thu Mar 30 09:09:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $ */ +/* $NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $"); #include #include @@ -1165,9 +1165,6 @@ tmpfs_getpages(void *v) KASSERT(vp->v_type == VREG); KASSERT(mutex_owned(vp->v_interlock)); - node = VP_TO_TMPFS_NODE(vp); - uobj = node->tn_spec.tn_reg.tn_aobj; - /* * Currently, PGO_PASTEOF is not supported. */ @@ -1184,6 +1181,12 @@ tmpfs_getpages(void *v) if ((flags & PGO_LOCKED) != 0) return EBUSY; + if (vdead_check(vp, VDEAD_NOWAIT) != 0) + return ENOENT; + + node = VP_TO_TMPFS_NODE(vp); + uobj = node->tn_spec.tn_reg.tn_aobj; + if ((flags & PGO_NOTIMESTAMP) == 0) { u_int tflags = 0;
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Thu Mar 9 10:10:02 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Protect genfs_do_putpages() against vnodes disappearing during a forced mount update from read-write to read-only. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.64 src/sys/miscfs/genfs/genfs_io.c:1.65 --- src/sys/miscfs/genfs/genfs_io.c:1.64 Wed Mar 1 10:47:26 2017 +++ src/sys/miscfs/genfs/genfs_io.c Thu Mar 9 10:10:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $ */ +/* $NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.65 2017/03/09 10:10:02 hannken Exp $"); #include #include @@ -842,11 +842,11 @@ genfs_do_putpages(struct vnode *vp, off_ bool pagedaemon = curlwp == uvm.pagedaemon_lwp; struct lwp * const l = curlwp ? curlwp : struct genfs_node * const gp = VTOG(vp); + struct mount *trans_mp; int flags; int dirtygen; bool modified; - bool need_wapbl; - bool has_trans; + bool holds_wapbl; bool cleanall; bool onworklst; @@ -859,9 +859,8 @@ genfs_do_putpages(struct vnode *vp, off_ UVMHIST_LOG(ubchist, "vp %p pages %d off 0x%x len 0x%x", vp, uobj->uo_npages, startoff, endoff - startoff); - has_trans = false; - need_wapbl = (!pagedaemon && vp->v_mount && vp->v_mount->mnt_wapbl && - (origflags & PGO_JOURNALLOCKED) == 0); + trans_mp = NULL; + holds_wapbl = false; retry: modified = false; @@ -874,10 +873,10 @@ retry: if (LIST_FIRST(>v_dirtyblkhd) == NULL) vn_syncer_remove_from_worklist(vp); } - if (has_trans) { - if (need_wapbl) -WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mp) { + if (holds_wapbl) +WAPBL_END(trans_mp); + fstrans_done(trans_mp); } mutex_exit(slock); return (0); @@ -887,24 +886,41 @@ retry: * the vnode has pages, set up to process the request. */ - if (!has_trans && (flags & PGO_CLEANIT) != 0) { - mutex_exit(slock); + if (trans_mp == NULL && (flags & PGO_CLEANIT) != 0) { if (pagedaemon) { - error = fstrans_start_nowait(vp->v_mount, FSTRANS_LAZY); - if (error) -return error; - } else - fstrans_start(vp->v_mount, FSTRANS_LAZY); - if (need_wapbl) { - error = WAPBL_BEGIN(vp->v_mount); + /* Pagedaemon must not sleep here. */ + trans_mp = vp->v_mount; + error = fstrans_start_nowait(trans_mp, FSTRANS_LAZY); if (error) { -fstrans_done(vp->v_mount); +mutex_exit(slock); return error; } + } else { + /* + * Cannot use vdeadcheck() here as this operation + * usually gets used from VOP_RECLAIM(). Test for + * change of v_mount instead and retry on change. + */ + mutex_exit(slock); + trans_mp = vp->v_mount; + fstrans_start(trans_mp, FSTRANS_LAZY); + if (vp->v_mount != trans_mp) { +fstrans_done(trans_mp); +trans_mp = NULL; + } else { +holds_wapbl = (trans_mp->mnt_wapbl && +(origflags & PGO_JOURNALLOCKED) == 0); +if (holds_wapbl) { + error = WAPBL_BEGIN(trans_mp); + if (error) { + fstrans_done(trans_mp); + return error; + } +} + } + mutex_enter(slock); + goto retry; } - has_trans = true; - mutex_enter(slock); - goto retry; } error = 0; @@ -1277,10 +1293,10 @@ skip_scan: goto retry; } - if (has_trans) { - if (need_wapbl) - WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mp) { + if (holds_wapbl) + WAPBL_END(trans_mp); + fstrans_done(trans_mp); } return (error);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Tue Mar 7 11:54:17 UTC 2017 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Fix a logic error introduced with Rev. 1.507: defer setting MNT_RDONLY only if going from read-write to read-only. Should fix PR kern/52045 (panic: ffs_sync: rofs mod, fs=/ after fsck) To generate a diff of this commit: cvs rdiff -u -r1.508 -r1.509 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.508 src/sys/kern/vfs_syscalls.c:1.509 --- src/sys/kern/vfs_syscalls.c:1.508 Wed Mar 1 10:45:24 2017 +++ src/sys/kern/vfs_syscalls.c Tue Mar 7 11:54:16 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.509 2017/03/07 11:54:16 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -306,7 +306,10 @@ mount_update(struct lwp *l, struct vnode mp->mnt_iflag |= IMNT_WANTRDWR; } mp->mnt_flag &= ~MNT_BASIC_FLAGS; - mp->mnt_flag |= (flags & ~MNT_RDONLY) & MNT_BASIC_FLAGS; + mp->mnt_flag |= flags & MNT_BASIC_FLAGS; + if ((mp->mnt_iflag & IMNT_WANTRDONLY)) + mp->mnt_flag &= ~MNT_RDONLY; + error = VFS_MOUNT(mp, path, data, data_len); if (error && data != NULL) { @@ -329,8 +332,6 @@ mount_update(struct lwp *l, struct vnode if (error == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY)) mp->mnt_flag |= MNT_RDONLY; - else if (error == 0 && (mp->mnt_iflag & IMNT_WANTRDWR)) - mp->mnt_flag &= ~MNT_RDONLY; if (error) mp->mnt_flag = saved_flags; mp->mnt_flag &= ~MNT_OP_FLAGS;
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Mon Mar 6 10:12:00 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: Adapt the test "enable WAPBL on rw mounts only" to the recent change of the protocol to update a mounted file. Should fix PR kern/52031 (FFS mount update doesn't play nice with WAPBL) To generate a diff of this commit: cvs rdiff -u -r1.348 -r1.349 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.348 src/sys/ufs/ffs/ffs_vfsops.c:1.349 --- src/sys/ufs/ffs/ffs_vfsops.c:1.348 Wed Mar 1 10:46:43 2017 +++ src/sys/ufs/ffs/ffs_vfsops.c Mon Mar 6 10:12:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.349 2017/03/06 10:12:00 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -518,7 +518,8 @@ ffs_mount(struct mount *mp, const char * #ifdef WAPBL /* WAPBL can only be enabled on a r/w mount. */ - if ((mp->mnt_flag & MNT_RDONLY) && !(mp->mnt_iflag & IMNT_WANTRDWR)) { + if (((mp->mnt_flag & MNT_RDONLY) && !(mp->mnt_iflag & IMNT_WANTRDWR)) || + (mp->mnt_iflag & IMNT_WANTRDONLY)) { mp->mnt_flag &= ~MNT_LOG; } #else /* !WAPBL */
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Mar 6 10:11:21 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c vfs_trans.c Log Message: Always use the lowest mount for fstrans and suspend. This way we enter/leave or suspend/resume the stack of layered file systems as a unit. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.38 -r1.39 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.49 src/sys/kern/vfs_mount.c:1.50 --- src/sys/kern/vfs_mount.c:1.49 Mon Mar 6 10:10:43 2017 +++ src/sys/kern/vfs_mount.c Mon Mar 6 10:11:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.50 2017/03/06 10:11:21 hannken Exp $"); #include #include @@ -711,12 +711,6 @@ mount_domount(struct lwp *l, vnode_t **v return ENOMEM; } - if ((error = fstrans_mount(mp)) != 0) { - vfs_unbusy(mp, false, NULL); - vfs_destroy(mp); - return error; - } - mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred); /* @@ -734,6 +728,12 @@ mount_domount(struct lwp *l, vnode_t **v if (error != 0) goto err_unmounted; + if (mp->mnt_lower == NULL) { + error = fstrans_mount(mp); + if (error) + goto err_mounted; + } + /* * Validate and prepare the mount point. */ Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.38 src/sys/kern/vfs_trans.c:1.39 --- src/sys/kern/vfs_trans.c:1.38 Thu Mar 2 10:41:27 2017 +++ src/sys/kern/vfs_trans.c Mon Mar 6 10:11:21 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.39 2017/03/06 10:11:21 hannken Exp $"); /* * File system transaction operations. @@ -123,6 +123,8 @@ static inline struct mount * fstrans_normalize_mount(struct mount *mp) { + while (mp && mp->mnt_lower) + mp = mp->mnt_lower; if (mp == NULL) return NULL; if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0)
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Mar 6 10:10:43 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c Log Message: Deny unmounting file systems below layered file systems. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.48 src/sys/kern/vfs_mount.c:1.49 --- src/sys/kern/vfs_mount.c:1.48 Wed Feb 22 09:50:13 2017 +++ src/sys/kern/vfs_mount.c Mon Mar 6 10:10:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.48 2017/02/22 09:50:13 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.48 2017/02/22 09:50:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.49 2017/03/06 10:10:43 hannken Exp $"); #include #include @@ -817,6 +817,7 @@ err_unmounted: int dounmount(struct mount *mp, int flags, struct lwp *l) { + struct mount *cmp; vnode_t *coveredvp; int error, async, used_syncer, used_extattr; @@ -827,6 +828,18 @@ dounmount(struct mount *mp, int flags, s #endif /* NVERIEXEC > 0 */ /* + * No unmount below layered mounts. + */ + mutex_enter(_lock); + TAILQ_FOREACH(cmp, , mnt_list) { + if (cmp->mnt_lower == mp) { + mutex_exit(_lock); + return EBUSY; + } + } + mutex_exit(_lock); + + /* * XXX Freeze syncer. Must do this before locking the * mount point. See dounmount() for details. */
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Mon Mar 6 10:10:07 UTC 2017 Modified Files: src/sys/fs/union: union_vfsops.c src/sys/miscfs/nullfs: null_vfsops.c src/sys/miscfs/overlay: overlay_vfsops.c src/sys/miscfs/umapfs: umap_vfsops.c src/sys/sys: mount.h param.h Log Message: Add field "mnt_lower" to "struct mount" to track the file system a layered file system is mounted on. Welcome to 7.99.65 To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/sys/fs/union/union_vfsops.c cvs rdiff -u -r1.91 -r1.92 src/sys/miscfs/nullfs/null_vfsops.c cvs rdiff -u -r1.64 -r1.65 src/sys/miscfs/overlay/overlay_vfsops.c cvs rdiff -u -r1.96 -r1.97 src/sys/miscfs/umapfs/umap_vfsops.c cvs rdiff -u -r1.220 -r1.221 src/sys/sys/mount.h cvs rdiff -u -r1.531 -r1.532 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_vfsops.c diff -u src/sys/fs/union/union_vfsops.c:1.76 src/sys/fs/union/union_vfsops.c:1.77 --- src/sys/fs/union/union_vfsops.c:1.76 Fri Feb 17 08:31:25 2017 +++ src/sys/fs/union/union_vfsops.c Mon Mar 6 10:10:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vfsops.c,v 1.76 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: union_vfsops.c,v 1.77 2017/03/06 10:10:07 hannken Exp $ */ /* * Copyright (c) 1994 The Regents of the University of California. @@ -77,7 +77,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.76 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vfsops.c,v 1.77 2017/03/06 10:10:07 hannken Exp $"); #include #include @@ -252,6 +252,8 @@ union_mount(struct mount *mp, const char if (error) goto bad; + mp->mnt_lower = um->um_uppervp->v_mount; + switch (um->um_op) { case UNMNT_ABOVE: cp = ":"; Index: src/sys/miscfs/nullfs/null_vfsops.c diff -u src/sys/miscfs/nullfs/null_vfsops.c:1.91 src/sys/miscfs/nullfs/null_vfsops.c:1.92 --- src/sys/miscfs/nullfs/null_vfsops.c:1.91 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/nullfs/null_vfsops.c Mon Mar 6 10:10:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: null_vfsops.c,v 1.91 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.91 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: null_vfsops.c,v 1.92 2017/03/06 10:10:07 hannken Exp $"); #include #include @@ -170,6 +170,7 @@ nullfs_mount(struct mount *mp, const cha vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vp->v_vflag |= VV_ROOT; nmp->nullm_rootvp = vp; + mp->mnt_lower = nmp->nullm_vfs; mp->mnt_iflag |= IMNT_MPSAFE; VOP_UNLOCK(vp); Index: src/sys/miscfs/overlay/overlay_vfsops.c diff -u src/sys/miscfs/overlay/overlay_vfsops.c:1.64 src/sys/miscfs/overlay/overlay_vfsops.c:1.65 --- src/sys/miscfs/overlay/overlay_vfsops.c:1.64 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/overlay/overlay_vfsops.c Mon Mar 6 10:10:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: overlay_vfsops.c,v 1.64 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: overlay_vfsops.c,v 1.65 2017/03/06 10:10:07 hannken Exp $ */ /* * Copyright (c) 1999, 2000 National Aeronautics & Space Administration @@ -74,7 +74,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.64 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.65 2017/03/06 10:10:07 hannken Exp $"); #include #include @@ -185,6 +185,7 @@ ov_mount(struct mount *mp, const char *p vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vp->v_vflag |= VV_ROOT; nmp->ovm_rootvp = vp; + mp->mnt_lower = nmp->ovm_vfs; VOP_UNLOCK(vp); error = set_statvfs_info(path, UIO_USERSPACE, args->la.target, Index: src/sys/miscfs/umapfs/umap_vfsops.c diff -u src/sys/miscfs/umapfs/umap_vfsops.c:1.96 src/sys/miscfs/umapfs/umap_vfsops.c:1.97 --- src/sys/miscfs/umapfs/umap_vfsops.c:1.96 Fri Feb 17 08:31:25 2017 +++ src/sys/miscfs/umapfs/umap_vfsops.c Mon Mar 6 10:10:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: umap_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: umap_vfsops.c,v 1.97 2017/03/06 10:10:07 hannken Exp $ */ /* * Copyright (c) 1992, 1993 @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.96 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: umap_vfsops.c,v 1.97 2017/03/06 10:10:07 hannken Exp $"); #include #include @@ -220,6 +220,7 @@ umapfs_mount(struct mount *mp, const cha vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); vp->v_vflag |= VV_ROOT; amp->umapm_rootvp = vp; + mp->mnt_lower = amp->umapm_vfs; VOP_UNLOCK(vp); error = set_statvfs_info(path, UIO_USERSPACE, args->umap_target, Index: src/sys/sys/mount.h diff -u src/sys/sys/mount.h:1.220 src/sys/sys/mount.h:1.221 --- src/sys/sys/mount.h:1.220 Wed Jan 11
CVS commit: src/sys/fs/union
Module Name:src Committed By: hannken Date: Mon Mar 6 10:08:49 UTC 2017 Modified Files: src/sys/fs/union: union_vnops.c Log Message: Handle v_writecount from union_open(), union_close() and union_revoke() so lower file system vnodes get marked as open for writing. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/fs/union/union_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/union/union_vnops.c diff -u src/sys/fs/union/union_vnops.c:1.63 src/sys/fs/union/union_vnops.c:1.64 --- src/sys/fs/union/union_vnops.c:1.63 Mon Apr 20 23:03:08 2015 +++ src/sys/fs/union/union_vnops.c Mon Mar 6 10:08:49 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: union_vnops.c,v 1.63 2015/04/20 23:03:08 riastradh Exp $ */ +/* $NetBSD: union_vnops.c,v 1.64 2017/03/06 10:08:49 hannken Exp $ */ /* * Copyright (c) 1992, 1993, 1994, 1995 @@ -72,7 +72,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.63 2015/04/20 23:03:08 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.64 2017/03/06 10:08:49 hannken Exp $"); #include #include @@ -616,6 +616,11 @@ union_open(void *v) error = union_copyup(un, (mode_TRUNC) == 0, cred, l); if (error == 0) error = VOP_OPEN(un->un_uppervp, mode, cred); + if (error == 0) { +mutex_enter(un->un_uppervp->v_interlock); +un->un_uppervp->v_writecount++; +mutex_exit(un->un_uppervp->v_interlock); + } return (error); } @@ -640,6 +645,11 @@ union_open(void *v) return ENXIO; error = VOP_OPEN(tvp, mode, cred); + if (error == 0 && (ap->a_mode & FWRITE)) { + mutex_enter(tvp->v_interlock); + tvp->v_writecount++; + mutex_exit(tvp->v_interlock); + } return (error); } @@ -669,6 +679,12 @@ union_close(void *v) KASSERT(vp != NULLVP); ap->a_vp = vp; + if ((ap->a_fflag & FWRITE)) { + KASSERT(vp == un->un_uppervp); + mutex_enter(vp->v_interlock); + vp->v_writecount--; + mutex_exit(vp->v_interlock); + } if (do_lock) vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); error = VCALL(vp, VOFFSET(vop_close), ap); @@ -1048,8 +1064,13 @@ union_revoke(void *v) } */ *ap = v; struct vnode *vp = ap->a_vp; - if (UPPERVP(vp)) + if (UPPERVP(vp)) { + mutex_enter(UPPERVP(vp)->v_interlock); + KASSERT(vp->v_interlock == UPPERVP(vp)->v_interlock); + UPPERVP(vp)->v_writecount -= vp->v_writecount; + mutex_exit(UPPERVP(vp)->v_interlock); VOP_REVOKE(UPPERVP(vp), ap->a_flags); + } if (LOWERVP(vp)) VOP_REVOKE(LOWERVP(vp), ap->a_flags); vgone(vp); /* XXXAD?? */
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Mar 6 10:07:52 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change vrecycle() and vgone() to lock with LK_RETRY. If this node is a layerfs node the lower node(s) may already be reclaimed. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.75 src/sys/kern/vfs_vnode.c:1.76 --- src/sys/kern/vfs_vnode.c:1.75 Fri Feb 17 08:30:00 2017 +++ src/sys/kern/vfs_vnode.c Mon Mar 6 10:07:52 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.75 2017/02/17 08:30:00 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.75 2017/02/17 08:30:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.76 2017/03/06 10:07:52 hannken Exp $"); #include #include @@ -919,7 +919,7 @@ vrecycle(vnode_t *vp) * On layered file systems waiting for the lock would open a can of * deadlocks as the lower vnodes may have other active references. */ - error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); + error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_NOWAIT); mutex_enter(vp->v_interlock); VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE); @@ -978,13 +978,12 @@ void vgone(vnode_t *vp) { - if (vn_lock(vp, LK_EXCLUSIVE) != 0) { - VSTATE_ASSERT(vp, VS_RECLAIMED); - vrele(vp); - } - + vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); mutex_enter(vp->v_interlock); - vcache_reclaim(vp); + VSTATE_WAIT_STABLE(vp); + if (VSTATE_GET(vp) == VS_ACTIVE) + vcache_reclaim(vp); + VSTATE_ASSERT(vp, VS_RECLAIMED); vrelel(vp, 0); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Mar 2 10:41:27 UTC 2017 Modified Files: src/sys/kern: vfs_trans.c Log Message: Add an operation to test a mount for fstrans support and use it for _fstrans_start(), fstrans_done(), fstrans_is_owner(), vfs_suspend() and vfs_resume(). Test for fstrans support before ASSERT_SLEEPABLE(). To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.37 src/sys/kern/vfs_trans.c:1.38 --- src/sys/kern/vfs_trans.c:1.37 Thu Feb 23 11:23:22 2017 +++ src/sys/kern/vfs_trans.c Thu Mar 2 10:41:27 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.37 2017/02/23 11:23:22 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.37 2017/02/23 11:23:22 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.38 2017/03/02 10:41:27 hannken Exp $"); /* * File system transaction operations. @@ -85,6 +85,7 @@ static pserialize_t fstrans_psz; /* Pser static LIST_HEAD(fstrans_lwp_head, fstrans_lwp_info) fstrans_fli_head; /* List of all fstrans_lwp_info. */ +static inline struct mount *fstrans_normalize_mount(struct mount *); static void fstrans_lwp_dtor(void *); static void fstrans_mount_dtor(struct mount *); static struct fstrans_lwp_info *fstrans_get_lwp_info(struct mount *, bool); @@ -115,6 +116,21 @@ fstrans_init(void) } /* + * Normalize mount. + * Return mount if file system supports fstrans, NULL otherwise. + */ +static inline struct mount * +fstrans_normalize_mount(struct mount *mp) +{ + + if (mp == NULL) + return NULL; + if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) + return NULL; + return mp; +} + +/* * Deallocate lwp state. */ static void @@ -199,6 +215,9 @@ void fstrans_unmount(struct mount *mp) { + if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) + return; + KASSERT(mp->mnt_transinfo != NULL); fstrans_mount_dtor(mp); @@ -235,16 +254,6 @@ fstrans_get_lwp_info(struct mount *mp, b return NULL; /* - * Does this file system support fstrans? - */ - mutex_enter(_mount_lock); - if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) { - mutex_exit(_mount_lock); - return NULL; - } - mutex_exit(_mount_lock); - - /* * Try to reuse a cleared entry or allocate a new one. */ for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) { @@ -321,9 +330,12 @@ _fstrans_start(struct mount *mp, enum fs struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; + if ((mp = fstrans_normalize_mount(mp)) == NULL) + return 0; + ASSERT_SLEEPABLE(); - if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL) + if ((fli = fstrans_get_lwp_info(mp, true)) == NULL) return 0; if (fli->fli_trans_cnt > 0) { @@ -367,7 +379,9 @@ fstrans_done(struct mount *mp) struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; - if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL) + if ((mp = fstrans_normalize_mount(mp)) == NULL) + return; + if ((fli = fstrans_get_lwp_info(mp, true)) == NULL) return; KASSERT(fli->fli_trans_cnt > 0); @@ -402,7 +416,9 @@ fstrans_is_owner(struct mount *mp) { struct fstrans_lwp_info *fli; - if (mp == NULL || (fli = fstrans_get_lwp_info(mp, false)) == NULL) + if ((mp = fstrans_normalize_mount(mp)) == NULL) + return 0; + if ((fli = fstrans_get_lwp_info(mp, false)) == NULL) return 0; if (fli->fli_trans_cnt == 0) @@ -506,6 +522,8 @@ vfs_suspend(struct mount *mp, int nowait { int error; + if ((mp = fstrans_normalize_mount(mp)) == NULL) + return EOPNOTSUPP; if (nowait) { if (!mutex_tryenter(_suspend_lock)) return EWOULDBLOCK; @@ -525,6 +543,9 @@ void vfs_resume(struct mount *mp) { + mp = fstrans_normalize_mount(mp); + KASSERT(mp != NULL); + VFS_SUSPENDCTL(mp, SUSPEND_RESUME); mutex_exit(_suspend_lock); }
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Wed Mar 1 21:55:07 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_vnops.c Log Message: Make compile again without "options WAPBL". >From John D. Baker via current-users@, slightly modified by me. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/sys/ufs/ffs/ffs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vnops.c diff -u src/sys/ufs/ffs/ffs_vnops.c:1.126 src/sys/ufs/ffs/ffs_vnops.c:1.127 --- src/sys/ufs/ffs/ffs_vnops.c:1.126 Wed Mar 1 10:42:45 2017 +++ src/sys/ufs/ffs/ffs_vnops.c Wed Mar 1 21:55:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vnops.c,v 1.126 2017/03/01 10:42:45 hannken Exp $ */ +/* $NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.126 2017/03/01 10:42:45 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vnops.c,v 1.127 2017/03/01 21:55:07 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -283,18 +283,20 @@ ffs_spec_fsync(void *v) } */ *ap = v; int error, flags, uflags; struct vnode *vp; +#ifdef WAPBL struct mount *mp; +#endif /* WAPBL */ flags = ap->a_flags; uflags = UPDATE_CLOSE | ((flags & FSYNC_WAIT) ? UPDATE_WAIT : 0); vp = ap->a_vp; - mp = vp->v_mount; error = spec_fsync(v); if (error) goto out; #ifdef WAPBL + mp = vp->v_mount; if (mp && mp->mnt_wapbl) { /* * Don't bother writing out metadata if the syncer is
CVS commit: src/sys/miscfs/genfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:47:26 UTC 2017 Modified Files: src/sys/miscfs/genfs: genfs_io.c Log Message: Protect genfs_getpages() against vnodes disappearing during a forced mount update from read-write to read-only. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/genfs/genfs_io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/genfs_io.c diff -u src/sys/miscfs/genfs/genfs_io.c:1.63 src/sys/miscfs/genfs/genfs_io.c:1.64 --- src/sys/miscfs/genfs/genfs_io.c:1.63 Thu Sep 29 19:08:48 2016 +++ src/sys/miscfs/genfs/genfs_io.c Wed Mar 1 10:47:26 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $ */ +/* $NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -31,7 +31,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.63 2016/09/29 19:08:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: genfs_io.c,v 1.64 2017/03/01 10:47:26 hannken Exp $"); #include #include @@ -129,8 +129,8 @@ genfs_getpages(void *v) const bool overwrite = (flags & PGO_OVERWRITE) != 0; const bool blockalloc = memwrite && (flags & PGO_NOBLOCKALLOC) == 0; const bool glocked = (flags & PGO_GLOCKHELD) != 0; - const bool need_wapbl = blockalloc && vp->v_mount->mnt_wapbl; - bool has_trans_wapbl = false; + bool holds_wapbl = false; + struct mount *trans_mount = NULL; UVMHIST_FUNC("genfs_getpages"); UVMHIST_CALLED(ubchist); UVMHIST_LOG(ubchist, "vp %p off 0x%x/%x count %d", @@ -291,20 +291,27 @@ startover: UVMHIST_LOG(ubchist, "ridx %d npages %d startoff %ld endoff %ld", ridx, npages, startoffset, endoffset); - if (!has_trans_wapbl) { - fstrans_start(vp->v_mount, FSTRANS_SHARED); + if (trans_mount == NULL) { + trans_mount = vp->v_mount; + fstrans_start(trans_mount, FSTRANS_SHARED); + /* + * check if this vnode is still valid. + */ + mutex_enter(vp->v_interlock); + error = vdead_check(vp, 0); + mutex_exit(vp->v_interlock); + if (error) + goto out_err_free; /* * XXX: This assumes that we come here only via * the mmio path */ - if (need_wapbl) { - error = WAPBL_BEGIN(vp->v_mount); - if (error) { -fstrans_done(vp->v_mount); + if (blockalloc && vp->v_mount->mnt_wapbl) { + error = WAPBL_BEGIN(trans_mount); + if (error) goto out_err_free; - } + holds_wapbl = true; } - has_trans_wapbl = true; } /* @@ -491,10 +498,10 @@ out_err_free: if (pgs != NULL && pgs != pgs_onstack) kmem_free(pgs, pgs_size); out_err: - if (has_trans_wapbl) { - if (need_wapbl) - WAPBL_END(vp->v_mount); - fstrans_done(vp->v_mount); + if (trans_mount != NULL) { + if (holds_wapbl) + WAPBL_END(trans_mount); + fstrans_done(trans_mount); } return error; }
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:46:43 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: Bring back read-write to read-only mount update for ffs. To generate a diff of this commit: cvs rdiff -u -r1.347 -r1.348 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.347 src/sys/ufs/ffs/ffs_vfsops.c:1.348 --- src/sys/ufs/ffs/ffs_vfsops.c:1.347 Wed Mar 1 10:42:45 2017 +++ src/sys/ufs/ffs/ffs_vfsops.c Wed Mar 1 10:46:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.348 2017/03/01 10:46:43 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -564,7 +564,7 @@ ffs_mount(struct mount *mp, const char * ump = VFSTOUFS(mp); fs = ump->um_fs; - if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { + if (fs->fs_ronly == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY)) { /* * Changing from r/w to r/o */ @@ -599,7 +599,7 @@ ffs_mount(struct mount *mp, const char * } #endif /* WAPBL */ - if (fs->fs_ronly == 0 && (mp->mnt_flag & MNT_RDONLY)) { + if (fs->fs_ronly == 0 && (mp->mnt_iflag & IMNT_WANTRDONLY)) { /* * Finish change from r/w to r/o */ @@ -1455,7 +1455,7 @@ ffs_mountfs(struct vnode *devvp, struct mp->mnt_fs_bshift = fs->fs_bshift; mp->mnt_dev_bshift = DEV_BSHIFT; /* XXX */ mp->mnt_flag |= MNT_LOCAL; - mp->mnt_iflag |= IMNT_MPSAFE; + mp->mnt_iflag |= IMNT_MPSAFE | IMNT_CAN_RWTORO; #ifdef FFS_EI if (needswap) ump->um_flags |= UFS_NEEDSWAP;
CVS commit: src/sys/miscfs/specfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:46:05 UTC 2017 Modified Files: src/sys/miscfs/specfs: spec_vnops.c Log Message: Add a diagnostic test for buffers written to a block device holding a read-only mounted file system. This will become a KASSERT in the near future. To generate a diff of this commit: cvs rdiff -u -r1.168 -r1.169 src/sys/miscfs/specfs/spec_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/specfs/spec_vnops.c diff -u src/sys/miscfs/specfs/spec_vnops.c:1.168 src/sys/miscfs/specfs/spec_vnops.c:1.169 --- src/sys/miscfs/specfs/spec_vnops.c:1.168 Mon Jan 2 10:33:28 2017 +++ src/sys/miscfs/specfs/spec_vnops.c Wed Mar 1 10:46:05 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: spec_vnops.c,v 1.169 2017/03/01 10:46:05 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.168 2017/01/02 10:33:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: spec_vnops.c,v 1.169 2017/03/01 10:46:05 hannken Exp $"); #include #include @@ -1053,6 +1053,16 @@ spec_strategy(void *v) bp->b_dev = dev; if (!(bp->b_flags & B_READ)) { +#ifdef DIAGNOSTIC + if (bp->b_vp && bp->b_vp->v_type == VBLK) { + struct mount *mp = spec_node_getmountedfs(bp->b_vp); + + if (mp && (mp->mnt_flag & MNT_RDONLY)) { +printf("%s blk %"PRId64" written while ro!\n", +mp->mnt_stat.f_mntonname, bp->b_blkno); + } + } +#endif /* DIAGNOSTIC */ error = fscow_run(bp, false); if (error) goto out;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Mar 1 10:45:24 UTC 2017 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Suspend the mounted file system while updating. To generate a diff of this commit: cvs rdiff -u -r1.507 -r1.508 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.507 src/sys/kern/vfs_syscalls.c:1.508 --- src/sys/kern/vfs_syscalls.c:1.507 Wed Mar 1 10:44:47 2017 +++ src/sys/kern/vfs_syscalls.c Wed Mar 1 10:45:24 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.507 2017/03/01 10:44:47 hannken Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.507 2017/03/01 10:44:47 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.508 2017/03/01 10:45:24 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -287,6 +287,10 @@ mount_update(struct lwp *l, struct vnode goto out; } + error = vfs_suspend(mp, 0); + if (error) + goto out; + mutex_enter(>mnt_updating); mp->mnt_flag &= ~MNT_OP_FLAGS; @@ -339,6 +343,7 @@ mount_update(struct lwp *l, struct vnode vfs_syncer_remove_from_worklist(mp); } mutex_exit(>mnt_updating); + vfs_resume(mp); vfs_unbusy(mp, false, NULL); if ((error == 0) && !(saved_flags & MNT_EXTATTR) &&
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Wed Mar 1 10:44:47 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c src/sys/kern: vfs_syscalls.c src/sys/rump/librump/rumpvfs: rumpfs.c src/sys/sys: fstypes.h param.h Log Message: Change the protocol to update a mounted file system from read-write to read-only and vice versa: - Add an internal flag IMNT_WANTRDONLY. - Set either IMNT_WANTRDWR or IMNT_WANTRDONLY if going from or to read-only. - After successfull call to VFS_MOUNT() set or clear MNT_RDONLY. Adapt tmpfs and rumpfs to the new protocol. Other file systems will be updated when they get the IMNT_CAN_RWTORO property. Welcome to 7.99.64 To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.70 -r1.71 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.506 -r1.507 src/sys/kern/vfs_syscalls.c cvs rdiff -u -r1.144 -r1.145 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.34 -r1.35 src/sys/sys/fstypes.h cvs rdiff -u -r1.530 -r1.531 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs.h diff -u src/sys/fs/tmpfs/tmpfs.h:1.53 src/sys/fs/tmpfs/tmpfs.h:1.54 --- src/sys/fs/tmpfs/tmpfs.h:1.53 Fri Jan 27 10:47:54 2017 +++ src/sys/fs/tmpfs/tmpfs.h Wed Mar 1 10:44:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.53 2017/01/27 10:47:54 hannken Exp $ */ +/* $NetBSD: tmpfs.h,v 1.54 2017/03/01 10:44:47 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -217,9 +217,6 @@ typedef struct tmpfs_mount { uint64_t tm_bytes_used; kmutex_t tm_acc_lock; - /* Read-only indicator. */ - bool tm_rdonly; - /* Pointer to the root inode. */ tmpfs_node_t * tm_root; Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.70 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.71 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.70 Fri Feb 17 08:31:25 2017 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Wed Mar 1 10:44:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.70 2017/02/17 08:31:25 hannken Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.71 2017/03/01 10:44:47 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.70 2017/02/17 08:31:25 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.71 2017/03/01 10:44:47 hannken Exp $"); #include #include @@ -160,7 +160,7 @@ tmpfs_mount(struct mount *mp, const char tmp = VFS_TO_TMPFS(mp); if (set_nodes && nodes < tmp->tm_nodes_cnt) return EBUSY; - if (!tmp->tm_rdonly && (mp->mnt_flag & MNT_RDONLY)) { + if ((mp->mnt_iflag & IMNT_WANTRDONLY)) { /* Changing from read/write to read-only. */ flags = WRITECLOSE; if ((mp->mnt_flag & MNT_FORCE)) @@ -168,11 +168,6 @@ tmpfs_mount(struct mount *mp, const char error = vflush(mp, NULL, flags); if (error) return error; - tmp->tm_rdonly = true; - } - if (tmp->tm_rdonly && (mp->mnt_flag & IMNT_WANTRDWR)) { - /* Changing from read-only to read/write. */ - tmp->tm_rdonly = false; } if (set_memlimit) { if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0) @@ -192,8 +187,6 @@ tmpfs_mount(struct mount *mp, const char if (tmp == NULL) return ENOMEM; - if ((mp->mnt_flag & MNT_RDONLY)) - tmp->tm_rdonly = true; tmp->tm_nodes_max = nodes; tmp->tm_nodes_cnt = 0; LIST_INIT(>tm_nodes); Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.506 src/sys/kern/vfs_syscalls.c:1.507 --- src/sys/kern/vfs_syscalls.c:1.506 Fri Feb 17 08:26:07 2017 +++ src/sys/kern/vfs_syscalls.c Wed Mar 1 10:44:47 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.506 2017/02/17 08:26:07 hannken Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.507 2017/03/01 10:44:47 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.506 2017/02/17 08:26:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.507 2017/03/01 10:44:47 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -295,12 +295,14 @@ mount_update(struct lwp *l, struct vnode /* * Set the mount level flags. */ - if (flags & MNT_RDONLY) - mp->mnt_flag |= MNT_RDONLY; - else if (mp->mnt_flag & MNT_RDONLY) - mp->mnt_iflag |= IMNT_WANTRDWR; + if ((flags & MNT_RDONLY) != (mp->mnt_flag & MNT_RDONLY)) { + if ((flags & MNT_RDONLY)) + mp->mnt_iflag |= IMNT_WANTRDONLY; + else + mp->mnt_iflag |= IMNT_WANTRDWR; + } mp->mnt_flag &= ~MNT_BASIC_FLAGS; - mp->mnt_flag |= flags & MNT_BASIC_FLAGS; + mp->mnt_flag |= (flags & ~MNT_RDONLY) & MNT_BASIC_FLAGS; error = VFS_MOUNT(mp, path, data, data_len); if (error && data != NULL) { @@ -321,12 +323,14 @@ mount_update(struct lwp *l, struct vnode error = error2;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Mar 1 10:43:37 UTC 2017 Modified Files: src/sys/kern: vfs_vnops.c Log Message: Must always lock the parent -> lock the child -> unlock the parent. To generate a diff of this commit: cvs rdiff -u -r1.193 -r1.194 src/sys/kern/vfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnops.c diff -u src/sys/kern/vfs_vnops.c:1.193 src/sys/kern/vfs_vnops.c:1.194 --- src/sys/kern/vfs_vnops.c:1.193 Wed Feb 4 07:09:37 2015 +++ src/sys/kern/vfs_vnops.c Wed Mar 1 10:43:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnops.c,v 1.193 2015/02/04 07:09:37 msaitoh Exp $ */ +/* $NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -66,7 +66,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.193 2015/02/04 07:09:37 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $"); #include "veriexec.h" @@ -210,12 +210,14 @@ vn_open(struct nameidata *ndp, int fmode va.va_vaflags |= VA_EXCLUSIVE; error = VOP_CREATE(ndp->ni_dvp, >ni_vp, >ni_cnd, ); - vput(ndp->ni_dvp); - if (error) + if (error) { +vput(ndp->ni_dvp); goto out; + } fmode &= ~O_TRUNC; vp = ndp->ni_vp; vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); + vput(ndp->ni_dvp); } else { VOP_ABORTOP(ndp->ni_dvp, >ni_cnd); if (ndp->ni_dvp == ndp->ni_vp)
CVS commit: src/sys/ufs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:42:46 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_alloc.c ffs_snapshot.c ffs_vfsops.c ffs_vnops.c src/sys/ufs/ufs: ufs_bmap.c ufs_inode.c ufs_quota2.c ufs_readwrite.c ufs_vnops.c ufs_wapbl.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.154 -r1.155 src/sys/ufs/ffs/ffs_alloc.c cvs rdiff -u -r1.145 -r1.146 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.346 -r1.347 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.125 -r1.126 src/sys/ufs/ffs/ffs_vnops.c cvs rdiff -u -r1.50 -r1.51 src/sys/ufs/ufs/ufs_bmap.c cvs rdiff -u -r1.98 -r1.99 src/sys/ufs/ufs/ufs_inode.c cvs rdiff -u -r1.41 -r1.42 src/sys/ufs/ufs/ufs_quota2.c cvs rdiff -u -r1.120 -r1.121 src/sys/ufs/ufs/ufs_readwrite.c cvs rdiff -u -r1.234 -r1.235 src/sys/ufs/ufs/ufs_vnops.c cvs rdiff -u -r1.23 -r1.24 src/sys/ufs/ufs/ufs_wapbl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_alloc.c diff -u src/sys/ufs/ffs/ffs_alloc.c:1.154 src/sys/ufs/ffs/ffs_alloc.c:1.155 --- src/sys/ufs/ffs/ffs_alloc.c:1.154 Sun Oct 30 15:01:46 2016 +++ src/sys/ufs/ffs/ffs_alloc.c Wed Mar 1 10:42:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.154 2016/10/30 15:01:46 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.155 2017/03/01 10:42:45 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -82,7 +82,6 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c, #include #include #include -#include #include #include #include Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.145 src/sys/ufs/ffs/ffs_snapshot.c:1.146 --- src/sys/ufs/ffs/ffs_snapshot.c:1.145 Fri Feb 17 08:30:00 2017 +++ src/sys/ufs/ffs/ffs_snapshot.c Wed Mar 1 10:42:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.145 2017/02/17 08:30:00 hannken Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.145 2017/02/17 08:30:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.146 2017/03/01 10:42:45 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -2086,7 +2086,6 @@ ffs_snapshot_read(struct vnode *vp, stru long size, xfersize, blkoffset; int error; - fstrans_start(vp->v_mount, FSTRANS_SHARED); mutex_enter(>si_snaplock); if (ioflag & IO_ALTSEMANTICS) @@ -2139,7 +2138,6 @@ ffs_snapshot_read(struct vnode *vp, stru brelse(bp, BC_AGE); mutex_exit(>si_snaplock); - fstrans_done(vp->v_mount); return error; } Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.346 src/sys/ufs/ffs/ffs_vfsops.c:1.347 --- src/sys/ufs/ffs/ffs_vfsops.c:1.346 Wed Feb 22 09:50:13 2017 +++ src/sys/ufs/ffs/ffs_vfsops.c Wed Mar 1 10:42:45 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.346 2017/02/22 09:50:13 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.346 2017/02/22 09:50:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.347 2017/03/01 10:42:45 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -92,7 +92,6 @@ __KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c #include #include #include -#include #include #include @@ -1832,7 +1831,6 @@ ffs_statvfs(struct mount *mp, struct sta struct ffs_sync_ctx { int waitfor; - bool is_suspending; }; static bool @@ -1869,9 +1867,6 @@ ffs_sync_selector(void *cl, struct vnode UVM_OBJ_IS_CLEAN(>v_uobj return false; - if (vp->v_type == VBLK && c->is_suspending) - return false; - return true; } @@ -1890,7 +1885,6 @@ ffs_sync(struct mount *mp, int waitfor, struct fs *fs; struct vnode_iterator *marker; int error, allerror = 0; - bool is_suspending; struct ffs_sync_ctx ctx; fs = ump->um_fs; @@ -1898,15 +1892,12 @@ ffs_sync(struct mount *mp, int waitfor, panic("%s: rofs mod, fs=%s", __func__, fs->fs_fsmnt); } - fstrans_start(mp, FSTRANS_SHARED); - is_suspending = (fstrans_getstate(mp) == FSTRANS_SUSPENDING); /* * Write back each (modified) inode. */ vfs_vnode_iterator_init(mp, ); ctx.waitfor = waitfor; - ctx.is_suspending = is_suspending; while ((vp = vfs_vnode_iterator_next(marker, ffs_sync_selector, ))) { error = vn_lock(vp, @@ -1971,7 +1962,6 @@ ffs_sync(struct
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Wed Mar 1 10:41:28 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_denode.c msdosfs_vfsops.c msdosfs_vnops.c Log Message: Remove now redundant calls to fstrans_start()/fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.123 -r1.124 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.96 -r1.97 src/sys/fs/msdosfs/msdosfs_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_denode.c diff -u src/sys/fs/msdosfs/msdosfs_denode.c:1.52 src/sys/fs/msdosfs/msdosfs_denode.c:1.53 --- src/sys/fs/msdosfs/msdosfs_denode.c:1.52 Sat Aug 20 12:37:07 2016 +++ src/sys/fs/msdosfs/msdosfs_denode.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $ */ +/* $NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,12 +48,11 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.52 2016/08/20 12:37:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.53 2017/03/01 10:41:28 hannken Exp $"); #include #include #include -#include #include #include #include @@ -537,10 +536,8 @@ msdosfs_reclaim(void *v) struct vnode *a_vp; } */ *ap = v; struct vnode *vp = ap->a_vp; - struct mount *mp = vp->v_mount; struct denode *dep = VTODE(vp); - fstrans_start(mp, FSTRANS_LAZY); #ifdef MSDOSFS_DEBUG printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n", dep, dep->de_Name, dep->de_refcnt); @@ -566,7 +563,6 @@ msdosfs_reclaim(void *v) vp->v_data = NULL; mutex_exit(vp->v_interlock); pool_put(_denode_pool, dep); - fstrans_done(mp); return (0); } @@ -578,7 +574,6 @@ msdosfs_inactive(void *v) bool *a_recycle; } */ *ap = v; struct vnode *vp = ap->a_vp; - struct mount *mp = vp->v_mount; struct denode *dep = VTODE(vp); int error = 0; @@ -586,7 +581,6 @@ msdosfs_inactive(void *v) printf("msdosfs_inactive(): dep %p, de_Name[0] %x\n", dep, dep->de_Name[0]); #endif - fstrans_start(mp, FSTRANS_LAZY); /* * Get rid of denodes related to stale file handles. */ @@ -623,7 +617,6 @@ out: #endif *ap->a_recycle = (dep->de_Name[0] == SLOT_DELETED); VOP_UNLOCK(vp); - fstrans_done(mp); return (error); } Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.124 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 Wed Feb 22 09:50:13 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.124 2017/03/01 10:41:28 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -69,7 +69,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vfso #include #include #include -#include #include #include #include @@ -1002,7 +1001,6 @@ msdosfs_sync(struct mount *mp, int waitf /* update FATs here */ } } - fstrans_start(mp, FSTRANS_SHARED); /* * Write back each (modified) denode. */ @@ -1031,7 +1029,6 @@ msdosfs_sync(struct mount *mp, int waitf waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) allerror = error; VOP_UNLOCK(pmp->pm_devvp); - fstrans_done(mp); return (allerror); } Index: src/sys/fs/msdosfs/msdosfs_vnops.c diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 src/sys/fs/msdosfs/msdosfs_vnops.c:1.97 --- src/sys/fs/msdosfs/msdosfs_vnops.c:1.96 Mon Feb 1 16:53:23 2016 +++ src/sys/fs/msdosfs/msdosfs_vnops.c Wed Mar 1 10:41:28 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $ */ +/* $NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.96 2016/02/01 16:53:23 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $"); #include #include @@ -60,7 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vnop #include #include #include -#include #include #include #include @@ -120,7 +119,6 @@ msdosfs_create(void *v) printf("msdosfs_create(cnp %p, vap %p\n", cnp, ap->a_vap); #endif - fstrans_start(ap->a_dvp->v_mount, FSTRANS_SHARED); /* * If this is the root directory and there is no space left we * can't do anything. This is because the root directory can not @@
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Feb 23 11:23:22 UTC 2017 Modified Files: src/sys/kern: vfs_trans.c Log Message: Test for fstrans support before trying to allocate per-thread info. PR kern/51996 (kmem_alloc called from intr context in fstrans_get_lwp_info) To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.36 src/sys/kern/vfs_trans.c:1.37 --- src/sys/kern/vfs_trans.c:1.36 Fri Feb 17 08:25:15 2017 +++ src/sys/kern/vfs_trans.c Thu Feb 23 11:23:22 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.36 2017/02/17 08:25:15 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.37 2017/02/23 11:23:22 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.36 2017/02/17 08:25:15 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.37 2017/02/23 11:23:22 hannken Exp $"); /* * File system transaction operations. @@ -235,6 +235,16 @@ fstrans_get_lwp_info(struct mount *mp, b return NULL; /* + * Does this file system support fstrans? + */ + mutex_enter(_mount_lock); + if ((mp->mnt_iflag & IMNT_HAS_TRANS) == 0) { + mutex_exit(_mount_lock); + return NULL; + } + mutex_exit(_mount_lock); + + /* * Try to reuse a cleared entry or allocate a new one. */ for (fli = lwp_getspecific(lwp_data_key); fli; fli = fli->fli_succ) { @@ -274,14 +284,10 @@ fstrans_get_lwp_info(struct mount *mp, b * Attach the entry to the mount. */ mutex_enter(_mount_lock); - if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) { - fli = NULL; - } else { - fmi = mp->mnt_transinfo; - KASSERT(fmi != NULL); - fli->fli_mount = mp; - fmi->fmi_ref_cnt += 1; - } + fmi = mp->mnt_transinfo; + KASSERT(fmi != NULL); + fli->fli_mount = mp; + fmi->fmi_ref_cnt += 1; mutex_exit(_mount_lock); return fli;
CVS commit: src/sys/rump/librump/rumpkern
Module Name:src Committed By: hannken Date: Wed Feb 22 11:20:59 UTC 2017 Modified Files: src/sys/rump/librump/rumpkern: emul.c Log Message: Add weak aliases for _fstrans_start() and fstrans_done(). To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/sys/rump/librump/rumpkern/emul.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpkern/emul.c diff -u src/sys/rump/librump/rumpkern/emul.c:1.180 src/sys/rump/librump/rumpkern/emul.c:1.181 --- src/sys/rump/librump/rumpkern/emul.c:1.180 Thu Dec 22 16:05:15 2016 +++ src/sys/rump/librump/rumpkern/emul.c Wed Feb 22 11:20:59 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: emul.c,v 1.180 2016/12/22 16:05:15 cherry Exp $ */ +/* $NetBSD: emul.c,v 1.181 2017/02/22 11:20:59 hannken Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -26,11 +26,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.180 2016/12/22 16:05:15 cherry Exp $"); +__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.181 2017/02/22 11:20:59 hannken Exp $"); #include #include #include +#include #include #include #include @@ -240,6 +241,25 @@ void (*delay_func)(unsigned int) = rump_ __strong_alias(delay,rump_delay); __strong_alias(_delay,rump_delay); +/* Weak aliases for fstrans to be used unless librumpvfs is present. */ + +int rump__fstrans_start(struct mount *, enum fstrans_lock_type, int); +int +rump__fstrans_start(struct mount *mp, enum fstrans_lock_type lock, int wait) +{ + + return 0; +} +__weak_alias(_fstrans_start,rump__fstrans_start); + +void rump_fstrans_done(struct mount *); +void +rump_fstrans_done(struct mount *mp) +{ + +} +__weak_alias(fstrans_done,rump_fstrans_done); + /* * Provide weak aliases for tty routines used by printf. * They will be used unless the rumpkern_tty component is present.
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Wed Feb 22 09:50:13 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/kern: vfs_mount.c src/sys/sys: param.h src/sys/ufs/ffs: ffs_vfsops.c Log Message: Enable fstrans on all file systems. Welcome to 7.99.61 To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.47 -r1.48 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.527 -r1.528 src/sys/sys/param.h cvs rdiff -u -r1.345 -r1.346 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.122 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.123 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.122 Fri Feb 17 08:31:24 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Feb 22 09:50:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.122 2017/02/17 08:31:24 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.122 2017/02/17 08:31:24 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.123 2017/02/22 09:50:13 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -478,10 +478,6 @@ msdosfs_mountfs(struct vnode *devvp, str bp = NULL; /* both used in error_exit */ pmp = NULL; - error = fstrans_mount(mp); - if (error) - goto error_exit; - error = getdisksize(devvp, , ); if (error) { if (argp->flags & MSDOSFSMNT_GEMDOSFS) @@ -858,7 +854,6 @@ msdosfs_mountfs(struct vnode *devvp, str return (0); error_exit: - fstrans_unmount(mp); if (bp) brelse(bp, BC_AGE); if (pmp) { @@ -923,7 +918,6 @@ msdosfs_unmount(struct mount *mp, int mn free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; mp->mnt_flag &= ~MNT_LOCAL; - fstrans_unmount(mp); return (0); } Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.47 src/sys/kern/vfs_mount.c:1.48 --- src/sys/kern/vfs_mount.c:1.47 Fri Jan 27 10:50:10 2017 +++ src/sys/kern/vfs_mount.c Wed Feb 22 09:50:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.47 2017/01/27 10:50:10 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.48 2017/02/22 09:50:13 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.47 2017/01/27 10:50:10 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.48 2017/02/22 09:50:13 hannken Exp $"); #include #include @@ -82,6 +82,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c, #include #include #include +#include #include #include #include @@ -710,6 +711,12 @@ mount_domount(struct lwp *l, vnode_t **v return ENOMEM; } + if ((error = fstrans_mount(mp)) != 0) { + vfs_unbusy(mp, false, NULL); + vfs_destroy(mp); + return error; + } + mp->mnt_stat.f_owner = kauth_cred_geteuid(l->l_cred); /* @@ -794,6 +801,7 @@ err_mounted: err_unmounted: vp->v_mountedhere = NULL; mutex_exit(>mnt_updating); + fstrans_unmount(mp); vfs_unbusy(mp, false, NULL); vfs_destroy(mp); @@ -919,6 +927,7 @@ dounmount(struct mount *mp, int flags, s mutex_exit(_mutex); vfs_hooks_unmount(mp); + fstrans_unmount(mp); vfs_destroy(mp); /* reference from mount() */ if (coveredvp != NULLVP) { vrele(coveredvp); @@ -1200,6 +1209,8 @@ done: mp = TAILQ_FIRST(); mp->mnt_flag |= MNT_ROOTFS; mp->mnt_op->vfs_refcount++; + error = fstrans_mount(mp); + KASSERT(error == 0); /* * Get the vnode for '/'. Set cwdi0.cwdi_cdir to Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.527 src/sys/sys/param.h:1.528 --- src/sys/sys/param.h:1.527 Fri Feb 17 08:32:04 2017 +++ src/sys/sys/param.h Wed Feb 22 09:50:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.527 2017/02/17 08:32:04 hannken Exp $ */ +/* $NetBSD: param.h,v 1.528 2017/02/22 09:50:13 hannken Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 799006000 /* NetBSD 7.99.60 */ +#define __NetBSD_Version__ 799006100 /* NetBSD 7.99.61 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__) Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.345 src/sys/ufs/ffs/ffs_vfsops.c:1.346 --- src/sys/ufs/ffs/ffs_vfsops.c:1.345 Fri Feb 17 08:31:26 2017 +++ src/sys/ufs/ffs/ffs_vfsops.c Wed Feb 22 09:50:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.345 2017/02/17 08:31:26 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.346 2017/02/22 09:50:13 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0,
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Wed Feb 22 09:47:18 UTC 2017 Modified Files: src/sys/kern: vnode_if.c src/sys/rump/include/rump: rumpvnode_if.h src/sys/rump/librump/rumpvfs: rumpvnode_if.c src/sys/sys: vnode_if.h Log Message: Regen. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/kern/vnode_if.c cvs rdiff -u -r1.20 -r1.21 src/sys/rump/include/rump/rumpvnode_if.h cvs rdiff -u -r1.20 -r1.21 src/sys/rump/librump/rumpvfs/rumpvnode_if.c cvs rdiff -u -r1.91 -r1.92 src/sys/sys/vnode_if.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vnode_if.c diff -u src/sys/kern/vnode_if.c:1.96 src/sys/kern/vnode_if.c:1.97 --- src/sys/kern/vnode_if.c:1.96 Tue Jan 26 23:30:10 2016 +++ src/sys/kern/vnode_if.c Wed Feb 22 09:47:18 2017 @@ -1,13 +1,13 @@ -/* $NetBSD: vnode_if.c,v 1.96 2016/01/26 23:30:10 pooka Exp $ */ +/* $NetBSD: vnode_if.c,v 1.97 2017/02/22 09:47:18 hannken Exp $ */ /* * Warning: DO NOT EDIT! This file is automatically generated! * (Modifications made here may easily be lost!) * * Created from the file: - * NetBSD: vnode_if.src,v 1.69 2015/04/20 23:08:07 riastradh Exp + * NetBSD: vnode_if.src,v 1.70 2017/02/22 09:45:51 hannken Exp * by the script: - * NetBSD: vnode_if.sh,v 1.60 2014/01/13 12:07:55 hannken Exp + * NetBSD: vnode_if.sh,v 1.62 2017/02/22 09:45:51 hannken Exp */ /* @@ -40,13 +40,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.96 2016/01/26 23:30:10 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vnode_if.c,v 1.97 2017/02/22 09:47:18 hannken Exp $"); #include #include #include #include #include +#include const struct vnodeop_desc vop_default_desc = { 0, @@ -79,12 +80,15 @@ VOP_BWRITE(struct vnode *vp, int error; bool mpsafe; struct vop_bwrite_args a; + struct mount *mp = vp->v_mount; a.a_desc = VDESC(vop_bwrite); a.a_vp = vp; a.a_bp = bp; mpsafe = (vp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(vp, VOFFSET(vop_bwrite), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -588,12 +592,15 @@ VOP_POLL(struct vnode *vp, int error; bool mpsafe; struct vop_poll_args a; + struct mount *mp = vp->v_mount; a.a_desc = VDESC(vop_poll); a.a_vp = vp; a.a_events = events; mpsafe = (vp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(vp, VOFFSET(vop_poll), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -618,12 +625,15 @@ VOP_KQFILTER(struct vnode *vp, int error; bool mpsafe; struct vop_kqfilter_args a; + struct mount *mp = vp->v_mount; a.a_desc = VDESC(vop_kqfilter); a.a_vp = vp; a.a_kn = kn; mpsafe = (vp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(vp, VOFFSET(vop_kqfilter), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -679,13 +689,16 @@ VOP_MMAP(struct vnode *vp, int error; bool mpsafe; struct vop_mmap_args a; + struct mount *mp = vp->v_mount; a.a_desc = VDESC(vop_mmap); a.a_vp = vp; a.a_prot = prot; a.a_cred = cred; mpsafe = (vp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(vp, VOFFSET(vop_mmap), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -748,6 +761,7 @@ VOP_SEEK(struct vnode *vp, int error; bool mpsafe; struct vop_seek_args a; + struct mount *mp = vp->v_mount; a.a_desc = VDESC(vop_seek); a.a_vp = vp; a.a_oldoff = oldoff; @@ -755,7 +769,9 @@ VOP_SEEK(struct vnode *vp, a.a_cred = cred; mpsafe = (vp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(vp, VOFFSET(vop_seek), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -853,6 +869,7 @@ VOP_RENAME(struct vnode *fdvp, int error; bool mpsafe; struct vop_rename_args a; + struct mount *mp = fdvp->v_mount; a.a_desc = VDESC(vop_rename); a.a_fdvp = fdvp; a.a_fvp = fvp; @@ -862,7 +879,9 @@ VOP_RENAME(struct vnode *fdvp, a.a_tcnp = tcnp; mpsafe = (fdvp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp); } + fstrans_start(mp, FSTRANS_SHARED); error = (VCALL(fdvp, VOFFSET(vop_rename), )); + fstrans_done(mp); if (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); } return error; } @@ -1070,12 +1089,15 @@ VOP_ABORTOP(struct vnode *dvp, int error; bool mpsafe; struct vop_abortop_args a; + struct mount *mp = dvp->v_mount; a.a_desc = VDESC(vop_abortop); a.a_dvp = dvp; a.a_cnp = cnp; mpsafe = (dvp->v_vflag & VV_MPSAFE); if (!mpsafe) { KERNEL_LOCK(1, curlwp);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Feb 22 09:45:52 UTC 2017 Modified Files: src/sys/kern: vnode_if.sh vnode_if.src Log Message: Prepare to move fstrans into vnode_if.c, allow "FSTRANS=YES" and "FSTRANS=NO" in the vop description. Add fstrans_start()/fstrans_done() to all vops that have FSTRANS=YES or have the first vnode unlocked. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vnode_if.sh cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vnode_if.src Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vnode_if.sh diff -u src/sys/kern/vnode_if.sh:1.61 src/sys/kern/vnode_if.sh:1.62 --- src/sys/kern/vnode_if.sh:1.61 Tue Jan 26 23:28:06 2016 +++ src/sys/kern/vnode_if.sh Wed Feb 22 09:45:51 2017 @@ -29,7 +29,7 @@ copyright="\ * SUCH DAMAGE. */ " -SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.61 2016/01/26 23:28:06 pooka Exp $' +SCRIPT_ID='$NetBSD: vnode_if.sh,v 1.62 2017/02/22 09:45:51 hannken Exp $' # Script to produce VFS front-end sugar. # @@ -100,6 +100,7 @@ awk_parser=' args_name=$1; argc=0; willmake=-1; + fstrans=0; next; } # Last line of description @@ -112,6 +113,12 @@ awk_parser=' if ($1 == "VERSION") { args_name=args_name "_v" $2; next; + } else if ($1 == "FSTRANS=YES") { + fstrans = 1; + next; + } else if ($1 == "FSTRANS=NO") { + fstrans = -1; + next; } argdir[argc] = $1; i=2; @@ -144,6 +151,8 @@ awk_parser=' willmake=argc; i++; } + if (argc == 0 && fstrans == 0 && lockstate[0] != 1) + fstrans = 1; # XXX: replace non-portable types for rump. We should really # nuke the types from the kernel, but that is a battle for @@ -305,6 +314,7 @@ echo ' #include #include #include ' +[ -z "${rump}" ] && echo '#include ' [ ! -z "${rump}" ] && echo '#include ' \ && echo '#include ' @@ -397,6 +407,8 @@ function bodyrump() { function bodynorm() { printf("{\n\tint error;\n\tbool mpsafe;\n\tstruct %s_args a;\n", args_name); + if (fstrans == 1) + printf("\tstruct mount *mp = %s->v_mount;\n", argname[0]); if (lockdebug) { printf("#ifdef VNODE_LOCKDEBUG\n"); for (i=0; iv_vflag & VV_MPSAFE);\n", argname[0]); printf("\tif (!mpsafe) { KERNEL_LOCK(1, curlwp); }\n"); + if (fstrans == 1) + printf("\tfstrans_start(mp, FSTRANS_SHARED);\n"); printf("\terror = (VCALL(%s, VOFFSET(%s), ));\n", argname[0], name); + if (fstrans == 1) + printf("\tfstrans_done(mp);\n"); printf("\tif (!mpsafe) { KERNEL_UNLOCK_ONE(curlwp); }\n"); if (willmake != -1) { printf("#ifdef DIAGNOSTIC\n"); Index: src/sys/kern/vnode_if.src diff -u src/sys/kern/vnode_if.src:1.69 src/sys/kern/vnode_if.src:1.70 --- src/sys/kern/vnode_if.src:1.69 Mon Apr 20 23:08:07 2015 +++ src/sys/kern/vnode_if.src Wed Feb 22 09:45:51 2017 @@ -1,4 +1,4 @@ -# $NetBSD: vnode_if.src,v 1.69 2015/04/20 23:08:07 riastradh Exp $ +# $NetBSD: vnode_if.src,v 1.70 2017/02/22 09:45:51 hannken Exp $ # # Copyright (c) 1992, 1993 # The Regents of the University of California. All rights reserved. @@ -72,7 +72,7 @@ vop_bwrite { # vop_lookup { VERSION 2 - IN struct vnode *dvp; + IN LOCKED=YES struct vnode *dvp; OUT WILLMAKE struct vnode **vpp; IN struct componentname *cnp; }; @@ -136,7 +136,7 @@ vop_access { #% getattrvp L L L # vop_getattr { - IN struct vnode *vp; + IN LOCKED=YES struct vnode *vp; IN struct vattr *vap; IN kauth_cred_t cred; }; @@ -192,6 +192,7 @@ vop_fdiscard { #% ioctl vp U U U # vop_ioctl { + FSTRANS=NO IN LOCKED=NO struct vnode *vp; IN u_long command; IN void *data; @@ -203,6 +204,7 @@ vop_ioctl { #% fcntl vp U U U # vop_fcntl { + FSTRANS=NO IN LOCKED=NO struct vnode *vp; IN u_int command; IN void *data; @@ -230,6 +232,7 @@ vop_kqfilter { #% revoke vp U U U # vop_revoke { + FSTRANS=NO IN LOCKED=NO struct vnode *vp; IN int flags; }; @@ -392,6 +395,7 @@ vop_inactive { #% reclaimvp U U U # vop_reclaim { + FSTRANS=NO IN LOCKED=NO struct vnode *vp; }; @@ -399,6 +403,7 @@ vop_reclaim { #% lock vp U L U # vop_lock { + FSTRANS=NO IN LOCKED=NO struct vnode *vp; IN int flags; }; @@ -407,6 +412,7 @@ vop_lock { #% unlock vp L U L # vop_unlock { + FSTRANS=NO IN LOCKED=YES struct vnode *vp; }; @@ -441,6 +447,7 @@ vop_print { #% islocked vp = = = # vop_islocked { + FSTRANS=NO IN struct vnode *vp; }; @@ -481,6 +488,7 @@ vop_whiteout { #% getpages vp = = = # vop_getpages { + FSTRANS=NO IN struct vnode *vp; IN voff_t offset; IN struct vm_page **m; @@ -495,6 +503,7 @@ vop_getpages { #% putpages vp = = = # vop_putpages { + FSTRANS=NO IN struct vnode *vp; IN voff_t offlo; IN voff_t offhi;
CVS commit: src/sys/sys
Module Name:src Committed By: hannken Date: Fri Feb 17 08:32:04 UTC 2017 Modified Files: src/sys/sys: param.h Log Message: Welcome to 7.99.60 To generate a diff of this commit: cvs rdiff -u -r1.526 -r1.527 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.526 src/sys/sys/param.h:1.527 --- src/sys/sys/param.h:1.526 Fri Jan 13 23:05:24 2017 +++ src/sys/sys/param.h Fri Feb 17 08:32:04 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.526 2017/01/13 23:05:24 kamil Exp $ */ +/* $NetBSD: param.h,v 1.527 2017/02/17 08:32:04 hannken Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 799005900 /* NetBSD 7.99.59 */ +#define __NetBSD_Version__ 799006000 /* NetBSD 7.99.60 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src
Module Name:src Committed By: hannken Date: Fri Feb 17 08:31:26 UTC 2017 Modified Files: src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_vfsops.c src/sys/coda: coda_vfsops.c src/sys/fs/adosfs: advfsops.c src/sys/fs/cd9660: cd9660_vfsops.c src/sys/fs/efs: efs_vfsops.c src/sys/fs/filecorefs: filecore_vfsops.c src/sys/fs/hfs: hfs_vfsops.c src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/fs/nilfs: nilfs_vfsops.c src/sys/fs/ntfs: ntfs_vfsops.c src/sys/fs/ptyfs: ptyfs_vfsops.c src/sys/fs/puffs: puffs_vfsops.c src/sys/fs/smbfs: smbfs_vfsops.c src/sys/fs/sysvbfs: sysvbfs.c src/sys/fs/tmpfs: tmpfs_vfsops.c src/sys/fs/udf: udf_vfsops.c src/sys/fs/union: union_vfsops.c src/sys/fs/v7fs: v7fs_extern.c src/sys/miscfs/fdesc: fdesc_vfsops.c src/sys/miscfs/genfs: genfs.h genfs_vfsops.c layer_extern.h layer_vfsops.c src/sys/miscfs/kernfs: kernfs_vfsops.c src/sys/miscfs/nullfs: null_vfsops.c src/sys/miscfs/overlay: overlay_vfsops.c src/sys/miscfs/procfs: procfs_vfsops.c src/sys/miscfs/umapfs: umap_vfsops.c src/sys/nfs: nfs_vfsops.c src/sys/rump/librump/rumpvfs: rumpfs.c src/sys/ufs/chfs: chfs_vfsops.c src/sys/ufs/ext2fs: ext2fs_vfsops.c src/sys/ufs/ffs: ffs_vfsops.c src/sys/ufs/lfs: lfs_vfsops.c src/sys/ufs/mfs: mfs_vfsops.c Log Message: Add generic genfs_suspendctl() and use it for all file systems. Layered file systems need work. To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c cvs rdiff -u -r1.84 -r1.85 src/sys/coda/coda_vfsops.c cvs rdiff -u -r1.75 -r1.76 src/sys/fs/adosfs/advfsops.c cvs rdiff -u -r1.90 -r1.91 src/sys/fs/cd9660/cd9660_vfsops.c cvs rdiff -u -r1.27 -r1.28 src/sys/fs/efs/efs_vfsops.c cvs rdiff -u -r1.78 -r1.79 src/sys/fs/filecorefs/filecore_vfsops.c cvs rdiff -u -r1.33 -r1.34 src/sys/fs/hfs/hfs_vfsops.c cvs rdiff -u -r1.121 -r1.122 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.22 -r1.23 src/sys/fs/nilfs/nilfs_vfsops.c cvs rdiff -u -r1.104 -r1.105 src/sys/fs/ntfs/ntfs_vfsops.c cvs rdiff -u -r1.55 -r1.56 src/sys/fs/ptyfs/ptyfs_vfsops.c cvs rdiff -u -r1.118 -r1.119 src/sys/fs/puffs/puffs_vfsops.c cvs rdiff -u -r1.104 -r1.105 src/sys/fs/smbfs/smbfs_vfsops.c cvs rdiff -u -r1.15 -r1.16 src/sys/fs/sysvbfs/sysvbfs.c cvs rdiff -u -r1.69 -r1.70 src/sys/fs/tmpfs/tmpfs_vfsops.c cvs rdiff -u -r1.73 -r1.74 src/sys/fs/udf/udf_vfsops.c cvs rdiff -u -r1.75 -r1.76 src/sys/fs/union/union_vfsops.c cvs rdiff -u -r1.4 -r1.5 src/sys/fs/v7fs/v7fs_extern.c cvs rdiff -u -r1.91 -r1.92 src/sys/miscfs/fdesc/fdesc_vfsops.c cvs rdiff -u -r1.32 -r1.33 src/sys/miscfs/genfs/genfs.h cvs rdiff -u -r1.3 -r1.4 src/sys/miscfs/genfs/genfs_vfsops.c cvs rdiff -u -r1.37 -r1.38 src/sys/miscfs/genfs/layer_extern.h cvs rdiff -u -r1.46 -r1.47 src/sys/miscfs/genfs/layer_vfsops.c cvs rdiff -u -r1.95 -r1.96 src/sys/miscfs/kernfs/kernfs_vfsops.c cvs rdiff -u -r1.90 -r1.91 src/sys/miscfs/nullfs/null_vfsops.c cvs rdiff -u -r1.63 -r1.64 src/sys/miscfs/overlay/overlay_vfsops.c cvs rdiff -u -r1.95 -r1.96 src/sys/miscfs/procfs/procfs_vfsops.c cvs rdiff -u -r1.95 -r1.96 src/sys/miscfs/umapfs/umap_vfsops.c cvs rdiff -u -r1.231 -r1.232 src/sys/nfs/nfs_vfsops.c cvs rdiff -u -r1.143 -r1.144 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/chfs/chfs_vfsops.c cvs rdiff -u -r1.204 -r1.205 src/sys/ufs/ext2fs/ext2fs_vfsops.c cvs rdiff -u -r1.344 -r1.345 src/sys/ufs/ffs/ffs_vfsops.c cvs rdiff -u -r1.351 -r1.352 src/sys/ufs/lfs/lfs_vfsops.c cvs rdiff -u -r1.110 -r1.111 src/sys/ufs/mfs/mfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c diff -u src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.14 src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.15 --- src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c:1.14 Fri Dec 5 09:13:32 2014 +++ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c Fri Feb 17 08:31:23 2017 @@ -116,6 +116,7 @@ static struct vfsops zfs_vfsops_template .vfs_fhtovp = (void *)eopnotsupp, .vfs_quotactl = (void *)eopnotsupp, .vfs_extattrctl = (void *)eopnotsupp, + .vfs_suspendctl = genfs_suspendctl, .vfs_snapshot = (void *)eopnotsupp, .vfs_fsync = (void *)eopnotsupp, }; Index: src/sys/coda/coda_vfsops.c diff -u src/sys/coda/coda_vfsops.c:1.84 src/sys/coda/coda_vfsops.c:1.85 --- src/sys/coda/coda_vfsops.c:1.84 Sat Dec 13 15:59:30 2014 +++ src/sys/coda/coda_vfsops.c Fri Feb 17 08:31:23 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: coda_vfsops.c,v 1.84 2014/12/13 15:59:30 hannken Exp $ */ +/* $NetBSD: coda_vfsops.c,v 1.85 2017/02/17 08:31:23 hannken Exp $ */ /* * @@
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Fri Feb 17 08:30:00 UTC 2017 Modified Files: src/sys/dev: fss.c src/sys/kern: vfs_vnode.c src/sys/sys: vnode.h src/sys/ufs/ffs: ffs_snapshot.c Log Message: Bring back vrele_flush() to flush deferred vrele() o an suspended file system. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/sys/dev/fss.c cvs rdiff -u -r1.74 -r1.75 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.273 -r1.274 src/sys/sys/vnode.h cvs rdiff -u -r1.144 -r1.145 src/sys/ufs/ffs/ffs_snapshot.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.96 src/sys/dev/fss.c:1.97 --- src/sys/dev/fss.c:1.96 Fri Feb 17 08:29:11 2017 +++ src/sys/dev/fss.c Fri Feb 17 08:30:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.96 2017/02/17 08:29:11 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.97 2017/02/17 08:30:00 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.96 2017/02/17 08:29:11 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.97 2017/02/17 08:30:00 hannken Exp $"); #include #include @@ -851,6 +851,7 @@ fss_create_snapshot(struct fss_softc *sc microtime(>sc_time); + vrele_flush(sc->sc_mount); error = VFS_SYNC(sc->sc_mount, MNT_WAIT, curlwp->l_cred); if (error == 0) error = fscow_establish(sc->sc_mount, fss_copy_on_write, sc); Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.74 src/sys/kern/vfs_vnode.c:1.75 --- src/sys/kern/vfs_vnode.c:1.74 Fri Feb 17 08:27:58 2017 +++ src/sys/kern/vfs_vnode.c Fri Feb 17 08:30:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.74 2017/02/17 08:27:58 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.75 2017/02/17 08:30:00 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.74 2017/02/17 08:27:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.75 2017/02/17 08:30:00 hannken Exp $"); #include #include @@ -455,6 +455,45 @@ lru_requeue(vnode_t *vp, vnodelst_t *lis } /* + * Release deferred vrele vnodes for this mount. + * Called with file system suspended. + */ +void +vrele_flush(struct mount *mp) +{ + vnode_impl_t *vip, *marker; + + KASSERT(fstrans_is_owner(mp)); + + marker = VNODE_TO_VIMPL(vnalloc_marker(NULL)); + + mutex_enter(_lock); + TAILQ_INSERT_HEAD(_vrele_list, marker, vi_lrulist); + + while ((vip = TAILQ_NEXT(marker, vi_lrulist))) { + TAILQ_REMOVE(_vrele_list, marker, vi_lrulist); + TAILQ_INSERT_AFTER(_vrele_list, vip, marker, vi_lrulist); + if (vnis_marker(VIMPL_TO_VNODE(vip))) + continue; + + KASSERT(vip->vi_lrulisthd == _vrele_list); + TAILQ_REMOVE(vip->vi_lrulisthd, vip, vi_lrulist); + vip->vi_lrulisthd = _hold_list; + TAILQ_INSERT_TAIL(vip->vi_lrulisthd, vip, vi_lrulist); + mutex_exit(_lock); + + vrele(VIMPL_TO_VNODE(vip)); + + mutex_enter(_lock); + } + + TAILQ_REMOVE(_vrele_list, marker, vi_lrulist); + mutex_exit(_lock); + + vnfree_marker(VIMPL_TO_VNODE(marker)); +} + +/* * Reclaim a cached vnode. Used from vdrain_thread only. */ static __inline void @@ -556,6 +595,8 @@ vdrain_thread(void *cookie) TAILQ_REMOVE(listhd[i], marker, vi_lrulist); TAILQ_INSERT_AFTER(listhd[i], vip, marker, vi_lrulist); +if (vnis_marker(VIMPL_TO_VNODE(vip))) + continue; if (listhd[i] == _vrele_list) vdrain_vrele(VIMPL_TO_VNODE(vip)); else if (numvnodes < target) Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.273 src/sys/sys/vnode.h:1.274 --- src/sys/sys/vnode.h:1.273 Wed Jan 11 12:17:34 2017 +++ src/sys/sys/vnode.h Fri Feb 17 08:30:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.273 2017/01/11 12:17:34 joerg Exp $ */ +/* $NetBSD: vnode.h,v 1.274 2017/02/17 08:30:00 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -515,6 +515,7 @@ void vput(struct vnode *); bool vrecycle(struct vnode *); void vrele(struct vnode *); void vrele_async(struct vnode *); +void vrele_flush(struct mount *); int vtruncbuf(struct vnode *, daddr_t, bool, int); void vwakeup(struct buf *); int vdead_check(struct vnode *, int); Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.144 src/sys/ufs/ffs/ffs_snapshot.c:1.145 --- src/sys/ufs/ffs/ffs_snapshot.c:1.144 Fri Feb 17 08:29:11 2017 +++ src/sys/ufs/ffs/ffs_snapshot.c Fri Feb 17 08:30:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.144 2017/02/17 08:29:11 hannken Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.145 2017/02/17 08:30:00 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.144 2017/02/17 08:29:11 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD:
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Fri Feb 17 08:29:11 UTC 2017 Modified Files: src/sys/dev: fss.c src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/ufs/ffs: ffs_snapshot.c ffs_vfsops.c Log Message: Untangle VFS_SYNC() from VFS_SUSPENDCTL(). To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/sys/dev/fss.c cvs rdiff -u -r1.120 -r1.121 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.143 -r1.144 src/sys/ufs/ffs/ffs_snapshot.c cvs rdiff -u -r1.343 -r1.344 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.95 src/sys/dev/fss.c:1.96 --- src/sys/dev/fss.c:1.95 Sun Jul 31 12:17:36 2016 +++ src/sys/dev/fss.c Fri Feb 17 08:29:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.95 2016/07/31 12:17:36 hannken Exp $ */ +/* $NetBSD: fss.c,v 1.96 2017/02/17 08:29:11 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.95 2016/07/31 12:17:36 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.96 2017/02/17 08:29:11 hannken Exp $"); #include #include @@ -851,7 +851,9 @@ fss_create_snapshot(struct fss_softc *sc microtime(>sc_time); - error = fscow_establish(sc->sc_mount, fss_copy_on_write, sc); + error = VFS_SYNC(sc->sc_mount, MNT_WAIT, curlwp->l_cred); + if (error == 0) + error = fscow_establish(sc->sc_mount, fss_copy_on_write, sc); if (error == 0) sc->sc_flags |= FSS_ACTIVE; Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.120 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.121 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.120 Fri Feb 17 08:27:20 2017 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Feb 17 08:29:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.121 2017/02/17 08:29:11 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.121 2017/02/17 08:29:11 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1120,10 +1120,7 @@ msdosfs_suspendctl(struct mount *mp, int case SUSPEND_SUSPEND: if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDING)) != 0) return error; - error = msdosfs_sync(mp, MNT_WAIT, l->l_proc->p_cred); - if (error == 0) - error = fstrans_setstate(mp, FSTRANS_SUSPENDED); - if (error != 0) { + if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDED)) != 0) { (void) fstrans_setstate(mp, FSTRANS_NORMAL); return error; } Index: src/sys/ufs/ffs/ffs_snapshot.c diff -u src/sys/ufs/ffs/ffs_snapshot.c:1.143 src/sys/ufs/ffs/ffs_snapshot.c:1.144 --- src/sys/ufs/ffs/ffs_snapshot.c:1.143 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ffs/ffs_snapshot.c Fri Feb 17 08:29:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_snapshot.c,v 1.143 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ffs_snapshot.c,v 1.144 2017/02/17 08:29:11 hannken Exp $ */ /* * Copyright 2000 Marshall Kirk McKusick. All Rights Reserved. @@ -38,7 +38,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.143 2016/10/28 20:38:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_snapshot.c,v 1.144 2017/02/17 08:29:11 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -254,10 +254,13 @@ ffs_snapshot(struct mount *mp, struct vn * All allocations are done, so we can now suspend the filesystem. */ error = vfs_suspend(vp->v_mount, 0); + if (error == 0) { + suspended = true; + error = VFS_SYNC(vp->v_mount, MNT_WAIT, curlwp->l_cred); + } vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); if (error) goto out; - suspended = true; getmicrotime(); /* * First, copy all the cylinder group maps that have changed. Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.343 src/sys/ufs/ffs/ffs_vfsops.c:1.344 --- src/sys/ufs/ffs/ffs_vfsops.c:1.343 Fri Feb 17 08:26:41 2017 +++ src/sys/ufs/ffs/ffs_vfsops.c Fri Feb 17 08:29:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.344 2017/02/17 08:29:11 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.344 2017/02/17 08:29:11 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -2408,14 +2408,7 @@ ffs_suspendctl(struct mount *mp, int cmd case SUSPEND_SUSPEND: if ((error = fstrans_setstate(mp, FSTRANS_SUSPENDING)) != 0) return error; - error = ffs_sync(mp, MNT_WAIT,
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Feb 17 08:27:58 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Make sure vcache_reclaim() will complete before file system suspension. To generate a diff of this commit: cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.73 src/sys/kern/vfs_vnode.c:1.74 --- src/sys/kern/vfs_vnode.c:1.73 Fri Jan 27 10:50:10 2017 +++ src/sys/kern/vfs_vnode.c Fri Feb 17 08:27:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.73 2017/01/27 10:50:10 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.74 2017/02/17 08:27:58 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.73 2017/01/27 10:50:10 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.74 2017/02/17 08:27:58 hannken Exp $"); #include #include @@ -1441,6 +1441,7 @@ vcache_reclaim(vnode_t *vp) { lwp_t *l = curlwp; vnode_impl_t *vip = VNODE_TO_VIMPL(vp); + struct mount *mp = vp->v_mount; uint32_t hash; uint8_t temp_buf[64], *temp_key; size_t temp_key_len; @@ -1477,6 +1478,8 @@ vcache_reclaim(vnode_t *vp) vip->vi_key.vk_key = temp_key; mutex_exit(_lock); + fstrans_start(mp, FSTRANS_LAZY); + /* * Clean out any cached data associated with the vnode. * If purging an active vnode, it must be closed and @@ -1537,6 +1540,8 @@ vcache_reclaim(vnode_t *vp) vp->v_tag = VT_NON; KNOTE(>v_klist, NOTE_REVOKE); + fstrans_done(mp); + KASSERT((vp->v_iflag & VI_ONWORKLST) == 0); }
CVS commit: src/sys/fs/msdosfs
Module Name:src Committed By: hannken Date: Fri Feb 17 08:27:20 UTC 2017 Modified Files: src/sys/fs/msdosfs: msdosfs_vfsops.c Log Message: Take vnode lock for VOP_FSYNC(). To generate a diff of this commit: cvs rdiff -u -r1.119 -r1.120 src/sys/fs/msdosfs/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.120 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 Wed Dec 14 15:48:54 2016 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Fri Feb 17 08:27:20 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $ */ +/* $NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $ */ /*- * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank. @@ -48,7 +48,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.119 2016/12/14 15:48:54 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.120 2017/02/17 08:27:20 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_compat_netbsd.h" @@ -1032,9 +1032,11 @@ msdosfs_sync(struct mount *mp, int waitf /* * Force stale file system control information to be flushed. */ + vn_lock(pmp->pm_devvp, LK_EXCLUSIVE | LK_RETRY); if ((error = VOP_FSYNC(pmp->pm_devvp, cred, waitfor == MNT_WAIT ? FSYNC_WAIT : 0, 0, 0)) != 0) allerror = error; + VOP_UNLOCK(pmp->pm_devvp); fstrans_done(mp); return (allerror); }
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Fri Feb 17 08:26:41 UTC 2017 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: Flush the log to disk when ffs_sync() gets called with MNT_WAIT. To generate a diff of this commit: cvs rdiff -u -r1.342 -r1.343 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.342 src/sys/ufs/ffs/ffs_vfsops.c:1.343 --- src/sys/ufs/ffs/ffs_vfsops.c:1.342 Tue Dec 27 10:54:38 2016 +++ src/sys/ufs/ffs/ffs_vfsops.c Fri Feb 17 08:26:41 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.343 2017/02/17 08:26:41 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1973,7 +1973,7 @@ ffs_sync(struct mount *mp, int waitfor, #ifdef WAPBL if (mp->mnt_wapbl) { - error = wapbl_flush(mp->mnt_wapbl, 0); + error = wapbl_flush(mp->mnt_wapbl, (waitfor == MNT_WAIT)); if (error) allerror = error; }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Feb 17 08:26:07 UTC 2017 Modified Files: src/sys/kern: vfs_syscalls.c Log Message: Take fstrans_start before syncing a file system. To generate a diff of this commit: cvs rdiff -u -r1.505 -r1.506 src/sys/kern/vfs_syscalls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_syscalls.c diff -u src/sys/kern/vfs_syscalls.c:1.505 src/sys/kern/vfs_syscalls.c:1.506 --- src/sys/kern/vfs_syscalls.c:1.505 Sun Jul 31 20:34:04 2016 +++ src/sys/kern/vfs_syscalls.c Fri Feb 17 08:26:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_syscalls.c,v 1.505 2016/07/31 20:34:04 dholland Exp $ */ +/* $NetBSD: vfs_syscalls.c,v 1.506 2017/02/17 08:26:07 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.505 2016/07/31 20:34:04 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.506 2017/02/17 08:26:07 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_fileassoc.h" @@ -87,6 +87,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_syscalls #include #include #include +#include #include #include #include @@ -638,6 +639,7 @@ do_sys_sync(struct lwp *l) if (vfs_busy(mp, )) { continue; } + fstrans_start(mp, FSTRANS_SHARED); mutex_enter(>mnt_updating); if ((mp->mnt_flag & MNT_RDONLY) == 0) { asyncflag = mp->mnt_flag & MNT_ASYNC; @@ -647,6 +649,7 @@ do_sys_sync(struct lwp *l) mp->mnt_flag |= MNT_ASYNC; } mutex_exit(>mnt_updating); + fstrans_done(mp); vfs_unbusy(mp, false, ); } mutex_exit(_lock);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Feb 17 08:25:15 UTC 2017 Modified Files: src/sys/kern: vfs_subr.c vfs_trans.c Log Message: Let syncer try fstrans_start() before running VFS_SYNC() to get rid of the syncer lock/unlock from vfs_suspend(). To generate a diff of this commit: cvs rdiff -u -r1.459 -r1.460 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.35 -r1.36 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.459 src/sys/kern/vfs_subr.c:1.460 --- src/sys/kern/vfs_subr.c:1.459 Wed Jan 11 14:52:02 2017 +++ src/sys/kern/vfs_subr.c Fri Feb 17 08:25:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.459 2017/01/11 14:52:02 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.460 2017/02/17 08:25:15 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.459 2017/01/11 14:52:02 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.460 2017/02/17 08:25:15 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v #include #include #include +#include #include #include #include @@ -782,7 +783,10 @@ sched_sync(void *arg) mp->mnt_synclist_slot = sync_delay_slot(sync_delay(mp)); if (vfs_busy(mp, )) continue; - VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred); + if (fstrans_start_nowait(mp, FSTRANS_SHARED) == 0) { +VFS_SYNC(mp, MNT_LAZY, curlwp->l_cred); +fstrans_done(mp); + } vfs_unbusy(mp, false, ); } mutex_exit(_lock); Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.35 src/sys/kern/vfs_trans.c:1.36 --- src/sys/kern/vfs_trans.c:1.35 Fri Feb 17 08:24:07 2017 +++ src/sys/kern/vfs_trans.c Fri Feb 17 08:25:15 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.35 2017/02/17 08:24:07 hannken Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.36 2017/02/17 08:25:15 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.35 2017/02/17 08:24:07 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.36 2017/02/17 08:25:15 hannken Exp $"); /* * File system transaction operations. @@ -506,11 +506,8 @@ vfs_suspend(struct mount *mp, int nowait } else mutex_enter(_suspend_lock); - mutex_enter(_mutex); - if ((error = VFS_SUSPENDCTL(mp, SUSPEND_SUSPEND)) != 0) { - mutex_exit(_mutex); + if ((error = VFS_SUSPENDCTL(mp, SUSPEND_SUSPEND)) != 0) mutex_exit(_suspend_lock); - } return error; } @@ -523,7 +520,6 @@ vfs_resume(struct mount *mp) { VFS_SUSPENDCTL(mp, SUSPEND_RESUME); - mutex_exit(_mutex); mutex_exit(_suspend_lock); }
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Feb 17 08:24:07 UTC 2017 Modified Files: src/sys/kern: vfs_trans.c Log Message: Protect attaching and detaching lwp_info to mount with a mutex. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/sys/kern/vfs_trans.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_trans.c diff -u src/sys/kern/vfs_trans.c:1.34 src/sys/kern/vfs_trans.c:1.35 --- src/sys/kern/vfs_trans.c:1.34 Mon Aug 24 22:50:32 2015 +++ src/sys/kern/vfs_trans.c Fri Feb 17 08:24:07 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_trans.c,v 1.34 2015/08/24 22:50:32 pooka Exp $ */ +/* $NetBSD: vfs_trans.c,v 1.35 2017/02/17 08:24:07 hannken Exp $ */ /*- * Copyright (c) 2007 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.34 2015/08/24 22:50:32 pooka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_trans.c,v 1.35 2017/02/17 08:24:07 hannken Exp $"); /* * File system transaction operations. @@ -78,6 +78,7 @@ struct fstrans_mount_info { static specificdata_key_t lwp_data_key; /* Our specific data key. */ static kmutex_t vfs_suspend_lock; /* Serialize suspensions. */ static kmutex_t fstrans_lock; /* Fstrans big lock. */ +static kmutex_t fstrans_mount_lock; /* Fstrans mount big lock. */ static kcondvar_t fstrans_state_cv; /* Fstrans or cow state changed. */ static kcondvar_t fstrans_count_cv; /* Fstrans or cow count changed. */ static pserialize_t fstrans_psz; /* Pserialize state. */ @@ -106,6 +107,7 @@ fstrans_init(void) mutex_init(_suspend_lock, MUTEX_DEFAULT, IPL_NONE); mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(_mount_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(_state_cv, "fstchg"); cv_init(_count_cv, "fstcnt"); fstrans_psz = pserialize_create(); @@ -140,17 +142,25 @@ fstrans_mount_dtor(struct mount *mp) { struct fstrans_mount_info *fmi; + mutex_enter(_mount_lock); + fmi = mp->mnt_transinfo; - if (atomic_dec_uint_nv(>fmi_ref_cnt) > 0) + KASSERT(fmi != NULL); + fmi->fmi_ref_cnt -= 1; + if (fmi->fmi_ref_cnt > 0) { + mutex_exit(_mount_lock); return; + } KASSERT(fmi->fmi_state == FSTRANS_NORMAL); KASSERT(LIST_FIRST(>fmi_cow_handler) == NULL); - kmem_free(fmi, sizeof(*fmi)); mp->mnt_iflag &= ~IMNT_HAS_TRANS; mp->mnt_transinfo = NULL; + mutex_exit(_mount_lock); + + kmem_free(fmi, sizeof(*fmi)); vfs_destroy(mp); } @@ -172,8 +182,10 @@ fstrans_mount(struct mount *mp) LIST_INIT(>fmi_cow_handler); newfmi->fmi_cow_change = false; + mutex_enter(_mount_lock); mp->mnt_transinfo = newfmi; mp->mnt_iflag |= IMNT_HAS_TRANS; + mutex_exit(_mount_lock); vfs_unbusy(mp, true, NULL); @@ -236,6 +248,7 @@ fstrans_get_lwp_info(struct mount *mp, b mutex_enter(_lock); LIST_FOREACH(fli, _fli_head, fli_list) { if (fli->fli_self == NULL) { +KASSERT(fli->fli_mount == NULL); KASSERT(fli->fli_trans_cnt == 0); KASSERT(fli->fli_cow_cnt == 0); fli->fli_self = curlwp; @@ -260,9 +273,16 @@ fstrans_get_lwp_info(struct mount *mp, b /* * Attach the entry to the mount. */ - fmi = mp->mnt_transinfo; - fli->fli_mount = mp; - atomic_inc_uint(>fmi_ref_cnt); + mutex_enter(_mount_lock); + if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) { + fli = NULL; + } else { + fmi = mp->mnt_transinfo; + KASSERT(fmi != NULL); + fli->fli_mount = mp; + fmi->fmi_ref_cnt += 1; + } + mutex_exit(_mount_lock); return fli; } @@ -297,11 +317,9 @@ _fstrans_start(struct mount *mp, enum fs ASSERT_SLEEPABLE(); - if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) + if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL) return 0; - fli = fstrans_get_lwp_info(mp, true); - if (fli->fli_trans_cnt > 0) { KASSERT(lock_type != FSTRANS_EXCL); fli->fli_trans_cnt += 1; @@ -343,11 +361,9 @@ fstrans_done(struct mount *mp) struct fstrans_lwp_info *fli; struct fstrans_mount_info *fmi; - if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) + if (mp == NULL || (fli = fstrans_get_lwp_info(mp, true)) == NULL) return; - fli = fstrans_get_lwp_info(mp, false); - KASSERT(fli != NULL); KASSERT(fli->fli_trans_cnt > 0); if (fli->fli_trans_cnt > 1) { @@ -380,11 +396,10 @@ fstrans_is_owner(struct mount *mp) { struct fstrans_lwp_info *fli; - if (mp == NULL || (mp->mnt_iflag & IMNT_HAS_TRANS) == 0) + if (mp == NULL || (fli = fstrans_get_lwp_info(mp, false)) == NULL) return 0; - fli = fstrans_get_lwp_info(mp, false); - if (fli == NULL || fli->fli_trans_cnt == 0) + if (fli->fli_trans_cnt == 0) return 0; KASSERT(fli->fli_mount == mp);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Jan 27 10:50:10 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c vfs_vnode.c Log Message: Vrecycle() cannot wait for the vnode lock. On a leaf file system this lock will always succeed as we hold the last reference and prevent further references. On layered file systems waiting for the lock would open a can of deadlocks as the lower vnodes may have other active references. To generate a diff of this commit: cvs rdiff -u -r1.46 -r1.47 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.72 -r1.73 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.46 src/sys/kern/vfs_mount.c:1.47 --- src/sys/kern/vfs_mount.c:1.46 Fri Jan 27 10:46:18 2017 +++ src/sys/kern/vfs_mount.c Fri Jan 27 10:50:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.46 2017/01/27 10:46:18 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.47 2017/01/27 10:50:10 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.46 2017/01/27 10:46:18 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.47 2017/01/27 10:50:10 hannken Exp $"); #include #include @@ -551,30 +551,35 @@ vflush(struct mount *mp, vnode_t *skipvp { vnode_t *vp; struct vnode_iterator *marker; - int busy, error, when; + int busy, error, when, retries = 2; - busy = error = when = 0; + do { + busy = error = when = 0; - /* First, flush out any vnode references from deferred vrele list. */ - vfs_drainvnodes(); + /* + * First, flush out any vnode references from the + * deferred vrele list. + */ + vfs_drainvnodes(); - vfs_vnode_iterator_init(mp, ); + vfs_vnode_iterator_init(mp, ); - while ((vp = vflushnext(marker, )) != NULL) { - error = vflush_one(vp, skipvp, flags); - if (error == EBUSY) { - error = 0; - busy++; + while ((vp = vflushnext(marker, )) != NULL) { + error = vflush_one(vp, skipvp, flags); + if (error == EBUSY) { +error = 0; +busy++; #ifdef DEBUG - if (busyprt) -vprint("vflush: busy vnode", vp); +if (busyprt && retries == 0) + vprint("vflush: busy vnode", vp); #endif - } else if (error != 0) { - break; + } else if (error != 0) { +break; + } } - } - vfs_vnode_iterator_destroy(marker); + vfs_vnode_iterator_destroy(marker); + } while (error == 0 && busy > 0 && retries-- > 0); if (error) return error; Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.72 src/sys/kern/vfs_vnode.c:1.73 --- src/sys/kern/vfs_vnode.c:1.72 Wed Jan 11 09:08:58 2017 +++ src/sys/kern/vfs_vnode.c Fri Jan 27 10:50:10 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.73 2017/01/27 10:50:10 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.73 2017/01/27 10:50:10 hannken Exp $"); #include #include @@ -872,12 +872,22 @@ vrecycle(vnode_t *vp) VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED); mutex_exit(vp->v_interlock); - error = vn_lock(vp, LK_EXCLUSIVE); - KASSERT(error == 0); + /* + * On a leaf file system this lock will always succeed as we hold + * the last reference and prevent further references. + * On layered file systems waiting for the lock would open a can of + * deadlocks as the lower vnodes may have other active references. + */ + error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT); mutex_enter(vp->v_interlock); VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE); + if (error) { + mutex_exit(vp->v_interlock); + return false; + } + KASSERT(vp->v_usecount == 1); vcache_reclaim(vp); vrelel(vp, 0);
CVS commit: src/sys/rump/librump/rumpvfs
Module Name:src Committed By: hannken Date: Fri Jan 27 10:48:51 UTC 2017 Modified Files: src/sys/rump/librump/rumpvfs: rumpfs.c Log Message: Run vflush() when going from read/write to read only. Set link count to zero once a node has been removed. "Implement" MNT_GETARGS. To generate a diff of this commit: cvs rdiff -u -r1.142 -r1.143 src/sys/rump/librump/rumpvfs/rumpfs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.142 src/sys/rump/librump/rumpvfs/rumpfs.c:1.143 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.142 Sat Aug 20 12:37:09 2016 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Fri Jan 27 10:48:51 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: rumpfs.c,v 1.142 2016/08/20 12:37:09 hannken Exp $ */ +/* $NetBSD: rumpfs.c,v 1.143 2017/01/27 10:48:51 hannken Exp $ */ /* * Copyright (c) 2009, 2010, 2011 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.142 2016/08/20 12:37:09 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.143 2017/01/27 10:48:51 hannken Exp $"); #include #include @@ -216,6 +216,7 @@ struct rumpfs_node { struct rumpfs_mount { struct vnode *rfsmp_rvp; + bool rfsmp_rdonly; }; #define INO_WHITEOUT 1 @@ -1012,6 +1013,7 @@ rump_vop_rmdir(void *v) freedir(rnd, cnp); rn->rn_flags |= RUMPNODE_CANRECLAIM; rn->rn_parent = NULL; + rn->rn_va.va_nlink = 0; out: vput(dvp); @@ -1040,6 +1042,7 @@ rump_vop_remove(void *v) freedir(rnd, cnp); rn->rn_flags |= RUMPNODE_CANRECLAIM; + rn->rn_va.va_nlink = 0; vput(dvp); vput(vp); @@ -1803,6 +1806,7 @@ rumpfs_mountfs(struct mount *mp) } rfsmp->rfsmp_rvp->v_vflag |= VV_ROOT; + rfsmp->rfsmp_rdonly = (mp->mnt_flag & MNT_RDONLY) != 0; mp->mnt_data = rfsmp; mp->mnt_stat.f_namemax = RUMPFS_MAXNAMLEN; @@ -1818,9 +1822,27 @@ rumpfs_mountfs(struct mount *mp) int rumpfs_mount(struct mount *mp, const char *mntpath, void *arg, size_t *alen) { - int error; + struct rumpfs_mount *rfsmp = mp->mnt_data; + int error, flags; + if (mp->mnt_flag & MNT_GETARGS) { + return 0; + } if (mp->mnt_flag & MNT_UPDATE) { + if (!rfsmp->rfsmp_rdonly && (mp->mnt_flag & MNT_RDONLY)) { + /* Changing from read/write to read-only. */ + flags = WRITECLOSE; + if ((mp->mnt_flag & MNT_FORCE)) +flags |= FORCECLOSE; + error = vflush(mp, NULL, flags); + if (error) +return error; + rfsmp->rfsmp_rdonly = true; + } + if (rfsmp->rfsmp_rdonly && (mp->mnt_flag & IMNT_WANTRDWR)) { + /* Changing from read-only to read/write. */ + rfsmp->rfsmp_rdonly = false; + } return 0; } @@ -1944,6 +1966,7 @@ int rumpfs_mountroot() { struct mount *mp; + struct rumpfs_mount *rfsmp; int error; if ((error = vfs_rootmountalloc(MOUNT_RUMPFS, "rootdev", )) != 0) { @@ -1961,7 +1984,9 @@ rumpfs_mountroot() if (error) panic("set_statvfs_info failed for rootfs: %d", error); + rfsmp = mp->mnt_data; mp->mnt_flag &= ~MNT_RDONLY; + rfsmp->rfsmp_rdonly = false; vfs_unbusy(mp, false, NULL); return 0;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Fri Jan 27 10:47:54 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs.h tmpfs_vfsops.c Log Message: Run vflush() when going from read/write to read only. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/sys/fs/tmpfs/tmpfs.h cvs rdiff -u -r1.68 -r1.69 src/sys/fs/tmpfs/tmpfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs.h diff -u src/sys/fs/tmpfs/tmpfs.h:1.52 src/sys/fs/tmpfs/tmpfs.h:1.53 --- src/sys/fs/tmpfs/tmpfs.h:1.52 Mon Jul 6 10:07:12 2015 +++ src/sys/fs/tmpfs/tmpfs.h Fri Jan 27 10:47:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs.h,v 1.52 2015/07/06 10:07:12 hannken Exp $ */ +/* $NetBSD: tmpfs.h,v 1.53 2017/01/27 10:47:54 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -217,6 +217,9 @@ typedef struct tmpfs_mount { uint64_t tm_bytes_used; kmutex_t tm_acc_lock; + /* Read-only indicator. */ + bool tm_rdonly; + /* Pointer to the root inode. */ tmpfs_node_t * tm_root; Index: src/sys/fs/tmpfs/tmpfs_vfsops.c diff -u src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68 src/sys/fs/tmpfs/tmpfs_vfsops.c:1.69 --- src/sys/fs/tmpfs/tmpfs_vfsops.c:1.68 Fri Aug 26 21:44:24 2016 +++ src/sys/fs/tmpfs/tmpfs_vfsops.c Fri Jan 27 10:47:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $ */ +/* $NetBSD: tmpfs_vfsops.c,v 1.69 2017/01/27 10:47:54 hannken Exp $ */ /* * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc. @@ -42,7 +42,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.68 2016/08/26 21:44:24 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.69 2017/01/27 10:47:54 hannken Exp $"); #include #include @@ -92,7 +92,7 @@ tmpfs_mount(struct mount *mp, const char struct vnode *vp; uint64_t memlimit; ino_t nodes; - int error; + int error, flags; bool set_memlimit; bool set_nodes; @@ -160,6 +160,20 @@ tmpfs_mount(struct mount *mp, const char tmp = VFS_TO_TMPFS(mp); if (set_nodes && nodes < tmp->tm_nodes_cnt) return EBUSY; + if (!tmp->tm_rdonly && (mp->mnt_flag & MNT_RDONLY)) { + /* Changing from read/write to read-only. */ + flags = WRITECLOSE; + if ((mp->mnt_flag & MNT_FORCE)) +flags |= FORCECLOSE; + error = vflush(mp, NULL, flags); + if (error) +return error; + tmp->tm_rdonly = true; + } + if (tmp->tm_rdonly && (mp->mnt_flag & IMNT_WANTRDWR)) { + /* Changing from read-only to read/write. */ + tmp->tm_rdonly = false; + } if (set_memlimit) { if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0) return error; @@ -178,6 +192,8 @@ tmpfs_mount(struct mount *mp, const char if (tmp == NULL) return ENOMEM; + if ((mp->mnt_flag & MNT_RDONLY)) + tmp->tm_rdonly = true; tmp->tm_nodes_max = nodes; tmp->tm_nodes_cnt = 0; LIST_INIT(>tm_nodes);
CVS commit: src/sys/miscfs
Module Name:src Committed By: hannken Date: Fri Jan 27 10:47:13 UTC 2017 Modified Files: src/sys/miscfs/genfs: layer_extern.h layer_vnops.c src/sys/miscfs/nullfs: null_vnops.c src/sys/miscfs/overlay: overlay_vnops.c src/sys/miscfs/umapfs: umap_vnops.c Log Message: Handle v_writecount from layer_open(), layer_close() and layer_revoke() so lower file system vnodes get marked as open for writing. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/miscfs/genfs/layer_extern.h cvs rdiff -u -r1.59 -r1.60 src/sys/miscfs/genfs/layer_vnops.c cvs rdiff -u -r1.39 -r1.40 src/sys/miscfs/nullfs/null_vnops.c cvs rdiff -u -r1.21 -r1.22 src/sys/miscfs/overlay/overlay_vnops.c cvs rdiff -u -r1.57 -r1.58 src/sys/miscfs/umapfs/umap_vnops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/miscfs/genfs/layer_extern.h diff -u src/sys/miscfs/genfs/layer_extern.h:1.36 src/sys/miscfs/genfs/layer_extern.h:1.37 --- src/sys/miscfs/genfs/layer_extern.h:1.36 Sun May 25 13:51:25 2014 +++ src/sys/miscfs/genfs/layer_extern.h Fri Jan 27 10:47:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_extern.h,v 1.36 2014/05/25 13:51:25 hannken Exp $ */ +/* $NetBSD: layer_extern.h,v 1.37 2017/01/27 10:47:13 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -106,6 +106,7 @@ int layer_lookup(void *); int layer_setattr(void *); int layer_access(void *); int layer_open(void *); +int layer_close(void *); int layer_remove(void *); int layer_rename(void *); int layer_revoke(void *); Index: src/sys/miscfs/genfs/layer_vnops.c diff -u src/sys/miscfs/genfs/layer_vnops.c:1.59 src/sys/miscfs/genfs/layer_vnops.c:1.60 --- src/sys/miscfs/genfs/layer_vnops.c:1.59 Sat Aug 20 12:37:09 2016 +++ src/sys/miscfs/genfs/layer_vnops.c Fri Jan 27 10:47:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: layer_vnops.c,v 1.59 2016/08/20 12:37:09 hannken Exp $ */ +/* $NetBSD: layer_vnops.c,v 1.60 2017/01/27 10:47:13 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -170,7 +170,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.59 2016/08/20 12:37:09 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.60 2017/01/27 10:47:13 hannken Exp $"); #include #include @@ -182,6 +182,7 @@ __KERNEL_RCSID(0, "$NetBSD: layer_vnops. #include #include #include +#include #include #include @@ -491,7 +492,8 @@ layer_access(void *v) } /* - * We must handle open to be able to catch MNT_NODEV and friends. + * We must handle open to be able to catch MNT_NODEV and friends + * and increment the lower v_writecount. */ int layer_open(void *v) @@ -503,12 +505,43 @@ layer_open(void *v) kauth_cred_t a_cred; } */ *ap = v; struct vnode *vp = ap->a_vp; - enum vtype lower_type = LAYERVPTOLOWERVP(vp)->v_type; + struct vnode *lvp = LAYERVPTOLOWERVP(vp); + int error; - if (((lower_type == VBLK) || (lower_type == VCHR)) && + if (((lvp->v_type == VBLK) || (lvp->v_type == VCHR)) && (vp->v_mount->mnt_flag & MNT_NODEV)) return ENXIO; + error = LAYERFS_DO_BYPASS(vp, ap); + if (error == 0 && (ap->a_mode & FWRITE)) { + mutex_enter(lvp->v_interlock); + lvp->v_writecount++; + mutex_exit(lvp->v_interlock); + } + return error; +} + +/* + * We must handle close to decrement the lower v_writecount. + */ +int +layer_close(void *v) +{ + struct vop_close_args /* { + const struct vnodeop_desc *a_desc; + struct vnode *a_vp; + int a_fflag; + kauth_cred_t a_cred; + } */ *ap = v; + struct vnode *vp = ap->a_vp; + struct vnode *lvp = LAYERVPTOLOWERVP(vp); + + if ((ap->a_fflag & FWRITE)) { + mutex_enter(lvp->v_interlock); + KASSERT(lvp->v_writecount > 0); + lvp->v_writecount--; + mutex_exit(lvp->v_interlock); + } return LAYERFS_DO_BYPASS(vp, ap); } @@ -660,8 +693,15 @@ layer_revoke(void *v) * We will most likely end up in vclean which uses the v_usecount * to determine if a vnode is active. Take an extra reference on * the lower vnode so it will always close and inactivate. + * Remove our writecount from the lower vnode. */ vref(lvp); + + mutex_enter(vp->v_interlock); + KASSERT(vp->v_interlock == lvp->v_interlock); + lvp->v_writecount -= vp->v_writecount; + mutex_exit(vp->v_interlock); + error = LAYERFS_DO_BYPASS(vp, ap); vrele(lvp); Index: src/sys/miscfs/nullfs/null_vnops.c diff -u src/sys/miscfs/nullfs/null_vnops.c:1.39 src/sys/miscfs/nullfs/null_vnops.c:1.40 --- src/sys/miscfs/nullfs/null_vnops.c:1.39 Thu Feb 27 16:51:38 2014 +++ src/sys/miscfs/nullfs/null_vnops.c Fri Jan 27 10:47:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: null_vnops.c,v 1.39 2014/02/27 16:51:38 hannken Exp $ */ +/* $NetBSD: null_vnops.c,v 1.40 2017/01/27 10:47:13 hannken Exp $ */ /* * Copyright (c) 1999 National Aeronautics & Space Administration @@ -80,7 +80,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Jan 27 10:46:18 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c Log Message: When called with WRITECLOSE vflush() must sync the vnode and take care of unlinked but open vnodes. PR kern/30525 remounting ffs read-only (mount -ur) does not sync metadata. To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.45 src/sys/kern/vfs_mount.c:1.46 --- src/sys/kern/vfs_mount.c:1.45 Fri Jan 13 10:10:32 2017 +++ src/sys/kern/vfs_mount.c Fri Jan 27 10:46:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.45 2017/01/13 10:10:32 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.46 2017/01/27 10:46:18 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.45 2017/01/13 10:10:32 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.46 2017/01/27 10:46:18 hannken Exp $"); #include #include @@ -478,87 +478,108 @@ int busyprt = 0; /* print out busy vnode struct ctldebug debug1 = { "busyprt", }; #endif -struct vflush_ctx { - const struct vnode *skipvp; - int flags; -}; +static vnode_t * +vflushnext(struct vnode_iterator *marker, int *when) +{ + if (hardclock_ticks > *when) { + yield(); + *when = hardclock_ticks + hz / 10; + } + return vfs_vnode_iterator_next1(marker, NULL, NULL, true); +} -static bool -vflush_selector(void *cl, struct vnode *vp) +/* + * Flush one vnode. Referenced on entry, unreferenced on return. + */ +static int +vflush_one(vnode_t *vp, vnode_t *skipvp, int flags) { - struct vflush_ctx *c = cl; + int error; + struct vattr vattr; + + if (vp == skipvp || + ((flags & SKIPSYSTEM) && (vp->v_vflag & VV_SYSTEM))) { + vrele(vp); + return 0; + } /* - * Skip over a selected vnode. + * If WRITECLOSE is set, only flush out regular file + * vnodes open for writing or open and unlinked. */ - if (vp == c->skipvp) - return false; + if ((flags & WRITECLOSE)) { + if (vp->v_type != VREG) { + vrele(vp); + return 0; + } + error = vn_lock(vp, LK_EXCLUSIVE); + if (error) { + KASSERT(error == ENOENT); + vrele(vp); + return 0; + } + error = VOP_FSYNC(vp, curlwp->l_cred, FSYNC_WAIT, 0, 0); + if (error == 0) + error = VOP_GETATTR(vp, , curlwp->l_cred); + VOP_UNLOCK(vp); + if (error) { + vrele(vp); + return error; + } + if (vp->v_writecount == 0 && vattr.va_nlink > 0) { + vrele(vp); + return 0; + } + } /* - * Skip over a vnodes marked VSYSTEM. + * First try to recycle the vnode. */ - if ((c->flags & SKIPSYSTEM) && (vp->v_vflag & VV_SYSTEM)) - return false; - + if (vrecycle(vp)) + return 0; /* - * If WRITECLOSE is set, only flush out regular file - * vnodes open for writing. + * If FORCECLOSE is set, forcibly close the vnode. */ - if ((c->flags & WRITECLOSE) && vp->v_type == VREG) { - if (vp->v_writecount == 0) - return false; + if (flags & FORCECLOSE) { + vgone(vp); + return 0; } - return true; + vrele(vp); + return EBUSY; } -static vnode_t * -vflushnext(struct vnode_iterator *marker, void *ctx, int *when) -{ - if (hardclock_ticks > *when) { - yield(); - *when = hardclock_ticks + hz / 10; - } - return vfs_vnode_iterator_next1(marker, vflush_selector, ctx, true); -} - - int vflush(struct mount *mp, vnode_t *skipvp, int flags) { vnode_t *vp; struct vnode_iterator *marker; - int busy = 0, when = 0; - struct vflush_ctx ctx; + int busy, error, when; + + busy = error = when = 0; /* First, flush out any vnode references from deferred vrele list. */ vfs_drainvnodes(); vfs_vnode_iterator_init(mp, ); - ctx.skipvp = skipvp; - ctx.flags = flags; - while ((vp = vflushnext(marker, , )) != NULL) { - /* - * First try to recycle the vnode. - */ - if (vrecycle(vp)) - continue; - /* - * If FORCECLOSE is set, forcibly close the vnode. - */ - if (flags & FORCECLOSE) { - vgone(vp); - continue; - } + while ((vp = vflushnext(marker, )) != NULL) { + error = vflush_one(vp, skipvp, flags); + if (error == EBUSY) { + error = 0; + busy++; #ifdef DEBUG - if (busyprt) - vprint("vflush: busy vnode", vp); + if (busyprt) +vprint("vflush: busy vnode", vp); #endif - vrele(vp); - busy++; + } else if (error != 0) { + break; + } } + vfs_vnode_iterator_destroy(marker); - if (busy) - return (EBUSY); + if (error) + return error; + if (busy) + return EBUSY; return 0; }
CVS commit: src
Module Name:src Committed By: hannken Date: Fri Jan 27 10:45:11 UTC 2017 Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/tests/fs/vfs: Makefile Added Files: src/tests/fs/vfs: t_rwtoro.c Log Message: Add test for read/write to readonly update mount. To generate a diff of this commit: cvs rdiff -u -r1.192 -r1.193 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.714 -r1.715 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.22 -r1.23 src/tests/fs/vfs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/fs/vfs/t_rwtoro.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.192 src/distrib/sets/lists/debug/mi:1.193 --- src/distrib/sets/lists/debug/mi:1.192 Mon Jan 16 08:18:11 2017 +++ src/distrib/sets/lists/debug/mi Fri Jan 27 10:45:11 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.192 2017/01/16 08:18:11 ozaki-r Exp $ +# $NetBSD: mi,v 1.193 2017/01/27 10:45:11 hannken Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib comp-sys-usr compatdir ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile @@ -1642,6 +1642,7 @@ ./usr/libdata/debug/usr/tests/fs/vfs/t_renamerace.debug tests-fs-debug debug,atf,rump ./usr/libdata/debug/usr/tests/fs/vfs/t_rmdirrace.debug tests-fs-debug debug,atf,rump ./usr/libdata/debug/usr/tests/fs/vfs/t_ro.debug tests-fs-debug debug,atf,rump +./usr/libdata/debug/usr/tests/fs/vfs/t_rwtoro.debug tests-fs-debug debug,atf,rump ./usr/libdata/debug/usr/tests/fs/vfs/t_union.debug tests-fs-debug debug,atf,rump ./usr/libdata/debug/usr/tests/fs/vfs/t_unpriv.debug tests-fs-debug debug,atf,rump ./usr/libdata/debug/usr/tests/fs/vfs/t_vfsops.debug tests-fs-debug debug,atf,rump Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.714 src/distrib/sets/lists/tests/mi:1.715 --- src/distrib/sets/lists/tests/mi:1.714 Sat Jan 14 01:44:13 2017 +++ src/distrib/sets/lists/tests/mi Fri Jan 27 10:45:11 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.714 2017/01/14 01:44:13 christos Exp $ +# $NetBSD: mi,v 1.715 2017/01/27 10:45:11 hannken Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -1549,6 +1549,7 @@ ./usr/tests/fs/vfs/t_renameracetests-fs-tests atf,rump ./usr/tests/fs/vfs/t_rmdirracetests-fs-tests atf,rump ./usr/tests/fs/vfs/t_ro tests-fs-tests atf,rump +./usr/tests/fs/vfs/t_rwtorotests-fs-tests atf,rump ./usr/tests/fs/vfs/t_uniontests-fs-tests atf,rump ./usr/tests/fs/vfs/t_unprivtests-fs-tests atf,rump ./usr/tests/fs/vfs/t_vfsopstests-fs-tests atf,rump Index: src/tests/fs/vfs/Makefile diff -u src/tests/fs/vfs/Makefile:1.22 src/tests/fs/vfs/Makefile:1.23 --- src/tests/fs/vfs/Makefile:1.22 Sat Aug 27 08:38:58 2016 +++ src/tests/fs/vfs/Makefile Fri Jan 27 10:45:11 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.22 2016/08/27 08:38:58 christos Exp $ +# $NetBSD: Makefile,v 1.23 2017/01/27 10:45:11 hannken Exp $ # .include @@ -11,6 +11,7 @@ TESTS_C+= t_io TESTS_C+= t_renamerace TESTS_C+= t_ro TESTS_C+= t_rmdirrace +TESTS_C+= t_rwtoro TESTS_C+= t_union TESTS_C+= t_unpriv TESTS_C+= t_vfsops @@ -30,6 +31,7 @@ LDADD+=-lrumpfs_udf # udf LDADD+=-lrumpfs_union # union LDADD+=-lrumpfs_v7fs # v7fs LDADD+=-lrumpdev_disk -lrumpdev # disk device +LDADD+=-lrumpfs_null -lrumpvfs_layerfs# nullfs VFSTESTDIR != cd ${.CURDIR}/../common && ${PRINTOBJDIR} Added files: Index: src/tests/fs/vfs/t_rwtoro.c diff -u /dev/null src/tests/fs/vfs/t_rwtoro.c:1.1 --- /dev/null Fri Jan 27 10:45:11 2017 +++ src/tests/fs/vfs/t_rwtoro.c Fri Jan 27 10:45:11 2017 @@ -0,0 +1,233 @@ +/* $NetBSD: t_rwtoro.c,v 1.1 2017/01/27 10:45:11 hannken Exp $ */ + +/*- + * Copyright (c) 2017 The NetBSD Foundation, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Fri Jan 13 10:10:32 UTC 2017 Modified Files: src/sys/kern: vfs_mount.c Log Message: Add file-local iterator variant vfs_vnode_iterator_next1() that waits for vnodes to become reclaimed and use it from vflush(). To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/sys/kern/vfs_mount.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.44 src/sys/kern/vfs_mount.c:1.45 --- src/sys/kern/vfs_mount.c:1.44 Wed Jan 11 09:07:57 2017 +++ src/sys/kern/vfs_mount.c Fri Jan 13 10:10:32 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.45 2017/01/13 10:10:32 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.45 2017/01/13 10:10:32 hannken Exp $"); #include #include @@ -93,6 +93,9 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c, #include #include +static struct vnode *vfs_vnode_iterator_next1(struct vnode_iterator *, +bool (*)(void *, struct vnode *), void *, bool); + /* Root filesystem. */ vnode_t * rootvnode; @@ -374,9 +377,9 @@ vfs_vnode_iterator_destroy(struct vnode_ vnfree_marker(mvp); } -struct vnode * -vfs_vnode_iterator_next(struct vnode_iterator *vni, -bool (*f)(void *, struct vnode *), void *cl) +static struct vnode * +vfs_vnode_iterator_next1(struct vnode_iterator *vni, +bool (*f)(void *, struct vnode *), void *cl, bool do_wait) { vnode_impl_t *mvip = >vi_vnode; struct mount *mp = VIMPL_TO_VNODE(mvip)->v_mount; @@ -399,7 +402,7 @@ again: } mutex_enter(vp->v_interlock); if (vnis_marker(vp) || - vdead_check(vp, VDEAD_NOWAIT) || + vdead_check(vp, (do_wait ? 0 : VDEAD_NOWAIT)) || (f && !(*f)(cl, vp))) { mutex_exit(vp->v_interlock); vip = TAILQ_NEXT(vip, vi_mntvnodes); @@ -416,6 +419,14 @@ again: return vp; } +struct vnode * +vfs_vnode_iterator_next(struct vnode_iterator *vni, +bool (*f)(void *, struct vnode *), void *cl) +{ + + return vfs_vnode_iterator_next1(vni, f, cl, false); +} + /* * Move a vnode from one mount queue to another. */ @@ -505,7 +516,7 @@ vflushnext(struct vnode_iterator *marker yield(); *when = hardclock_ticks + hz / 10; } - return vfs_vnode_iterator_next(marker, vflush_selector, ctx); + return vfs_vnode_iterator_next1(marker, vflush_selector, ctx, true); } @@ -513,9 +524,8 @@ int vflush(struct mount *mp, vnode_t *skipvp, int flags) { vnode_t *vp; - vnode_impl_t *vip; struct vnode_iterator *marker; - int error, busy = 0, when = 0; + int busy = 0, when = 0; struct vflush_ctx ctx; /* First, flush out any vnode references from deferred vrele list. */ @@ -549,32 +559,7 @@ vflush(struct mount *mp, vnode_t *skipvp if (busy) return (EBUSY); - /* Wait for all vnodes to be reclaimed. */ - for (;;) { - mutex_enter(_lock); - TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) { - vp = VIMPL_TO_VNODE(vip); - if (vp == skipvp) -continue; - if ((flags & SKIPSYSTEM) && (vp->v_vflag & VV_SYSTEM)) -continue; - break; - } - if (vip != NULL) { - KASSERT(vp == VIMPL_TO_VNODE(vip)); - mutex_enter(vp->v_interlock); - mutex_exit(_lock); - error = vcache_vget(vp); - if (error == ENOENT) -continue; - else if (error == 0) -vrele(vp); - return EBUSY; - } else { - mutex_exit(_lock); - return 0; - } - } + return 0; } /*
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Jan 11 14:52:03 UTC 2017 Modified Files: src/sys/kern: vfs_subr.c Log Message: Adapt to the recent vnode changes. To generate a diff of this commit: cvs rdiff -u -r1.458 -r1.459 src/sys/kern/vfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.458 src/sys/kern/vfs_subr.c:1.459 --- src/sys/kern/vfs_subr.c:1.458 Wed Jan 11 12:17:34 2017 +++ src/sys/kern/vfs_subr.c Wed Jan 11 14:52:02 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.458 2017/01/11 12:17:34 joerg Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.459 2017/01/11 14:52:02 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.458 2017/01/11 12:17:34 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.459 2017/01/11 14:52:02 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1543,13 +1543,13 @@ void vfs_vnode_lock_print(void *vlock, int full, void (*pr)(const char *, ...)) { struct mount *mp; - struct vnode *vp; + vnode_impl_t *vip; TAILQ_FOREACH(mp, , mnt_list) { - TAILQ_FOREACH(vp, >mnt_vnodelist, v_mntvnodes) { - if (>v_lock != vlock) + TAILQ_FOREACH(vip, >mnt_vnodelist, vi_mntvnodes) { + if (>vi_lock != vlock) continue; - vfs_vnode_print(vp, full, pr); + vfs_vnode_print(VIMPL_TO_VNODE(vip), full, pr); } } }
CVS commit: src/sys/sys
Module Name:src Committed By: hannken Date: Wed Jan 11 09:09:42 UTC 2017 Modified Files: src/sys/sys: param.h Log Message: Welcome to 7.99.58, vnode layout changed. To generate a diff of this commit: cvs rdiff -u -r1.524 -r1.525 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.524 src/sys/sys/param.h:1.525 --- src/sys/sys/param.h:1.524 Tue Jan 10 01:02:23 2017 +++ src/sys/sys/param.h Wed Jan 11 09:09:42 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.524 2017/01/10 01:02:23 kamil Exp $ */ +/* $NetBSD: param.h,v 1.525 2017/01/11 09:09:42 hannken Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -67,7 +67,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 799005700 /* NetBSD 7.99.57 */ +#define __NetBSD_Version__ 799005800 /* NetBSD 7.99.58 */ #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \ (m) * 100) + (p) * 100) <= __NetBSD_Version__)
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Jan 11 09:08:59 UTC 2017 Modified Files: src/share/man/man9: vnode.9 src/sys/kern: vfs_subr.c vfs_vnode.c src/sys/miscfs/genfs: genfs_vnops.c src/sys/sys: vnode.h vnode_impl.h Log Message: Move vnode member v_lock as vi_lock to vnode_impl.h. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/share/man/man9/vnode.9 cvs rdiff -u -r1.456 -r1.457 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.71 -r1.72 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.192 -r1.193 src/sys/miscfs/genfs/genfs_vnops.c cvs rdiff -u -r1.271 -r1.272 src/sys/sys/vnode.h cvs rdiff -u -r1.10 -r1.11 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.77 src/share/man/man9/vnode.9:1.78 --- src/share/man/man9/vnode.9:1.77 Wed Jan 11 09:07:57 2017 +++ src/share/man/man9/vnode.9 Wed Jan 11 09:08:58 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.77 2017/01/11 09:07:57 hannken Exp $ +.\" $NetBSD: vnode.9,v 1.78 2017/01/11 09:08:58 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -180,7 +180,6 @@ struct vnode { } v_un; enum vtype v_type; /* vnode type */ enum vtagtype v_tag; /* type of underlying data */ - struct vnlock v_lock; /* lock for this vnode */ void *v_data; /* private data for fs */ struct klist v_klist; /* notes attached to vnode */ }; @@ -433,9 +432,7 @@ universal disk format file system systemV boot file system .El .Pp -All vnode locking operations use -.Em v_lock . -This lock is acquired by calling +The vnode lock is acquired by calling .Xr vn_lock 9 and released by calling .Xr VOP_UNLOCK 9 . @@ -461,10 +458,8 @@ locking. Multiple-reader locking functions equivalently only in the presence of big-lock SMP locking or a uni-processor machine. The lock may be held while sleeping. -While the -.Em v_lock -is acquired, the holder is guaranteed that the vnode will not be -reclaimed or invalidated. +While the vnode lock is acquired, the holder is guaranteed that the +vnode will not be reclaimed or invalidated. Most file system functions require that you hold the vnode lock on entry. See .Xr lock 9 Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.456 src/sys/kern/vfs_subr.c:1.457 --- src/sys/kern/vfs_subr.c:1.456 Wed Jan 11 09:07:57 2017 +++ src/sys/kern/vfs_subr.c Wed Jan 11 09:08:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.456 2017/01/11 09:07:57 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.457 2017/01/11 09:08:58 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1116,7 +1116,7 @@ vprint_common(struct vnode *vp, const ch vp->v_usecount, vp->v_writecount, vp->v_holdcnt); (*pr)("%ssize %" PRIx64 " writesize %" PRIx64 " numoutput %d\n", prefix, vp->v_size, vp->v_writesize, vp->v_numoutput); - (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, >v_lock); + (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, >vi_lock); (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(vip->vi_state), vip->vi_key.vk_mount, vip->vi_key.vk_key_len); Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.71 src/sys/kern/vfs_vnode.c:1.72 --- src/sys/kern/vfs_vnode.c:1.71 Wed Jan 11 09:04:37 2017 +++ src/sys/kern/vfs_vnode.c Wed Jan 11 09:08:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.71 2017/01/11 09:04:37 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.71 2017/01/11 09:04:37 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.72 2017/01/11 09:08:58 hannken Exp $"); #include #include @@ -1022,6 +1022,7 @@ vcache_alloc(void) vip = pool_cache_get(vcache_pool, PR_WAITOK); memset(vip, 0, sizeof(*vip)); + rw_init(>vi_lock); /* SLIST_INIT(>vi_hash); */ /* LIST_INIT(>vi_nclist); */ /* LIST_INIT(>vi_dnclist); */ @@ -1030,7 +1031,6 @@ vcache_alloc(void) uvm_obj_init(>v_uobj, _vnodeops, true, 0); cv_init(>v_cv, "vnode"); - rw_init(>v_lock); vp->v_usecount = 1; vp->v_type = VNON; vp->v_size = vp->v_writesize = VSIZENOTSET; @@ -1064,7 +1064,7 @@ vcache_free(vnode_impl_t *vip) if (vp->v_type == VBLK || vp->v_type == VCHR) spec_node_destroy(vp); - rw_destroy(>v_lock); + rw_destroy(>vi_lock); uvm_obj_destroy(>v_uobj, true); cv_destroy(>v_cv); pool_cache_put(vcache_pool, vip); Index:
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Jan 11 09:07:58 UTC 2017 Modified Files: src/share/man/man9: vnode.9 src/sys/kern: vfs_mount.c vfs_subr.c src/sys/sys: mount.h vnode.h vnode_impl.h src/usr.sbin/pstat: pstat.c Log Message: Move vnode member v_mntvnodes as vi_mntvnodes to vnode_impl.h. Add an ugly hack so pstat.c may still traverse the list. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/share/man/man9/vnode.9 cvs rdiff -u -r1.43 -r1.44 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.455 -r1.456 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.219 -r1.220 src/sys/sys/mount.h cvs rdiff -u -r1.270 -r1.271 src/sys/sys/vnode.h cvs rdiff -u -r1.9 -r1.10 src/sys/sys/vnode_impl.h cvs rdiff -u -r1.125 -r1.126 src/usr.sbin/pstat/pstat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.76 src/share/man/man9/vnode.9:1.77 --- src/share/man/man9/vnode.9:1.76 Wed Jan 11 09:06:57 2017 +++ src/share/man/man9/vnode.9 Wed Jan 11 09:07:57 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.76 2017/01/11 09:06:57 hannken Exp $ +.\" $NetBSD: vnode.9,v 1.77 2017/01/11 09:07:57 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -169,7 +169,6 @@ struct vnode { int v_holdcnt; /* page & buffer refs */ struct mount *v_mount; /* ptr to vfs we are in */ int (**v_op)(void *); /* vnode operations vector */ - TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ union { Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.43 src/sys/kern/vfs_mount.c:1.44 --- src/sys/kern/vfs_mount.c:1.43 Mon Jan 2 10:33:28 2017 +++ src/sys/kern/vfs_mount.c Wed Jan 11 09:07:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.43 2017/01/02 10:33:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.44 2017/01/11 09:07:57 hannken Exp $"); #include #include @@ -99,6 +99,8 @@ vnode_t * rootvnode; /* Mounted filesystem list. */ struct mntlist mountlist; kmutex_t mountlist_lock; +int vnode_offset_next_by_mount /* XXX: ugly hack for pstat.c */ += offsetof(vnode_impl_t, vi_mntvnodes.tqe_next); kmutex_t mntvnode_lock; kmutex_t vfs_list_lock; @@ -336,33 +338,36 @@ vfs_unbusy(struct mount *mp, bool keepre } struct vnode_iterator { - struct vnode vi_vnode; + vnode_impl_t vi_vnode; }; void -vfs_vnode_iterator_init(struct mount *mp, struct vnode_iterator **vip) +vfs_vnode_iterator_init(struct mount *mp, struct vnode_iterator **vnip) { - struct vnode *vp; + vnode_t *vp; + vnode_impl_t *vip; vp = vnalloc_marker(mp); + vip = VNODE_TO_VIMPL(vp); mutex_enter(_lock); - TAILQ_INSERT_HEAD(>mnt_vnodelist, vp, v_mntvnodes); + TAILQ_INSERT_HEAD(>mnt_vnodelist, vip, vi_mntvnodes); vp->v_usecount = 1; mutex_exit(_lock); - *vip = (struct vnode_iterator *)vp; + *vnip = (struct vnode_iterator *)vip; } void -vfs_vnode_iterator_destroy(struct vnode_iterator *vi) +vfs_vnode_iterator_destroy(struct vnode_iterator *vni) { - struct vnode *mvp = >vi_vnode; + vnode_impl_t *mvip = >vi_vnode; + vnode_t *mvp = VIMPL_TO_VNODE(mvip); mutex_enter(_lock); KASSERT(vnis_marker(mvp)); if (mvp->v_usecount != 0) { - TAILQ_REMOVE(>v_mount->mnt_vnodelist, mvp, v_mntvnodes); + TAILQ_REMOVE(>v_mount->mnt_vnodelist, mvip, vi_mntvnodes); mvp->v_usecount = 0; } mutex_exit(_lock); @@ -370,22 +375,24 @@ vfs_vnode_iterator_destroy(struct vnode_ } struct vnode * -vfs_vnode_iterator_next(struct vnode_iterator *vi, +vfs_vnode_iterator_next(struct vnode_iterator *vni, bool (*f)(void *, struct vnode *), void *cl) { - struct vnode *mvp = >vi_vnode; - struct mount *mp = mvp->v_mount; - struct vnode *vp; + vnode_impl_t *mvip = >vi_vnode; + struct mount *mp = VIMPL_TO_VNODE(mvip)->v_mount; + vnode_t *vp; + vnode_impl_t *vip; int error; - KASSERT(vnis_marker(mvp)); + KASSERT(vnis_marker(VIMPL_TO_VNODE(mvip))); do { mutex_enter(_lock); - vp = TAILQ_NEXT(mvp, v_mntvnodes); - TAILQ_REMOVE(>mnt_vnodelist, mvp, v_mntvnodes); - mvp->v_usecount = 0; + vip = TAILQ_NEXT(mvip, vi_mntvnodes); + TAILQ_REMOVE(>mnt_vnodelist, mvip, vi_mntvnodes); + VIMPL_TO_VNODE(mvip)->v_usecount = 0; again: + vp = VIMPL_TO_VNODE(vip); if (vp == NULL) { mutex_exit(_lock); return NULL; @@ -395,12 +402,12 @@ again: vdead_check(vp, VDEAD_NOWAIT) || (f && !(*f)(cl, vp))) { mutex_exit(vp->v_interlock); - vp =
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Jan 11 09:06:57 UTC 2017 Modified Files: src/share/man/man9: vnode.9 src/sys/kern: vfs_subr.c src/sys/sys: vnode.h vnode_impl.h Log Message: Move vnode members v_synclist_slot and v_synclist as vi_synclist_slot and vi_synclist to vnode_impl.h. To generate a diff of this commit: cvs rdiff -u -r1.75 -r1.76 src/share/man/man9/vnode.9 cvs rdiff -u -r1.454 -r1.455 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.269 -r1.270 src/sys/sys/vnode.h cvs rdiff -u -r1.8 -r1.9 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.75 src/share/man/man9/vnode.9:1.76 --- src/share/man/man9/vnode.9:1.75 Wed Jan 11 09:04:37 2017 +++ src/share/man/man9/vnode.9 Wed Jan 11 09:06:57 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.75 2017/01/11 09:04:37 hannken Exp $ +.\" $NetBSD: vnode.9,v 1.76 2017/01/11 09:06:57 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -167,13 +167,11 @@ struct vnode { int v_numoutput; /* # of pending writes */ int v_writecount; /* ref count of writers */ int v_holdcnt; /* page & buffer refs */ - int v_synclist_slot; /* synclist slot index */ struct mount *v_mount; /* ptr to vfs we are in */ int (**v_op)(void *); /* vnode operations vector */ TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ - TAILQ_ENTRY(vnode) v_synclist; /* vnodes with dirty bufs */ union { struct mount *vu_mountedhere;/* ptr to vfs (VDIR) */ struct socket *vu_socket; /* unix ipc (VSOCK) */ @@ -483,9 +481,8 @@ The members .Em v_numoutput , .Em v_holdcnt , .Em v_dirtyblkhd , -.Em v_cleanblkhd , and -.Em v_synclist +.Em v_cleanblkhd are modified in interrupt context and must be protected by .Xr splbio 9 unless it is certain that there is no chance an interrupt handler will Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.454 src/sys/kern/vfs_subr.c:1.455 --- src/sys/kern/vfs_subr.c:1.454 Thu Jan 5 10:05:11 2017 +++ src/sys/kern/vfs_subr.c Wed Jan 11 09:06:57 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.454 2017/01/05 10:05:11 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.455 2017/01/11 09:06:57 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.454 2017/01/05 10:05:11 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.455 2017/01/11 09:06:57 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -552,7 +552,7 @@ vdevgone(int maj, int minl, int minh, en #define SYNCER_MAXDELAY 32 -typedef TAILQ_HEAD(synclist, vnode) synclist_t; +typedef TAILQ_HEAD(synclist, vnode_impl) synclist_t; static void vn_syncer_add1(struct vnode *, int); static void sysctl_vfs_syncfs_setup(struct sysctllog **); @@ -624,6 +624,7 @@ static void vn_syncer_add1(struct vnode *vp, int delayx) { synclist_t *slp; + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); KASSERT(mutex_owned(_data_lock)); @@ -633,17 +634,17 @@ vn_syncer_add1(struct vnode *vp, int del * Note: called from sched_sync(), which will not hold * interlock, therefore we cannot modify v_iflag here. */ - slp = _workitem_pending[vp->v_synclist_slot]; - TAILQ_REMOVE(slp, vp, v_synclist); + slp = _workitem_pending[vip->vi_synclist_slot]; + TAILQ_REMOVE(slp, vip, vi_synclist); } else { KASSERT(mutex_owned(vp->v_interlock)); vp->v_iflag |= VI_ONWORKLST; } - vp->v_synclist_slot = sync_delay_slot(delayx); + vip->vi_synclist_slot = sync_delay_slot(delayx); - slp = _workitem_pending[vp->v_synclist_slot]; - TAILQ_INSERT_TAIL(slp, vp, v_synclist); + slp = _workitem_pending[vip->vi_synclist_slot]; + TAILQ_INSERT_TAIL(slp, vip, vi_synclist); } void @@ -664,14 +665,15 @@ void vn_syncer_remove_from_worklist(struct vnode *vp) { synclist_t *slp; + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); KASSERT(mutex_owned(vp->v_interlock)); mutex_enter(_data_lock); if (vp->v_iflag & VI_ONWORKLST) { vp->v_iflag &= ~VI_ONWORKLST; - slp = _workitem_pending[vp->v_synclist_slot]; - TAILQ_REMOVE(slp, vp, v_synclist); + slp = _workitem_pending[vip->vi_synclist_slot]; + TAILQ_REMOVE(slp, vip, vi_synclist); } mutex_exit(_data_lock); } @@ -795,14 +797,14 @@ sched_sync(void *arg) if (syncer_delayno >= syncer_last) syncer_delayno = 0; - while ((vp = TAILQ_FIRST(slp)) != NULL) { + while ((vp = VIMPL_TO_VNODE(TAILQ_FIRST(slp))) != NULL) { synced = lazy_sync_vnode(vp); /* * XXX The vnode may have been recycled, in which * case it may have a new identity. */ - if (TAILQ_FIRST(slp) == vp)
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Jan 11 09:04:37 UTC 2017 Modified Files: src/share/man/man9: vnode.9 src/sys/kern: vfs_cache.c vfs_vnode.c src/sys/sys: vnode.h vnode_impl.h Log Message: Move vnode members v_dnclist and v_nclist as vi_dnclist and vi_nclist to vnode_impl.h. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/share/man/man9/vnode.9 cvs rdiff -u -r1.111 -r1.112 src/sys/kern/vfs_cache.c cvs rdiff -u -r1.70 -r1.71 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.268 -r1.269 src/sys/sys/vnode.h cvs rdiff -u -r1.7 -r1.8 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.74 src/share/man/man9/vnode.9:1.75 --- src/share/man/man9/vnode.9:1.74 Mon Jan 2 10:33:28 2017 +++ src/share/man/man9/vnode.9 Wed Jan 11 09:04:37 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.74 2017/01/02 10:33:28 hannken Exp $ +.\" $NetBSD: vnode.9,v 1.75 2017/01/11 09:04:37 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd January 2, 2017 +.Dd January 11, 2017 .Dt VNODE 9 .Os .Sh NAME @@ -174,8 +174,6 @@ struct vnode { struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ TAILQ_ENTRY(vnode) v_synclist; /* vnodes with dirty bufs */ - LIST_HEAD(, namecache) v_dnclist; /* namecaches (children) */ - LIST_HEAD(, namecache) v_nclist; /* namecaches (parent) */ union { struct mount *vu_mountedhere;/* ptr to vfs (VDIR) */ struct socket *vu_socket; /* unix ipc (VSOCK) */ @@ -316,15 +314,6 @@ Its value must only be modified at splbi It does not track the number of dirty buffers attached to the vnode. .Pp -.Em v_dnclist -and -.Em v_nclist -are used by -.Xr namecache 9 -to maintain the list of associated entries so that -.Xr cache_purge 9 -can purge them. -.Pp The link to the file system which owns the vnode is recorded by .Em v_mount . See Index: src/sys/kern/vfs_cache.c diff -u src/sys/kern/vfs_cache.c:1.111 src/sys/kern/vfs_cache.c:1.112 --- src/sys/kern/vfs_cache.c:1.111 Mon Jan 2 10:33:28 2017 +++ src/sys/kern/vfs_cache.c Wed Jan 11 09:04:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: vfs_cache.c,v 1.112 2017/01/11 09:04:37 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.111 2017/01/02 10:33:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.112 2017/01/11 09:04:37 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -844,9 +844,9 @@ cache_enter(struct vnode *dvp, struct vn /* Fill in cache info. */ ncp->nc_dvp = dvp; - LIST_INSERT_HEAD(>v_dnclist, ncp, nc_dvlist); + LIST_INSERT_HEAD(_TO_VIMPL(dvp)->vi_dnclist, ncp, nc_dvlist); if (vp) - LIST_INSERT_HEAD(>v_nclist, ncp, nc_vlist); + LIST_INSERT_HEAD(_TO_VIMPL(vp)->vi_nclist, ncp, nc_vlist); else { ncp->nc_vlist.le_prev = NULL; ncp->nc_vlist.le_next = NULL; @@ -1031,8 +1031,8 @@ cache_purge1(struct vnode *vp, const cha if (flags & PURGE_PARENTS) { SDT_PROBE(vfs, namecache, purge, parents, vp, 0, 0, 0, 0); - for (ncp = LIST_FIRST(>v_nclist); ncp != NULL; - ncp = ncnext) { + for (ncp = LIST_FIRST(_TO_VIMPL(vp)->vi_nclist); + ncp != NULL; ncp = ncnext) { ncnext = LIST_NEXT(ncp, nc_vlist); mutex_enter(>nc_lock); cache_invalidate(ncp); @@ -1042,8 +1042,8 @@ cache_purge1(struct vnode *vp, const cha } if (flags & PURGE_CHILDREN) { SDT_PROBE(vfs, namecache, purge, children, vp, 0, 0, 0, 0); - for (ncp = LIST_FIRST(>v_dnclist); ncp != NULL; - ncp = ncnext) { + for (ncp = LIST_FIRST(_TO_VIMPL(vp)->vi_dnclist); + ncp != NULL; ncp = ncnext) { ncnext = LIST_NEXT(ncp, nc_dvlist); mutex_enter(>nc_lock); cache_invalidate(ncp); Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.70 src/sys/kern/vfs_vnode.c:1.71 --- src/sys/kern/vfs_vnode.c:1.70 Thu Jan 5 10:05:11 2017 +++ src/sys/kern/vfs_vnode.c Wed Jan 11 09:04:37 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.70 2017/01/05 10:05:11 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.71 2017/01/11 09:04:37 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.70 2017/01/05 10:05:11 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.71 2017/01/11 09:04:37 hannken Exp $"); #include #include @@ -1023,12 +1023,12 @@ vcache_alloc(void) memset(vip, 0, sizeof(*vip)); /* SLIST_INIT(>vi_hash); */ + /*
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Jan 5 10:05:11 UTC 2017 Modified Files: src/sys/kern: vfs_subr.c vfs_vnode.c src/sys/sys: vnode_impl.h Log Message: Name all "vnode_impl_t" variables "vip". No functional change. To generate a diff of this commit: cvs rdiff -u -r1.453 -r1.454 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.69 -r1.70 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.6 -r1.7 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.453 src/sys/kern/vfs_subr.c:1.454 --- src/sys/kern/vfs_subr.c:1.453 Mon Jan 2 10:33:28 2017 +++ src/sys/kern/vfs_subr.c Thu Jan 5 10:05:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.453 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.454 2017/01/05 10:05:11 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.453 2017/01/02 10:33:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.454 2017/01/05 10:05:11 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1091,7 +1091,7 @@ vprint_common(struct vnode *vp, const ch int n; char bf[96]; const uint8_t *cp; - vnode_impl_t *node; + vnode_impl_t *vip; const char * const vnode_tags[] = { VNODE_TAGS }; const char * const vnode_types[] = { VNODE_TYPES }; const char vnode_flagbits[] = VNODE_FLAGBITS; @@ -1100,7 +1100,7 @@ vprint_common(struct vnode *vp, const ch #define ARRAY_PRINT(idx, arr) \ ((unsigned int)(idx) < ARRAY_SIZE(arr) ? (arr)[(idx)] : "UNKNOWN") - node = VNODE_TO_VIMPL(vp); + vip = VNODE_TO_VIMPL(vp); snprintb(bf, sizeof(bf), vnode_flagbits, vp->v_iflag | vp->v_vflag | vp->v_uflag); @@ -1116,14 +1116,14 @@ vprint_common(struct vnode *vp, const ch prefix, vp->v_size, vp->v_writesize, vp->v_numoutput); (*pr)("%sdata %p lock %p\n", prefix, vp->v_data, >v_lock); - (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(node->vi_state), - node->vi_key.vk_mount, node->vi_key.vk_key_len); - n = node->vi_key.vk_key_len; - cp = node->vi_key.vk_key; + (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(vip->vi_state), + vip->vi_key.vk_mount, vip->vi_key.vk_key_len); + n = vip->vi_key.vk_key_len; + cp = vip->vi_key.vk_key; while (n-- > 0) (*pr)(" %02x", *cp++); (*pr)("\n"); - (*pr)("%slrulisthd %p\n", prefix, node->vi_lrulisthd); + (*pr)("%slrulisthd %p\n", prefix, vip->vi_lrulisthd); #undef ARRAY_PRINT #undef ARRAY_SIZE Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.69 src/sys/kern/vfs_vnode.c:1.70 --- src/sys/kern/vfs_vnode.c:1.69 Wed Jan 4 17:13:50 2017 +++ src/sys/kern/vfs_vnode.c Thu Jan 5 10:05:11 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.69 2017/01/04 17:13:50 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.70 2017/01/05 10:05:11 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.69 2017/01/04 17:13:50 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.70 2017/01/05 10:05:11 hannken Exp $"); #include #include @@ -241,52 +241,52 @@ extern struct vfsops dead_vfsops; static void vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line) { - vnode_impl_t *node = VNODE_TO_VIMPL(vp); + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line); - if (__predict_true(node->vi_state == state)) + if (__predict_true(vip->vi_state == state)) return; vnpanic(vp, "state is %s, expected %s at %s:%d", - vstate_name(node->vi_state), vstate_name(state), func, line); + vstate_name(vip->vi_state), vstate_name(state), func, line); } static enum vnode_state vstate_assert_get(vnode_t *vp, const char *func, int line) { - vnode_impl_t *node = VNODE_TO_VIMPL(vp); + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line); - if (node->vi_state == VS_MARKER) + if (vip->vi_state == VS_MARKER) vnpanic(vp, "state is %s at %s:%d", - vstate_name(node->vi_state), func, line); + vstate_name(vip->vi_state), func, line); - return node->vi_state; + return vip->vi_state; } static void vstate_assert_wait_stable(vnode_t *vp, const char *func, int line) { - vnode_impl_t *node = VNODE_TO_VIMPL(vp); + vnode_impl_t *vip = VNODE_TO_VIMPL(vp); KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line); - if (node->vi_state == VS_MARKER) + if (vip->vi_state == VS_MARKER) vnpanic(vp, "state is %s at %s:%d", - vstate_name(node->vi_state), func, line); + vstate_name(vip->vi_state), func, line); - while (node->vi_state != VS_ACTIVE && node->vi_state != VS_RECLAIMED) + while (vip->vi_state !=
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Jan 4 17:13:50 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Expand struct vcache to individual variables (vcache.* -> vcache_*). No functional change. To generate a diff of this commit: cvs rdiff -u -r1.68 -r1.69 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.68 src/sys/kern/vfs_vnode.c:1.69 --- src/sys/kern/vfs_vnode.c:1.68 Mon Jan 2 10:36:58 2017 +++ src/sys/kern/vfs_vnode.c Wed Jan 4 17:13:50 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.68 2017/01/02 10:36:58 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.69 2017/01/04 17:13:50 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -132,7 +132,7 @@ * and it is possible to wait for state change. * * State is protected with v_interlock with one exception: - * to change from LOADING both v_interlock and vcache.lock must be held + * to change from LOADING both v_interlock and vcache_lock must be held * so it is possible to check "state == LOADING" without holding * v_interlock. See vcache_get() for details. * @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.68 2017/01/02 10:36:58 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.69 2017/01/04 17:13:50 hannken Exp $"); #include #include @@ -202,15 +202,12 @@ static kcondvar_t vdrain_gen_cv; static bool vdrain_retry; static lwp_t * vdrain_lwp; SLIST_HEAD(hashhead, vnode_impl); -static struct { - kmutex_t lock; - kcondvar_t cv; - u_int hashsize; - u_long hashmask; - struct hashhead *hashtab; - pool_cache_t pool; -} vcache __cacheline_aligned; - +static kmutex_t vcache_lock __cacheline_aligned; +static kcondvar_t vcache_cv __cacheline_aligned; +static u_int vcache_hashsize; +static u_long vcache_hashmask; +static struct hashhead *vcache_hashtab __cacheline_aligned; +static pool_cache_t vcache_pool; static void lru_requeue(vnode_t *, vnodelst_t *); static vnodelst_t * lru_which(vnode_t *); static vnode_impl_t * vcache_alloc(void); @@ -293,7 +290,7 @@ vstate_assert_change(vnode_t *vp, enum v KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line); if (from == VS_LOADING) - KASSERTMSG(mutex_owned(), "at %s:%d", func, line); + KASSERTMSG(mutex_owned(_lock), "at %s:%d", func, line); if (from == VS_MARKER) vnpanic(vp, "from is %s at %s:%d", @@ -311,7 +308,7 @@ vstate_assert_change(vnode_t *vp, enum v node->vi_state = to; if (from == VS_LOADING) - cv_broadcast(); + cv_broadcast(_cv); if (to == VS_ACTIVE || to == VS_RECLAIMED) cv_broadcast(>v_cv); } @@ -342,7 +339,7 @@ vstate_change(vnode_t *vp, enum vnode_st node->vi_state = to; if (from == VS_LOADING) - cv_broadcast(); + cv_broadcast(_cv); if (to == VS_ACTIVE || to == VS_RECLAIMED) cv_broadcast(>v_cv); } @@ -381,7 +378,7 @@ vnalloc_marker(struct mount *mp) vnode_impl_t *node; vnode_t *vp; - node = pool_cache_get(vcache.pool, PR_WAITOK); + node = pool_cache_get(vcache_pool, PR_WAITOK); memset(node, 0, sizeof(*node)); vp = VIMPL_TO_VNODE(node); uvm_obj_init(>v_uobj, _vnodeops, true, 0); @@ -403,7 +400,7 @@ vnfree_marker(vnode_t *vp) node = VNODE_TO_VIMPL(vp); KASSERT(node->vi_state == VS_MARKER); uvm_obj_destroy(>v_uobj, true); - pool_cache_put(vcache.pool, node); + pool_cache_put(vcache_pool, node); } /* @@ -954,14 +951,14 @@ static void vcache_init(void) { - vcache.pool = pool_cache_init(sizeof(vnode_impl_t), 0, 0, 0, + vcache_pool = pool_cache_init(sizeof(vnode_impl_t), 0, 0, 0, "vcachepl", NULL, IPL_NONE, NULL, NULL, NULL); - KASSERT(vcache.pool != NULL); - mutex_init(, MUTEX_DEFAULT, IPL_NONE); - cv_init(, "vcache"); - vcache.hashsize = desiredvnodes; - vcache.hashtab = hashinit(desiredvnodes, HASH_SLIST, true, - ); + KASSERT(vcache_pool != NULL); + mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); + cv_init(_cv, "vcache"); + vcache_hashsize = desiredvnodes; + vcache_hashtab = hashinit(desiredvnodes, HASH_SLIST, true, + _hashmask); } static void @@ -974,21 +971,21 @@ vcache_reinit(void) vnode_impl_t *node; newtab = hashinit(desiredvnodes, HASH_SLIST, true, ); - mutex_enter(); - oldtab = vcache.hashtab; - oldmask = vcache.hashmask; - vcache.hashsize = desiredvnodes; - vcache.hashtab = newtab; - vcache.hashmask = newmask; + mutex_enter(_lock); + oldtab = vcache_hashtab; + oldmask = vcache_hashmask; + vcache_hashsize = desiredvnodes; + vcache_hashtab = newtab; + vcache_hashmask = newmask; for (i = 0; i <= oldmask; i++) { while ((node = SLIST_FIRST([i])) != NULL) { SLIST_REMOVE([i], node, vnode_impl, vi_hash); hash = vcache_hash(>vi_key); - SLIST_INSERT_HEAD([hash & vcache.hashmask], + SLIST_INSERT_HEAD([hash & vcache_hashmask], node, vi_hash); } } -
CVS commit: src/sys/sys
Module Name:src Committed By: hannken Date: Wed Jan 4 17:06:13 UTC 2017 Modified Files: src/sys/sys: vnode_impl.h Log Message: Comment the fields of struct vnode_impl. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/sys/vnode_impl.h diff -u src/sys/sys/vnode_impl.h:1.5 src/sys/sys/vnode_impl.h:1.6 --- src/sys/sys/vnode_impl.h:1.5 Mon Jan 2 10:33:28 2017 +++ src/sys/sys/vnode_impl.h Wed Jan 4 17:06:13 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode_impl.h,v 1.5 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: vnode_impl.h,v 1.6 2017/01/04 17:06:13 hannken Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -42,20 +42,31 @@ enum vnode_state { VS_RECLAIMING, /* Intermediate, detaching the fs node. */ VS_RECLAIMED /* Stable, no fs node attached. */ }; + TAILQ_HEAD(vnodelst, vnode_impl); typedef struct vnodelst vnodelst_t; + struct vcache_key { struct mount *vk_mount; const void *vk_key; size_t vk_key_len; }; + +/* + * Reading or writing any of these items requires holding the appropriate + * lock. Field markings and the corresponding locks: + * + * c vcache_lock + * d vdrain_lock + * i v_interlock + */ struct vnode_impl { struct vnode vi_vnode; - enum vnode_state vi_state; - struct vnodelst *vi_lrulisthd; - TAILQ_ENTRY(vnode_impl) vi_lrulist; - SLIST_ENTRY(vnode_impl) vi_hash; - struct vcache_key vi_key; + enum vnode_state vi_state; /* i: current state */ + struct vnodelst *vi_lrulisthd; /* d: current lru list head */ + TAILQ_ENTRY(vnode_impl) vi_lrulist; /* d: lru list */ + SLIST_ENTRY(vnode_impl) vi_hash; /* c: vnode cache list */ + struct vcache_key vi_key; /* c: vnode cache key */ }; typedef struct vnode_impl vnode_impl_t;
CVS commit: src/sys/fs/tmpfs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:06:43 UTC 2017 Modified Files: src/sys/fs/tmpfs: tmpfs_subr.c Log Message: Change tmpfs_chsize() to update mtime etc. even if "length == node->tn_size". Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.101 -r1.102 src/sys/fs/tmpfs/tmpfs_subr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/fs/tmpfs/tmpfs_subr.c diff -u src/sys/fs/tmpfs/tmpfs_subr.c:1.101 src/sys/fs/tmpfs/tmpfs_subr.c:1.102 --- src/sys/fs/tmpfs/tmpfs_subr.c:1.101 Thu Oct 29 16:19:44 2015 +++ src/sys/fs/tmpfs/tmpfs_subr.c Wed Jan 4 10:06:43 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $ */ +/* $NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $ */ /* * Copyright (c) 2005-2013 The NetBSD Foundation, Inc. @@ -73,7 +73,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.101 2015/10/29 16:19:44 leot Exp $"); +__KERNEL_RCSID(0, "$NetBSD: tmpfs_subr.c,v 1.102 2017/01/04 10:06:43 hannken Exp $"); #include #include @@ -1125,12 +1125,10 @@ tmpfs_chsize(vnode_t *vp, u_quad_t size, if (length < 0) { return EINVAL; } - if (node->tn_size == length) { - return 0; - } /* Note: tmpfs_reg_resize() will raise NOTE_EXTEND and NOTE_ATTRIB. */ - if ((error = tmpfs_reg_resize(vp, length)) != 0) { + if (node->tn_size != length && + (error = tmpfs_reg_resize(vp, length)) != 0) { return error; } tmpfs_update(vp, TMPFS_UPDATE_CTIME | TMPFS_UPDATE_MTIME);
CVS commit: src/sys/ufs/ufs
Module Name:src Committed By: hannken Date: Wed Jan 4 10:04:17 UTC 2017 Modified Files: src/sys/ufs/ufs: ufs_inode.c Log Message: Change ufs_truncate_retry() to call UFS_TRUNCATE() at least once. Even with "newsize == ip->i_size" it must set mtime etc. Adresses PR kern/51762 "mtime not updated by open(O_TRUNC)" To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.97 src/sys/ufs/ufs/ufs_inode.c:1.98 --- src/sys/ufs/ufs/ufs_inode.c:1.97 Fri Oct 28 20:38:12 2016 +++ src/sys/ufs/ufs/ufs_inode.c Wed Jan 4 10:04:17 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.97 2016/10/28 20:38:12 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.98 2017/01/04 10:04:17 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -303,7 +303,7 @@ ufs_truncate_retry(struct vnode *vp, uin /* * Truncate might temporarily fail, loop until done. */ - while (ip->i_size != newsize) { + do { error = UFS_WAPBL_BEGIN(mp); if (error) goto out; @@ -313,7 +313,7 @@ ufs_truncate_retry(struct vnode *vp, uin if (error != 0 && error != EAGAIN) goto out; - } + } while (ip->i_size != newsize); out: return error;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Jan 2 10:36:58 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Now that v_usecount tracks valid references add some "v_usecount == 1" assertions. To generate a diff of this commit: cvs rdiff -u -r1.67 -r1.68 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.67 src/sys/kern/vfs_vnode.c:1.68 --- src/sys/kern/vfs_vnode.c:1.67 Mon Jan 2 10:35:00 2017 +++ src/sys/kern/vfs_vnode.c Mon Jan 2 10:36:58 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.67 2017/01/02 10:35:00 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.68 2017/01/02 10:36:58 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.67 2017/01/02 10:35:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.68 2017/01/02 10:36:58 hannken Exp $"); #include #include @@ -304,6 +304,10 @@ vstate_assert_change(vnode_t *vp, enum v if (node->vi_state != from) vnpanic(vp, "from is %s, expected %s at %s:%d\n", vstate_name(node->vi_state), vstate_name(from), func, line); + if ((from == VS_BLOCKED || to == VS_BLOCKED) && vp->v_usecount != 1) + vnpanic(vp, "%s to %s with usecount %d at %s:%d", + vstate_name(from), vstate_name(to), vp->v_usecount, + func, line); node->vi_state = to; if (from == VS_LOADING) @@ -877,6 +881,7 @@ vrecycle(vnode_t *vp) mutex_enter(vp->v_interlock); VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE); + KASSERT(vp->v_usecount == 1); vcache_reclaim(vp); vrelel(vp, 0);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Mon Jan 2 10:35:00 UTC 2017 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change vcache_*vget() to increment v_usecount on success only. Increment v_holdcnt to prevent the vnode from disappearing while vcache_vget() waits for a stable state. Now v_usecount tracks the number of successfull references. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.66 src/sys/kern/vfs_vnode.c:1.67 --- src/sys/kern/vfs_vnode.c:1.66 Mon Jan 2 10:33:28 2017 +++ src/sys/kern/vfs_vnode.c Mon Jan 2 10:35:00 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.66 2017/01/02 10:33:28 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.67 2017/01/02 10:35:00 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.66 2017/01/02 10:33:28 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.67 2017/01/02 10:35:00 hannken Exp $"); #include #include @@ -755,18 +755,11 @@ vrelel(vnode_t *vp, int flags) return; } - if (VSTATE_GET(vp) == VS_RECLAIMED) { + if (VSTATE_GET(vp) == VS_RECLAIMED && vp->v_holdcnt == 0) { /* * It's clean so destroy it. It isn't referenced * anywhere since it has been reclaimed. */ - KASSERT(vp->v_holdcnt == 0); - KASSERT(vp->v_writecount == 0); - mutex_exit(vp->v_interlock); - vfs_insmntque(vp, NULL); - if (vp->v_type == VBLK || vp->v_type == VCHR) { - spec_node_destroy(vp); - } vcache_free(VNODE_TO_VIMPL(vp)); } else { /* @@ -1049,6 +1042,7 @@ vcache_alloc(void) /* * Free an unused, unreferenced vcache node. + * v_interlock locked on entry. */ static void vcache_free(vnode_impl_t *node) @@ -1056,10 +1050,18 @@ vcache_free(vnode_impl_t *node) vnode_t *vp; vp = VIMPL_TO_VNODE(node); + KASSERT(mutex_owned(vp->v_interlock)); KASSERT(vp->v_usecount == 0); - + KASSERT(vp->v_holdcnt == 0); + KASSERT(vp->v_writecount == 0); lru_requeue(vp, NULL); + mutex_exit(vp->v_interlock); + + vfs_insmntque(vp, NULL); + if (vp->v_type == VBLK || vp->v_type == VCHR) + spec_node_destroy(vp); + rw_destroy(>v_lock); uvm_obj_destroy(>v_uobj, true); cv_destroy(>v_cv); @@ -1076,39 +1078,22 @@ vcache_free(vnode_impl_t *node) int vcache_tryvget(vnode_t *vp) { + int error = 0; KASSERT(mutex_owned(vp->v_interlock)); - /* - * Before adding a reference, we must remove the vnode - * from its freelist. - */ - if (vp->v_usecount == 0) { + if (__predict_false(VSTATE_GET(vp) == VS_RECLAIMED)) + error = ENOENT; + else if (__predict_false(VSTATE_GET(vp) != VS_ACTIVE)) + error = EBUSY; + else if (vp->v_usecount == 0) vp->v_usecount = 1; - } else { + else atomic_inc_uint(>v_usecount); - } - /* - * If the vnode is in the process of changing state we wait - * for the change to complete and take care not to return - * a clean vnode. - */ - if (VSTATE_GET(vp) == VS_RECLAIMED) { - vrelel(vp, 0); - return ENOENT; - } else if (VSTATE_GET(vp) != VS_ACTIVE) { - vrelel(vp, 0); - return EBUSY; - } - - /* - * Ok, we got it in good shape. - */ - VSTATE_ASSERT(vp, VS_ACTIVE); mutex_exit(vp->v_interlock); - return 0; + return error; } /* @@ -1124,34 +1109,25 @@ vcache_vget(vnode_t *vp) KASSERT(mutex_owned(vp->v_interlock)); - /* - * Before adding a reference, we must remove the vnode - * from its freelist. - */ - if (vp->v_usecount == 0) { - vp->v_usecount = 1; - } else { - atomic_inc_uint(>v_usecount); - } - - /* - * If the vnode is in the process of changing state we wait - * for the change to complete and take care not to return - * a clean vnode. - */ + /* Increment hold count to prevent vnode from disappearing. */ + vp->v_holdcnt++; VSTATE_WAIT_STABLE(vp); - if (VSTATE_GET(vp) == VS_RECLAIMED) { - vrelel(vp, 0); + vp->v_holdcnt--; + + /* If this was the last reference to a reclaimed vnode free it now. */ + if (__predict_false(VSTATE_GET(vp) == VS_RECLAIMED)) { + if (vp->v_holdcnt == 0 && vp->v_usecount == 0) + vcache_free(VNODE_TO_VIMPL(vp)); + else + mutex_exit(vp->v_interlock); return ENOENT; - } else if (VSTATE_GET(vp) != VS_ACTIVE) { - vrelel(vp, 0); - return EBUSY; } - - /* - * Ok, we got it in good shape. - */ VSTATE_ASSERT(vp, VS_ACTIVE); + if (vp->v_usecount == 0) + vp->v_usecount = 1; + else + atomic_inc_uint(>v_usecount); + mutex_exit(vp->v_interlock); return 0;
CVS commit: src
Module Name:src Committed By: hannken Date: Mon Jan 2 10:33:28 UTC 2017 Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man9: Makefile vnode.9 vnsubr.9 src/sys/kern: vfs_cache.c vfs_mount.c vfs_subr.c vfs_vnode.c src/sys/miscfs/specfs: spec_vnops.c src/sys/sys: param.h vnode.h vnode_impl.h Log Message: Rename vget() to vcache_vget() and vcache_tryvget() respectively and move the definitions to sys/vnode_impl.h. No functional change intended. Welcome to 7.99.54 To generate a diff of this commit: cvs rdiff -u -r1.2089 -r1.2090 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.399 -r1.400 src/share/man/man9/Makefile cvs rdiff -u -r1.73 -r1.74 src/share/man/man9/vnode.9 cvs rdiff -u -r1.43 -r1.44 src/share/man/man9/vnsubr.9 cvs rdiff -u -r1.110 -r1.111 src/sys/kern/vfs_cache.c cvs rdiff -u -r1.42 -r1.43 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.452 -r1.453 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.65 -r1.66 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.167 -r1.168 src/sys/miscfs/specfs/spec_vnops.c cvs rdiff -u -r1.520 -r1.521 src/sys/sys/param.h cvs rdiff -u -r1.267 -r1.268 src/sys/sys/vnode.h cvs rdiff -u -r1.4 -r1.5 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2089 src/distrib/sets/lists/comp/mi:1.2090 --- src/distrib/sets/lists/comp/mi:1.2089 Mon Jan 2 10:28:35 2017 +++ src/distrib/sets/lists/comp/mi Mon Jan 2 10:33:28 2017 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2089 2017/01/02 10:28:35 roy Exp $ +# $NetBSD: mi,v 1.2090 2017/01/02 10:33:28 hannken Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -11234,7 +11234,7 @@ ./usr/share/man/cat9/vfs_write_suspend.0 comp-obsolete obsolete ./usr/share/man/cat9/vfsops.0 comp-sys-catman .cat ./usr/share/man/cat9/vfssubr.0 comp-sys-catman .cat -./usr/share/man/cat9/vget.0 comp-sys-catman .cat +./usr/share/man/cat9/vget.0 comp-sys-catman obsolete ./usr/share/man/cat9/vgone.0 comp-sys-catman .cat ./usr/share/man/cat9/vgonel.0 comp-sys-catman .cat ./usr/share/man/cat9/vhold.0 comp-sys-catman .cat @@ -18418,7 +18418,7 @@ ./usr/share/man/html9/vfs_vnode_iterator_next.html comp-sys-htmlman html ./usr/share/man/html9/vfsops.html comp-sys-htmlman html ./usr/share/man/html9/vfssubr.html comp-sys-htmlman html -./usr/share/man/html9/vget.html comp-sys-htmlman html +./usr/share/man/html9/vget.html comp-sys-htmlman obsolete ./usr/share/man/html9/vgone.html comp-sys-htmlman html ./usr/share/man/html9/vgonel.html comp-sys-htmlman html ./usr/share/man/html9/vhold.html comp-sys-htmlman html @@ -25842,7 +25842,7 @@ ./usr/share/man/man9/vfs_write_suspend.9 comp-obsolete obsolete ./usr/share/man/man9/vfsops.9 comp-sys-man .man ./usr/share/man/man9/vfssubr.9 comp-sys-man .man -./usr/share/man/man9/vget.9 comp-sys-man .man +./usr/share/man/man9/vget.9 comp-sys-man obsolete ./usr/share/man/man9/vgone.9 comp-sys-man .man ./usr/share/man/man9/vgonel.9 comp-sys-man .man ./usr/share/man/man9/vhold.9 comp-sys-man .man Index: src/share/man/man9/Makefile diff -u src/share/man/man9/Makefile:1.399 src/share/man/man9/Makefile:1.400 --- src/share/man/man9/Makefile:1.399 Thu Dec 22 11:46:48 2016 +++ src/share/man/man9/Makefile Mon Jan 2 10:33:28 2017 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.399 2016/12/22 11:46:48 cherry Exp $ +# $NetBSD: Makefile,v 1.400 2017/01/02 10:33:28 hannken Exp $ # Makefile for section 9 (kernel function and variable) manual pages. @@ -949,7 +949,6 @@ MLINKS+=vmem.9 vmem_alloc.9 \ MLINKS+=vnode.9 vref.9 \ vnode.9 vrele.9 \ vnode.9 vrele_async.9 \ - vnode.9 vget.9 \ vnode.9 vput.9 \ vnode.9 vhold.9 \ vnode.9 holdrele.9 \ Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.73 src/share/man/man9/vnode.9:1.74 --- src/share/man/man9/vnode.9:1.73 Wed Dec 14 15:48:54 2016 +++ src/share/man/man9/vnode.9 Mon Jan 2 10:33:28 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.73 2016/12/14 15:48:54 hannken Exp $ +.\" $NetBSD: vnode.9,v 1.74 2017/01/02 10:33:28 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd December 14, 2016 +.Dd January 2, 2017 .Dt VNODE 9 .Os .Sh NAME @@ -35,7 +35,6 @@ .Nm vref , .Nm vrele , .Nm vrele_async , -.Nm vget , .Nm vput , .Nm vhold , .Nm holdrele , @@ -68,8 +67,6 @@ .Fn vrele "struct vnode *vp" .Ft void .Fn vrele_async "struct vnode *vp" -.Ft int -.Fn vget "struct vnode *vp" "int lockflag" "int wait" .Ft void .Fn vput "struct vnode *vp" .Ft void @@ -152,12 +149,10 @@ When a file system retrieves a
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Tue Dec 27 11:59:36 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: It is wrong to block the vnode during vcache_rekey. The vnode may be looked up using the old key until vcache_rekey_exit changes the key to the new one. Add an assertion that the temporary key is different from the current one. To generate a diff of this commit: cvs rdiff -u -r1.64 -r1.65 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.64 src/sys/kern/vfs_vnode.c:1.65 --- src/sys/kern/vfs_vnode.c:1.64 Tue Dec 20 10:02:21 2016 +++ src/sys/kern/vfs_vnode.c Tue Dec 27 11:59:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.65 2016/12/27 11:59:36 hannken Exp $"); #include #include @@ -1305,7 +1305,7 @@ vcache_new(struct mount *mp, struct vnod } /* - * Prepare key change: lock old and new cache node. + * Prepare key change: update old cache nodes key and lock new cache node. * Return an error if the new node already exists. */ int @@ -1345,20 +1345,18 @@ vcache_rekey_enter(struct mount *mp, str SLIST_INSERT_HEAD([new_hash & vcache.hashmask], new_node, vi_hash); - /* Lock old node. */ + /* Replace old nodes key with the temporary copy. */ node = vcache_hash_lookup(_vcache_key, old_hash); KASSERT(node != NULL); KASSERT(VIMPL_TO_VNODE(node) == vp); - mutex_enter(vp->v_interlock); - VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED); + KASSERT(node->vi_key.vk_key != old_vcache_key.vk_key); node->vi_key = old_vcache_key; - mutex_exit(vp->v_interlock); mutex_exit(); return 0; } /* - * Key change complete: remove old node and unlock new node. + * Key change complete: update old node and remove placeholder. */ void vcache_rekey_exit(struct mount *mp, struct vnode *vp, @@ -1386,8 +1384,6 @@ vcache_rekey_exit(struct mount *mp, stru old_node = vcache_hash_lookup(_vcache_key, old_hash); KASSERT(old_node != NULL); KASSERT(VIMPL_TO_VNODE(old_node) == vp); - mutex_enter(vp->v_interlock); - VSTATE_ASSERT(vp, VS_BLOCKED); new_node = vcache_hash_lookup(_vcache_key, new_hash); KASSERT(new_node != NULL); @@ -1404,8 +1400,6 @@ vcache_rekey_exit(struct mount *mp, stru SLIST_INSERT_HEAD([new_hash & vcache.hashmask], old_node, vi_hash); } - VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE); - mutex_exit(vp->v_interlock); /* Remove new node used as placeholder. */ SLIST_REMOVE([new_hash & vcache.hashmask],
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Tue Dec 27 10:54:38 UTC 2016 Modified Files: src/sys/ufs/ffs: ffs_vfsops.c Log Message: Fix a bug introduced with Rev. 1.294: use LK_NOWAIT when called with MNT_LAZY. To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/sys/ufs/ffs/ffs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_vfsops.c diff -u src/sys/ufs/ffs/ffs_vfsops.c:1.341 src/sys/ufs/ffs/ffs_vfsops.c:1.342 --- src/sys/ufs/ffs/ffs_vfsops.c:1.341 Thu Oct 20 19:31:32 2016 +++ src/sys/ufs/ffs/ffs_vfsops.c Tue Dec 27 10:54:38 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $ */ +/* $NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.341 2016/10/20 19:31:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_vfsops.c,v 1.342 2016/12/27 10:54:38 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -1917,7 +1917,8 @@ ffs_sync(struct mount *mp, int waitfor, ctx.is_suspending = is_suspending; while ((vp = vfs_vnode_iterator_next(marker, ffs_sync_selector, ))) { - error = vn_lock(vp, LK_EXCLUSIVE); + error = vn_lock(vp, + LK_EXCLUSIVE | (waitfor == MNT_LAZY ? LK_NOWAIT : 0)); if (error) { vrele(vp); continue;
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Tue Dec 20 10:02:21 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Restructure vdrain_vrele(). While it is not possible for another thread to lock this vnodes v_interlock -> vdrain_lock another vnode sharing the v_interlock may lock this order. While here, restore fstrans_start_nowait arg to FSTRANS_LAZY. Fixes a deadlock seen recently on some pbulk environments. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.63 src/sys/kern/vfs_vnode.c:1.64 --- src/sys/kern/vfs_vnode.c:1.63 Wed Dec 14 15:49:35 2016 +++ src/sys/kern/vfs_vnode.c Tue Dec 20 10:02:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.64 2016/12/20 10:02:21 hannken Exp $"); #include #include @@ -502,26 +502,25 @@ vdrain_vrele(vnode_t *vp) KASSERT(mutex_owned(_lock)); - /* - * Safe to take v_interlock -- no other thread will - * lock v_interlock -> vdrain_lock as usecount > 0. - */ - mutex_enter(vp->v_interlock); mp = vp->v_mount; - if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0) { - mutex_exit(vp->v_interlock); + if (fstrans_start_nowait(mp, FSTRANS_LAZY) != 0) return; - } - /* First put the vnode back onto its lru list. */ + /* + * First remove the vnode from the vrele list. + * Put it on the last lru list, the last vrele() + * will put it back onto the right list before + * its v_usecount reaches zero. + */ KASSERT(node->vi_lrulisthd == _vrele_list); TAILQ_REMOVE(node->vi_lrulisthd, node, vi_lrulist); - node->vi_lrulisthd = lru_which(vp); + node->vi_lrulisthd = _hold_list; TAILQ_INSERT_TAIL(node->vi_lrulisthd, node, vi_lrulist); vdrain_retry = true; mutex_exit(_lock); + mutex_enter(vp->v_interlock); vrelel(vp, 0); fstrans_done(mp);
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Wed Dec 14 15:49:35 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change the freelists to lrulists, all vnodes are always on one of the lists. Speeds up namei on cached vnodes by ~3 percent. Merge "vrele_thread" into "vdrain_thread" so we have one thread working on the lrulists. Adapt vfs_drainvnodes() to always wait for a complete cycle of vdrain_thread(). To generate a diff of this commit: cvs rdiff -u -r1.62 -r1.63 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.62 src/sys/kern/vfs_vnode.c:1.63 --- src/sys/kern/vfs_vnode.c:1.62 Wed Dec 14 15:48:55 2016 +++ src/sys/kern/vfs_vnode.c Wed Dec 14 15:49:35 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.62 2016/12/14 15:48:55 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.62 2016/12/14 15:48:55 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.63 2016/12/14 15:49:35 hannken Exp $"); #include #include @@ -188,22 +188,19 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, u_int numvnodes __cacheline_aligned; /* - * There are two free lists: one is for vnodes which have no buffer/page - * references and one for those which do (i.e. v_holdcnt is non-zero). - * Vnode recycling mechanism first attempts to look into the former list. - */ -static kmutex_t vnode_free_list_lock __cacheline_aligned; -static vnodelst_t vnode_free_list __cacheline_aligned; -static vnodelst_t vnode_hold_list __cacheline_aligned; + * There are three lru lists: one holds vnodes waiting for async release, + * one is for vnodes which have no buffer/page references and + * one for those which do (i.e. v_holdcnt is non-zero). + */ +static vnodelst_t lru_vrele_list __cacheline_aligned; +static vnodelst_t lru_free_list __cacheline_aligned; +static vnodelst_t lru_hold_list __cacheline_aligned; +static kmutex_t vdrain_lock __cacheline_aligned; static kcondvar_t vdrain_cv __cacheline_aligned; - -static vnodelst_t vrele_list __cacheline_aligned; -static kmutex_t vrele_lock __cacheline_aligned; -static kcondvar_t vrele_cv __cacheline_aligned; -static lwp_t * vrele_lwp __cacheline_aligned; -static int vrele_pending __cacheline_aligned; -static int vrele_gen __cacheline_aligned; - +static int vdrain_gen; +static kcondvar_t vdrain_gen_cv; +static bool vdrain_retry; +static lwp_t * vdrain_lwp; SLIST_HEAD(hashhead, vnode_impl); static struct { kmutex_t lock; @@ -214,15 +211,15 @@ static struct { pool_cache_t pool; } vcache __cacheline_aligned; -static int cleanvnode(void); -static vnode_impl_t *vcache_alloc(void); +static void lru_requeue(vnode_t *, vnodelst_t *); +static vnodelst_t * lru_which(vnode_t *); +static vnode_impl_t * vcache_alloc(void); static void vcache_free(vnode_impl_t *); static void vcache_init(void); static void vcache_reinit(void); static void vcache_reclaim(vnode_t *); static void vrelel(vnode_t *, int); static void vdrain_thread(void *); -static void vrele_thread(void *); static void vnpanic(vnode_t *, const char *, ...) __printflike(2, 3); @@ -357,22 +354,18 @@ vfs_vnode_sysinit(void) KASSERT(dead_rootmount != NULL); dead_rootmount->mnt_iflag = IMNT_MPSAFE; - mutex_init(_free_list_lock, MUTEX_DEFAULT, IPL_NONE); - TAILQ_INIT(_free_list); - TAILQ_INIT(_hold_list); - TAILQ_INIT(_list); + mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); + TAILQ_INIT(_free_list); + TAILQ_INIT(_hold_list); + TAILQ_INIT(_vrele_list); vcache_init(); - mutex_init(_lock, MUTEX_DEFAULT, IPL_NONE); cv_init(_cv, "vdrain"); - cv_init(_cv, "vrele"); + cv_init(_gen_cv, "vdrainwt"); error = kthread_create(PRI_VM, KTHREAD_MPSAFE, NULL, vdrain_thread, - NULL, NULL, "vdrain"); + NULL, _lwp, "vdrain"); KASSERTMSG((error == 0), "kthread_create(vdrain) failed: %d", error); - error = kthread_create(PRI_VM, KTHREAD_MPSAFE, NULL, vrele_thread, - NULL, _lwp, "vrele"); - KASSERTMSG((error == 0), "kthread_create(vrele) failed: %d", error); } /* @@ -420,53 +413,74 @@ vnis_marker(vnode_t *vp) } /* - * cleanvnode: grab a vnode from freelist, clean and free it. - * - * => Releases vnode_free_list_lock. + * Return the lru list this node should be on. */ -static int -cleanvnode(void) +static vnodelst_t * +lru_which(vnode_t *vp) { - vnode_t *vp; - vnode_impl_t *vi; - vnodelst_t *listhd; - struct mount *mp; - KASSERT(mutex_owned(_free_list_lock)); + KASSERT(mutex_owned(vp->v_interlock)); - listhd = _free_list; -try_nextlist: - TAILQ_FOREACH(vi, listhd, vi_lrulist) { - vp = VIMPL_TO_VNODE(vi); - /* - * It's safe to test v_usecount and v_iflag - * without holding the
CVS commit: src
Module Name:src Committed By: hannken Date: Wed Dec 14 15:48:55 UTC 2016 Modified Files: src/share/man/man9: vnode.9 src/sys/fs/msdosfs: msdosfs_vfsops.c src/sys/gdbscripts: vchain vdump src/sys/kern: vfs_subr.c vfs_vnode.c src/sys/sys: param.h vnode.h vnode_impl.h Log Message: Move vnode members "v_freelisthd" and "v_freelist" from "struct vnode" to "struct vnode_impl" and rename to "vi_lrulisthd" and "vi_lrulist". No functional change intended. Welcome to 7.99.48 To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/share/man/man9/vnode.9 cvs rdiff -u -r1.118 -r1.119 src/sys/fs/msdosfs/msdosfs_vfsops.c cvs rdiff -u -r1.7 -r1.8 src/sys/gdbscripts/vchain cvs rdiff -u -r1.5 -r1.6 src/sys/gdbscripts/vdump cvs rdiff -u -r1.451 -r1.452 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.61 -r1.62 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.514 -r1.515 src/sys/sys/param.h cvs rdiff -u -r1.266 -r1.267 src/sys/sys/vnode.h cvs rdiff -u -r1.3 -r1.4 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man9/vnode.9 diff -u src/share/man/man9/vnode.9:1.72 src/share/man/man9/vnode.9:1.73 --- src/share/man/man9/vnode.9:1.72 Sat Aug 20 12:41:31 2016 +++ src/share/man/man9/vnode.9 Wed Dec 14 15:48:54 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: vnode.9,v 1.72 2016/08/20 12:41:31 wiz Exp $ +.\" $NetBSD: vnode.9,v 1.73 2016/12/14 15:48:54 hannken Exp $ .\" .\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 20, 2016 +.Dd December 14, 2016 .Dt VNODE 9 .Os .Sh NAME @@ -175,8 +175,6 @@ struct vnode { int v_synclist_slot; /* synclist slot index */ struct mount *v_mount; /* ptr to vfs we are in */ int (**v_op)(void *); /* vnode operations vector */ - TAILQ_ENTRY(vnode) v_freelist; /* vnode freelist */ - struct vnodelst *v_freelisthd; /* which freelist? */ TAILQ_ENTRY(vnode) v_mntvnodes; /* vnodes for mount point */ struct buflists v_cleanblkhd; /* clean blocklist head */ struct buflists v_dirtyblkhd; /* dirty blocklist head */ @@ -300,11 +298,8 @@ When both the .Em v_usecount and .Em v_holdcnt -reach zero, the vnode is recycled to the freelist and may be reused -for another file. -The transition to and from the freelist is handled by -a kernel thread -and +reach zero, the vnode is cached. +The transition from the cache is handled by a kernel thread and .Fn vrecycle . Access to .Em v_usecount , @@ -354,14 +349,9 @@ See .Xr vnodeops 9 for a description of vnode operations. .Pp -When not in use, vnodes are kept on the freelist through -.Em v_freelist . -The vnodes still reference valid files but may be reused to refer to a -new file at any time. -When a valid vnode which is on the freelist is used again, the user -must call +When a valid vnode which is cached is used again, the user must call .Fn vget -to increment the reference count and retrieve it from the freelist. +to increment the reference count. When a user wants a new vnode for another file, .Fn vcache_get or @@ -512,7 +502,6 @@ The members .Em v_holdcnt , .Em v_dirtyblkhd , .Em v_cleanblkhd , -.Em v_freelist , and .Em v_synclist are modified in interrupt context and must be protected by @@ -547,14 +536,14 @@ If both .Em v_usecount and .Em v_holdcnt -are zero, the vnode is placed on the freelist. +are zero, the vnode is cached. .It Fn vrele_async "vp" Will asychronously release the vnode in different context than the caller, sometime after the call. .It Fn vget "vp" "lockflags" "wait" Reclaim vnode .Fa vp -from the freelist and increment its reference count. +from the cache and increment its reference count. .Pp The vnode .Fa vp @@ -628,17 +617,15 @@ directly. Mark the vnode .Fa vp as active by incrementing -.Em vp-\*[Gt]v_holdcnt -and moving the vnode from the freelist to the holdlist. -Once on the holdlist, the vnode will not be recycled until it is +.Em vp-\*[Gt]v_holdcnt . +Once held, the vnode will not be recycled until it is released with .Fn holdrele . .It Fn holdrele "vp" Mark the vnode .Fa vp as inactive by decrementing -.Em vp-\*[Gt]v_holdcnt -and moving the vnode from the holdlist to the freelist. +.Em vp-\*[Gt]v_holdcnt . .It Fn vcache_get "mp" "key" "key_len" "vpp" Allocate a new vnode. The new vnode is returned referenced in the address specified by Index: src/sys/fs/msdosfs/msdosfs_vfsops.c diff -u src/sys/fs/msdosfs/msdosfs_vfsops.c:1.118 src/sys/fs/msdosfs/msdosfs_vfsops.c:1.119 --- src/sys/fs/msdosfs/msdosfs_vfsops.c:1.118 Sat Mar 28 19:24:05 2015 +++ src/sys/fs/msdosfs/msdosfs_vfsops.c Wed Dec 14 15:48:54 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: msdosfs_vfsops.c,v 1.118 2015/03/28 19:24:05 maxv Exp $ */ +/* $NetBSD:
CVS commit: src
Module Name:src Committed By: hannken Date: Thu Dec 1 14:49:04 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c src/tests/fs/puffs: t_basic.c Log Message: - Change vcache_reclaim() to always call VOP_INACTIVE() before VOP_RECLAIM(). When called from vrecycle() or vgone() there is a window where the refcount is greater than zero and another thread could get and release a reference that would miss VOP_INACTIVE() as the refcount doesn't drop to zero. Adjust test fs/puffs/t_basic: test VOP_INACTIVE count being greater zero. - Make vrecycle() more robust by checking v_usecount first and preventing further references across vn_lock(). Fixes a deadlock where one thread starts unmount, second thread locks a directory and allocates a vnode and first thread tries to vrecycle() the directory. First thread holds vfs_busy and wants vnode, second thread holds vnode and wants vfs_busy. - With these fixes in place change cleanvnode() to use vget()/vrecycle() to reclaim the vnode. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.12 -r1.13 src/tests/fs/puffs/t_basic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.59 src/sys/kern/vfs_vnode.c:1.60 --- src/sys/kern/vfs_vnode.c:1.59 Thu Nov 3 11:04:21 2016 +++ src/sys/kern/vfs_vnode.c Thu Dec 1 14:49:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.59 2016/11/03 11:04:21 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.60 2016/12/01 14:49:03 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.59 2016/11/03 11:04:21 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.60 2016/12/01 14:49:03 hannken Exp $"); #include #include @@ -444,16 +444,11 @@ try_nextlist: KASSERT(vp->v_usecount == 0); KASSERT(vp->v_freelisthd == listhd); - if (vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT) != 0) + if (!mutex_tryenter(vp->v_interlock)) continue; - if (!mutex_tryenter(vp->v_interlock)) { - VOP_UNLOCK(vp); - continue; - } mp = vp->v_mount; if (fstrans_start_nowait(mp, FSTRANS_SHARED) != 0) { mutex_exit(vp->v_interlock); - VOP_UNLOCK(vp); continue; } break; @@ -468,21 +463,12 @@ try_nextlist: return EBUSY; } - /* Remove it from the freelist. */ - TAILQ_REMOVE(listhd, vp, v_freelist); - vp->v_freelisthd = NULL; mutex_exit(_free_list_lock); - KASSERT(vp->v_usecount == 0); - - /* - * The vnode is still associated with a file system, so we must - * clean it out before freeing it. We need to add a reference - * before doing this. - */ - vp->v_usecount = 1; - vcache_reclaim(vp); - vrelel(vp, 0); + if (vget(vp, 0, true /* wait */) == 0) { + if (!vrecycle(vp)) + vrele(vp); + } fstrans_done(mp); return 0; @@ -949,19 +935,37 @@ holdrelel(vnode_t *vp) bool vrecycle(vnode_t *vp) { - - if (vn_lock(vp, LK_EXCLUSIVE) != 0) - return false; + int error __diagused; mutex_enter(vp->v_interlock); + /* Make sure we hold the last reference. */ + VSTATE_WAIT_STABLE(vp); if (vp->v_usecount != 1) { mutex_exit(vp->v_interlock); - VOP_UNLOCK(vp); return false; } + + /* If the vnode is already clean we're done. */ + if (VSTATE_GET(vp) != VS_ACTIVE) { + VSTATE_ASSERT(vp, VS_RECLAIMED); + vrelel(vp, 0); + return true; + } + + /* Prevent further references until the vnode is locked. */ + VSTATE_CHANGE(vp, VS_ACTIVE, VS_BLOCKED); + mutex_exit(vp->v_interlock); + + error = vn_lock(vp, LK_EXCLUSIVE); + KASSERT(error == 0); + + mutex_enter(vp->v_interlock); + VSTATE_CHANGE(vp, VS_BLOCKED, VS_ACTIVE); + vcache_reclaim(vp); vrelel(vp, 0); + return true; } @@ -1488,8 +1492,7 @@ vcache_reclaim(vnode_t *vp) /* * Clean out any cached data associated with the vnode. * If purging an active vnode, it must be closed and - * deactivated before being reclaimed. Note that the - * VOP_INACTIVE will unlock the vnode. + * deactivated before being reclaimed. */ error = vinvalbuf(vp, V_SAVE, NOCRED, l, 0, 0); if (error != 0) { @@ -1502,17 +1505,12 @@ vcache_reclaim(vnode_t *vp) if (active && (vp->v_type == VBLK || vp->v_type == VCHR)) { spec_node_revoke(vp); } - if (active) { - VOP_INACTIVE(vp, ); - } else { - /* - * Any other processes trying to obtain this lock must first - * wait for VS_RECLAIMED, then call the new lock operation. - */ - VOP_UNLOCK(vp); - } - /* Disassociate the underlying file system from the vnode. */ + /* + * Disassociate the underlying file system from the vnode. + * Note that the VOP_INACTIVE will unlock the vnode. + */ + VOP_INACTIVE(vp, ); if (VOP_RECLAIM(vp)) { vnpanic(vp, "%s: cannot reclaim", __func__); } Index: src/tests/fs/puffs/t_basic.c diff -u src/tests/fs/puffs/t_basic.c:1.12
CVS commit: src/sys/ufs/ffs
Module Name:src Committed By: hannken Date: Fri Nov 11 10:50:16 UTC 2016 Modified Files: src/sys/ufs/ffs: ffs_inode.c Log Message: Fix a "slight tweak" from Rev. 1.121: bap1/bap2 must be valid before using BAP_ASSIGN(). Prevents NULL pointer dereference when "lastbn >= 0". To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/sys/ufs/ffs/ffs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.122 src/sys/ufs/ffs/ffs_inode.c:1.123 --- src/sys/ufs/ffs/ffs_inode.c:1.122 Thu Nov 10 20:56:32 2016 +++ src/sys/ufs/ffs/ffs_inode.c Fri Nov 11 10:50:16 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.122 2016/11/10 20:56:32 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.123 2016/11/11 10:50:16 hannken Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -659,6 +659,10 @@ ffs_indirtrunc(struct inode *ip, daddr_t * This assumes the truncate process would not fail, contrary * to the wapbl case. */ + if (ip->i_ump->um_fstype == UFS1) + bap1 = (int32_t *)bp->b_data; + else + bap2 = (int64_t *)bp->b_data; if (lastbn >= 0 && !wapbl) { copy = kmem_alloc(fs->fs_bsize, KM_SLEEP); memcpy((void *)copy, bp->b_data, (u_int)fs->fs_bsize); @@ -672,11 +676,6 @@ ffs_indirtrunc(struct inode *ip, daddr_t bap1 = (int32_t *)copy; else bap2 = (int64_t *)copy; - } else { - if (ip->i_ump->um_fstype == UFS1) - bap1 = (int32_t *)bp->b_data; - else - bap2 = (int64_t *)bp->b_data; } /*
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Nov 3 11:04:21 UTC 2016 Modified Files: src/sys/kern: vfs_subr.c vfs_vnode.c src/sys/sys: vnode_impl.h Log Message: Add a function to print the fields of a vnode including its implementation and use it from vprint() and vfs_vnode_print(). Move vstate_name() to vfs_subr.c. To generate a diff of this commit: cvs rdiff -u -r1.450 -r1.451 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.58 -r1.59 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.1 -r1.2 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.450 src/sys/kern/vfs_subr.c:1.451 --- src/sys/kern/vfs_subr.c:1.450 Thu Nov 3 11:03:31 2016 +++ src/sys/kern/vfs_subr.c Thu Nov 3 11:04:21 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.451 2016/11/03 11:04:21 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1056,13 +1056,78 @@ vattr_null(struct vattr *vap) vap->va_bytes = VNOVAL; } +/* + * Vnode state to string. + */ +const char * +vstate_name(enum vnode_state state) +{ + + switch (state) { + case VS_MARKER: + return "MARKER"; + case VS_LOADING: + return "LOADING"; + case VS_ACTIVE: + return "ACTIVE"; + case VS_BLOCKED: + return "BLOCKED"; + case VS_RECLAIMING: + return "RECLAIMING"; + case VS_RECLAIMED: + return "RECLAIMED"; + default: + return "ILLEGAL"; + } +} + +/* + * Print a description of a vnode (common part). + */ +static void +vprint_common(struct vnode *vp, const char *prefix, +void (*pr)(const char *, ...) __printflike(1, 2)) +{ + int n; + char bf[96]; + const uint8_t *cp; + vnode_impl_t *node; + const char * const vnode_tags[] = { VNODE_TAGS }; + const char * const vnode_types[] = { VNODE_TYPES }; + const char vnode_flagbits[] = VNODE_FLAGBITS; + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) #define ARRAY_PRINT(idx, arr) \ ((unsigned int)(idx) < ARRAY_SIZE(arr) ? (arr)[(idx)] : "UNKNOWN") -const char * const vnode_tags[] = { VNODE_TAGS }; -const char * const vnode_types[] = { VNODE_TYPES }; -const char vnode_flagbits[] = VNODE_FLAGBITS; + node = VNODE_TO_VIMPL(vp); + + snprintb(bf, sizeof(bf), + vnode_flagbits, vp->v_iflag | vp->v_vflag | vp->v_uflag); + + (*pr)("vnode %p flags %s\n", vp, bf); + (*pr)("%stag %s(%d) type %s(%d) mount %p typedata %p\n", prefix, + ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag, + ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type, + vp->v_mount, vp->v_mountedhere); + (*pr)("%susecount %d writecount %d holdcount %d\n", prefix, + vp->v_usecount, vp->v_writecount, vp->v_holdcnt); + (*pr)("%ssize %" PRIx64 " writesize %" PRIx64 " numoutput %d\n", + prefix, vp->v_size, vp->v_writesize, vp->v_numoutput); + (*pr)("%sfreelisthd %p data %p lock %p\n", prefix, + vp->v_freelisthd, vp->v_data, >v_lock); + + (*pr)("%sstate %s key(%p %zd)", prefix, vstate_name(node->vi_state), + node->vi_key.vk_mount, node->vi_key.vk_key_len); + n = node->vi_key.vk_key_len; + cp = node->vi_key.vk_key; + while (n-- > 0) + (*pr)(" %02x", *cp++); + (*pr)("\n"); + +#undef ARRAY_PRINT +#undef ARRAY_SIZE +} /* * Print out a description of a vnode. @@ -1070,22 +1135,10 @@ const char vnode_flagbits[] = VNODE_FLAG void vprint(const char *label, struct vnode *vp) { - char bf[96]; - int flag; - - flag = vp->v_iflag | vp->v_vflag | vp->v_uflag; - snprintb(bf, sizeof(bf), vnode_flagbits, flag); if (label != NULL) printf("%s: ", label); - printf("vnode @ %p, flags (%s)\n\ttag %s(%d), type %s(%d), " - "usecount %d, writecount %d, holdcount %d\n" - "\tfreelisthd %p, mount %p, data %p lock %p\n", - vp, bf, ARRAY_PRINT(vp->v_tag, vnode_tags), vp->v_tag, - ARRAY_PRINT(vp->v_type, vnode_types), vp->v_type, - vp->v_usecount, vp->v_writecount, vp->v_holdcnt, - vp->v_freelisthd, vp->v_mount, vp->v_data, >v_lock); - vcache_print(vp, "\t", printf); + vprint_common(vp, "\t", printf); if (vp->v_data != NULL) { printf("\t"); VOP_PRINT(vp); @@ -1463,27 +1516,10 @@ vfs_buf_print(struct buf *bp, int full, void vfs_vnode_print(struct vnode *vp, int full, void (*pr)(const char *, ...)) { - char bf[256]; uvm_object_printit(>v_uobj, full, pr); - snprintb(bf, sizeof(bf), - vnode_flagbits, vp->v_iflag | vp->v_vflag | vp->v_uflag); - (*pr)("\nVNODE flags %s\n", bf); - (*pr)("mp %p numoutput %d size 0x%llx writesize 0x%llx\n", - vp->v_mount, vp->v_numoutput, vp->v_size, vp->v_writesize); - - (*pr)("data %p writecount %ld holdcnt %ld\n", -
CVS commit: src/sys
Module Name:src Committed By: hannken Date: Thu Nov 3 11:03:31 UTC 2016 Modified Files: src/sys/kern: vfs_mount.c vfs_subr.c vfs_vnode.c src/sys/sys: vnode.h Added Files: src/sys/sys: vnode_impl.h Log Message: Split sys/vnode.h into sys/vnode.h and sys/vnode_impl.h - Move _VFS_VNODE_PRIVATE protected operations into vnode_impl.h. - Move struct vnode_impl definition and operations into vnode_impl.h. - Include vnode_impl.h where we include vnode.h with _VFS_VNODE_PRIVATE defined. - Get rid of _VFS_VNODE_PRIVATE. To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/kern/vfs_mount.c cvs rdiff -u -r1.449 -r1.450 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.57 -r1.58 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.264 -r1.265 src/sys/sys/vnode.h cvs rdiff -u -r0 -r1.1 src/sys/sys/vnode_impl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_mount.c diff -u src/sys/kern/vfs_mount.c:1.40 src/sys/kern/vfs_mount.c:1.41 --- src/sys/kern/vfs_mount.c:1.40 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/vfs_mount.c Thu Nov 3 11:03:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_mount.c,v 1.40 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: vfs_mount.c,v 1.41 2016/11/03 11:03:31 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -67,9 +67,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.40 2016/07/07 06:55:43 msaitoh Exp $"); - -#define _VFS_VNODE_PRIVATE +__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.41 2016/11/03 11:03:31 hannken Exp $"); #include #include @@ -90,7 +88,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_mount.c, #include #include #include -#include +#include #include #include Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.449 src/sys/kern/vfs_subr.c:1.450 --- src/sys/kern/vfs_subr.c:1.449 Thu May 26 11:07:33 2016 +++ src/sys/kern/vfs_subr.c Thu Nov 3 11:03:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_subr.c,v 1.449 2016/05/26 11:07:33 hannken Exp $ */ +/* $NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $ */ /*- * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.449 2016/05/26 11:07:33 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.450 2016/11/03 11:03:31 hannken Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -76,8 +76,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v #include "opt_compat_43.h" #endif -#define _VFS_VNODE_PRIVATE /* for vcache_print(). */ - #include #include #include @@ -85,7 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v #include #include #include -#include +#include #include #include #include Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.57 src/sys/kern/vfs_vnode.c:1.58 --- src/sys/kern/vfs_vnode.c:1.57 Thu Nov 3 11:02:09 2016 +++ src/sys/kern/vfs_vnode.c Thu Nov 3 11:03:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.58 2016/11/03 11:03:31 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,9 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 hannken Exp $"); - -#define _VFS_VNODE_PRIVATE +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.58 2016/11/03 11:03:31 hannken Exp $"); #include #include @@ -177,7 +175,7 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, #include #include #include -#include +#include #include #include @@ -187,30 +185,6 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, /* Flags to vrelel. */ #define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */ -enum vnode_state { - VS_MARKER, /* Stable, used as marker. Will not change. */ - VS_LOADING, /* Intermediate, initialising the fs node. */ - VS_ACTIVE, /* Stable, valid fs node attached. */ - VS_BLOCKED, /* Intermediate, active, no new references allowed. */ - VS_RECLAIMING, /* Intermediate, detaching the fs node. */ - VS_RECLAIMED /* Stable, no fs node attached. */ -}; -struct vcache_key { - struct mount *vk_mount; - const void *vk_key; - size_t vk_key_len; -}; -struct vnode_impl { - struct vnode vi_vnode; - enum vnode_state vi_state; - SLIST_ENTRY(vnode_impl) vi_hash; - struct vcache_key vi_key; -}; -typedef struct vnode_impl vnode_impl_t; - -#define VIMPL_TO_VNODE(node) ((vnode_t *)(node)) -#define VNODE_TO_VIMPL(vp) ((vnode_impl_t *)(vp)) - u_int numvnodes __cacheline_aligned; /* Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.264 src/sys/sys/vnode.h:1.265 --- src/sys/sys/vnode.h:1.264 Sat Aug 20 12:37:09 2016 +++ src/sys/sys/vnode.h Thu Nov 3 11:03:31 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vnode.h,v 1.264 2016/08/20 12:37:09 hannken Exp $ */ +/* $NetBSD: vnode.h,v 1.265 2016/11/03 11:03:31 hannken Exp $ */ /*- *
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Thu Nov 3 11:02:10 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Prepare the split of sys/vnode.h into sys/vnode.h and sys/vnode_impl.h - Rename struct vcache_node to vnode_impl, start its fields with vi_. - Rename enum vcache_state to vnode_state, start its elements with VS_. - Rename macros VN_TO_VP and VP_TO_VN to VIMPL_TO_VNODE and VNODE_TO_VIMPL. - Add typedef struct vnode_impl vnode_impl_t. To generate a diff of this commit: cvs rdiff -u -r1.56 -r1.57 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.56 src/sys/kern/vfs_vnode.c:1.57 --- src/sys/kern/vfs_vnode.c:1.56 Sat Aug 20 12:37:08 2016 +++ src/sys/kern/vfs_vnode.c Thu Nov 3 11:02:09 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.56 2016/08/20 12:37:08 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.56 2016/08/20 12:37:08 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.57 2016/11/03 11:02:09 hannken Exp $"); #define _VFS_VNODE_PRIVATE @@ -187,28 +187,29 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c, /* Flags to vrelel. */ #define VRELEL_ASYNC_RELE 0x0001 /* Always defer to vrele thread. */ -enum vcache_state { - VN_MARKER, /* Stable, used as marker. Will not change. */ - VN_LOADING, /* Intermediate, initialising the fs node. */ - VN_ACTIVE, /* Stable, valid fs node attached. */ - VN_BLOCKED, /* Intermediate, active, no new references allowed. */ - VN_RECLAIMING, /* Intermediate, detaching the fs node. */ - VN_RECLAIMED /* Stable, no fs node attached. */ +enum vnode_state { + VS_MARKER, /* Stable, used as marker. Will not change. */ + VS_LOADING, /* Intermediate, initialising the fs node. */ + VS_ACTIVE, /* Stable, valid fs node attached. */ + VS_BLOCKED, /* Intermediate, active, no new references allowed. */ + VS_RECLAIMING, /* Intermediate, detaching the fs node. */ + VS_RECLAIMED /* Stable, no fs node attached. */ }; struct vcache_key { struct mount *vk_mount; const void *vk_key; size_t vk_key_len; }; -struct vcache_node { - struct vnode vn_vnode; - enum vcache_state vn_state; - SLIST_ENTRY(vcache_node) vn_hash; - struct vcache_key vn_key; +struct vnode_impl { + struct vnode vi_vnode; + enum vnode_state vi_state; + SLIST_ENTRY(vnode_impl) vi_hash; + struct vcache_key vi_key; }; +typedef struct vnode_impl vnode_impl_t; -#define VN_TO_VP(node) ((vnode_t *)(node)) -#define VP_TO_VN(vp) ((struct vcache_node *)(vp)) +#define VIMPL_TO_VNODE(node) ((vnode_t *)(node)) +#define VNODE_TO_VIMPL(vp) ((vnode_impl_t *)(vp)) u_int numvnodes __cacheline_aligned; @@ -229,7 +230,7 @@ static lwp_t * vrele_lwp __cacheline_a static int vrele_pending __cacheline_aligned; static int vrele_gen __cacheline_aligned; -SLIST_HEAD(hashhead, vcache_node); +SLIST_HEAD(hashhead, vnode_impl); static struct { kmutex_t lock; kcondvar_t cv; @@ -239,8 +240,8 @@ static struct { } vcache __cacheline_aligned; static int cleanvnode(void); -static struct vcache_node *vcache_alloc(void); -static void vcache_free(struct vcache_node *); +static vnode_impl_t *vcache_alloc(void); +static void vcache_free(vnode_impl_t *); static void vcache_init(void); static void vcache_reinit(void); static void vcache_reclaim(vnode_t *); @@ -258,21 +259,21 @@ extern struct vfsops dead_vfsops; /* Vnode state operations and diagnostics. */ static const char * -vstate_name(enum vcache_state state) +vstate_name(enum vnode_state state) { switch (state) { - case VN_MARKER: + case VS_MARKER: return "MARKER"; - case VN_LOADING: + case VS_LOADING: return "LOADING"; - case VN_ACTIVE: + case VS_ACTIVE: return "ACTIVE"; - case VN_BLOCKED: + case VS_BLOCKED: return "BLOCKED"; - case VN_RECLAIMING: + case VS_RECLAIMING: return "RECLAIMING"; - case VN_RECLAIMED: + case VS_RECLAIMED: return "RECLAIMED"; default: return "ILLEGAL"; @@ -291,80 +292,80 @@ vstate_name(enum vcache_state state) vstate_assert((vp), (state), __func__, __LINE__) static void -vstate_assert(vnode_t *vp, enum vcache_state state, const char *func, int line) +vstate_assert(vnode_t *vp, enum vnode_state state, const char *func, int line) { - struct vcache_node *node = VP_TO_VN(vp); + vnode_impl_t *node = VNODE_TO_VIMPL(vp); KASSERTMSG(mutex_owned(vp->v_interlock), "at %s:%d", func, line); - if (__predict_true(node->vn_state == state)) + if (__predict_true(node->vi_state == state)) return; vnpanic(vp, "state is %s, expected %s at %s:%d", - vstate_name(node->vn_state), vstate_name(state), func, line); + vstate_name(node->vi_state), vstate_name(state), func, line); } -static enum
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sun Aug 21 15:24:18 UTC 2016 Modified Files: src/sys/kern: kern_sig.c Log Message: siggetinfo: use TAILQ_FOREACH_SAFE as the element gets removed from the list. To generate a diff of this commit: cvs rdiff -u -r1.328 -r1.329 src/sys/kern/kern_sig.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/kern_sig.c diff -u src/sys/kern/kern_sig.c:1.328 src/sys/kern/kern_sig.c:1.329 --- src/sys/kern/kern_sig.c:1.328 Thu Aug 4 06:43:43 2016 +++ src/sys/kern/kern_sig.c Sun Aug 21 15:24:17 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_sig.c,v 1.328 2016/08/04 06:43:43 christos Exp $ */ +/* $NetBSD: kern_sig.c,v 1.329 2016/08/21 15:24:17 hannken Exp $ */ /*- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc. @@ -70,7 +70,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.328 2016/08/04 06:43:43 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.329 2016/08/21 15:24:17 hannken Exp $"); #include "opt_ptrace.h" #include "opt_dtrace.h" @@ -527,14 +527,14 @@ ksiginfo_queue_drain0(ksiginfoq_t *kq) static int siggetinfo(sigpend_t *sp, ksiginfo_t *out, int signo) { - ksiginfo_t *ksi; + ksiginfo_t *ksi, *nksi; if (sp == NULL) goto out; /* Find siginfo and copy it out. */ int count = 0; - TAILQ_FOREACH(ksi, >sp_info, ksi_list) { + TAILQ_FOREACH_SAFE(ksi, >sp_info, ksi_list, nksi) { if (ksi->ksi_signo != signo) continue; if (count++ > 0) /* Only remove the first, count all of them */
CVS commit: src
Module Name:src Committed By: hannken Date: Sat Aug 20 12:37:10 UTC 2016 Modified Files: src/distrib/sets/lists/comp: mi src/external/cddl/osnet/dist/uts/common/fs/zfs: zfs_znode.c src/share/man/man9: Makefile vnode.9 src/sys/coda: coda_vnops.c src/sys/fs/adosfs: advnops.c src/sys/fs/cd9660: cd9660_node.c src/sys/fs/efs: efs_vnops.c src/sys/fs/filecorefs: filecore_node.c src/sys/fs/hfs: hfs_vnops.c src/sys/fs/msdosfs: msdosfs_denode.c src/sys/fs/nilfs: nilfs_vnops.c src/sys/fs/ntfs: ntfs_vnops.c src/sys/fs/ptyfs: ptyfs_vnops.c src/sys/fs/puffs: puffs_node.c src/sys/fs/smbfs: smbfs_node.c src/sys/fs/sysvbfs: sysvbfs_vnops.c src/sys/fs/tmpfs: tmpfs_vnops.c src/sys/fs/udf: udf_vnops.c src/sys/fs/union: union_subr.c src/sys/fs/v7fs: v7fs_vnops.c src/sys/kern: vfs_vnode.c src/sys/miscfs/fdesc: fdesc_vnops.c src/sys/miscfs/genfs: layer_vnops.c src/sys/miscfs/kernfs: kernfs_vnops.c src/sys/miscfs/procfs: procfs_vnops.c src/sys/miscfs/specfs: spec_vnops.c src/sys/nfs: nfs_node.c src/sys/rump/librump/rumpvfs: rumpfs.c src/sys/sys: param.h vnode.h src/sys/ufs/chfs: chfs_vnops.c src/sys/ufs/lfs: ulfs_inode.c src/sys/ufs/ufs: ufs_inode.c Log Message: Remove now obsolete operation vcache_remove(). Welcome to 7.99.36 To generate a diff of this commit: cvs rdiff -u -r1.2057 -r1.2058 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.18 -r1.19 \ src/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_znode.c cvs rdiff -u -r1.396 -r1.397 src/share/man/man9/Makefile cvs rdiff -u -r1.70 -r1.71 src/share/man/man9/vnode.9 cvs rdiff -u -r1.102 -r1.103 src/sys/coda/coda_vnops.c cvs rdiff -u -r1.47 -r1.48 src/sys/fs/adosfs/advnops.c cvs rdiff -u -r1.34 -r1.35 src/sys/fs/cd9660/cd9660_node.c cvs rdiff -u -r1.35 -r1.36 src/sys/fs/efs/efs_vnops.c cvs rdiff -u -r1.27 -r1.28 src/sys/fs/filecorefs/filecore_node.c cvs rdiff -u -r1.32 -r1.33 src/sys/fs/hfs/hfs_vnops.c cvs rdiff -u -r1.51 -r1.52 src/sys/fs/msdosfs/msdosfs_denode.c cvs rdiff -u -r1.32 -r1.33 src/sys/fs/nilfs/nilfs_vnops.c cvs rdiff -u -r1.59 -r1.60 src/sys/fs/ntfs/ntfs_vnops.c cvs rdiff -u -r1.51 -r1.52 src/sys/fs/ptyfs/ptyfs_vnops.c cvs rdiff -u -r1.36 -r1.37 src/sys/fs/puffs/puffs_node.c cvs rdiff -u -r1.53 -r1.54 src/sys/fs/smbfs/smbfs_node.c cvs rdiff -u -r1.59 -r1.60 src/sys/fs/sysvbfs/sysvbfs_vnops.c cvs rdiff -u -r1.127 -r1.128 src/sys/fs/tmpfs/tmpfs_vnops.c cvs rdiff -u -r1.101 -r1.102 src/sys/fs/udf/udf_vnops.c cvs rdiff -u -r1.73 -r1.74 src/sys/fs/union/union_subr.c cvs rdiff -u -r1.21 -r1.22 src/sys/fs/v7fs/v7fs_vnops.c cvs rdiff -u -r1.55 -r1.56 src/sys/kern/vfs_vnode.c cvs rdiff -u -r1.126 -r1.127 src/sys/miscfs/fdesc/fdesc_vnops.c cvs rdiff -u -r1.58 -r1.59 src/sys/miscfs/genfs/layer_vnops.c cvs rdiff -u -r1.155 -r1.156 src/sys/miscfs/kernfs/kernfs_vnops.c cvs rdiff -u -r1.193 -r1.194 src/sys/miscfs/procfs/procfs_vnops.c cvs rdiff -u -r1.162 -r1.163 src/sys/miscfs/specfs/spec_vnops.c cvs rdiff -u -r1.118 -r1.119 src/sys/nfs/nfs_node.c cvs rdiff -u -r1.141 -r1.142 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.501 -r1.502 src/sys/sys/param.h cvs rdiff -u -r1.263 -r1.264 src/sys/sys/vnode.h cvs rdiff -u -r1.28 -r1.29 src/sys/ufs/chfs/chfs_vnops.c cvs rdiff -u -r1.15 -r1.16 src/sys/ufs/lfs/ulfs_inode.c cvs rdiff -u -r1.95 -r1.96 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.2057 src/distrib/sets/lists/comp/mi:1.2058 --- src/distrib/sets/lists/comp/mi:1.2057 Sat Aug 20 11:34:49 2016 +++ src/distrib/sets/lists/comp/mi Sat Aug 20 12:37:06 2016 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.2057 2016/08/20 11:34:49 christos Exp $ +# $NetBSD: mi,v 1.2058 2016/08/20 12:37:06 hannken Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. ./etc/mtree/set.compcomp-sys-root @@ -1,7 +1,7 @@ ./usr/share/man/cat9/vcache_new.0 comp-sys-catman .cat ./usr/share/man/cat9/vcache_rekey_enter.0 comp-sys-catman .cat ./usr/share/man/cat9/vcache_rekey_exit.0 comp-sys-catman .cat -./usr/share/man/cat9/vcache_remove.0 comp-sys-catman .cat +./usr/share/man/cat9/vcache_remove.0 comp-sys-catman obsolete ./usr/share/man/cat9/vcons.0 comp-sys-catman .cat ./usr/share/man/cat9/vcount.0 comp-obsolete obsolete ./usr/share/man/cat9/vdead_check.0 comp-sys-catman .cat @@ -18226,7 +18226,7 @@ ./usr/share/man/html9/vcache_new.html comp-sys-htmlman html ./usr/share/man/html9/vcache_rekey_enter.html comp-sys-htmlman html ./usr/share/man/html9/vcache_rekey_exit.html comp-sys-htmlman html -./usr/share/man/html9/vcache_remove.html comp-sys-htmlman html
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Aug 20 12:33:57 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Change vcache_reclaim() to remove vnode from vnode cache once the vnode was reclaimed from the file system. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.54 src/sys/kern/vfs_vnode.c:1.55 --- src/sys/kern/vfs_vnode.c:1.54 Sat Aug 20 12:31:37 2016 +++ src/sys/kern/vfs_vnode.c Sat Aug 20 12:33:57 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.54 2016/08/20 12:31:37 hannken Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.55 2016/08/20 12:33:57 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -156,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.54 2016/08/20 12:31:37 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.55 2016/08/20 12:33:57 hannken Exp $"); #define _VFS_VNODE_PRIVATE @@ -1495,6 +1495,10 @@ static void vcache_reclaim(vnode_t *vp) { lwp_t *l = curlwp; + struct vcache_node *node = VP_TO_VN(vp); + uint32_t hash; + uint8_t temp_buf[64], *temp_key; + size_t temp_key_len; bool recycle, active; int error; @@ -1504,6 +1508,7 @@ vcache_reclaim(vnode_t *vp) KASSERT(vp->v_usecount != 0); active = (vp->v_usecount > 1); + temp_key_len = node->vn_key.vk_key_len; /* * Prevent the vnode from being recycled or brought into use * while we clean it out. @@ -1516,6 +1521,17 @@ vcache_reclaim(vnode_t *vp) vp->v_iflag &= ~(VI_TEXT|VI_EXECMAP); mutex_exit(vp->v_interlock); + /* Replace the vnode key with a temporary copy. */ + if (node->vn_key.vk_key_len > sizeof(temp_buf)) { + temp_key = kmem_alloc(temp_key_len, KM_SLEEP); + } else { + temp_key = temp_buf; + } + mutex_enter(); + memcpy(temp_key, node->vn_key.vk_key, temp_key_len); + node->vn_key.vk_key = temp_key; + mutex_exit(); + /* * Clean out any cached data associated with the vnode. * If purging an active vnode, it must be closed and @@ -1564,6 +1580,16 @@ vcache_reclaim(vnode_t *vp) atomic_inc_uint(_rootmount->mnt_refcnt); vfs_insmntque(vp, dead_rootmount); + /* Remove from vnode cache. */ + hash = vcache_hash(>vn_key); + mutex_enter(); + KASSERT(node == vcache_hash_lookup(>vn_key, hash)); + SLIST_REMOVE([hash & vcache.hashmask], + node, vcache_node, vn_hash); + mutex_exit(); + if (temp_key != temp_buf) + kmem_free(temp_key, temp_key_len); + /* Done with purge, notify sleepers of the grim news. */ mutex_enter(vp->v_interlock); vp->v_op = dead_vnodeop_p; @@ -1581,6 +1607,7 @@ vcache_reclaim(vnode_t *vp) void vcache_remove(struct mount *mp, const void *key, size_t key_len) { +#ifdef DIAGNOSTIC uint32_t hash; struct vcache_key vcache_key; struct vcache_node *node; @@ -1593,9 +1620,8 @@ vcache_remove(struct mount *mp, const vo mutex_enter(); node = vcache_hash_lookup(_key, hash); KASSERT(node != NULL); - SLIST_REMOVE([hash & vcache.hashmask], - node, vcache_node, vn_hash); mutex_exit(); +#endif } /*
CVS commit: src/sys/kern
Module Name:src Committed By: hannken Date: Sat Aug 20 12:31:37 UTC 2016 Modified Files: src/sys/kern: vfs_vnode.c Log Message: Rename vclean() to vcache_reclaim(). No functional change. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/sys/kern/vfs_vnode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/kern/vfs_vnode.c diff -u src/sys/kern/vfs_vnode.c:1.53 src/sys/kern/vfs_vnode.c:1.54 --- src/sys/kern/vfs_vnode.c:1.53 Thu Jul 7 06:55:43 2016 +++ src/sys/kern/vfs_vnode.c Sat Aug 20 12:31:37 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: vfs_vnode.c,v 1.53 2016/07/07 06:55:43 msaitoh Exp $ */ +/* $NetBSD: vfs_vnode.c,v 1.54 2016/08/20 12:31:37 hannken Exp $ */ /*- * Copyright (c) 1997-2011 The NetBSD Foundation, Inc. @@ -89,8 +89,9 @@ * references, e.g. count of links, whether the file was removed). * * Depending on indication, vnode can be put into a free list (cache), - * or cleaned via vclean(9), which calls VOP_RECLAIM(9) to disassociate - * underlying file system from the vnode, and finally destroyed. + * or cleaned via vcache_reclaim, which calls VOP_RECLAIM(9) to + * disassociate underlying file system from the vnode, and finally + * destroyed. * * Vnode state * @@ -113,10 +114,10 @@ * vcache_new() and is ready to use. * ACTIVE -> RECLAIMING * Vnode starts disassociation from underlying file - * system in vclean(). + * system in vcache_reclaim(). * RECLAIMING -> RECLAIMED * Vnode finished disassociation from underlying file - * system in vclean(). + * system in vcache_reclaim(). * ACTIVE -> BLOCKED * Either vcache_rekey*() is changing the vnode key or * vrelel() is about to call VOP_INACTIVE(). @@ -155,7 +156,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.53 2016/07/07 06:55:43 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.54 2016/08/20 12:31:37 hannken Exp $"); #define _VFS_VNODE_PRIVATE @@ -242,7 +243,7 @@ static struct vcache_node *vcache_alloc( static void vcache_free(struct vcache_node *); static void vcache_init(void); static void vcache_reinit(void); -static void vclean(vnode_t *); +static void vcache_reclaim(vnode_t *); static void vrelel(vnode_t *, int); static void vdrain_thread(void *); static void vrele_thread(void *); @@ -527,7 +528,7 @@ try_nextlist: * before doing this. */ vp->v_usecount = 1; - vclean(vp); + vcache_reclaim(vp); vrelel(vp, 0); fstrans_done(mp); @@ -588,7 +589,7 @@ vremfree(vnode_t *vp) * * => Must be called with v_interlock held. * - * If state is VN_RECLAIMING, the vnode may be eliminated in vgone()/vclean(). + * If state is VN_RECLAIMING, the vnode may be eliminated in vcache_reclaim(). * In that case, we cannot grab the vnode, so the process is awakened when * the transition is completed, and an error returned to indicate that the * vnode is no longer usable. @@ -783,7 +784,7 @@ vrelel(vnode_t *vp, int flags) */ VOP_INACTIVE(vp, ); if (recycle) { - /* vclean() below will drop the lock. */ + /* vcache_reclaim() below will drop the lock. */ if (vn_lock(vp, LK_EXCLUSIVE) != 0) recycle = false; } @@ -812,7 +813,7 @@ vrelel(vnode_t *vp, int flags) */ if (recycle) { VSTATE_ASSERT(vp, VN_ACTIVE); - vclean(vp); + vcache_reclaim(vp); } KASSERT(vp->v_usecount > 0); } @@ -990,96 +991,6 @@ holdrelel(vnode_t *vp) } /* - * Disassociate the underlying file system from a vnode. - * - * Must be called with vnode locked and will return unlocked. - * Must be called with the interlock held, and will return with it held. - */ -static void -vclean(vnode_t *vp) -{ - lwp_t *l = curlwp; - bool recycle, active; - int error; - - KASSERT((vp->v_vflag & VV_LOCKSWORK) == 0 || - VOP_ISLOCKED(vp) == LK_EXCLUSIVE); - KASSERT(mutex_owned(vp->v_interlock)); - KASSERT(vp->v_usecount != 0); - - active = (vp->v_usecount > 1); - /* - * Prevent the vnode from being recycled or brought into use - * while we clean it out. - */ - VSTATE_CHANGE(vp, VN_ACTIVE, VN_RECLAIMING); - if (vp->v_iflag & VI_EXECMAP) { - atomic_add_int(, -vp->v_uobj.uo_npages); - atomic_add_int(, vp->v_uobj.uo_npages); - } - vp->v_iflag &= ~(VI_TEXT|VI_EXECMAP); - mutex_exit(vp->v_interlock); - - /* - * Clean out any cached data associated with the vnode. - * If purging an active vnode, it must be closed and - * deactivated before being reclaimed. Note that the - * VOP_INACTIVE will unlock the vnode. - */ - error = vinvalbuf(vp, V_SAVE, NOCRED, l, 0, 0); - if (error != 0) { - if (wapbl_vphaswapbl(vp)) - WAPBL_DISCARD(wapbl_vptomp(vp)); - error = vinvalbuf(vp, 0, NOCRED, l, 0, 0); - } - KASSERTMSG((error == 0), "vinvalbuf failed: %d", error); - KASSERT((vp->v_iflag & VI_ONWORKLST) == 0); - if (active && (vp->v_type == VBLK || vp->v_type == VCHR)) { - spec_node_revoke(vp); - } - if (active) { -
CVS commit: src/sys/dev
Module Name:src Committed By: hannken Date: Sun Jul 31 12:17:36 UTC 2016 Modified Files: src/sys/dev: fss.c Log Message: Disestablish COW handler on error. No need to do further copies after the snapshot device failed. Should fix PR kern/51377: fss(4) panic if snapshot mounted read/write To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/sys/dev/fss.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/fss.c diff -u src/sys/dev/fss.c:1.94 src/sys/dev/fss.c:1.95 --- src/sys/dev/fss.c:1.94 Sat Jul 30 22:36:14 2016 +++ src/sys/dev/fss.c Sun Jul 31 12:17:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: fss.c,v 1.94 2016/07/30 22:36:14 pgoyette Exp $ */ +/* $NetBSD: fss.c,v 1.95 2016/07/31 12:17:36 hannken Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.94 2016/07/30 22:36:14 pgoyette Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.95 2016/07/31 12:17:36 hannken Exp $"); #include #include @@ -445,17 +445,20 @@ fss_dump(dev_t dev, daddr_t blkno, void /* * An error occurred reading or writing the snapshot or backing store. - * If it is the first error log to console. + * If it is the first error log to console and disestablish cow handler. * The caller holds the mutex. */ static inline void fss_error(struct fss_softc *sc, const char *msg) { - if ((sc->sc_flags & (FSS_ACTIVE|FSS_ERROR)) == FSS_ACTIVE) - aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); - if ((sc->sc_flags & FSS_ACTIVE) == FSS_ACTIVE) - sc->sc_flags |= FSS_ERROR; + if ((sc->sc_flags & (FSS_ACTIVE | FSS_ERROR)) != FSS_ACTIVE) + return; + + aprint_error_dev(sc->sc_dev, "snapshot invalid: %s\n", msg); + if ((sc->sc_flags & FSS_PERSISTENT) == 0) + fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); + sc->sc_flags |= FSS_ERROR; } /* @@ -575,9 +578,8 @@ fss_unmount_hook(struct mount *mp) if ((sc = device_lookup_private(_cd, i)) == NULL) continue; mutex_enter(>sc_slock); - if ((sc->sc_flags & FSS_ACTIVE) != 0 && - sc->sc_mount == mp) - fss_error(sc, "forced unmount"); + if ((sc->sc_flags & FSS_ACTIVE) != 0 && sc->sc_mount == mp) + fss_error(sc, "forced by unmount"); mutex_exit(>sc_slock); } mutex_exit(_device_lock); @@ -886,7 +888,7 @@ static int fss_delete_snapshot(struct fss_softc *sc, struct lwp *l) { - if ((sc->sc_flags & FSS_PERSISTENT) == 0) + if ((sc->sc_flags & (FSS_PERSISTENT | FSS_ERROR)) == 0) fscow_disestablish(sc->sc_mount, fss_copy_on_write, sc); mutex_enter(>sc_slock);
CVS commit: src/sys/net
Module Name:src Committed By: hannken Date: Wed Jul 13 09:56:20 UTC 2016 Modified Files: src/sys/net: route.c Log Message: rtcache_clear_rtentry: use LIST_FOREACH_SAFE as the element gets removed from the list. To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/sys/net/route.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/net/route.c diff -u src/sys/net/route.c:1.170 src/sys/net/route.c:1.171 --- src/sys/net/route.c:1.170 Mon Jul 11 07:37:00 2016 +++ src/sys/net/route.c Wed Jul 13 09:56:20 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: route.c,v 1.170 2016/07/11 07:37:00 ozaki-r Exp $ */ +/* $NetBSD: route.c,v 1.171 2016/07/13 09:56:20 hannken Exp $ */ /*- * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. @@ -96,7 +96,7 @@ #endif #include -__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.170 2016/07/11 07:37:00 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: route.c,v 1.171 2016/07/13 09:56:20 hannken Exp $"); #include #ifdef RTFLUSH_DEBUG @@ -1410,12 +1410,12 @@ static void rtcache_clear_rtentry(int family, struct rtentry *rt) { struct domain *dom; - struct route *ro; + struct route *ro, *nro; if ((dom = pffinddomain(family)) == NULL) return; - LIST_FOREACH(ro, >dom_rtcache, ro_rtcache_next) { + LIST_FOREACH_SAFE(ro, >dom_rtcache, ro_rtcache_next, nro) { if (ro->_ro_rt == rt) rtcache_clear(ro); }
CVS commit: src/sys/dev/acpi
Module Name:src Committed By: hannken Date: Tue Jul 12 09:45:34 UTC 2016 Modified Files: src/sys/dev/acpi: acpi_mcfg.c Log Message: According to "PCI Express Base Specification Revision 3.0" from November 10, 2010, section 7.9.1 an Extended Capability header with value 0:0:0 represents the absence of Extended Capabilities. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/dev/acpi/acpi_mcfg.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/dev/acpi/acpi_mcfg.c diff -u src/sys/dev/acpi/acpi_mcfg.c:1.3 src/sys/dev/acpi/acpi_mcfg.c:1.4 --- src/sys/dev/acpi/acpi_mcfg.c:1.3 Tue Jul 12 09:29:32 2016 +++ src/sys/dev/acpi/acpi_mcfg.c Tue Jul 12 09:45:34 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_mcfg.c,v 1.3 2016/07/12 09:29:32 hannken Exp $ */ +/* $NetBSD: acpi_mcfg.c,v 1.4 2016/07/12 09:45:34 hannken Exp $ */ /*- * Copyright (C) 2015 NONAKA Kimihiro@@ -26,7 +26,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.3 2016/07/12 09:29:32 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_mcfg.c,v 1.4 2016/07/12 09:45:34 hannken Exp $"); #include #include @@ -490,7 +490,7 @@ acpimcfg_device_probe(const struct pci_a /* Probe extended configuration space. */ if (((reg = pci_conf_read(pc, tag, PCI_CONF_SIZE)) == (pcireg_t)-1) || - (alias = acpimcfg_ext_conf_is_aliased(pc, tag))) { + (reg == 0) || (alias = acpimcfg_ext_conf_is_aliased(pc, tag))) { aprint_debug_dev(acpi_sc->sc_dev, "MCFG: %03d:%02d:%d: invalid config space " "(cfg[0x%03x]=0x%08x, alias=%s)\n", bus, dev, func,