Re: remove VOP_UNLOCK() flags
Martin Natano wrote: > The VOP_UNLOCK() function has a flags parameter, which is documented to > should be zero in most cases. It turns out that the flags argument is > zero for all ~200 callers in the tree. On a closer look it is revealed > that VOP_UNLOCK() uses lockmgr() for all filesystems that support > locking. The only lockmgr() flag that is useful for unlocking is > LK_RELEASE, which is set by the implementation anyways, so passing flags > to VOP_UNLOCK() doesn't make sense anyway. > > Ok to remove the flags argument from VOP_UNLOCK()? Makes sense to me. NetBSD does not have the flags argument for VOP_UNLOCK either. > natano > > > Index: share/man/man9/VOP_LOOKUP.9 > === > RCS file: /cvs/src/share/man/man9/VOP_LOOKUP.9,v > retrieving revision 1.32 > diff -u -p -r1.32 VOP_LOOKUP.9 > --- share/man/man9/VOP_LOOKUP.9 2 Dec 2015 11:03:40 - 1.32 > +++ share/man/man9/VOP_LOOKUP.9 2 Mar 2016 20:02:46 - > @@ -283,7 +283,6 @@ > .Ft int > .Fo VOP_UNLOCK > .Fa "struct vnode *vp" > -.Fa "int flags" > .Fa "struct proc *p" > .Fc > .Ft int > @@ -564,7 +563,7 @@ returned. > .Pp > .It Fn VOP_ISLOCKED vp > .It Fn VOP_LOCK vp flags p > -.It Fn VOP_UNLOCK vp flags p > +.It Fn VOP_UNLOCK vp p > .Fn VOP_LOCK > is used internally by > .Xr vn_lock 9 > @@ -572,8 +571,6 @@ to lock a vnode. > It should not be used by other file system code. > .Fn VOP_UNLOCK > unlocks a vnode. > -.Fa flags > -should be zero in most cases. > .Fn VOP_ISLOCKED > returns 1 if > .Fa vp > Index: share/man/man9/vinvalbuf.9 > === > RCS file: /cvs/src/share/man/man9/vinvalbuf.9,v > retrieving revision 1.9 > diff -u -p -r1.9 vinvalbuf.9 > --- share/man/man9/vinvalbuf.917 Jul 2013 20:21:56 - 1.9 > +++ share/man/man9/vinvalbuf.92 Mar 2016 20:02:46 - > @@ -87,7 +87,7 @@ A value of 0 is returned on success. > .Bd -literal -offset indent > vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); > error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0); > -VOP_UNLOCK(devvp, 0, p); > +VOP_UNLOCK(devvp, p); > if (error) > return (error); > .Ed > Index: sys/arch/sparc64/dev/vdsp.c > === > RCS file: /cvs/src/sys/arch/sparc64/dev/vdsp.c,v > retrieving revision 1.41 > diff -u -p -r1.41 vdsp.c > --- sys/arch/sparc64/dev/vdsp.c 29 Dec 2015 04:46:28 - 1.41 > +++ sys/arch/sparc64/dev/vdsp.c 2 Mar 2016 20:02:49 - > @@ -941,7 +941,7 @@ vdsp_open(void *arg1) > sc->sc_vdisk_size = va.va_size / DEV_BSIZE; > } > > - VOP_UNLOCK(nd.ni_vp, 0, p); > + VOP_UNLOCK(nd.ni_vp, p); > sc->sc_vp = nd.ni_vp; > > vdsp_readlabel(sc); > @@ -1013,7 +1013,7 @@ vdsp_readlabel(struct vdsp_softc *sc) > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > err = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > if (err) { > free(sc->sc_label, M_DEVBUF, 0); > sc->sc_label = NULL; > @@ -1043,7 +1043,7 @@ vdsp_writelabel(struct vdsp_softc *sc) > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > err = VOP_WRITE(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > > return (err); > } > @@ -1074,7 +1074,7 @@ vdsp_is_iso(struct vdsp_softc *sc) > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > err = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > > if (err == 0 && memcmp(vdp->id, ISO_STANDARD_ID, sizeof(vdp->id))) > err = ENOENT; > @@ -1153,7 +1153,7 @@ vdsp_read_desc(struct vdsp_softc *sc, st > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > dm->status = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > > KERNEL_UNLOCK(); > if (dm->status == 0) { > @@ -1227,7 +1227,7 @@ vdsp_read_dring(void *arg1, void *arg2) > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > vd->status = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > > KERNEL_UNLOCK(); > if (vd->status == 0) { > @@ -1326,7 +1326,7 @@ vdsp_write_dring(void *arg1, void *arg2) > > vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); > vd->status = VOP_WRITE(sc->sc_vp, &uio, 0, p->p_ucred); > - VOP_UNLOCK(sc->sc_vp, 0, p); > + VOP_UNLOCK(sc->sc_vp, p); > > fail: > free(buf, M_DEVBUF, 0); > Index: sys/dev/diskmap.c > === > RCS file: /cvs/src/sys/dev/diskmap.c,v > retrieving revision 1.13 > diff -u -p -r1.13 diskma
remove VOP_UNLOCK() flags
The VOP_UNLOCK() function has a flags parameter, which is documented to should be zero in most cases. It turns out that the flags argument is zero for all ~200 callers in the tree. On a closer look it is revealed that VOP_UNLOCK() uses lockmgr() for all filesystems that support locking. The only lockmgr() flag that is useful for unlocking is LK_RELEASE, which is set by the implementation anyways, so passing flags to VOP_UNLOCK() doesn't make sense anyway. Ok to remove the flags argument from VOP_UNLOCK()? natano Index: share/man/man9/VOP_LOOKUP.9 === RCS file: /cvs/src/share/man/man9/VOP_LOOKUP.9,v retrieving revision 1.32 diff -u -p -r1.32 VOP_LOOKUP.9 --- share/man/man9/VOP_LOOKUP.9 2 Dec 2015 11:03:40 - 1.32 +++ share/man/man9/VOP_LOOKUP.9 2 Mar 2016 20:02:46 - @@ -283,7 +283,6 @@ .Ft int .Fo VOP_UNLOCK .Fa "struct vnode *vp" -.Fa "int flags" .Fa "struct proc *p" .Fc .Ft int @@ -564,7 +563,7 @@ returned. .Pp .It Fn VOP_ISLOCKED vp .It Fn VOP_LOCK vp flags p -.It Fn VOP_UNLOCK vp flags p +.It Fn VOP_UNLOCK vp p .Fn VOP_LOCK is used internally by .Xr vn_lock 9 @@ -572,8 +571,6 @@ to lock a vnode. It should not be used by other file system code. .Fn VOP_UNLOCK unlocks a vnode. -.Fa flags -should be zero in most cases. .Fn VOP_ISLOCKED returns 1 if .Fa vp Index: share/man/man9/vinvalbuf.9 === RCS file: /cvs/src/share/man/man9/vinvalbuf.9,v retrieving revision 1.9 diff -u -p -r1.9 vinvalbuf.9 --- share/man/man9/vinvalbuf.9 17 Jul 2013 20:21:56 - 1.9 +++ share/man/man9/vinvalbuf.9 2 Mar 2016 20:02:46 - @@ -87,7 +87,7 @@ A value of 0 is returned on success. .Bd -literal -offset indent vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); error = vinvalbuf(devvp, V_SAVE, cred, p, 0, 0); -VOP_UNLOCK(devvp, 0, p); +VOP_UNLOCK(devvp, p); if (error) return (error); .Ed Index: sys/arch/sparc64/dev/vdsp.c === RCS file: /cvs/src/sys/arch/sparc64/dev/vdsp.c,v retrieving revision 1.41 diff -u -p -r1.41 vdsp.c --- sys/arch/sparc64/dev/vdsp.c 29 Dec 2015 04:46:28 - 1.41 +++ sys/arch/sparc64/dev/vdsp.c 2 Mar 2016 20:02:49 - @@ -941,7 +941,7 @@ vdsp_open(void *arg1) sc->sc_vdisk_size = va.va_size / DEV_BSIZE; } - VOP_UNLOCK(nd.ni_vp, 0, p); + VOP_UNLOCK(nd.ni_vp, p); sc->sc_vp = nd.ni_vp; vdsp_readlabel(sc); @@ -1013,7 +1013,7 @@ vdsp_readlabel(struct vdsp_softc *sc) vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); err = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); if (err) { free(sc->sc_label, M_DEVBUF, 0); sc->sc_label = NULL; @@ -1043,7 +1043,7 @@ vdsp_writelabel(struct vdsp_softc *sc) vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); err = VOP_WRITE(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); return (err); } @@ -1074,7 +1074,7 @@ vdsp_is_iso(struct vdsp_softc *sc) vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); err = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); if (err == 0 && memcmp(vdp->id, ISO_STANDARD_ID, sizeof(vdp->id))) err = ENOENT; @@ -1153,7 +1153,7 @@ vdsp_read_desc(struct vdsp_softc *sc, st vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); dm->status = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); KERNEL_UNLOCK(); if (dm->status == 0) { @@ -1227,7 +1227,7 @@ vdsp_read_dring(void *arg1, void *arg2) vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); vd->status = VOP_READ(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); KERNEL_UNLOCK(); if (vd->status == 0) { @@ -1326,7 +1326,7 @@ vdsp_write_dring(void *arg1, void *arg2) vn_lock(sc->sc_vp, LK_EXCLUSIVE | LK_RETRY, p); vd->status = VOP_WRITE(sc->sc_vp, &uio, 0, p->p_ucred); - VOP_UNLOCK(sc->sc_vp, 0, p); + VOP_UNLOCK(sc->sc_vp, p); fail: free(buf, M_DEVBUF, 0); Index: sys/dev/diskmap.c === RCS file: /cvs/src/sys/dev/diskmap.c,v retrieving revision 1.13 diff -u -p -r1.13 diskmap.c --- sys/dev/diskmap.c 20 Nov 2015 16:06:53 - 1.13 +++ sys/dev/diskmap.c 2 Mar 2016 20:02:49 - @@ -116,7 +116,7 @@ diskmapioctl(dev_t dev, u_long cmd, cadd fp->f_rbytes = 0; fp->f_wbytes = 0; - VOP_UNLOCK(vp, 0, p); + VOP_UNLOCK(vp, p); FRELE(fp, p); fdpunlock(