diff options
Diffstat (limited to 'sys/fs')
43 files changed, 609 insertions, 537 deletions
diff --git a/sys/fs/cd9660/cd9660_lookup.c b/sys/fs/cd9660/cd9660_lookup.c index 75fcdc9152cd..4d0bf73ab235 100644 --- a/sys/fs/cd9660/cd9660_lookup.c +++ b/sys/fs/cd9660/cd9660_lookup.c @@ -386,7 +386,7 @@ found: return (error); *vpp = tdp; } else if (dp->i_number == i_ino) { - VREF(vdp); /* we want ourself, ie "." */ + vref(vdp); /* we want ourself, ie "." */ /* * When we lookup "." we still can be asked to lock it * differently. diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index b4db4c4f7331..ce6d03b73290 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -617,13 +617,13 @@ cd9660_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) #endif if ((error = VFS_VGET(mp, ifh.ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) { - *vpp = NULLVP; + *vpp = NULL; return (error); } ip = VTOI(nvp); if (ip->inode.iso_mode == 0) { vput(nvp); - *vpp = NULLVP; + *vpp = NULL; return (ESTALE); } *vpp = nvp; @@ -704,7 +704,7 @@ cd9660_vget_internal(struct mount *mp, ino_t ino, int flags, /* Allocate a new vnode/iso_node. */ if ((error = getnewvnode("isofs", mp, &cd9660_vnodeops, &vp)) != 0) { - *vpp = NULLVP; + *vpp = NULL; return (error); } ip = malloc(sizeof(struct iso_node), M_ISOFSNODE, @@ -717,7 +717,7 @@ cd9660_vget_internal(struct mount *mp, ino_t ino, int flags, error = insmntque(vp, mp); if (error != 0) { free(ip, M_ISOFSNODE); - *vpp = NULLVP; + *vpp = NULL; return (error); } error = vfs_hash_insert(vp, ino, flags, td, vpp, cd9660_vfs_hash_cmp, diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index c4d0e6ba7b30..4a2b80a7ccdd 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -124,7 +124,7 @@ cd9660_access(struct vop_access_args *ap) uid_t uid; gid_t gid; - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); /* @@ -162,7 +162,7 @@ cd9660_open(struct vop_open_args *ap) struct vnode *vp = ap->a_vp; struct iso_node *ip = VTOI(vp); - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); vnode_create_vobject(vp, ip->i_size, ap->a_td); @@ -191,7 +191,7 @@ cd9660_getattr(struct vop_getattr_args *ap) vap->va_atime = ip->inode.iso_atime; vap->va_mtime = ip->inode.iso_mtime; vap->va_ctime = ip->inode.iso_ctime; - vap->va_rdev = ip->inode.iso_rdev; + vap->va_rdev = VN_ISDEV(vp) ? ip->inode.iso_rdev : NODEV; vap->va_size = (u_quad_t) ip->i_size; if (ip->i_size == 0 && (vap->va_mode & S_IFMT) == S_IFLNK) { @@ -242,7 +242,7 @@ cd9660_ioctl(struct vop_ioctl_args *ap) VOP_UNLOCK(vp); return (EBADF); } - if (vp->v_type == VCHR || vp->v_type == VBLK) { + if (VN_ISDEV(vp)) { VOP_UNLOCK(vp); return (EOPNOTSUPP); } @@ -280,7 +280,7 @@ cd9660_read(struct vop_read_args *ap) int seqcount; long size, n, on; - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); seqcount = ap->a_ioflag >> IO_SEQSHIFT; @@ -711,7 +711,7 @@ cd9660_strategy(struct vop_strategy_args *ap) struct bufobj *bo; ip = VTOI(vp); - if (vp->v_type == VBLK || vp->v_type == VCHR) + if (VN_ISDEV(vp)) panic("cd9660_strategy: spec"); if (bp->b_blkno == bp->b_lblkno) { bp->b_blkno = (ip->iso_start + bp->b_lblkno) << @@ -818,7 +818,7 @@ cd9660_getpages(struct vop_getpages_args *ap) struct vnode *vp; vp = ap->a_vp; - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); if (use_buf_pager) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 3a64c205186f..caadf257b8ad 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -1061,7 +1061,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock) mp = dvp->v_mount; dmp = VFSTODEVFS(mp); dd = dvp->v_data; - *vpp = NULLVP; + *vpp = NULL; if ((flags & ISLASTCN) && nameiop == RENAME) return (EOPNOTSUPP); @@ -1080,7 +1080,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock) if ((flags & ISLASTCN) && nameiop != LOOKUP) return (EINVAL); *vpp = dvp; - VREF(dvp); + vref(dvp); return (0); } @@ -1170,7 +1170,7 @@ devfs_lookupx(struct vop_lookup_args *ap, int *dm_unlock) if (error) return (error); if (*vpp == dvp) { - VREF(dvp); + vref(dvp); *vpp = dvp; return (0); } diff --git a/sys/fs/ext2fs/ext2_lookup.c b/sys/fs/ext2fs/ext2_lookup.c index c80e0f99ab56..bb830d07b126 100644 --- a/sys/fs/ext2fs/ext2_lookup.c +++ b/sys/fs/ext2fs/ext2_lookup.c @@ -579,7 +579,7 @@ found: if (dd_ino != NULL) return (0); if (dp->i_number == ino) { - VREF(vdp); + vref(vdp); *vpp = vdp; return (0); } @@ -675,7 +675,7 @@ found: } *vpp = tdp; } else if (dp->i_number == ino) { - VREF(vdp); /* we want ourself, ie "." */ + vref(vdp); /* we want ourself, ie "." */ /* * When we lookup "." we still can be asked to lock it * differently. diff --git a/sys/fs/ext2fs/ext2_vfsops.c b/sys/fs/ext2fs/ext2_vfsops.c index 9e7a03fffd71..0f3808a7c747 100644 --- a/sys/fs/ext2fs/ext2_vfsops.c +++ b/sys/fs/ext2fs/ext2_vfsops.c @@ -1334,14 +1334,14 @@ ext2_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp); if (error) { - *vpp = NULLVP; + *vpp = NULL; return (error); } ip = VTOI(nvp); if (ip->i_mode == 0 || ip->i_gen != ufhp->ufid_gen || ip->i_nlink <= 0) { vput(nvp); - *vpp = NULLVP; + *vpp = NULL; return (ESTALE); } *vpp = nvp; diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index 064c10bd18b2..35e7ca77c732 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -222,7 +222,7 @@ ext2_itimes_locked(struct vnode *vp) ip = VTOI(vp); if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_UPDATE)) == 0) return; - if ((vp->v_type == VBLK || vp->v_type == VCHR)) + if (VN_ISDEV(vp)) ip->i_flag |= IN_LAZYMOD; else ip->i_flag |= IN_MODIFIED; @@ -276,7 +276,7 @@ static int ext2_open(struct vop_open_args *ap) { - if (ap->a_vp->v_type == VBLK || ap->a_vp->v_type == VCHR) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); /* @@ -360,7 +360,7 @@ ext2_getattr(struct vop_getattr_args *ap) vap->va_nlink = ip->i_nlink; vap->va_uid = ip->i_uid; vap->va_gid = ip->i_gid; - vap->va_rdev = ip->i_rdev; + vap->va_rdev = VN_ISDEV(vp) ? ip->i_rdev : NODEV; vap->va_size = ip->i_size; vap->va_atime.tv_sec = ip->i_atime; vap->va_atime.tv_nsec = E2DI_HAS_XTIME(ip) ? ip->i_atimensec : 0; @@ -905,7 +905,7 @@ abortit: error = ext2_checkpath(ip, dp, tcnp->cn_cred); if (error) goto out; - VREF(tdvp); + vref(tdvp); error = vfs_relookup(tdvp, &tvp, tcnp, true); if (error) goto out; @@ -1031,7 +1031,7 @@ abortit: */ fcnp->cn_flags &= ~MODMASK; fcnp->cn_flags |= LOCKPARENT | LOCKLEAF; - VREF(fdvp); + vref(fdvp); error = vfs_relookup(fdvp, &fvp, fcnp, true); if (error == 0) vrele(fdvp); @@ -1571,7 +1571,7 @@ ext2_strategy(struct vop_strategy_args *ap) daddr_t blkno; int error; - if (vp->v_type == VBLK || vp->v_type == VCHR) + if (VN_ISDEV(vp)) panic("ext2_strategy: spec"); if (bp->b_blkno == bp->b_lblkno) { if (VTOI(ap->a_vp)->i_flag & IN_E4EXTENTS) @@ -1733,7 +1733,7 @@ ext2_deleteextattr(struct vop_deleteextattr_args *ap) if (!EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXT_ATTR)) return (EOPNOTSUPP); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, @@ -1771,7 +1771,7 @@ ext2_getextattr(struct vop_getextattr_args *ap) if (!EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXT_ATTR)) return (EOPNOTSUPP); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, @@ -1814,7 +1814,7 @@ ext2_listextattr(struct vop_listextattr_args *ap) if (!EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXT_ATTR)) return (EOPNOTSUPP); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, @@ -1855,7 +1855,7 @@ ext2_setextattr(struct vop_setextattr_args *ap) if (!EXT2_HAS_COMPAT_FEATURE(ip->i_e2fs, EXT2F_COMPAT_EXT_ATTR)) return (EOPNOTSUPP); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index 58a22b8bdc50..c1188c3819e7 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -196,7 +196,7 @@ loop: if (error != 0) { vgone(vp); vput(vp); - *vpp = NULLVP; + *vpp = NULL; return (error); } @@ -211,7 +211,7 @@ loop: mtx_unlock(&fdesc_hashmtx); vgone(vp); vput(vp); - *vpp = NULLVP; + *vpp = NULL; return (-1); } @@ -227,7 +227,7 @@ loop: vput(vp); /* If we didn't get it, return no vnode. */ if (error) - vp2 = NULLVP; + vp2 = NULL; *vpp = vp2; return (error); } @@ -301,7 +301,7 @@ fdesc_lookup(struct vop_lookup_args *ap) if (cnp->cn_namelen == 1 && *pname == '.') { *vpp = dvp; - VREF(dvp); + vref(dvp); return (0); } diff --git a/sys/fs/fuse/fuse_ipc.c b/sys/fs/fuse/fuse_ipc.c index a751c09159ff..7f754ab7f1d4 100644 --- a/sys/fs/fuse/fuse_ipc.c +++ b/sys/fs/fuse/fuse_ipc.c @@ -193,7 +193,6 @@ fuse_interrupt_send(struct fuse_ticket *otick, int err) struct fuse_data *data = otick->tk_data; struct fuse_ticket *tick, *xtick; struct ucred reused_creds; - gid_t reused_groups[1]; if (otick->irq_unique == 0) { /* @@ -237,8 +236,7 @@ fuse_interrupt_send(struct fuse_ticket *otick, int err) */ ftick_hdr = fticket_in_header(otick); reused_creds.cr_uid = ftick_hdr->uid; - reused_groups[0] = ftick_hdr->gid; - reused_creds.cr_groups = reused_groups; + reused_creds.cr_gid = ftick_hdr->gid; fdisp_init(&fdi, sizeof(*fii)); fdisp_make_pid(&fdi, FUSE_INTERRUPT, data, ftick_hdr->nodeid, ftick_hdr->pid, &reused_creds); diff --git a/sys/fs/fuse/fuse_vfsops.c b/sys/fs/fuse/fuse_vfsops.c index 1b858a988289..b617925c4e5f 100644 --- a/sys/fs/fuse/fuse_vfsops.c +++ b/sys/fs/fuse/fuse_vfsops.c @@ -278,13 +278,13 @@ fuse_vfsop_fhtovp(struct mount *mp, struct fid *fhp, int flags, error = VFS_VGET(mp, ffhp->nid, LK_EXCLUSIVE, &nvp); if (error) { - *vpp = NULLVP; + *vpp = NULL; return (error); } fvdat = VTOFUD(nvp); if (fvdat->generation != ffhp->gen ) { vput(nvp); - *vpp = NULLVP; + *vpp = NULL; return (ESTALE); } *vpp = nvp; diff --git a/sys/fs/fuse/fuse_vnops.c b/sys/fs/fuse/fuse_vnops.c index b782146b7278..5c28db29fc63 100644 --- a/sys/fs/fuse/fuse_vnops.c +++ b/sys/fs/fuse/fuse_vnops.c @@ -795,11 +795,15 @@ fuse_vnop_close(struct vop_close_args *ap) struct mount *mp = vnode_mount(vp); struct ucred *cred = ap->a_cred; int fflag = ap->a_fflag; - struct thread *td = ap->a_td; - pid_t pid = td->td_proc->p_pid; + struct thread *td; struct fuse_vnode_data *fvdat = VTOFUD(vp); + pid_t pid; int err = 0; + /* NB: a_td will be NULL from some async kernel contexts */ + td = ap->a_td ? ap->a_td : curthread; + pid = td->td_proc->p_pid; + if (fuse_isdeadfs(vp)) return 0; if (vnode_isdir(vp)) @@ -838,7 +842,7 @@ fuse_vnop_close(struct vop_close_args *ap) } /* TODO: close the file handle, if we're sure it's no longer used */ if ((fvdat->flag & FN_SIZECHANGE) != 0) { - fuse_vnode_savesize(vp, cred, td->td_proc->p_pid); + fuse_vnode_savesize(vp, cred, pid); } return err; } @@ -953,7 +957,7 @@ fuse_vnop_copy_file_range(struct vop_copy_file_range_args *ap) *ap->a_outoffp += fwo->size; fuse_internal_clear_suid_on_write(outvp, outcred, td); if (*ap->a_outoffp > outfvdat->cached_attrs.va_size) { - fuse_vnode_setsize(outvp, *ap->a_outoffp, false); + fuse_vnode_setsize(outvp, *ap->a_outoffp, false); getnanouptime(&outfvdat->last_local_modify); } fuse_vnode_update(invp, FN_ATIMECHANGE); @@ -1748,7 +1752,7 @@ fuse_vnop_open(struct vop_open_args *ap) if (fuse_isdeadfs(vp)) return (EXTERROR(ENXIO, "This FUSE session is about " "to be closed")); - if (vp->v_type == VCHR || vp->v_type == VBLK || vp->v_type == VFIFO) + if (VN_ISDEV(vp) || vp->v_type == VFIFO) return (EXTERROR(EOPNOTSUPP, "Unsupported vnode type", vp->v_type)); if ((a_mode & (FREAD | FWRITE | FEXEC)) == 0) diff --git a/sys/fs/msdosfs/bootsect.h b/sys/fs/msdosfs/bootsect.h index 170d94cb9512..94b1137a153e 100644 --- a/sys/fs/msdosfs/bootsect.h +++ b/sys/fs/msdosfs/bootsect.h @@ -20,7 +20,7 @@ /* * Format of a boot sector. This is the first sector on a DOS floppy disk - * or the fist sector of a partition on a hard disk. But, it is not the + * or the first sector of a partition on a hard disk. But, it is not the * first sector of a partitioned hard disk. */ struct bootsector33 { diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 8ab6d35a2685..58ce8eff9dbd 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/msdosfs/msdosfs_lookup.c @@ -515,7 +515,7 @@ foundroot: * Save directory inode pointer in ndp->ni_dvp for dirremove(). */ if (dp->de_StartCluster == scn && isadir) { /* "." */ - VREF(vdp); + vref(vdp); *vpp = vdp; return (0); } @@ -602,7 +602,7 @@ foundroot: msdosfs_integrity_error(pmp); return (EBADF); } - VREF(vdp); /* we want ourself, ie "." */ + vref(vdp); /* we want ourself, ie "." */ *vpp = vdp; } else { if ((error = deget(pmp, cluster, blkoff, LK_EXCLUSIVE, diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 4431d36c8a8e..30c63cfa8a35 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -1184,7 +1184,7 @@ msdosfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) error = deget(pmp, defhp->defid_dirclust, defhp->defid_dirofs, LK_EXCLUSIVE, &dep); if (error) { - *vpp = NULLVP; + *vpp = NULL; return (error); } *vpp = DETOV(dep); diff --git a/sys/fs/nfs/nfs_commonport.c b/sys/fs/nfs/nfs_commonport.c index e5fdb395c9f7..862780741ee7 100644 --- a/sys/fs/nfs/nfs_commonport.c +++ b/sys/fs/nfs/nfs_commonport.c @@ -371,8 +371,6 @@ nfsrv_atroot(struct vnode *vp, uint64_t *retp) /* * Set the credentials to refer to root. - * If only the various BSDen could agree on whether cr_gid is a separate - * field or cr_groups[0]... */ void newnfs_setroot(struct ucred *cred) diff --git a/sys/fs/nfs/nfsport.h b/sys/fs/nfs/nfsport.h index bd6107187966..4e9aae70da6f 100644 --- a/sys/fs/nfs/nfsport.h +++ b/sys/fs/nfs/nfsport.h @@ -909,15 +909,6 @@ int nfsmsleep(void *, void *, int, const char *, struct timespec *); #define NFSBZERO(s, l) bzero((s), (l)) /* - * Some queue.h files don't have these dfined in them. - */ -#ifndef LIST_END -#define LIST_END(head) NULL -#define SLIST_END(head) NULL -#define TAILQ_END(head) NULL -#endif - -/* * This must be defined to be a global variable that increments once * per second, but never stops or goes backwards, even when a "date" * command changes the TOD clock. It is used for delta times for @@ -1026,7 +1017,7 @@ MALLOC_DECLARE(M_NEWNFSDSESSION); int nfscl_loadattrcache(struct vnode **, struct nfsvattr *, void *, int, int); int newnfs_realign(struct mbuf **, int); bool ncl_pager_setsize(struct vnode *vp, u_quad_t *nsizep); -void ncl_copy_vattr(struct vattr *dst, struct vattr *src); +void ncl_copy_vattr(struct vnode *vp, struct vattr *dst, struct vattr *src); /* * If the port runs on an SMP box that can enforce Atomic ops with low @@ -1038,9 +1029,6 @@ void ncl_copy_vattr(struct vattr *dst, struct vattr *src); #define NFSDECRGLOBAL(a) ((a)--) /* - * Assorted funky stuff to make things work under Darwin8. - */ -/* * These macros checks for a field in vattr being set. */ #define NFSATTRISSET(t, v, a) ((v)->a != (t)VNOVAL) diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 704aeeeabdf2..77e71d4153c9 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -412,7 +412,7 @@ nfscl_warn_fileid(struct nfsmount *nmp, struct nfsvattr *oldnap, } void -ncl_copy_vattr(struct vattr *dst, struct vattr *src) +ncl_copy_vattr(struct vnode *vp, struct vattr *dst, struct vattr *src) { dst->va_type = src->va_type; dst->va_mode = src->va_mode; @@ -429,7 +429,7 @@ ncl_copy_vattr(struct vattr *dst, struct vattr *src) dst->va_birthtime = src->va_birthtime; dst->va_gen = src->va_gen; dst->va_flags = src->va_flags; - dst->va_rdev = src->va_rdev; + dst->va_rdev = VN_ISDEV(vp) ? src->va_rdev : NODEV; dst->va_bytes = src->va_bytes; dst->va_filerev = src->va_filerev; } @@ -595,7 +595,7 @@ nfscl_loadattrcache(struct vnode **vpp, struct nfsvattr *nap, void *nvaper, KDTRACE_NFS_ATTRCACHE_FLUSH_DONE(vp); } if (vaper != NULL) { - ncl_copy_vattr(vaper, vap); + ncl_copy_vattr(vp, vaper, vap); if (np->n_flag & NCHG) { if (np->n_flag & NACC) vaper->va_atime = np->n_atim; @@ -1098,9 +1098,10 @@ newnfs_copyincred(struct ucred *cr, struct nfscred *nfscr) KASSERT(cr->cr_ngroups >= 0, ("newnfs_copyincred: negative cr_ngroups")); nfscr->nfsc_uid = cr->cr_uid; - nfscr->nfsc_ngroups = MIN(cr->cr_ngroups, NFS_MAXGRPS + 1); - for (i = 0; i < nfscr->nfsc_ngroups; i++) - nfscr->nfsc_groups[i] = cr->cr_groups[i]; + nfscr->nfsc_ngroups = MIN(cr->cr_ngroups + 1, NFS_MAXGRPS + 1); + nfscr->nfsc_groups[0] = cr->cr_gid; + for (i = 1; i < nfscr->nfsc_ngroups; i++) + nfscr->nfsc_groups[i] = cr->cr_groups[i - 1]; } /* diff --git a/sys/fs/nfsclient/nfs_clrpcops.c b/sys/fs/nfsclient/nfs_clrpcops.c index 4ec621de2eff..ad9404a18fc8 100644 --- a/sys/fs/nfsclient/nfs_clrpcops.c +++ b/sys/fs/nfsclient/nfs_clrpcops.c @@ -3981,7 +3981,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, int len, left; struct dirent *dp = NULL; u_int32_t *tl; - vnode_t newvp = NULLVP; + vnode_t newvp = NULL; struct nfsrv_descript nfsd, *nd = &nfsd; struct nameidata nami, *ndp = &nami; struct componentname *cnp = &ndp->ni_cnd; @@ -4387,7 +4387,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, attr_ok = true; if (NFSRV_CMPFH(nfhp->nfh_fh, nfhp->nfh_len, dnp->n_fhp->nfh_fh, dnp->n_fhp->nfh_len)) { - VREF(vp); + vref(vp); newvp = vp; unlocknewvp = 0; free(nfhp, M_NFSFH); @@ -4436,7 +4436,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, } } nfhp = NULL; - if (newvp != NULLVP) { + if (newvp != NULL) { if (attr_ok) error = nfscl_loadattrcache(&newvp, &nfsva, NULL, 0, 0); @@ -4466,7 +4466,7 @@ nfsrpc_readdirplus(vnode_t vp, struct uio *uiop, nfsuint64 *cookiep, vput(newvp); else vrele(newvp); - newvp = NULLVP; + newvp = NULL; } } } else if (nfhp != NULL) { diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index 6824ee6ef13d..e9ae91e046e7 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -1026,7 +1026,7 @@ nfs_getattr(struct vop_getattr_args *ap) * cached attributes should be ignored. */ if (nmp->nm_fhsize > 0 && ncl_getattrcache(vp, &vattr) == 0) { - ncl_copy_vattr(vap, &vattr); + ncl_copy_vattr(vp, vap, &vattr); /* * Get the local modify time for the case of a write @@ -1284,7 +1284,7 @@ nfs_lookup(struct vop_lookup_args *ap) bool is_nameddir, needs_nameddir, opennamed; dattrflag = 0; - *vpp = NULLVP; + *vpp = NULL; nmp = VFSTONFS(mp); opennamed = (flags & (OPENNAMED | ISLASTCN)) == (OPENNAMED | ISLASTCN); if (opennamed && (!NFSHASNFSV4(nmp) || !NFSHASNFSV4N(nmp))) @@ -1309,7 +1309,7 @@ nfs_lookup(struct vop_lookup_args *ap) /* * If the named attribute directory is needed, acquire it now. */ - newvp = NULLVP; + newvp = NULL; if (needs_nameddir) { KASSERT(np->n_v4 == NULL, ("nfs_lookup: O_NAMEDATTR when" " n_v4 not NULL")); @@ -1322,10 +1322,10 @@ nfs_lookup(struct vop_lookup_args *ap) } dvp = newvp; np = VTONFS(dvp); - newvp = NULLVP; + newvp = NULL; } else if (opennamed && cnp->cn_namelen == 1 && *cnp->cn_nameptr == '.') { - VREF(dvp); + vref(dvp); *vpp = dvp; return (0); } @@ -1399,7 +1399,7 @@ nfs_lookup(struct vop_lookup_args *ap) vput(newvp); else vrele(newvp); - *vpp = NULLVP; + *vpp = NULL; } else if (error == ENOENT) { if (VN_IS_DOOMED(dvp)) return (ENOENT); @@ -1450,7 +1450,7 @@ nfs_lookup(struct vop_lookup_args *ap) NFSUNLOCKMNT(nmp); #endif - newvp = NULLVP; + newvp = NULL; NFSINCRGLOBAL(nfsstatsv1.lookupcache_misses); nanouptime(&ts); error = nfsrpc_lookup(dvp, cnp->cn_nameptr, cnp->cn_namelen, @@ -1464,9 +1464,9 @@ nfs_lookup(struct vop_lookup_args *ap) } handle_error: if (error) { - if (newvp != NULLVP) { + if (newvp != NULL) { vput(newvp); - *vpp = NULLVP; + *vpp = NULL; } if (error != ENOENT) { @@ -1587,7 +1587,7 @@ handle_error: 0, 1); } else if (NFS_CMPFH(np, nfhp->nfh_fh, nfhp->nfh_len)) { free(nfhp, M_NFSFH); - VREF(dvp); + vref(dvp); newvp = dvp; if (attrflag) (void) nfscl_loadattrcache(&newvp, &nfsva, NULL, @@ -1782,7 +1782,7 @@ nfs_mknodrpc(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, int error = 0, attrflag, dattrflag; u_int32_t rdev; - if (vap->va_type == VCHR || vap->va_type == VBLK) + if (VATTR_ISDEV(vap)) rdev = vap->va_rdev; else if (vap->va_type == VFIFO || vap->va_type == VSOCK) rdev = 0xffffffff; @@ -2863,7 +2863,7 @@ nfs_sillyrename(struct vnode *dvp, struct vnode *vp, struct componentname *cnp) M_NEWNFSREQ, M_WAITOK); sp->s_cred = crhold(cnp->cn_cred); sp->s_dvp = dvp; - VREF(dvp); + vref(dvp); /* * Fudge together a funny name. @@ -2961,7 +2961,7 @@ nfs_lookitup(struct vnode *dvp, char *name, int len, struct ucred *cred, newvp = NFSTOV(np); } else if (NFS_CMPFH(dnp, nfhp->nfh_fh, nfhp->nfh_len)) { free(nfhp, M_NFSFH); - VREF(dvp); + vref(dvp); newvp = dvp; } else { cn.cn_nameptr = name; @@ -3474,7 +3474,7 @@ nfs_advlock(struct vop_advlock_args *ap) u_quad_t size; struct nfsmount *nmp; - error = NFSVOPLOCK(vp, LK_SHARED); + error = NFSVOPLOCK(vp, LK_EXCLUSIVE); if (error != 0) return (EBADF); nmp = VFSTONFS(vp->v_mount); @@ -3511,11 +3511,6 @@ nfs_advlock(struct vop_advlock_args *ap) cred = p->p_ucred; else cred = td->td_ucred; - NFSVOPLOCK(vp, LK_UPGRADE | LK_RETRY); - if (VN_IS_DOOMED(vp)) { - error = EBADF; - goto out; - } /* * If this is unlocking a write locked region, flush and diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index b2966934f9b7..eb6ba285f8fe 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -675,7 +675,7 @@ nfsvno_namei(struct nfsrv_descript *nd, struct nameidata *ndp, } if (islocked) NFSVOPUNLOCK(dp); - VREF(dp); + vref(dp); *retdirp = dp; if (NFSVNO_EXRDONLY(exp)) cnp->cn_flags |= RDONLY; @@ -697,7 +697,7 @@ nfsvno_namei(struct nfsrv_descript *nd, struct nameidata *ndp, goto out; } dp = rootvnode; - VREF(dp); + vref(dp); } } else if ((nfsrv_enable_crossmntpt == 0 && NFSVNO_EXPORTED(exp)) || (nd->nd_flag & ND_NFSV4) == 0) { @@ -814,7 +814,7 @@ nfsvno_namei(struct nfsrv_descript *nd, struct nameidata *ndp, if (cnp->cn_pnbuf[0] == '/') { vrele(ndp->ni_dvp); ndp->ni_dvp = ndp->ni_rootdir; - VREF(ndp->ni_dvp); + vref(ndp->ni_dvp); } ndp->ni_startdir = ndp->ni_dvp; ndp->ni_dvp = NULL; @@ -2607,6 +2607,7 @@ again: * rpc reply */ if (siz == 0) { +ateof: vput(vp); if (nd->nd_flag & ND_NFSV3) nfsrv_postopattr(nd, getret, &at); @@ -2648,6 +2649,8 @@ again: ncookies--; } if (cpos >= cend || ncookies == 0) { + if (eofflag != 0) + goto ateof; siz = fullsiz; toff = off; goto again; @@ -3475,11 +3478,6 @@ nfsd_excred(struct nfsrv_descript *nd, struct nfsexstuff *exp, (nd->nd_flag & ND_AUTHNONE) != 0) { nd->nd_cred->cr_uid = credanon->cr_uid; nd->nd_cred->cr_gid = credanon->cr_gid; - /* - * 'credanon' is already a 'struct ucred' that was built - * internally with calls to crsetgroups_and_egid(), so - * we don't need a fallback here. - */ crsetgroups(nd->nd_cred, credanon->cr_ngroups, credanon->cr_groups); } else if ((nd->nd_flag & ND_GSS) == 0) { diff --git a/sys/fs/nfsserver/nfs_nfsdserv.c b/sys/fs/nfsserver/nfs_nfsdserv.c index a881968b03be..921ea4887af1 100644 --- a/sys/fs/nfsserver/nfs_nfsdserv.c +++ b/sys/fs/nfsserver/nfs_nfsdserv.c @@ -342,7 +342,7 @@ nfsrvd_getattr(struct nfsrv_descript *nd, int isdgram, (vp->v_vflag & VV_ROOT) != 0 && vp != rootvnode) { tvp = mp->mnt_vnodecovered; - VREF(tvp); + vref(tvp); at_root = 1; } else at_root = 0; @@ -1766,7 +1766,7 @@ nfsrvd_rename(struct nfsrv_descript *nd, int isdgram, /* If this is the same file handle, just VREF() the vnode. */ if (!NFSBCMP(tfh.nfsrvfh_data, &fh, NFSX_MYFH)) { - VREF(dp); + vref(dp); tdp = dp; tnes = *exp; tdirfor_ret = nfsvno_getattr(tdp, &tdirfor, nd, p, 1, diff --git a/sys/fs/nfsserver/nfs_nfsdsocket.c b/sys/fs/nfsserver/nfs_nfsdsocket.c index 636c4735a131..201f3b74b946 100644 --- a/sys/fs/nfsserver/nfs_nfsdsocket.c +++ b/sys/fs/nfsserver/nfs_nfsdsocket.c @@ -1110,7 +1110,7 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, if (vp != savevp) { if (savevp) vrele(savevp); - VREF(vp); + vref(vp); savevp = vp; savevpnes = vpnes; save_fsid = cur_fsid; @@ -1155,7 +1155,7 @@ nfsrvd_compound(struct nfsrv_descript *nd, int isdgram, u_char *tag, nfsvno_testexp(nd, &savevpnes); if (nd->nd_repstat == 0) { - VREF(savevp); + vref(savevp); vrele(vp); vp = savevp; vpnes = savevpnes; @@ -1235,7 +1235,7 @@ tryagain: break; } } - VREF(vp); + vref(vp); if (nfsv4_opflag[op].modifyfs) vn_start_write(vp, &temp_mp, V_WAIT); error = (*(nfsrv4_ops1[op]))(nd, isdgram, vp, @@ -1279,8 +1279,8 @@ tryagain: if (nfsv4_opflag[op].modifyfs) vn_start_write(savevp, &temp_mp, V_WAIT); if (NFSVOPLOCK(savevp, LK_EXCLUSIVE) == 0) { - VREF(vp); - VREF(savevp); + vref(vp); + vref(savevp); error = (*(nfsrv4_ops2[op]))(nd, isdgram, savevp, vp, &savevpnes, &vpnes); } else @@ -1301,7 +1301,7 @@ tryagain: lktype = LK_SHARED; } if (NFSVOPLOCK(vp, lktype) == 0) - VREF(vp); + vref(vp); else nd->nd_repstat = NFSERR_PERM; } else { diff --git a/sys/fs/nullfs/null.h b/sys/fs/nullfs/null.h index 0a93878c859f..aa7a689bec34 100644 --- a/sys/fs/nullfs/null.h +++ b/sys/fs/nullfs/null.h @@ -37,6 +37,9 @@ #define NULLM_CACHE 0x0001 +#include <sys/ck.h> +#include <vm/uma.h> + struct null_mount { struct mount *nullm_vfs; struct vnode *nullm_lowerrootvp; /* Ref to lower root vnode */ @@ -50,7 +53,7 @@ struct null_mount { * A cache of vnode references */ struct null_node { - LIST_ENTRY(null_node) null_hash; /* Hash list */ + CK_LIST_ENTRY(null_node) null_hash; /* Hash list */ struct vnode *null_lowervp; /* VREFed once */ struct vnode *null_vnode; /* Back pointer */ u_int null_flags; @@ -61,6 +64,7 @@ struct null_node { #define MOUNTTONULLMOUNT(mp) ((struct null_mount *)((mp)->mnt_data)) #define VTONULL(vp) ((struct null_node *)(vp)->v_data) +#define VTONULL_SMR(vp) ((struct null_node *)vn_load_v_data_smr(vp)) #define NULLTOV(xp) ((xp)->null_vnode) int nullfs_init(struct vfsconf *vfsp); @@ -79,9 +83,7 @@ struct vnode *null_checkvp(struct vnode *vp, char *fil, int lno); extern struct vop_vector null_vnodeops; -#ifdef MALLOC_DECLARE -MALLOC_DECLARE(M_NULLFSNODE); -#endif +extern uma_zone_t null_node_zone; #ifdef NULLFS_DEBUG #define NULLFSDEBUG(format, args...) printf(format ,## args) diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index 7dcc83880bb9..146d3bbdaedd 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -41,9 +41,14 @@ #include <sys/mount.h> #include <sys/proc.h> #include <sys/vnode.h> +#include <sys/smr.h> #include <fs/nullfs/null.h> +#include <vm/uma.h> + +VFS_SMR_DECLARE; + /* * Null layer cache: * Each cache entry holds a reference to the lower vnode @@ -54,12 +59,12 @@ #define NULL_NHASH(vp) (&null_node_hashtbl[vfs_hash_index(vp) & null_hash_mask]) -static LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl; +static CK_LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl; static struct rwlock null_hash_lock; static u_long null_hash_mask; static MALLOC_DEFINE(M_NULLFSHASH, "nullfs_hash", "NULLFS hash table"); -MALLOC_DEFINE(M_NULLFSNODE, "nullfs_node", "NULLFS vnode private part"); +uma_zone_t __read_mostly null_node_zone; static void null_hashins(struct mount *, struct null_node *); @@ -73,6 +78,10 @@ nullfs_init(struct vfsconf *vfsp) null_node_hashtbl = hashinit(desiredvnodes, M_NULLFSHASH, &null_hash_mask); rw_init(&null_hash_lock, "nullhs"); + null_node_zone = uma_zcreate("nullfs node", sizeof(struct null_node), + NULL, NULL, NULL, NULL, 0, UMA_ZONE_ZINIT); + VFS_SMR_ZONE_SET(null_node_zone); + return (0); } @@ -80,6 +89,7 @@ int nullfs_uninit(struct vfsconf *vfsp) { + uma_zdestroy(null_node_zone); rw_destroy(&null_hash_lock); hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_hash_mask); return (0); @@ -96,7 +106,7 @@ null_hashget_locked(struct mount *mp, struct vnode *lowervp) struct null_node *a; struct vnode *vp; - ASSERT_VOP_LOCKED(lowervp, "null_hashget"); + ASSERT_VOP_LOCKED(lowervp, __func__); rw_assert(&null_hash_lock, RA_LOCKED); /* @@ -106,37 +116,57 @@ null_hashget_locked(struct mount *mp, struct vnode *lowervp) * reference count (but NOT the lower vnode's VREF counter). */ hd = NULL_NHASH(lowervp); - LIST_FOREACH(a, hd, null_hash) { - if (a->null_lowervp == lowervp && NULLTOV(a)->v_mount == mp) { - /* - * Since we have the lower node locked the nullfs - * node can not be in the process of recycling. If - * it had been recycled before we grabed the lower - * lock it would not have been found on the hash. - */ - vp = NULLTOV(a); - vref(vp); - return (vp); - } + CK_LIST_FOREACH(a, hd, null_hash) { + if (a->null_lowervp != lowervp) + continue; + /* + * Since we have the lower node locked the nullfs + * node can not be in the process of recycling. If + * it had been recycled before we grabed the lower + * lock it would not have been found on the hash. + */ + vp = NULLTOV(a); + VNPASS(!VN_IS_DOOMED(vp), vp); + if (vp->v_mount != mp) + continue; + vref(vp); + return (vp); } - return (NULLVP); + return (NULL); } struct vnode * null_hashget(struct mount *mp, struct vnode *lowervp) { struct null_node_hashhead *hd; + struct null_node *a; struct vnode *vp; + enum vgetstate vs; - hd = NULL_NHASH(lowervp); - if (LIST_EMPTY(hd)) - return (NULLVP); - - rw_rlock(&null_hash_lock); - vp = null_hashget_locked(mp, lowervp); - rw_runlock(&null_hash_lock); + ASSERT_VOP_LOCKED(lowervp, "null_hashget"); + rw_assert(&null_hash_lock, RA_UNLOCKED); - return (vp); + vfs_smr_enter(); + hd = NULL_NHASH(lowervp); + CK_LIST_FOREACH(a, hd, null_hash) { + if (a->null_lowervp != lowervp) + continue; + /* + * See null_hashget_locked as to why the nullfs vnode can't be + * doomed here. + */ + vp = NULLTOV(a); + VNPASS(!VN_IS_DOOMED(vp), vp); + if (vp->v_mount != mp) + continue; + vs = vget_prep_smr(vp); + vfs_smr_exit(); + VNPASS(vs != VGET_NONE, vp); + vget_finish_ref(vp, vs); + return (vp); + } + vfs_smr_exit(); + return (NULL); } static void @@ -151,7 +181,7 @@ null_hashins(struct mount *mp, struct null_node *xp) hd = NULL_NHASH(xp->null_lowervp); #ifdef INVARIANTS - LIST_FOREACH(oxp, hd, null_hash) { + CK_LIST_FOREACH(oxp, hd, null_hash) { if (oxp->null_lowervp == xp->null_lowervp && NULLTOV(oxp)->v_mount == mp) { VNASSERT(0, NULLTOV(oxp), @@ -159,7 +189,7 @@ null_hashins(struct mount *mp, struct null_node *xp) } } #endif - LIST_INSERT_HEAD(hd, xp, null_hash); + CK_LIST_INSERT_HEAD(hd, xp, null_hash); } static void @@ -174,7 +204,7 @@ null_destroy_proto(struct vnode *vp, void *xp) VI_UNLOCK(vp); vgone(vp); vput(vp); - free(xp, M_NULLFSNODE); + uma_zfree_smr(null_node_zone, xp); } /* @@ -208,12 +238,12 @@ null_nodeget(struct mount *mp, struct vnode *lowervp, struct vnode **vpp) * Note that duplicate can only appear in hash if the lowervp is * locked LK_SHARED. */ - xp = malloc(sizeof(struct null_node), M_NULLFSNODE, M_WAITOK); + xp = uma_zalloc_smr(null_node_zone, M_WAITOK); error = getnewvnode("nullfs", mp, &null_vnodeops, &vp); if (error) { vput(lowervp); - free(xp, M_NULLFSNODE); + uma_zfree_smr(null_node_zone, xp); return (error); } @@ -261,8 +291,8 @@ null_nodeget(struct mount *mp, struct vnode *lowervp, struct vnode **vpp) return (error); } - null_hashins(mp, xp); vn_set_state(vp, VSTATE_CONSTRUCTED); + null_hashins(mp, xp); rw_wunlock(&null_hash_lock); *vpp = vp; @@ -277,7 +307,7 @@ null_hashrem(struct null_node *xp) { rw_wlock(&null_hash_lock); - LIST_REMOVE(xp, null_hash); + CK_LIST_REMOVE(xp, null_hash); rw_wunlock(&null_hash_lock); } @@ -298,7 +328,7 @@ null_checkvp(struct vnode *vp, char *fil, int lno) panic("null_checkvp"); } #endif - if (a->null_lowervp == NULLVP) { + if (a->null_lowervp == NULL) { /* Should never happen */ panic("null_checkvp %p", vp); } diff --git a/sys/fs/nullfs/null_vnops.c b/sys/fs/nullfs/null_vnops.c index 74c1a8f3acb6..375b6aa27531 100644 --- a/sys/fs/nullfs/null_vnops.c +++ b/sys/fs/nullfs/null_vnops.c @@ -174,6 +174,8 @@ #include <sys/mount.h> #include <sys/mutex.h> #include <sys/namei.h> +#include <sys/proc.h> +#include <sys/smr.h> #include <sys/sysctl.h> #include <sys/vnode.h> #include <sys/stat.h> @@ -185,6 +187,8 @@ #include <vm/vm_object.h> #include <vm/vnode_pager.h> +VFS_SMR_DECLARE; + static int null_bug_bypass = 0; /* for debugging: enables bypass printf'ing */ SYSCTL_INT(_debug, OID_AUTO, nullfs_bug_bypass, CTLFLAG_RW, &null_bug_bypass, 0, ""); @@ -273,9 +277,9 @@ null_bypass(struct vop_generic_args *ap) * are of our type. Check for and don't map any * that aren't. (We must always map first vp or vclean fails.) */ - if (i != 0 && (*this_vp_p == NULLVP || - (*this_vp_p)->v_op != &null_vnodeops)) { - old_vps[i] = NULLVP; + if (i != 0 && (*this_vp_p == NULL || + (*this_vp_p)->v_op != &null_vnodeops)) { + old_vps[i] = NULL; } else { old_vps[i] = *this_vp_p; *(vps_p[i]) = NULLVPTOLOWERVP(*this_vp_p); @@ -306,7 +310,7 @@ null_bypass(struct vop_generic_args *ap) * with the modified argument structure. */ if (vps_p[0] != NULL && *vps_p[0] != NULL) { - error = VCALL(ap); + error = ap->a_desc->vdesc_call(ap); } else { printf("null_bypass: no map for %s\n", descp->vdesc_name); error = EINVAL; @@ -336,7 +340,7 @@ null_bypass(struct vop_generic_args *ap) * must move lock ownership from lower to * upper (reclaimed) vnode. */ - if (lvp != NULLVP) { + if (lvp != NULL) { null_copy_inotify(old_vps[i], lvp, VIRF_INOTIFY); null_copy_inotify(old_vps[i], lvp, @@ -494,7 +498,7 @@ null_lookup(struct vop_lookup_args *ap) if ((error == 0 || error == EJUSTRETURN) && lvp != NULL) { if (ldvp == lvp) { *ap->a_vpp = dvp; - VREF(dvp); + vref(dvp); vrele(lvp); } else { error = null_nodeget(mp, lvp, &vp); @@ -665,7 +669,7 @@ null_remove(struct vop_remove_args *ap) vp = ap->a_vp; if (vrefcnt(vp) > 1) { lvp = NULLVPTOLOWERVP(vp); - VREF(lvp); + vref(lvp); vreleit = 1; } else vreleit = 0; @@ -768,83 +772,110 @@ null_rmdir(struct vop_rmdir_args *ap) } /* - * We need to process our own vnode lock and then clear the - * interlock flag as it applies only to our vnode, not the - * vnodes below us on the stack. + * We need to process our own vnode lock and then clear the interlock flag as + * it applies only to our vnode, not the vnodes below us on the stack. + * + * We have to hold the vnode here to solve a potential reclaim race. If we're + * forcibly vgone'd while we still have refs, a thread could be sleeping inside + * the lowervp's vop_lock routine. When we vgone we will drop our last ref to + * the lowervp, which would allow it to be reclaimed. The lowervp could then + * be recycled, in which case it is not legal to be sleeping in its VOP. We + * prevent it from being recycled by holding the vnode here. */ +static struct vnode * +null_lock_prep_with_smr(struct vop_lock1_args *ap) +{ + struct null_node *nn; + struct vnode *lvp; + + vfs_smr_enter(); + + lvp = NULL; + + nn = VTONULL_SMR(ap->a_vp); + if (__predict_true(nn != NULL)) { + lvp = nn->null_lowervp; + if (lvp != NULL && !vhold_smr(lvp)) + lvp = NULL; + } + + vfs_smr_exit(); + return (lvp); +} + +static struct vnode * +null_lock_prep_with_interlock(struct vop_lock1_args *ap) +{ + struct null_node *nn; + struct vnode *lvp; + + ASSERT_VI_LOCKED(ap->a_vp, __func__); + + ap->a_flags &= ~LK_INTERLOCK; + + lvp = NULL; + + nn = VTONULL(ap->a_vp); + if (__predict_true(nn != NULL)) { + lvp = nn->null_lowervp; + if (lvp != NULL) + vholdnz(lvp); + } + VI_UNLOCK(ap->a_vp); + return (lvp); +} + static int null_lock(struct vop_lock1_args *ap) { - struct vnode *vp = ap->a_vp; - int flags; - struct null_node *nn; struct vnode *lvp; - int error; + int error, flags; - if ((ap->a_flags & LK_INTERLOCK) == 0) - VI_LOCK(vp); - else - ap->a_flags &= ~LK_INTERLOCK; - flags = ap->a_flags; - nn = VTONULL(vp); + if (__predict_true((ap->a_flags & LK_INTERLOCK) == 0)) { + lvp = null_lock_prep_with_smr(ap); + if (__predict_false(lvp == NULL)) { + VI_LOCK(ap->a_vp); + lvp = null_lock_prep_with_interlock(ap); + } + } else { + lvp = null_lock_prep_with_interlock(ap); + } + + ASSERT_VI_UNLOCKED(ap->a_vp, __func__); + + if (__predict_false(lvp == NULL)) + return (vop_stdlock(ap)); + + VNPASS(lvp->v_holdcnt > 0, lvp); + error = VOP_LOCK(lvp, ap->a_flags); /* - * If we're still active we must ask the lower layer to - * lock as ffs has special lock considerations in its - * vop lock. + * We might have slept to get the lock and someone might have + * clean our vnode already, switching vnode lock from one in + * lowervp to v_lock in our own vnode structure. Handle this + * case by reacquiring correct lock in requested mode. */ - if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) { - /* - * We have to hold the vnode here to solve a potential - * reclaim race. If we're forcibly vgone'd while we - * still have refs, a thread could be sleeping inside - * the lowervp's vop_lock routine. When we vgone we will - * drop our last ref to the lowervp, which would allow it - * to be reclaimed. The lowervp could then be recycled, - * in which case it is not legal to be sleeping in its VOP. - * We prevent it from being recycled by holding the vnode - * here. - */ - vholdnz(lvp); - VI_UNLOCK(vp); - error = VOP_LOCK(lvp, flags); - - /* - * We might have slept to get the lock and someone might have - * clean our vnode already, switching vnode lock from one in - * lowervp to v_lock in our own vnode structure. Handle this - * case by reacquiring correct lock in requested mode. - */ - if (VTONULL(vp) == NULL && error == 0) { - ap->a_flags &= ~LK_TYPE_MASK; - switch (flags & LK_TYPE_MASK) { - case LK_SHARED: - ap->a_flags |= LK_SHARED; - break; - case LK_UPGRADE: - case LK_EXCLUSIVE: - ap->a_flags |= LK_EXCLUSIVE; - break; - default: - panic("Unsupported lock request %d\n", - ap->a_flags); - } - VOP_UNLOCK(lvp); - error = vop_stdlock(ap); + if (VTONULL(ap->a_vp) == NULL && error == 0) { + flags = ap->a_flags; + ap->a_flags &= ~LK_TYPE_MASK; + switch (flags & LK_TYPE_MASK) { + case LK_SHARED: + ap->a_flags |= LK_SHARED; + break; + case LK_UPGRADE: + case LK_EXCLUSIVE: + ap->a_flags |= LK_EXCLUSIVE; + break; + default: + panic("Unsupported lock request %d\n", + flags); } - vdrop(lvp); - } else { - VI_UNLOCK(vp); + VOP_UNLOCK(lvp); error = vop_stdlock(ap); } - + vdrop(lvp); return (error); } -/* - * We need to process our own vnode unlock and then clear the - * interlock flag as it applies only to our vnode, not the - * vnodes below us on the stack. - */ static int null_unlock(struct vop_unlock_args *ap) { @@ -853,11 +884,20 @@ null_unlock(struct vop_unlock_args *ap) struct vnode *lvp; int error; + /* + * Contrary to null_lock, we don't need to hold the vnode around + * unlock. + * + * We hold the lock, which means we can't be racing against vgone. + * + * At the same time VOP_UNLOCK promises to not touch anything after + * it finishes unlock, just like we don't. + * + * vop_stdunlock for a doomed vnode matches doomed locking in null_lock. + */ nn = VTONULL(vp); if (nn != NULL && (lvp = NULLVPTOLOWERVP(vp)) != NULL) { - vholdnz(lvp); error = VOP_UNLOCK(lvp); - vdrop(lvp); } else { error = vop_stdunlock(ap); } @@ -961,7 +1001,7 @@ null_reclaim(struct vop_reclaim_args *ap) vunref(lowervp); else vput(lowervp); - free(xp, M_NULLFSNODE); + uma_zfree_smr(null_node_zone, xp); return (0); } diff --git a/sys/fs/p9fs/p9fs_vfsops.c b/sys/fs/p9fs/p9fs_vfsops.c index e0e91e7e1709..953e6eda547a 100644 --- a/sys/fs/p9fs/p9fs_vfsops.c +++ b/sys/fs/p9fs/p9fs_vfsops.c @@ -287,7 +287,7 @@ p9fs_vget_common(struct mount *mp, struct p9fs_node *np, int flags, node->flags |= P9FS_NODE_DELETED; vput(vp); - *vpp = NULLVP; + *vpp = NULL; vp = NULL; } else { *vpp = vp; @@ -308,7 +308,7 @@ p9fs_vget_common(struct mount *mp, struct p9fs_node *np, int flags, /* Allocate a new vnode. */ if ((error = getnewvnode("p9fs", mp, &p9fs_vnops, &vp)) != 0) { - *vpp = NULLVP; + *vpp = NULL; P9_DEBUG(ERROR, "%s: getnewvnode failed: %d\n", __func__, error); return (error); } @@ -397,7 +397,7 @@ out: vput(vp); } - *vpp = NULLVP; + *vpp = NULL; return (error); } @@ -525,14 +525,14 @@ p9fs_root(struct mount *mp, int lkflags, struct vnode **vpp) if (vfid == NULL && clnt->trans_status == P9FS_BEGIN_DISCONNECT) vfid = vmp->p9fs_session.mnt_fid; else { - *vpp = NULLVP; + *vpp = NULL; return (error); } } error = p9fs_vget_common(mp, np, lkflags, np, vfid, vpp, NULL); if (error != 0) { - *vpp = NULLVP; + *vpp = NULL; return (error); } np->v_node = *vpp; diff --git a/sys/fs/p9fs/p9fs_vnops.c b/sys/fs/p9fs/p9fs_vnops.c index 227e2b93883e..2ed1be82b57f 100644 --- a/sys/fs/p9fs/p9fs_vnops.c +++ b/sys/fs/p9fs/p9fs_vnops.c @@ -233,7 +233,7 @@ p9fs_lookup(struct vop_lookup_args *ap) dnp = P9FS_VTON(dvp); error = 0; flags = cnp->cn_flags; - *vpp = NULLVP; + *vpp = NULL; if (dnp == NULL) return (ENOENT); @@ -329,7 +329,7 @@ p9fs_lookup(struct vop_lookup_args *ap) else vrele(vp); - *vpp = NULLVP; + *vpp = NULL; } else if (error == ENOENT) { if (VN_IS_DOOMED(dvp)) goto out; @@ -341,7 +341,7 @@ p9fs_lookup(struct vop_lookup_args *ap) } /* Reset values */ error = 0; - vp = NULLVP; + vp = NULL; tmpchr = cnp->cn_nameptr[cnp->cn_namelen]; cnp->cn_nameptr[cnp->cn_namelen] = '\0'; @@ -1326,7 +1326,7 @@ p9fs_read(struct vop_read_args *ap) np = P9FS_VTON(vp); error = 0; - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); if (vp->v_type != VREG) return (EISDIR); diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c index ab60ba47f322..cd66dd6f8b3b 100644 --- a/sys/fs/procfs/procfs.c +++ b/sys/fs/procfs/procfs.c @@ -156,42 +156,42 @@ procfs_init(PFS_INIT_ARGS) root = pi->pi_root; - pfs_create_link(root, "curproc", procfs_docurproc, - NULL, NULL, NULL, 0); - pfs_create_link(root, "self", procfs_docurproc, - NULL, NULL, NULL, 0); - - dir = pfs_create_dir(root, "pid", - procfs_attr_all_rx, NULL, NULL, PFS_PROCDEP); - pfs_create_file(dir, "cmdline", procfs_doproccmdline, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "dbregs", procfs_doprocdbregs, + pfs_create_link(root, NULL, "curproc", procfs_docurproc, NULL, NULL, + NULL, 0); + pfs_create_link(root, NULL, "self", procfs_docurproc, NULL, NULL, NULL, + 0); + + pfs_create_dir(root, &dir, "pid", procfs_attr_all_rx, NULL, NULL, + PFS_PROCDEP); + pfs_create_file(dir, NULL, "cmdline", procfs_doproccmdline, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "dbregs", procfs_doprocdbregs, procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "etype", procfs_doproctype, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "fpregs", procfs_doprocfpregs, + pfs_create_file(dir, NULL, "etype", procfs_doproctype, NULL, NULL, NULL, + PFS_RD); + pfs_create_file(dir, NULL, "fpregs", procfs_doprocfpregs, procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "map", procfs_doprocmap, - NULL, procfs_notsystem, NULL, PFS_RD); - pfs_create_file(dir, "mem", procfs_doprocmem, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "note", procfs_doprocnote, - procfs_attr_w, procfs_candebug, NULL, PFS_WR); - pfs_create_file(dir, "notepg", procfs_doprocnote, - procfs_attr_w, procfs_candebug, NULL, PFS_WR); - pfs_create_file(dir, "regs", procfs_doprocregs, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR | PFS_RAW); - pfs_create_file(dir, "rlimit", procfs_doprocrlimit, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "status", procfs_doprocstatus, - NULL, NULL, NULL, PFS_RD); - pfs_create_file(dir, "osrel", procfs_doosrel, - procfs_attr_rw, procfs_candebug, NULL, PFS_RDWR); - - pfs_create_link(dir, "file", procfs_doprocfile, - NULL, procfs_notsystem, NULL, 0); - pfs_create_link(dir, "exe", procfs_doprocfile, - NULL, procfs_notsystem, NULL, 0); + pfs_create_file(dir, NULL, "map", procfs_doprocmap, NULL, + procfs_notsystem, NULL, PFS_RD); + pfs_create_file(dir, NULL, "mem", procfs_doprocmem, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR | PFS_RAW); + pfs_create_file(dir, NULL, "note", procfs_doprocnote, procfs_attr_w, + procfs_candebug, NULL, PFS_WR); + pfs_create_file(dir, NULL, "notepg", procfs_doprocnote, procfs_attr_w, + procfs_candebug, NULL, PFS_WR); + pfs_create_file(dir, NULL, "regs", procfs_doprocregs, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR | PFS_RAW); + pfs_create_file(dir, NULL, "rlimit", procfs_doprocrlimit, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "status", procfs_doprocstatus, NULL, NULL, + NULL, PFS_RD); + pfs_create_file(dir, NULL, "osrel", procfs_doosrel, procfs_attr_rw, + procfs_candebug, NULL, PFS_RDWR); + + pfs_create_link(dir, NULL, "file", procfs_doprocfile, NULL, + procfs_notsystem, NULL, 0); + pfs_create_link(dir, NULL, "exe", procfs_doprocfile, NULL, + procfs_notsystem, NULL, 0); return (0); } diff --git a/sys/fs/procfs/procfs_status.c b/sys/fs/procfs/procfs_status.c index 38070e0946bb..49c084d02ff8 100644 --- a/sys/fs/procfs/procfs_status.c +++ b/sys/fs/procfs/procfs_status.c @@ -141,13 +141,9 @@ procfs_doprocstatus(PFS_FILL_ARGS) (u_long)cr->cr_uid, (u_long)cr->cr_ruid, (u_long)cr->cr_rgid); - - /* egid (cr->cr_svgid) is equal to cr_ngroups[0] - see also getegid(2) in /sys/kern/kern_prot.c */ - - for (i = 0; i < cr->cr_ngroups; i++) { + sbuf_printf(sb, ",%lu", (u_long)cr->cr_gid); + for (i = 0; i < cr->cr_ngroups; i++) sbuf_printf(sb, ",%lu", (u_long)cr->cr_groups[i]); - } if (jailed(cr)) { mtx_lock(&cr->cr_prison->pr_mtx); diff --git a/sys/fs/pseudofs/pseudofs.c b/sys/fs/pseudofs/pseudofs.c index ef45f96a6192..7a4e67455214 100644 --- a/sys/fs/pseudofs/pseudofs.c +++ b/sys/fs/pseudofs/pseudofs.c @@ -133,7 +133,7 @@ pfs_add_node(struct pfs_node *parent, struct pfs_node *pn) for (iter = parent->pn_nodes; iter != NULL; iter = iter->pn_next) { if (strcmp(pn->pn_name, iter->pn_name) != 0) continue; - printf("pfs_add_node: homonymous siblings: '%s/%s' type %d", + printf("pfs_add_node: homonymous siblings: '%s/%s' type %d\n", parent->pn_name, pn->pn_name, pn->pn_type); /* Do not detach, because we are not yet attached. */ pn->pn_parent = NULL; @@ -234,81 +234,101 @@ pfs_fixup_dir(struct pfs_node *parent) /* * Create a directory */ -struct pfs_node * -pfs_create_dir(struct pfs_node *parent, const char *name, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_dir(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags) { - struct pfs_node *pn; + struct pfs_node *pdir, *pn; int rc; - pn = pfs_alloc_node_flags(parent->pn_info, name, + /* Preserve in case the caller is reusing the one pointer for both. */ + pdir = parent; + if (opn != NULL) + *opn = NULL; + pn = pfs_alloc_node_flags(pdir->pn_info, name, (flags & PFS_PROCDEP) ? pfstype_procdir : pfstype_dir, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - rc = pfs_add_node(parent, pn); + rc = pfs_add_node(pdir, pn); if (rc == 0) rc = pfs_fixup_dir_flags(pn, flags); if (rc != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + + return (rc); } /* * Create a file */ -struct pfs_node * -pfs_create_file(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_file(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, pfs_attr_t attr, + pfs_vis_t vis, pfs_destroy_t destroy, int flags) { struct pfs_node *pn; + int rc; + if (opn != NULL) + *opn = NULL; pn = pfs_alloc_node_flags(parent->pn_info, name, pfstype_file, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); + pn->pn_fill = fill; pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - if (pfs_add_node(parent, pn) != 0) { + if ((rc = pfs_add_node(parent, pn)) != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + + return (rc); } /* * Create a symlink */ -struct pfs_node * -pfs_create_link(struct pfs_node *parent, const char *name, pfs_fill_t fill, - pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, - int flags) +int +pfs_create_link(struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, pfs_attr_t attr, + pfs_vis_t vis, pfs_destroy_t destroy, int flags) { struct pfs_node *pn; + int rc; + if (opn != NULL) + *opn = NULL; pn = pfs_alloc_node_flags(parent->pn_info, name, pfstype_symlink, flags); if (pn == NULL) - return (NULL); + return (ENOMEM); + pn->pn_fill = fill; pn->pn_attr = attr; pn->pn_vis = vis; pn->pn_destroy = destroy; pn->pn_flags = flags; - if (pfs_add_node(parent, pn) != 0) { + if ((rc = pfs_add_node(parent, pn)) != 0) { pfs_destroy(pn); pn = NULL; + } else if (opn != NULL) { + *opn = pn; } - return (pn); + return (rc); } /* @@ -475,6 +495,7 @@ pfs_init(struct pfs_info *pi, struct vfsconf *vfc) if (error) { pfs_destroy(root); pi->pi_root = NULL; + pfs_fileno_uninit(pi); return (error); } diff --git a/sys/fs/pseudofs/pseudofs.h b/sys/fs/pseudofs/pseudofs.h index c60dd7b339d1..2b08dcad978d 100644 --- a/sys/fs/pseudofs/pseudofs.h +++ b/sys/fs/pseudofs/pseudofs.h @@ -255,17 +255,18 @@ int pfs_uninit (struct pfs_info *pi, struct vfsconf *vfc); /* * Directory structure construction and manipulation */ -struct pfs_node *pfs_create_dir (struct pfs_node *parent, const char *name, - pfs_attr_t attr, pfs_vis_t vis, - pfs_destroy_t destroy, int flags); -struct pfs_node *pfs_create_file(struct pfs_node *parent, const char *name, - pfs_fill_t fill, pfs_attr_t attr, - pfs_vis_t vis, pfs_destroy_t destroy, - int flags); -struct pfs_node *pfs_create_link(struct pfs_node *parent, const char *name, - pfs_fill_t fill, pfs_attr_t attr, +int pfs_create_dir (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_attr_t attr, pfs_vis_t vis, pfs_destroy_t destroy, int flags); +int pfs_create_file (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, + pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags); +int pfs_create_link (struct pfs_node *parent, struct pfs_node **opn, + const char *name, pfs_fill_t fill, + pfs_attr_t attr, pfs_vis_t vis, + pfs_destroy_t destroy, int flags); struct pfs_node *pfs_find_node (struct pfs_node *parent, const char *name); void pfs_purge (struct pfs_node *pn); int pfs_destroy (struct pfs_node *pn); diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c index e58aced7f81b..4fd493f8b9d3 100644 --- a/sys/fs/pseudofs/pseudofs_vncache.c +++ b/sys/fs/pseudofs/pseudofs_vncache.c @@ -202,7 +202,7 @@ alloc: error = insmntque(*vpp, mp); if (error != 0) { free(pvd, M_PFSVNCACHE); - *vpp = NULLVP; + *vpp = NULL; return (error); } vn_set_state(*vpp, VSTATE_CONSTRUCTED); diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index 8cd092118d0e..a30b5e4f551d 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -485,7 +485,7 @@ pfs_lookup(struct vop_cachedlookup_args *va) if (namelen == 1 && pname[0] == '.') { pn = pd; *vpp = vn; - VREF(vn); + vref(vn); PFS_RETURN (0); } diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 63b249c93771..e960d8d78b66 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -1121,13 +1121,13 @@ smbfs_lookup(struct vop_lookup_args *ap) vput(vp); else vrele(vp); - *vpp = NULLVP; + *vpp = NULL; } /* * entry is not in the cache or has been expired */ error = 0; - *vpp = NULLVP; + *vpp = NULL; scred = smbfs_malloc_scred(); smb_makescred(scred, td, cnp->cn_cred); fap = &fattr; @@ -1174,7 +1174,7 @@ smbfs_lookup(struct vop_lookup_args *ap) if (error) goto out; if (isdot) { - VREF(dvp); + vref(dvp); *vpp = dvp; goto out; } diff --git a/sys/fs/tarfs/tarfs_vfsops.c b/sys/fs/tarfs/tarfs_vfsops.c index a534b18ebf34..4cc70e4d5781 100644 --- a/sys/fs/tarfs/tarfs_vfsops.c +++ b/sys/fs/tarfs/tarfs_vfsops.c @@ -1201,7 +1201,7 @@ tarfs_vget(struct mount *mp, ino_t ino, int lkflags, struct vnode **vpp) return (0); bad: - *vpp = NULLVP; + *vpp = NULL; return (error); } @@ -1220,7 +1220,7 @@ tarfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) error = VFS_VGET(mp, tfp->ino, LK_EXCLUSIVE, &nvp); if (error != 0) { - *vpp = NULLVP; + *vpp = NULL; return (error); } tnp = VP_TO_TARFS_NODE(nvp); @@ -1228,7 +1228,7 @@ tarfs_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) tnp->gen != tfp->gen || tnp->nlink <= 0) { vput(nvp); - *vpp = NULLVP; + *vpp = NULL; return (ESTALE); } *vpp = nvp; diff --git a/sys/fs/tarfs/tarfs_vnops.c b/sys/fs/tarfs/tarfs_vnops.c index afb8e05f5929..70fd7a441d81 100644 --- a/sys/fs/tarfs/tarfs_vnops.c +++ b/sys/fs/tarfs/tarfs_vnops.c @@ -208,8 +208,7 @@ tarfs_getattr(struct vop_getattr_args *ap) vap->va_birthtime = tnp->birthtime; vap->va_gen = tnp->gen; vap->va_flags = tnp->flags; - vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ? - tnp->rdev : NODEV; + vap->va_rdev = VN_ISDEV(vp) ? tnp->rdev : NODEV; vap->va_bytes = round_page(tnp->physize); vap->va_filerev = 0; @@ -232,7 +231,7 @@ tarfs_lookup(struct vop_cachedlookup_args *ap) vpp = ap->a_vpp; cnp = ap->a_cnp; - *vpp = NULLVP; + *vpp = NULL; dirnode = VP_TO_TARFS_NODE(dvp); parent = dirnode->parent; tmp = dirnode->tmp; @@ -257,7 +256,7 @@ tarfs_lookup(struct vop_cachedlookup_args *ap) if (error != 0) return (error); } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { - VREF(dvp); + vref(dvp); *vpp = dvp; #ifdef TARFS_DEBUG } else if (dirnode == dirnode->tmp->root && @@ -335,6 +334,10 @@ tarfs_readdir(struct vop_readdir_args *ap) tnp, tnp->name, uio->uio_offset, uio->uio_resid); if (uio->uio_offset == TARFS_COOKIE_EOF) { + if (eofflag != NULL) { + TARFS_DPF(VNODE, "%s: Setting EOF flag\n", __func__); + *eofflag = 1; + } TARFS_DPF(VNODE, "%s: EOF\n", __func__); return (0); } @@ -515,7 +518,7 @@ tarfs_read(struct vop_read_args *ap) uiop = ap->a_uio; vp = ap->a_vp; - if (vp->v_type == VCHR || vp->v_type == VBLK) + if (VN_ISDEV(vp)) return (EOPNOTSUPP); if (vp->v_type != VREG) @@ -582,7 +585,7 @@ tarfs_reclaim(struct vop_reclaim_args *ap) vfs_hash_remove(vp); TARFS_NODE_LOCK(tnp); - tnp->vnode = NULLVP; + tnp->vnode = NULL; vp->v_data = NULL; TARFS_NODE_UNLOCK(tnp); diff --git a/sys/fs/tmpfs/tmpfs_subr.c b/sys/fs/tmpfs/tmpfs_subr.c index 1237f6b92cdb..dd281d18d87d 100644 --- a/sys/fs/tmpfs/tmpfs_subr.c +++ b/sys/fs/tmpfs/tmpfs_subr.c @@ -551,7 +551,7 @@ tmpfs_alloc_node(struct mount *mp, struct tmpfs_mount *tmp, __enum_uint8(vtype) MPASS(IMPLIES(tmp->tm_root == NULL, parent == NULL && type == VDIR)); MPASS((type == VLNK) ^ (target == NULL)); - MPASS((type == VBLK || type == VCHR) ^ (rdev == VNOVAL)); + MPASS(VTYPE_ISDEV(type) ^ (rdev == VNOVAL)); if (tmp->tm_nodes_inuse >= tmp->tm_nodes_max) return (ENOSPC); diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index 79b6c8b2e6a1..5082ee1ebdd0 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -98,7 +98,7 @@ tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) /* Caller assumes responsibility for ensuring access (VEXEC). */ dnode = VP_TO_TMPFS_DIR(dvp); - *vpp = NULLVP; + *vpp = NULL; /* We cannot be requesting the parent directory of the root node. */ MPASS(IMPLIES(dnode->tn_type == VDIR && @@ -120,7 +120,7 @@ tmpfs_lookup1(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp) if (error != 0) goto out; } else if (cnp->cn_namelen == 1 && cnp->cn_nameptr[0] == '.') { - VREF(dvp); + vref(dvp); *vpp = dvp; error = 0; } else { @@ -222,7 +222,7 @@ out: * locked. */ if (error == 0) { - MPASS(*vpp != NULLVP); + MPASS(*vpp != NULL); ASSERT_VOP_LOCKED(*vpp, __func__); } else { MPASS(*vpp == NULL); @@ -280,8 +280,7 @@ tmpfs_mknod(struct vop_mknod_args *v) struct componentname *cnp = v->a_cnp; struct vattr *vap = v->a_vap; - if (vap->va_type != VBLK && vap->va_type != VCHR && - vap->va_type != VFIFO) + if (!VATTR_ISDEV(vap) && vap->va_type != VFIFO) return (EINVAL); return (tmpfs_alloc_file(dvp, vpp, vap, cnp, NULL)); @@ -462,8 +461,7 @@ tmpfs_stat(struct vop_stat_args *v) sb->st_nlink = node->tn_links; sb->st_uid = node->tn_uid; sb->st_gid = node->tn_gid; - sb->st_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ? - node->tn_rdev : NODEV; + sb->st_rdev = VN_ISDEV(vp) ? node->tn_rdev : NODEV; sb->st_size = node->tn_size; sb->st_atim.tv_sec = node->tn_atime.tv_sec; sb->st_atim.tv_nsec = node->tn_atime.tv_nsec; @@ -521,8 +519,7 @@ tmpfs_getattr(struct vop_getattr_args *v) vap->va_birthtime = node->tn_birthtime; vap->va_gen = node->tn_gen; vap->va_flags = node->tn_flags; - vap->va_rdev = (vp->v_type == VBLK || vp->v_type == VCHR) ? - node->tn_rdev : NODEV; + vap->va_rdev = VN_ISDEV(vp) ? node->tn_rdev : NODEV; if (vp->v_type == VREG) { #ifdef __ILP32__ vm_object_t obj = node->tn_reg.tn_aobj; @@ -1918,7 +1915,7 @@ tmpfs_deleteextattr(struct vop_deleteextattr_args *ap) node = VP_TO_TMPFS_NODE(vp); tmp = VFS_TO_TMPFS(vp->v_mount); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); @@ -1956,7 +1953,7 @@ tmpfs_getextattr(struct vop_getextattr_args *ap) int error; node = VP_TO_TMPFS_NODE(vp); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VREAD); @@ -1993,7 +1990,7 @@ tmpfs_listextattr(struct vop_listextattr_args *ap) int error; node = VP_TO_TMPFS_NODE(vp); - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VREAD); @@ -2037,7 +2034,7 @@ tmpfs_setextattr(struct vop_setextattr_args *ap) tmp = VFS_TO_TMPFS(vp->v_mount); attr_size = ap->a_uio->uio_resid; diff = 0; - if (ap->a_vp->v_type == VCHR || ap->a_vp->v_type == VBLK) + if (VN_ISDEV(ap->a_vp)) return (EOPNOTSUPP); error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, ap->a_cred, ap->a_td, VWRITE); diff --git a/sys/fs/udf/udf_vfsops.c b/sys/fs/udf/udf_vfsops.c index c5ef1f686093..c1627285a174 100644 --- a/sys/fs/udf/udf_vfsops.c +++ b/sys/fs/udf/udf_vfsops.c @@ -736,14 +736,14 @@ udf_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp) ifhp = (struct ifid *)fhp; if ((error = VFS_VGET(mp, ifhp->ifid_ino, LK_EXCLUSIVE, &nvp)) != 0) { - *vpp = NULLVP; + *vpp = NULL; return (error); } np = VTON(nvp); fsize = le64toh(np->fentry->inf_len); if (fsize > OFF_MAX) { - *vpp = NULLVP; + *vpp = NULL; return (EIO); } diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 37889241e8c3..ec61618b6e18 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -1226,7 +1226,7 @@ lookloop: if (flags & ISDOTDOT) { error = vn_vget_ino(dvp, id, lkflags, &tdp); } else if (node->hash_id == id) { - VREF(dvp); /* we want ourself, ie "." */ + vref(dvp); /* we want ourself, ie "." */ /* * When we lookup "." we still can be asked to lock it * differently. diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index edcc6716b674..a14f9ca74305 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -160,7 +160,7 @@ unionfs_get_cached_vnode_locked(struct vnode *lookup, struct vnode *dvp) if (VN_IS_DOOMED(vp) || ((vp->v_iflag & VI_DOINGINACT) != 0)) { VI_UNLOCK(vp); - vp = NULLVP; + vp = NULL; } else { vrefl(vp); VI_UNLOCK(vp); @@ -169,7 +169,7 @@ unionfs_get_cached_vnode_locked(struct vnode *lookup, struct vnode *dvp) } } - return (NULLVP); + return (NULL); } @@ -182,11 +182,11 @@ unionfs_get_cached_vnode(struct vnode *uvp, struct vnode *lvp, { struct vnode *vp; - vp = NULLVP; + vp = NULL; VI_LOCK(dvp); - if (uvp != NULLVP) + if (uvp != NULL) vp = unionfs_get_cached_vnode_locked(uvp, dvp); - else if (lvp != NULLVP) + else if (lvp != NULL) vp = unionfs_get_cached_vnode_locked(lvp, dvp); VI_UNLOCK(dvp); @@ -203,22 +203,22 @@ unionfs_ins_cached_vnode(struct unionfs_node *uncp, struct unionfs_node_hashhead *hd; struct vnode *vp; - vp = NULLVP; + vp = NULL; VI_LOCK(dvp); - if (uncp->un_uppervp != NULLVP) { + if (uncp->un_uppervp != NULL) { ASSERT_VOP_ELOCKED(uncp->un_uppervp, __func__); KASSERT(uncp->un_uppervp->v_type == VDIR, ("%s: v_type != VDIR", __func__)); vp = unionfs_get_cached_vnode_locked(uncp->un_uppervp, dvp); - } else if (uncp->un_lowervp != NULLVP) { + } else if (uncp->un_lowervp != NULL) { ASSERT_VOP_ELOCKED(uncp->un_lowervp, __func__); KASSERT(uncp->un_lowervp->v_type == VDIR, ("%s: v_type != VDIR", __func__)); vp = unionfs_get_cached_vnode_locked(uncp->un_lowervp, dvp); } - if (vp == NULLVP) { - hd = unionfs_get_hashhead(dvp, (uncp->un_uppervp != NULLVP ? - uncp->un_uppervp : uncp->un_lowervp)); + if (vp == NULL) { + hd = unionfs_get_hashhead(dvp, (uncp->un_uppervp != NULL ? + uncp->un_uppervp : uncp->un_lowervp)); LIST_INSERT_HEAD(hd, uncp, un_hash); } VI_UNLOCK(dvp); @@ -233,8 +233,8 @@ static void unionfs_rem_cached_vnode(struct unionfs_node *unp, struct vnode *dvp) { KASSERT(unp != NULL, ("%s: null node", __func__)); - KASSERT(dvp != NULLVP, - ("%s: null parent vnode", __func__)); + KASSERT(dvp != NULL, + ("%s: null parent vnode", __func__)); VI_LOCK(dvp); if (unp->un_hash.le_prev != NULL) { @@ -274,13 +274,13 @@ unionfs_nodeget_cleanup(struct vnode *vp, struct unionfs_node *unp) vgone(vp); vput(vp); - if (unp->un_dvp != NULLVP) + if (unp->un_dvp != NULL) vrele(unp->un_dvp); - if (unp->un_uppervp != NULLVP) { + if (unp->un_uppervp != NULL) { vput(unp->un_uppervp); - if (unp->un_lowervp != NULLVP) + if (unp->un_lowervp != NULL) vrele(unp->un_lowervp); - } else if (unp->un_lowervp != NULLVP) + } else if (unp->un_lowervp != NULL) vput(unp->un_lowervp); if (unp->un_hashtbl != NULL) hashdestroy(unp->un_hashtbl, M_UNIONFSHASH, UNIONFSHASHMASK); @@ -313,21 +313,21 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, ump = MOUNTTOUNIONFSMOUNT(mp); lkflags = (cnp ? cnp->cn_lkflags : 0); path = (cnp ? cnp->cn_nameptr : NULL); - *vpp = NULLVP; + *vpp = NULL; - if (uppervp == NULLVP && lowervp == NULLVP) + if (uppervp == NULL && lowervp == NULL) panic("%s: upper and lower are both null", __func__); - vt = (uppervp != NULLVP ? uppervp->v_type : lowervp->v_type); + vt = (uppervp != NULL ? uppervp->v_type : lowervp->v_type); /* If it has no ISLASTCN flag, path check is skipped. */ if (cnp && !(cnp->cn_flags & ISLASTCN)) path = NULL; /* check the cache */ - if (dvp != NULLVP && vt == VDIR) { + if (dvp != NULL && vt == VDIR) { vp = unionfs_get_cached_vnode(uppervp, lowervp, dvp); - if (vp != NULLVP) { + if (vp != NULL) { *vpp = vp; if (lkflags != 0) vn_lock(*vpp, lkflags | LK_RETRY); @@ -343,11 +343,11 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, free(unp, M_UNIONFSNODE); return (error); } - if (dvp != NULLVP) + if (dvp != NULL) vref(dvp); - if (uppervp != NULLVP) + if (uppervp != NULL) vref(uppervp); - if (lowervp != NULLVP) + if (lowervp != NULL) vref(lowervp); if (vt == VDIR) { @@ -361,7 +361,7 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, unp->un_uppervp = uppervp; unp->un_lowervp = lowervp; unp->un_dvp = dvp; - if (uppervp != NULLVP) + if (uppervp != NULL) vp->v_vnlock = uppervp->v_vnlock; else vp->v_vnlock = lowervp->v_vnlock; @@ -407,7 +407,7 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, * possibility of deadlock due to some other agent on the system * attempting to lock those two specific vnodes in the opposite order. */ - if (uppervp != NULLVP) + if (uppervp != NULL) vn_lock(uppervp, LK_EXCLUSIVE | LK_RETRY); else vn_lock(lowervp, LK_EXCLUSIVE | LK_RETRY); @@ -426,16 +426,16 @@ unionfs_nodeget(struct mount *mp, struct vnode *uppervp, * blocked on our vnode lock, effectively also preventing unmount * of the underlying filesystems. */ - VNASSERT(lowervp == NULLVP || !VN_IS_DOOMED(lowervp), vp, + VNASSERT(lowervp == NULL || !VN_IS_DOOMED(lowervp), vp, ("%s: doomed lowervp %p", __func__, lowervp)); - VNASSERT(uppervp == NULLVP || !VN_IS_DOOMED(uppervp), vp, + VNASSERT(uppervp == NULL || !VN_IS_DOOMED(uppervp), vp, ("%s: doomed lowervp %p", __func__, uppervp)); vn_set_state(vp, VSTATE_CONSTRUCTED); - if (dvp != NULLVP && vt == VDIR) + if (dvp != NULL && vt == VDIR) *vpp = unionfs_ins_cached_vnode(unp, dvp); - if (*vpp != NULLVP) { + if (*vpp != NULL) { unionfs_nodeget_cleanup(vp, unp); if (lkflags != 0) vn_lock(*vpp, lkflags | LK_RETRY); @@ -484,7 +484,7 @@ unionfs_noderem(struct vnode *vp) lvp = unp->un_lowervp; uvp = unp->un_uppervp; dvp = unp->un_dvp; - unlock_lvp = (uvp == NULLVP); + unlock_lvp = (uvp == NULL); /* * Lock the lower vnode in addition to the upper vnode lock in order @@ -496,7 +496,7 @@ unionfs_noderem(struct vnode *vp) * Moreover, during unmount of a non-"below" unionfs mount, the lower * root vnode will already be locked as it is the covered vnode. */ - if (uvp != NULLVP && lvp != NULLVP && (vp->v_vflag & VV_ROOT) == 0) { + if (uvp != NULL && lvp != NULL && (vp->v_vflag & VV_ROOT) == 0) { vn_lock_pair(uvp, true, LK_EXCLUSIVE, lvp, false, LK_EXCLUSIVE); unlock_lvp = true; } @@ -508,7 +508,7 @@ unionfs_noderem(struct vnode *vp) * prevent faults in unionfs_lock(). */ VI_LOCK(vp); - unp->un_lowervp = unp->un_uppervp = NULLVP; + unp->un_lowervp = unp->un_uppervp = NULL; vp->v_vnlock = &(vp->v_lock); vp->v_data = NULL; vp->v_object = NULL; @@ -543,14 +543,14 @@ unionfs_noderem(struct vnode *vp) ("%s: write reference without upper vnode", __func__)); VOP_ADD_WRITECOUNT(uvp, -writerefs); } - if (uvp != NULLVP) + if (uvp != NULL) vput(uvp); if (unlock_lvp) vput(lvp); - else if (lvp != NULLVP) + else if (lvp != NULL) vrele(lvp); - if (dvp != NULLVP) + if (dvp != NULL) unionfs_rem_cached_vnode(unp, dvp); if (unp->un_path != NULL) { @@ -567,7 +567,7 @@ unionfs_noderem(struct vnode *vp) LIST_REMOVE(unsp, uns_list); free(unsp, M_TEMP); } - if (dvp != NULLVP) { + if (dvp != NULL) { mtx_lock(&unionfs_deferred_rele_lock); STAILQ_INSERT_TAIL(&unionfs_deferred_rele_list, unp, un_rele); mtx_unlock(&unionfs_deferred_rele_lock); @@ -793,7 +793,7 @@ unionfs_node_update(struct unionfs_node *unp, struct vnode *uvp, /* * Re-cache the unionfs vnode against the upper vnode */ - if (dvp != NULLVP && vp->v_type == VDIR) { + if (dvp != NULL && vp->v_type == VDIR) { VI_LOCK(dvp); if (unp->un_hash.le_prev != NULL) { LIST_REMOVE(unp, un_hash); @@ -841,7 +841,7 @@ unionfs_set_in_progress_flag(struct vnode *vp, unsigned int flag) if (unp == NULL) error = ENOENT; else if (flag == UNIONFS_COPY_IN_PROGRESS && - unp->un_uppervp != NULLVP) + unp->un_uppervp != NULL) error = EJUSTRETURN; else if (flag == UNIONFS_LOOKUP_IN_PROGRESS) error = ERELOOKUP; @@ -902,7 +902,7 @@ unionfs_mkshadowdir(struct vnode *dvp, struct vnode *vp, ASSERT_VOP_ELOCKED(vp, __func__); ump = MOUNTTOUNIONFSMOUNT(vp->v_mount); unp = VTOUNIONFS(vp); - if (unp->un_uppervp != NULLVP) + if (unp->un_uppervp != NULL) return (EEXIST); dunp = VTOUNIONFS(dvp); udvp = dunp->un_uppervp; @@ -914,7 +914,7 @@ unionfs_mkshadowdir(struct vnode *dvp, struct vnode *vp, return (error); lvp = unp->un_lowervp; - uvp = NULLVP; + uvp = NULL; credbk = cnp->cn_cred; /* Authority change to root */ @@ -953,7 +953,7 @@ unionfs_mkshadowdir(struct vnode *dvp, struct vnode *vp, vput(udvp); goto unionfs_mkshadowdir_relock; } - if (uvp != NULLVP) { + if (uvp != NULL) { if (udvp == uvp) vrele(uvp); else @@ -1218,7 +1218,7 @@ unionfs_mkwhiteout(struct vnode *dvp, struct vnode *vp, ASSERT_VOP_ELOCKED(vp, __func__); udvp = VTOUNIONFS(dvp)->un_uppervp; - wvp = NULLVP; + wvp = NULL; NDPREINIT(&nd); vref(udvp); VOP_UNLOCK(vp); @@ -1226,7 +1226,7 @@ unionfs_mkwhiteout(struct vnode *dvp, struct vnode *vp, pathlen, CREATE))) { goto unionfs_mkwhiteout_cleanup; } - if (wvp != NULLVP) { + if (wvp != NULL) { if (udvp == wvp) vrele(wvp); else @@ -1281,7 +1281,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, ASSERT_VOP_ELOCKED(vp, __func__); unp = VTOUNIONFS(vp); ump = MOUNTTOUNIONFSMOUNT(UNIONFSTOV(unp)->v_mount); - uvp = NULLVP; + uvp = NULL; lvp = unp->un_lowervp; cred = td->td_ucred; fmode = FFLAGS(O_WRONLY | O_CREAT | O_TRUNC | O_EXCL); @@ -1310,7 +1310,7 @@ unionfs_vn_create_on_upper(struct vnode **vpp, struct vnode *udvp, return (error); } - if (uvp != NULLVP) { + if (uvp != NULL) { if (uvp == udvp) vrele(uvp); else @@ -1433,23 +1433,23 @@ unionfs_copyfile(struct vnode *vp, int docopy, struct ucred *cred, ASSERT_VOP_ELOCKED(vp, __func__); unp = VTOUNIONFS(vp); lvp = unp->un_lowervp; - uvp = NULLVP; + uvp = NULL; if ((UNIONFSTOV(unp)->v_mount->mnt_flag & MNT_RDONLY)) return (EROFS); - if (unp->un_dvp == NULLVP) + if (unp->un_dvp == NULL) return (EINVAL); - if (unp->un_uppervp != NULLVP) + if (unp->un_uppervp != NULL) return (EEXIST); - udvp = NULLVP; + udvp = NULL; VI_LOCK(unp->un_dvp); dunp = VTOUNIONFS(unp->un_dvp); if (dunp != NULL) udvp = dunp->un_uppervp; VI_UNLOCK(unp->un_dvp); - if (udvp == NULLVP) + if (udvp == NULL) return (EROFS); if ((udvp->v_mount->mnt_flag & MNT_RDONLY)) return (EROFS); @@ -1646,7 +1646,7 @@ unionfs_check_rmdir(struct vnode *vp, struct ucred *cred, struct thread *td) cn.cn_cred = cred; error = VOP_LOOKUP(uvp, &tvp, &cn); - if (tvp != NULLVP) + if (tvp != NULL) vput(tvp); if (error != 0 && error != ENOENT && error != EJUSTRETURN) break; diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index 9342317ad08e..284b24a604f4 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -256,7 +256,7 @@ unionfs_domount(struct mount *mp) ump->um_lowervp = lowerrootvp; ump->um_uppervp = upperrootvp; } - ump->um_rootvp = NULLVP; + ump->um_rootvp = NULL; ump->um_uid = uid; ump->um_gid = gid; ump->um_udir = udir; @@ -280,7 +280,7 @@ unionfs_domount(struct mount *mp) * Get the unionfs root vnode. */ error = unionfs_nodeget(mp, ump->um_uppervp, ump->um_lowervp, - NULLVP, &(ump->um_rootvp), NULL); + NULL, &(ump->um_rootvp), NULL); if (error != 0) { vrele(upperrootvp); free(ump, M_UNIONFSMNT); @@ -558,7 +558,7 @@ unionfs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp, ump = MOUNTTOUNIONFSMOUNT(mp); unp = VTOUNIONFS(filename_vp); - if (unp->un_uppervp != NULLVP) { + if (unp->un_uppervp != NULL) { return (VFS_EXTATTRCTL(ump->um_uppermp, cmd, unp->un_uppervp, namespace, attrname)); } else { diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 03130f0ca949..627b2f6e9a1d 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -114,9 +114,9 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) dunp = VTOUNIONFS(dvp); udvp = dunp->un_uppervp; ldvp = dunp->un_lowervp; - vp = uvp = lvp = NULLVP; + vp = uvp = lvp = NULL; td = curthread; - *(ap->a_vpp) = NULLVP; + *(ap->a_vpp) = NULL; UNIONFS_INTERNAL_DEBUG( "unionfs_lookup: enter: nameiop=%ld, flags=%lx, path=%s\n", @@ -159,7 +159,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) * lookup dotdot */ if (cnflags & ISDOTDOT) { - if (LOOKUP != nameiop && udvp == NULLVP) { + if (LOOKUP != nameiop && udvp == NULL) { error = EROFS; goto unionfs_lookup_return; } @@ -170,7 +170,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) goto unionfs_lookup_return; } - if (udvp != NULLVP) + if (udvp != NULL) dtmpvp = udvp; else dtmpvp = ldvp; @@ -186,7 +186,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) * reference, or (if dvp was reclaimed) we'll need to drop * vp's lock and reference to return early. */ - if (vp != NULLVP) + if (vp != NULL) vput(vp); dunp = VTOUNIONFS(dvp); if (error == 0 && dunp == NULL) @@ -202,7 +202,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) if (VN_IS_DOOMED(dtmpvp)) { vput(dtmpvp); - *(ap->a_vpp) = NULLVP; + *(ap->a_vpp) = NULL; error = ENOENT; } vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); @@ -219,11 +219,11 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) * The cost of this is that we may end up performing an unnecessary * lower layer lookup if a whiteout is present in the upper layer. */ - if (ldvp != NULLVP && !(cnflags & DOWHITEOUT)) { + if (ldvp != NULL && !(cnflags & DOWHITEOUT)) { struct componentname lcn; bool is_dot; - if (udvp != NULLVP) { + if (udvp != NULL) { vref(ldvp); VOP_UNLOCK(dvp); vn_lock(ldvp, LK_EXCLUSIVE | LK_RETRY); @@ -235,18 +235,18 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) lcn.cn_flags = cnflags; is_dot = false; - if (udvp == NULLVP) + if (udvp == NULL) unionfs_forward_vop_start(ldvp, &lkflags); lerror = VOP_LOOKUP(ldvp, &lvp, &lcn); - if (udvp == NULLVP && + if (udvp == NULL && unionfs_forward_vop_finish(dvp, ldvp, lkflags)) { - if (lvp != NULLVP) + if (lvp != NULL) VOP_UNLOCK(lvp); error = ENOENT; goto unionfs_lookup_cleanup; } - if (udvp == NULLVP) + if (udvp == NULL) cnp->cn_flags = lcn.cn_flags; if (lerror == 0) { @@ -256,11 +256,11 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) vref(dvp); is_dot = true; error = lerror; - } else if (lvp != NULLVP) + } else if (lvp != NULL) VOP_UNLOCK(lvp); } - if (udvp != NULLVP) { + if (udvp != NULL) { vput(ldvp); vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY); if (VN_IS_DOOMED(dvp)) @@ -274,13 +274,13 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) /* * lookup upper layer */ - if (udvp != NULLVP) { + if (udvp != NULL) { bool iswhiteout = false; unionfs_forward_vop_start(udvp, &lkflags); uerror = VOP_LOOKUP(udvp, &uvp, cnp); if (unionfs_forward_vop_finish(dvp, udvp, lkflags)) { - if (uvp != NULLVP) + if (uvp != NULL) VOP_UNLOCK(uvp); error = ENOENT; goto unionfs_lookup_cleanup; @@ -288,7 +288,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) if (uerror == 0) { if (udvp == uvp) { /* is dot */ - if (lvp != NULLVP) + if (lvp != NULL) vrele(lvp); vrele(uvp); *(ap->a_vpp) = dvp; @@ -296,7 +296,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) error = uerror; goto unionfs_lookup_return; - } else if (uvp != NULLVP) + } else if (uvp != NULL) VOP_UNLOCK(uvp); } @@ -308,9 +308,9 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) (va.va_flags & OPAQUE)) iswhiteout = true; - if (iswhiteout && lvp != NULLVP) { + if (iswhiteout && lvp != NULL) { vrele(lvp); - lvp = NULLVP; + lvp = NULL; } #if 0 @@ -323,29 +323,29 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) /* * check lookup result */ - if (uvp == NULLVP && lvp == NULLVP) { - error = (udvp != NULLVP ? uerror : lerror); + if (uvp == NULL && lvp == NULL) { + error = (udvp != NULL ? uerror : lerror); goto unionfs_lookup_return; } /* * check vnode type */ - if (uvp != NULLVP && lvp != NULLVP && uvp->v_type != lvp->v_type) { + if (uvp != NULL && lvp != NULL && uvp->v_type != lvp->v_type) { vrele(lvp); - lvp = NULLVP; + lvp = NULL; } /* * check shadow dir */ - if (uerror != 0 && uerror != EJUSTRETURN && udvp != NULLVP && - lerror == 0 && lvp != NULLVP && lvp->v_type == VDIR && + if (uerror != 0 && uerror != EJUSTRETURN && udvp != NULL && + lerror == 0 && lvp != NULL && lvp->v_type == VDIR && !(dvp->v_mount->mnt_flag & MNT_RDONLY) && (1 < cnp->cn_namelen || '.' != *(cnp->cn_nameptr))) { /* get unionfs vnode in order to create a new shadow dir. */ - error = unionfs_nodeget(dvp->v_mount, NULLVP, lvp, dvp, &vp, - cnp); + error = unionfs_nodeget(dvp->v_mount, NULL, lvp, dvp, &vp, + cnp); if (error != 0) goto unionfs_lookup_cleanup; @@ -382,7 +382,7 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) * get unionfs vnode. */ else { - if (uvp != NULLVP) + if (uvp != NULL) error = uerror; else error = lerror; @@ -409,14 +409,14 @@ unionfs_lookup(struct vop_cachedlookup_args *ap) cache_enter(dvp, vp, cnp); unionfs_lookup_cleanup: - if (uvp != NULLVP) + if (uvp != NULL) vrele(uvp); - if (lvp != NULLVP) + if (lvp != NULL) vrele(lvp); if (error == ENOENT && (cnflags & MAKEENTRY) != 0 && !VN_IS_DOOMED(dvp)) - cache_enter(dvp, NULLVP, cnp); + cache_enter(dvp, NULL, cnp); unionfs_lookup_return: unionfs_clear_in_progress_flag(dvp, UNIONFS_LOOKUP_IN_PROGRESS); @@ -444,7 +444,7 @@ unionfs_create(struct vop_create_args *ap) udvp = dunp->un_uppervp; error = EROFS; - if (udvp != NULLVP) { + if (udvp != NULL) { int lkflags; bool vp_created = false; unionfs_forward_vop_start(udvp, &lkflags); @@ -457,8 +457,8 @@ unionfs_create(struct vop_create_args *ap) } if (error == 0) { VOP_UNLOCK(vp); - error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, - ap->a_dvp, ap->a_vpp, cnp); + error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULL, + ap->a_dvp, ap->a_vpp, cnp); vrele(vp); } else if (vp_created) vput(vp); @@ -486,7 +486,7 @@ unionfs_whiteout(struct vop_whiteout_args *ap) udvp = dunp->un_uppervp; error = EOPNOTSUPP; - if (udvp != NULLVP) { + if (udvp != NULL) { int lkflags; switch (ap->a_flags) { case CREATE: @@ -525,7 +525,7 @@ unionfs_mknod(struct vop_mknod_args *ap) udvp = dunp->un_uppervp; error = EROFS; - if (udvp != NULLVP) { + if (udvp != NULL) { int lkflags; bool vp_created = false; unionfs_forward_vop_start(udvp, &lkflags); @@ -538,8 +538,8 @@ unionfs_mknod(struct vop_mknod_args *ap) } if (error == 0) { VOP_UNLOCK(vp); - error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULLVP, - ap->a_dvp, ap->a_vpp, cnp); + error = unionfs_nodeget(ap->a_dvp->v_mount, vp, NULL, + ap->a_dvp, ap->a_vpp, cnp); vrele(vp); } else if (vp_created) vput(vp); @@ -611,7 +611,7 @@ unionfs_lock_lvp(struct vnode *vp, int *lkflags) vn_lock(lvp, *lkflags | LK_RETRY); if (VN_IS_DOOMED(lvp)) { vput(lvp); - lvp = NULLVP; + lvp = NULL; vn_lock(vp, *lkflags | LK_RETRY); } return (lvp); @@ -656,7 +656,7 @@ unionfs_open(struct vop_open_args *ap) error = 0; vp = ap->a_vp; - targetvp = NULLVP; + targetvp = NULL; cred = ap->a_cred; td = ap->a_td; open_lvp = lock_lvp = false; @@ -686,10 +686,10 @@ unionfs_open(struct vop_open_args *ap) if (targetvp == lvp && (ap->a_mode & FWRITE) && lvp->v_type == VREG) - targetvp = NULLVP; + targetvp = NULL; } - if (targetvp == NULLVP) { - if (uvp == NULLVP) { + if (targetvp == NULL) { + if (uvp == NULL) { if ((ap->a_mode & FWRITE) && lvp->v_type == VREG) { error = unionfs_copyfile(vp, !(ap->a_mode & O_TRUNC), cred, td); @@ -704,16 +704,16 @@ unionfs_open(struct vop_open_args *ap) targetvp = uvp; } - if (targetvp == uvp && uvp->v_type == VDIR && lvp != NULLVP && + if (targetvp == uvp && uvp->v_type == VDIR && lvp != NULL && unsp->uns_lower_opencnt <= 0) open_lvp = true; - else if (targetvp == lvp && uvp != NULLVP) + else if (targetvp == lvp && uvp != NULL) lock_lvp = true; if (lock_lvp) { unp = NULL; lvp = unionfs_lock_lvp(vp, &lkflags); - if (lvp == NULLVP) { + if (lvp == NULL) { error = ENOENT; goto unionfs_open_abort; } @@ -736,7 +736,7 @@ unionfs_open(struct vop_open_args *ap) if (open_lvp) { unp = NULL; lvp = unionfs_lock_lvp(vp, &lkflags); - if (lvp == NULLVP) { + if (lvp == NULL) { error = ENOENT; goto unionfs_open_abort; } @@ -822,7 +822,7 @@ unionfs_close(struct vop_close_args *ap) if (unsp != NULL) printf("unionfs_close: warning: open count is 0\n"); #endif - if (uvp != NULLVP) + if (uvp != NULL) ovp = uvp; else ovp = lvp; @@ -831,11 +831,11 @@ unionfs_close(struct vop_close_args *ap) else ovp = lvp; - if (ovp == lvp && uvp != NULLVP) { + if (ovp == lvp && uvp != NULL) { lock_lvp = true; unp = NULL; lvp = unionfs_lock_lvp(vp, &lkflags); - if (lvp == NULLVP) { + if (lvp == NULL) { error = ENOENT; goto unionfs_close_abort; } @@ -861,7 +861,7 @@ unionfs_close(struct vop_close_args *ap) if (unsp->uns_node_flag & UNS_OPENL_4_READDIR) { unp = NULL; lvp = unionfs_lock_lvp(vp, &lkflags); - if (lvp == NULLVP) { + if (lvp == NULL) { error = ENOENT; goto unionfs_close_abort; } @@ -978,7 +978,7 @@ unionfs_access(struct vop_access_args *ap) } } - if (uvp != NULLVP) { + if (uvp != NULL) { error = VOP_ACCESS(uvp, accmode, ap->a_cred, td); UNIONFS_INTERNAL_DEBUG("unionfs_access: leave (%d)\n", error); @@ -986,7 +986,7 @@ unionfs_access(struct vop_access_args *ap) return (error); } - if (lvp != NULLVP) { + if (lvp != NULL) { if (accmode & VWRITE) { if ((ump->um_uppermp->mnt_flag & MNT_RDONLY) != 0) { switch (ap->a_vp->v_type) { @@ -1044,7 +1044,7 @@ unionfs_getattr(struct vop_getattr_args *ap) lvp = unp->un_lowervp; td = curthread; - if (uvp != NULLVP) { + if (uvp != NULL) { if ((error = VOP_GETATTR(uvp, ap->a_vap, ap->a_cred)) == 0) ap->a_vap->va_fsid = ap->a_vp->v_mount->mnt_stat.f_fsid.val[0]; @@ -1106,7 +1106,7 @@ unionfs_setattr(struct vop_setattr_args *ap) vap->va_mtime.tv_sec != VNOVAL || vap->va_mode != (mode_t)VNOVAL)) return (EROFS); - if (uvp == NULLVP && lvp->v_type == VREG) { + if (uvp == NULL && lvp->v_type == VREG) { error = unionfs_copyfile(ap->a_vp, (vap->va_size != 0), ap->a_cred, td); if (error != 0) @@ -1114,7 +1114,7 @@ unionfs_setattr(struct vop_setattr_args *ap) uvp = unp->un_uppervp; } - if (uvp != NULLVP) { + if (uvp != NULL) { int lkflags; unionfs_forward_vop_start(uvp, &lkflags); error = VOP_SETATTR(uvp, vap, ap->a_cred); @@ -1138,7 +1138,7 @@ unionfs_read(struct vop_read_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - tvp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + tvp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); error = VOP_READ(tvp, ap->a_uio, ap->a_ioflag, ap->a_cred); @@ -1160,7 +1160,7 @@ unionfs_write(struct vop_write_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - tvp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + tvp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); unionfs_forward_vop_start(tvp, &lkflags); error = VOP_WRITE(tvp, ap->a_uio, ap->a_ioflag, ap->a_cred); @@ -1190,7 +1190,7 @@ unionfs_ioctl(struct vop_ioctl_args *ap) unionfs_tryrem_node_status(unp, unsp); VOP_UNLOCK(ap->a_vp); - if (ovp == NULLVP) + if (ovp == NULL) return (EBADF); error = VOP_IOCTL(ovp, ap->a_command, ap->a_data, ap->a_fflag, @@ -1217,7 +1217,7 @@ unionfs_poll(struct vop_poll_args *ap) unionfs_tryrem_node_status(unp, unsp); VOP_UNLOCK(ap->a_vp); - if (ovp == NULLVP) + if (ovp == NULL) return (EBADF); return (VOP_POLL(ovp, ap->a_events, ap->a_cred, ap->a_td)); @@ -1246,7 +1246,7 @@ unionfs_fsync(struct vop_fsync_args *ap) unionfs_downgrade_lock(ap->a_vp, lkstatus); - if (ovp == NULLVP) + if (ovp == NULL) return (EBADF); unionfs_forward_vop_start(ovp, &lkflags); @@ -1289,20 +1289,20 @@ unionfs_remove(struct vop_remove_args *ap) path = unp->un_path; pathlen = unp->un_pathlen; - if (udvp == NULLVP) + if (udvp == NULL) return (EROFS); - if (uvp != NULLVP) { + if (uvp != NULL) { int udvp_lkflags, uvp_lkflags; if (ump == NULL || ump->um_whitemode == UNIONFS_WHITE_ALWAYS || - lvp != NULLVP) + lvp != NULL) cnp->cn_flags |= DOWHITEOUT; unionfs_forward_vop_start_pair(udvp, &udvp_lkflags, uvp, &uvp_lkflags); error = VOP_REMOVE(udvp, uvp, cnp); unionfs_forward_vop_finish_pair(ap->a_dvp, udvp, udvp_lkflags, ap->a_vp, uvp, uvp_lkflags); - } else if (lvp != NULLVP) { + } else if (lvp != NULL) { error = unionfs_mkwhiteout(ap->a_dvp, ap->a_vp, cnp, td, path, pathlen); } @@ -1332,16 +1332,16 @@ unionfs_link(struct vop_link_args *ap) dunp = VTOUNIONFS(ap->a_tdvp); unp = NULL; udvp = dunp->un_uppervp; - uvp = NULLVP; + uvp = NULL; cnp = ap->a_cnp; td = curthread; - if (udvp == NULLVP) + if (udvp == NULL) return (EROFS); unp = VTOUNIONFS(ap->a_vp); - if (unp->un_uppervp == NULLVP) { + if (unp->un_uppervp == NULL) { if (ap->a_vp->v_type != VREG) return (EOPNOTSUPP); @@ -1405,7 +1405,7 @@ unionfs_rename(struct vop_rename_args *ap) /* check for cross device rename */ if (fvp->v_mount != tdvp->v_mount || - (tvp != NULLVP && fvp->v_mount != tvp->v_mount)) { + (tvp != NULL && fvp->v_mount != tvp->v_mount)) { if (fvp->v_op != &unionfs_vnodeops) error = ENODEV; else @@ -1418,7 +1418,7 @@ unionfs_rename(struct vop_rename_args *ap) goto unionfs_rename_abort; KASSERT_UNIONFS_VNODE(tdvp); - if (tvp != NULLVP) + if (tvp != NULL) KASSERT_UNIONFS_VNODE(tvp); if (fdvp != tdvp) VI_LOCK(fdvp); @@ -1433,7 +1433,7 @@ unionfs_rename(struct vop_rename_args *ap) UNIONFS_INTERNAL_DEBUG("fdvp=%p, ufdvp=%p, lfdvp=%p\n", fdvp, unp->un_uppervp, unp->un_lowervp); #endif - if (unp->un_uppervp == NULLVP) { + if (unp->un_uppervp == NULL) { error = ENODEV; } else { rfdvp = unp->un_uppervp; @@ -1460,10 +1460,10 @@ unionfs_rename(struct vop_rename_args *ap) * If we only have a lower vnode, copy the source file to the upper * FS so that the rename operation can be issued against the upper FS. */ - if (unp->un_uppervp == NULLVP) { + if (unp->un_uppervp == NULL) { bool unlock_fdvp = false, relock_tdvp = false; VI_UNLOCK(fvp); - if (tvp != NULLVP) + if (tvp != NULL) VOP_UNLOCK(tvp); if (fvp->v_type == VREG) { /* @@ -1496,7 +1496,7 @@ unionfs_rename(struct vop_rename_args *ap) unp = VTOUNIONFS(fvp); if (unp == NULL) error = ENOENT; - else if (unp->un_uppervp == NULLVP) { + else if (unp->un_uppervp == NULL) { switch (fvp->v_type) { case VREG: error = unionfs_copyfile(fvp, 1, fcnp->cn_cred, td); @@ -1514,7 +1514,7 @@ unionfs_rename(struct vop_rename_args *ap) VOP_UNLOCK(fdvp); if (relock_tdvp) vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY); - if (tvp != NULLVP) + if (tvp != NULL) vn_lock(tvp, LK_EXCLUSIVE | LK_RETRY); /* * Since we've dropped tdvp's lock at some point in the copy @@ -1526,7 +1526,7 @@ unionfs_rename(struct vop_rename_args *ap) goto unionfs_rename_abort; } - if (unp->un_lowervp != NULLVP) + if (unp->un_lowervp != NULL) fcnp->cn_flags |= DOWHITEOUT; rfvp = unp->un_uppervp; vref(rfvp); @@ -1539,14 +1539,14 @@ unionfs_rename(struct vop_rename_args *ap) UNIONFS_INTERNAL_DEBUG("tdvp=%p, utdvp=%p, ltdvp=%p\n", tdvp, unp->un_uppervp, unp->un_lowervp); #endif - if (unp->un_uppervp == NULLVP) { + if (unp->un_uppervp == NULL) { error = ENODEV; goto unionfs_rename_abort; } rtdvp = unp->un_uppervp; vref(rtdvp); - if (tvp != NULLVP) { + if (tvp != NULL) { unp = VTOUNIONFS(tvp); if (unp == NULL) { error = ENOENT; @@ -1556,8 +1556,8 @@ unionfs_rename(struct vop_rename_args *ap) UNIONFS_INTERNAL_DEBUG("tvp=%p, utvp=%p, ltvp=%p\n", tvp, unp->un_uppervp, unp->un_lowervp); #endif - if (unp->un_uppervp == NULLVP) - rtvp = NULLVP; + if (unp->un_uppervp == NULL) + rtvp = NULL; else { if (tvp->v_type == VDIR) { error = EINVAL; @@ -1574,7 +1574,7 @@ unionfs_rename(struct vop_rename_args *ap) error = VOP_RENAME(rfdvp, rfvp, fcnp, rtdvp, rtvp, tcnp); if (error == 0) { - if (rtvp != NULLVP && rtvp->v_type == VDIR) + if (rtvp != NULL && rtvp->v_type == VDIR) cache_purge(tdvp); if (fvp->v_type == VDIR && fdvp != tdvp) cache_purge(fdvp); @@ -1582,8 +1582,8 @@ unionfs_rename(struct vop_rename_args *ap) if (tdvp != rtdvp) vrele(tdvp); - if (tvp != rtvp && tvp != NULLVP) { - if (rtvp == NULLVP) + if (tvp != rtvp && tvp != NULL) { + if (rtvp == NULL) vput(tvp); else vrele(tvp); @@ -1601,13 +1601,13 @@ unionfs_rename_abort: vput(tdvp); if (tdvp != rtdvp) vrele(rtdvp); - if (tvp != NULLVP) { + if (tvp != NULL) { if (tdvp != tvp) vput(tvp); else vrele(tvp); } - if (tvp != rtvp && rtvp != NULLVP) + if (tvp != rtvp && rtvp != NULL) vrele(rtvp); if (fdvp != rfdvp) vrele(rfdvp); @@ -1644,7 +1644,7 @@ unionfs_mkdir(struct vop_mkdir_args *ap) lkflags = cnp->cn_lkflags; udvp = dunp->un_uppervp; - if (udvp != NULLVP) { + if (udvp != NULL) { /* check opaque */ if (!(cnp->cn_flags & ISWHITEOUT)) { error = VOP_GETATTR(udvp, &va, cnp->cn_cred); @@ -1666,8 +1666,8 @@ unionfs_mkdir(struct vop_mkdir_args *ap) if (error == 0) { VOP_UNLOCK(uvp); cnp->cn_lkflags = LK_EXCLUSIVE; - error = unionfs_nodeget(dvp->v_mount, uvp, NULLVP, - dvp, ap->a_vpp, cnp); + error = unionfs_nodeget(dvp->v_mount, uvp, NULL, + dvp, ap->a_vpp, cnp); vrele(uvp); cnp->cn_lkflags = lkflags; } else if (uvp_created) @@ -1707,14 +1707,14 @@ unionfs_rmdir(struct vop_rmdir_args *ap) uvp = unp->un_uppervp; lvp = unp->un_lowervp; - if (udvp == NULLVP) + if (udvp == NULL) return (EROFS); if (udvp == uvp) return (EOPNOTSUPP); - if (uvp != NULLVP) { - if (lvp != NULLVP) { + if (uvp != NULL) { + if (lvp != NULL) { /* * We need to keep dvp and vp's upper vnodes locked * going into the VOP_RMDIR() call, but the empty @@ -1752,7 +1752,7 @@ unionfs_rmdir(struct vop_rmdir_args *ap) return (error); } ump = MOUNTTOUNIONFSMOUNT(ap->a_vp->v_mount); - if (ump->um_whitemode == UNIONFS_WHITE_ALWAYS || lvp != NULLVP) + if (ump->um_whitemode == UNIONFS_WHITE_ALWAYS || lvp != NULL) cnp->cn_flags |= (DOWHITEOUT | IGNOREWHITEOUT); int udvp_lkflags, uvp_lkflags; unionfs_forward_vop_start_pair(udvp, &udvp_lkflags, @@ -1760,7 +1760,7 @@ unionfs_rmdir(struct vop_rmdir_args *ap) error = VOP_RMDIR(udvp, uvp, cnp); unionfs_forward_vop_finish_pair(ap->a_dvp, udvp, udvp_lkflags, ap->a_vp, uvp, uvp_lkflags); - } else if (lvp != NULLVP) { + } else if (lvp != NULL) { error = unionfs_mkwhiteout(ap->a_dvp, ap->a_vp, cnp, td, unp->un_path, unp->un_pathlen); } @@ -1795,7 +1795,7 @@ unionfs_symlink(struct vop_symlink_args *ap) lkflags = cnp->cn_lkflags; udvp = dunp->un_uppervp; - if (udvp != NULLVP) { + if (udvp != NULL) { int udvp_lkflags; bool uvp_created = false; unionfs_forward_vop_start(udvp, &udvp_lkflags); @@ -1808,8 +1808,8 @@ unionfs_symlink(struct vop_symlink_args *ap) if (error == 0) { VOP_UNLOCK(uvp); cnp->cn_lkflags = LK_EXCLUSIVE; - error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULLVP, - ap->a_dvp, ap->a_vpp, cnp); + error = unionfs_nodeget(ap->a_dvp->v_mount, uvp, NULL, + ap->a_dvp, ap->a_vpp, cnp); vrele(uvp); cnp->cn_lkflags = lkflags; } else if (uvp_created) @@ -1849,8 +1849,8 @@ unionfs_readdir(struct vop_readdir_args *ap) eofflag = 0; uio_offset_bk = 0; uio = ap->a_uio; - uvp = NULLVP; - lvp = NULLVP; + uvp = NULL; + lvp = NULL; td = uio->uio_td; ncookies_bk = 0; cookies_bk = NULL; @@ -1872,8 +1872,8 @@ unionfs_readdir(struct vop_readdir_args *ap) lvp = unp->un_lowervp; /* check the open count. unionfs needs open before readdir. */ unionfs_get_node_status(unp, td, &unsp); - if ((uvp != NULLVP && unsp->uns_upper_opencnt <= 0) || - (lvp != NULLVP && unsp->uns_lower_opencnt <= 0)) { + if ((uvp != NULL && unsp->uns_upper_opencnt <= 0) || + (lvp != NULL && unsp->uns_lower_opencnt <= 0)) { unionfs_tryrem_node_status(unp, unsp); error = EBADF; } @@ -1883,15 +1883,15 @@ unionfs_readdir(struct vop_readdir_args *ap) goto unionfs_readdir_exit; /* check opaque */ - if (uvp != NULLVP && lvp != NULLVP) { + if (uvp != NULL && lvp != NULL) { if ((error = VOP_GETATTR(uvp, &va, ap->a_cred)) != 0) goto unionfs_readdir_exit; if (va.va_flags & OPAQUE) - lvp = NULLVP; + lvp = NULL; } /* upper only */ - if (uvp != NULLVP && lvp == NULLVP) { + if (uvp != NULL && lvp == NULL) { unionfs_forward_vop_start(uvp, &lkflags); error = VOP_READDIR(uvp, uio, ap->a_cred, ap->a_eofflag, ap->a_ncookies, ap->a_cookies); @@ -1904,7 +1904,7 @@ unionfs_readdir(struct vop_readdir_args *ap) } /* lower only */ - if (uvp == NULLVP && lvp != NULLVP) { + if (uvp == NULL && lvp != NULL) { unionfs_forward_vop_start(lvp, &lkflags); error = VOP_READDIR(lvp, uio, ap->a_cred, ap->a_eofflag, ap->a_ncookies, ap->a_cookies); @@ -1919,8 +1919,8 @@ unionfs_readdir(struct vop_readdir_args *ap) /* * readdir upper and lower */ - KASSERT(uvp != NULLVP, ("unionfs_readdir: null upper vp")); - KASSERT(lvp != NULLVP, ("unionfs_readdir: null lower vp")); + KASSERT(uvp != NULL, ("unionfs_readdir: null upper vp")); + KASSERT(lvp != NULL, ("unionfs_readdir: null lower vp")); if (uio->uio_offset == 0) unsp->uns_readdir_status = 0; @@ -2040,7 +2040,7 @@ unionfs_readlink(struct vop_readlink_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + vp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); error = VOP_READLINK(vp, ap->a_uio, ap->a_cred); @@ -2061,7 +2061,7 @@ unionfs_getwritemount(struct vop_getwritemount_args *ap) error = 0; vp = ap->a_vp; - uvp = NULLVP; + uvp = NULL; VI_LOCK(vp); unp = VTOUNIONFS(vp); @@ -2073,7 +2073,7 @@ unionfs_getwritemount(struct vop_getwritemount_args *ap) * We may be initiating a write operation that will produce a * new upper vnode through CoW. */ - if (uvp == NULLVP && unp != NULL) { + if (uvp == NULL && unp != NULL) { ovp = vp; vp = unp->un_dvp; /* @@ -2086,11 +2086,11 @@ unionfs_getwritemount(struct vop_getwritemount_args *ap) unp = VTOUNIONFS(vp); if (unp != NULL) uvp = unp->un_uppervp; - if (uvp == NULLVP) + if (uvp == NULL) error = EACCES; } - if (uvp != NULLVP) { + if (uvp != NULL) { vholdnz(uvp); VI_UNLOCK(vp); error = VOP_GETWRITEMOUNT(uvp, ap->a_mpp); @@ -2141,9 +2141,9 @@ unionfs_print(struct vop_print_args *ap) unsp->uns_upper_opencnt, unsp->uns_lower_opencnt); */ - if (unp->un_uppervp != NULLVP) + if (unp->un_uppervp != NULL) vn_printf(unp->un_uppervp, "unionfs: upper "); - if (unp->un_lowervp != NULLVP) + if (unp->un_lowervp != NULL) vn_printf(unp->un_lowervp, "unionfs: lower "); return (0); @@ -2232,7 +2232,7 @@ unionfs_lock_restart: * lower vnode lock here. */ unp = VTOUNIONFS(vp); - if (unp == NULL || unp->un_uppervp != NULLVP) { + if (unp == NULL || unp->un_uppervp != NULL) { VOP_UNLOCK(tvp); /* * If we previously held the lock, the upgrade may @@ -2287,7 +2287,7 @@ unionfs_pathconf(struct vop_pathconf_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + vp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); return (VOP_PATHCONF(vp, ap->a_name, ap->a_retval)); } @@ -2314,7 +2314,7 @@ unionfs_advlock(struct vop_advlock_args *ap) unp = VTOUNIONFS(ap->a_vp); uvp = unp->un_uppervp; - if (uvp == NULLVP) { + if (uvp == NULL) { error = unionfs_copyfile(ap->a_vp, 1, td->td_ucred, td); if (error != 0) goto unionfs_advlock_abort; @@ -2360,10 +2360,10 @@ unionfs_strategy(struct vop_strategy_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + vp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); #ifdef DIAGNOSTIC - if (vp == NULLVP) + if (vp == NULL) panic("unionfs_strategy: nullvp"); if (ap->a_bp->b_iocmd == BIO_WRITE && vp == unp->un_lowervp) @@ -2383,7 +2383,7 @@ unionfs_getacl(struct vop_getacl_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + vp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); UNIONFS_INTERNAL_DEBUG("unionfs_getacl: enter\n"); @@ -2416,13 +2416,13 @@ unionfs_setacl(struct vop_setacl_args *ap) if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if (uvp == NULLVP && lvp->v_type == VREG) { + if (uvp == NULL && lvp->v_type == VREG) { if ((error = unionfs_copyfile(ap->a_vp, 1, ap->a_cred, td)) != 0) return (error); uvp = unp->un_uppervp; } - if (uvp != NULLVP) { + if (uvp != NULL) { int lkflags; unionfs_forward_vop_start(uvp, &lkflags); error = VOP_SETACL(uvp, ap->a_type, ap->a_aclp, ap->a_cred, td); @@ -2446,7 +2446,7 @@ unionfs_aclcheck(struct vop_aclcheck_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + vp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); error = VOP_ACLCHECK(vp, ap->a_type, ap->a_aclp, ap->a_cred, ap->a_td); @@ -2467,7 +2467,7 @@ unionfs_openextattr(struct vop_openextattr_args *ap) vp = ap->a_vp; unp = VTOUNIONFS(vp); - tvp = (unp->un_uppervp != NULLVP ? unp->un_uppervp : unp->un_lowervp); + tvp = (unp->un_uppervp != NULL ? unp->un_uppervp : unp->un_lowervp); if ((tvp == unp->un_uppervp && (unp->un_flag & UNIONFS_OPENEXTU)) || (tvp == unp->un_lowervp && (unp->un_flag & UNIONFS_OPENEXTL))) @@ -2502,14 +2502,14 @@ unionfs_closeextattr(struct vop_closeextattr_args *ap) vp = ap->a_vp; unp = VTOUNIONFS(vp); - tvp = NULLVP; + tvp = NULL; if (unp->un_flag & UNIONFS_OPENEXTU) tvp = unp->un_uppervp; else if (unp->un_flag & UNIONFS_OPENEXTL) tvp = unp->un_lowervp; - if (tvp == NULLVP) + if (tvp == NULL) return (EOPNOTSUPP); error = VOP_CLOSEEXTATTR(tvp, ap->a_commit, ap->a_cred, ap->a_td); @@ -2538,14 +2538,14 @@ unionfs_getextattr(struct vop_getextattr_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = NULLVP; + vp = NULL; if (unp->un_flag & UNIONFS_OPENEXTU) vp = unp->un_uppervp; else if (unp->un_flag & UNIONFS_OPENEXTL) vp = unp->un_lowervp; - if (vp == NULLVP) + if (vp == NULL) return (EOPNOTSUPP); return (VOP_GETEXTATTR(vp, ap->a_attrnamespace, ap->a_name, @@ -2569,7 +2569,7 @@ unionfs_setextattr(struct vop_setextattr_args *ap) unp = VTOUNIONFS(ap->a_vp); uvp = unp->un_uppervp; lvp = unp->un_lowervp; - ovp = NULLVP; + ovp = NULL; cred = ap->a_cred; td = ap->a_td; @@ -2584,12 +2584,12 @@ unionfs_setextattr(struct vop_setextattr_args *ap) else if (unp->un_flag & UNIONFS_OPENEXTL) ovp = unp->un_lowervp; - if (ovp == NULLVP) + if (ovp == NULL) return (EOPNOTSUPP); if (ovp == lvp && lvp->v_type == VREG) { VOP_CLOSEEXTATTR(lvp, 0, cred, td); - if (uvp == NULLVP && + if (uvp == NULL && (error = unionfs_copyfile(ap->a_vp, 1, cred, td)) != 0) { unionfs_setextattr_reopen: unp = VTOUNIONFS(ap->a_vp); @@ -2633,14 +2633,14 @@ unionfs_listextattr(struct vop_listextattr_args *ap) KASSERT_UNIONFS_VNODE(ap->a_vp); unp = VTOUNIONFS(ap->a_vp); - vp = NULLVP; + vp = NULL; if (unp->un_flag & UNIONFS_OPENEXTU) vp = unp->un_uppervp; else if (unp->un_flag & UNIONFS_OPENEXTL) vp = unp->un_lowervp; - if (vp == NULLVP) + if (vp == NULL) return (EOPNOTSUPP); return (VOP_LISTEXTATTR(vp, ap->a_attrnamespace, ap->a_uio, @@ -2664,7 +2664,7 @@ unionfs_deleteextattr(struct vop_deleteextattr_args *ap) unp = VTOUNIONFS(ap->a_vp); uvp = unp->un_uppervp; lvp = unp->un_lowervp; - ovp = NULLVP; + ovp = NULL; cred = ap->a_cred; td = ap->a_td; @@ -2679,12 +2679,12 @@ unionfs_deleteextattr(struct vop_deleteextattr_args *ap) else if (unp->un_flag & UNIONFS_OPENEXTL) ovp = unp->un_lowervp; - if (ovp == NULLVP) + if (ovp == NULL) return (EOPNOTSUPP); if (ovp == lvp && lvp->v_type == VREG) { VOP_CLOSEEXTATTR(lvp, 0, cred, td); - if (uvp == NULLVP && + if (uvp == NULL && (error = unionfs_copyfile(ap->a_vp, 1, cred, td)) != 0) { unionfs_deleteextattr_reopen: unp = VTOUNIONFS(ap->a_vp); @@ -2737,13 +2737,13 @@ unionfs_setlabel(struct vop_setlabel_args *ap) if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) return (EROFS); - if (uvp == NULLVP && lvp->v_type == VREG) { + if (uvp == NULL && lvp->v_type == VREG) { if ((error = unionfs_copyfile(ap->a_vp, 1, ap->a_cred, td)) != 0) return (error); uvp = unp->un_uppervp; } - if (uvp != NULLVP) + if (uvp != NULL) error = VOP_SETLABEL(uvp, ap->a_label, ap->a_cred, td); UNIONFS_INTERNAL_DEBUG("unionfs_setlabel: leave (%d)\n", error); @@ -2796,10 +2796,10 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) dvp = ap->a_dvp; vpp = ap->a_vpp; - vp = NULLVP; - lvp = NULLVP; - uvp = NULLVP; - tvp = NULLVP; + vp = NULL; + lvp = NULL; + uvp = NULL; + tvp = NULL; unp = NULL; dunp = VTOUNIONFS(dvp); @@ -2819,11 +2819,11 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) if (vpp != NULL) vp = *vpp; - if (vp != NULLVP) { + if (vp != NULL) { unp = VTOUNIONFS(vp); uvp = unp->un_uppervp; lvp = unp->un_lowervp; - if (uvp != NULLVP) + if (uvp != NULL) tvp = uvp; else tvp = lvp; @@ -2838,9 +2838,9 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) */ if (!ap->a_unlock_vp) { vhold(vp); - if (uvp != NULLVP) + if (uvp != NULL) vhold(uvp); - if (lvp != NULLVP) + if (lvp != NULL) vhold(lvp); mp = vp->v_mount; vfs_ref(mp); @@ -2850,12 +2850,12 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) ASSERT_VOP_LOCKED(tdvp, __func__); ASSERT_VOP_LOCKED(tvp, __func__); - if (tdvp == dunp->un_uppervp && tvp != NULLVP && tvp == lvp) { + if (tdvp == dunp->un_uppervp && tvp != NULL && tvp == lvp) { vput(tvp); vput(tdvp); res = 0; } else { - res = VOP_VPUT_PAIR(tdvp, tvp != NULLVP ? &tvp : NULL, true); + res = VOP_VPUT_PAIR(tdvp, tvp != NULL ? &tvp : NULL, true); } ASSERT_VOP_UNLOCKED(tdvp, __func__); @@ -2865,11 +2865,11 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) * VOP_VPUT_PAIR() dropped the references we added to the underlying * vnodes, now drop the caller's reference to the unionfs vnodes. */ - if (vp != NULLVP && ap->a_unlock_vp) + if (vp != NULL && ap->a_unlock_vp) vrele(vp); vrele(dvp); - if (vp == NULLVP || ap->a_unlock_vp) + if (vp == NULL || ap->a_unlock_vp) return (res); /* @@ -2887,9 +2887,9 @@ unionfs_vput_pair(struct vop_vput_pair_args *ap) vget(vp, LK_EXCLUSIVE | LK_RETRY); vfs_unbusy(mp); } - if (lvp != NULLVP) + if (lvp != NULL) vdrop(lvp); - if (uvp != NULLVP) + if (uvp != NULL) vdrop(uvp); vdrop(vp); vfs_rel(mp); |