diff options
Diffstat (limited to 'sys/msdosfs')
-rw-r--r-- | sys/msdosfs/denode.h | 7 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_denode.c | 49 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_lookup.c | 31 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vfsops.c | 63 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 142 | ||||
-rw-r--r-- | sys/msdosfs/msdosfsmount.h | 4 |
6 files changed, 110 insertions, 186 deletions
diff --git a/sys/msdosfs/denode.h b/sys/msdosfs/denode.h index d5171d7f21e..e035b866bb4 100644 --- a/sys/msdosfs/denode.h +++ b/sys/msdosfs/denode.h @@ -1,4 +1,4 @@ -/* $OpenBSD: denode.h,v 1.5 1997/10/04 19:08:10 deraadt Exp $ */ +/* $OpenBSD: denode.h,v 1.6 1997/11/06 05:58:55 csapuntz Exp $ */ /* $NetBSD: denode.h,v 1.20 1996/02/09 19:13:39 christos Exp $ */ /*- @@ -148,8 +148,7 @@ struct denode { long de_refcnt; /* reference count */ struct msdosfsmount *de_pmp; /* addr of our mount struct */ struct lockf *de_lockf; /* byte level lock list */ - pid_t de_lockholder; /* current lock holder */ - pid_t de_lockwaiter; /* lock wanter */ + struct lock de_lock; /* denode lock */ u_char de_Name[12]; /* name, from DOS directory entry */ u_char de_Attributes; /* attributes, from directory entry */ u_char de_CTimeHundredth; /* creation time, 1/100th of a sec */ @@ -166,8 +165,6 @@ struct denode { /* * Values for the de_flag field of the denode. */ -#define DE_LOCKED 0x0001 /* Denode lock. */ -#define DE_WANTED 0x0002 /* Denode is wanted by a process. */ #define DE_UPDATE 0x0004 /* Modification time update request. */ #define DE_CREATE 0x0008 /* Creation time update */ #define DE_ACCESS 0x0010 /* Access time update */ diff --git a/sys/msdosfs/msdosfs_denode.c b/sys/msdosfs/msdosfs_denode.c index 0debd66175d..16214003faf 100644 --- a/sys/msdosfs/msdosfs_denode.c +++ b/sys/msdosfs/msdosfs_denode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_denode.c,v 1.7 1997/10/06 20:20:57 deraadt Exp $ */ +/* $OpenBSD: msdosfs_denode.c,v 1.8 1997/11/06 05:58:56 csapuntz Exp $ */ /* $NetBSD: msdosfs_denode.c,v 1.22 1996/10/13 04:16:31 christos Exp $ */ /*- @@ -76,10 +76,13 @@ static struct denode *msdosfs_hashget __P((dev_t, u_long, u_long)); static void msdosfs_hashins __P((struct denode *)); static void msdosfs_hashrem __P((struct denode *)); -void -msdosfs_init() +/*ARGSUSED*/ +int +msdosfs_init(vfsp) + struct vfsconf *vfsp; { dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash); + return (0); } static struct denode * @@ -89,7 +92,8 @@ msdosfs_hashget(dev, dirclust, diroff) u_long diroff; { struct denode *dep; - + struct proc *p = curproc; /* XXX */ + for (;;) for (dep = dehashtbl[DEHASH(dev, dirclust, diroff)];; dep = dep->de_next) { @@ -99,12 +103,8 @@ msdosfs_hashget(dev, dirclust, diroff) diroff == dep->de_diroffset && dev == dep->de_dev && dep->de_refcnt != 0) { - if (dep->de_flag & DE_LOCKED) { - dep->de_flag |= DE_WANTED; - sleep(dep, PINOD); - break; - } - if (!vget(DETOV(dep), 1)) + simple_lock(&vp->v_interlock); + if (!vget(DETOV(dep), LK_EXCLUSIVE | LK_INTERLOCK, p)) return (dep); break; } @@ -166,6 +166,7 @@ deget(pmp, dirclust, diroffset, depp) struct denode *ldep; struct vnode *nvp; struct buf *bp; + struct proc *p = curproc; /* XXX */ #ifdef MSDOSFS_DEBUG printf("deget(pmp %08x, dirclust %d, diroffset %x, depp %08x)\n", @@ -218,7 +219,7 @@ deget(pmp, dirclust, diroffset, depp) * can't be accessed until we've read it in and have done what we * need to it. */ - VOP_LOCK(nvp); + vn_lock(nvp, LK_EXCLUSIVE | LK_RETRY, p); msdosfs_hashins(ldep); /* @@ -562,9 +563,11 @@ msdosfs_inactive(v) { struct vop_inactive_args /* { struct vnode *a_vp; + struct proc *a_p; } */ *ap = v; struct vnode *vp = ap->a_vp; struct denode *dep = VTODE(vp); + struct proc *p = ap->a_p; int error; extern int prtactive; @@ -578,22 +581,10 @@ msdosfs_inactive(v) /* * Get rid of denodes related to stale file handles. */ - if (dep->de_Name[0] == SLOT_DELETED) { - if ((vp->v_flag & VXLOCK) == 0) - vgone(vp); - return (0); - } + if (dep->de_Name[0] == SLOT_DELETED) + goto out; error = 0; -#ifdef DIAGNOSTIC - if (VOP_ISLOCKED(vp)) - panic("msdosfs_inactive: locked denode"); - if (curproc) - dep->de_lockholder = curproc->p_pid; - else - dep->de_lockholder = -1; -#endif - dep->de_flag |= DE_LOCKED; /* * If the file has been deleted and it is on a read/write * filesystem, then truncate the file, and mark the directory slot @@ -608,7 +599,9 @@ msdosfs_inactive(v) dep->de_Name[0] = SLOT_DELETED; } deupdat(dep, 0); - VOP_UNLOCK(vp); + +out: + VOP_UNLOCK(vp, 0, p); /* * If we are done with the denode, reclaim it * so that it can be reused immediately. @@ -617,7 +610,7 @@ msdosfs_inactive(v) printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n", vp->v_usecount, dep->de_Name[0]); #endif - if (vp->v_usecount == 0 && dep->de_Name[0] == SLOT_DELETED) - vgone(vp); + if (dep->de_Name[0] == SLOT_DELETED) + vrecycle(vp, (struct simplelock *)0, p); return (error); } diff --git a/sys/msdosfs/msdosfs_lookup.c b/sys/msdosfs/msdosfs_lookup.c index 2305f74d9b0..9bb3aee0e37 100644 --- a/sys/msdosfs/msdosfs_lookup.c +++ b/sys/msdosfs/msdosfs_lookup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_lookup.c,v 1.7 1997/10/06 20:20:58 deraadt Exp $ */ +/* $OpenBSD: msdosfs_lookup.c,v 1.8 1997/11/06 05:58:57 csapuntz Exp $ */ /* $NetBSD: msdosfs_lookup.c,v 1.30 1996/10/25 23:14:08 cgd Exp $ */ /*- @@ -89,6 +89,7 @@ msdosfs_lookup(v) struct vnode *vdp = ap->a_dvp; struct vnode **vpp = ap->a_vpp; struct componentname *cnp = ap->a_cnp; + struct proc *p = cnp->cn_proc; daddr_t bn; int error; int lockparent; @@ -161,14 +162,14 @@ msdosfs_lookup(v) VREF(vdp); error = 0; } else if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); - error = vget(vdp, 1); + VOP_UNLOCK(pdp, 0, p); + error = vget(vdp, LK_EXCLUSIVE, p); if (!error && lockparent && (flags & ISLASTCN)) - error = VOP_LOCK(pdp); + error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); } else { - error = vget(vdp, 1); + error = vget(vdp, LK_EXCLUSIVE, p); if (!lockparent || error || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } /* * Check that the capability number did not change @@ -184,9 +185,9 @@ msdosfs_lookup(v) } vput(vdp); if (lockparent && pdp != vdp && (flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); } - if ((error = VOP_LOCK(pdp)) != 0) + if ((error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p)) != 0) return (error); vdp = pdp; dp = VTODE(vdp); @@ -414,7 +415,7 @@ notfound:; */ cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (EJUSTRETURN); } /* @@ -484,7 +485,7 @@ foundroot:; return (error); *vpp = DETOV(tdp); if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -512,7 +513,7 @@ foundroot:; *vpp = DETOV(tdp); cnp->cn_flags |= SAVENAME; if (!lockparent) - VOP_UNLOCK(vdp); + VOP_UNLOCK(vdp, 0, p); return (0); } @@ -537,13 +538,13 @@ foundroot:; */ pdp = vdp; if (flags & ISDOTDOT) { - VOP_UNLOCK(pdp); /* race to get the inode */ + VOP_UNLOCK(pdp, 0, p); /* race to get the inode */ if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) { - VOP_LOCK(pdp); + vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p); return (error); } if (lockparent && (flags & ISLASTCN) && - (error = VOP_LOCK(pdp))) { + (error = vn_lock(pdp, LK_EXCLUSIVE | LK_RETRY, p))) { vput(DETOV(tdp)); return (error); } @@ -555,7 +556,7 @@ foundroot:; if ((error = deget(pmp, cluster, blkoff, &tdp)) != 0) return (error); if (!lockparent || !(flags & ISLASTCN)) - VOP_UNLOCK(pdp); + VOP_UNLOCK(pdp, 0, p); *vpp = DETOV(tdp); } diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index f10de74c684..df59486df4d 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vfsops.c,v 1.9 1997/10/06 20:20:59 deraadt Exp $ */ +/* $OpenBSD: msdosfs_vfsops.c,v 1.10 1997/11/06 05:58:57 csapuntz Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.44 1996/12/22 10:10:32 cgd Exp $ */ /*- @@ -75,10 +75,8 @@ int msdosfs_mount __P((struct mount *, char *, caddr_t, struct nameidata *, int msdosfs_start __P((struct mount *, int, struct proc *)); int msdosfs_unmount __P((struct mount *, int, struct proc *)); int msdosfs_root __P((struct mount *, struct vnode **)); -int msdosfs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *)); int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *)); int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); -int msdosfs_vget __P((struct mount *, ino_t, struct vnode **)); int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **)); int msdosfs_vptofh __P((struct vnode *, struct fid *)); @@ -121,10 +119,10 @@ msdosfs_mount(mp, path, data, ndp, p) flags = WRITECLOSE; if (mp->mnt_flag & MNT_FORCE) flags |= FORCECLOSE; - if (vfs_busy(mp)) + if (vfs_busy(mp, 0, 0, p)) return (EBUSY); error = vflush(mp, NULLVP, flags); - vfs_unbusy(mp); + vfs_unbusy(mp, p); } if (!error && (mp->mnt_flag & MNT_RELOAD)) /* not yet implemented */ @@ -138,14 +136,14 @@ msdosfs_mount(mp, path, data, ndp, p) */ if (p->p_ucred->cr_uid != 0) { devvp = pmp->pm_devvp; - VOP_LOCK(devvp); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); error = VOP_ACCESS(devvp, VREAD | VWRITE, p->p_ucred, p); if (error) { - VOP_UNLOCK(devvp); + VOP_UNLOCK(devvp, 0, p); return (error); } - VOP_UNLOCK(devvp); + VOP_UNLOCK(devvp, 0, p); } pmp->pm_flags &= ~MSDOSFSMNT_RONLY; } @@ -189,13 +187,13 @@ msdosfs_mount(mp, path, data, ndp, p) accessmode = VREAD; if ((mp->mnt_flag & MNT_RDONLY) == 0) accessmode |= VWRITE; - VOP_LOCK(devvp); + vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p); error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p); if (error) { vput(devvp); return (error); } - VOP_UNLOCK(devvp); + VOP_UNLOCK(devvp, 0, p); } if ((mp->mnt_flag & MNT_UPDATE) == 0) error = msdosfs_mountfs(devvp, mp, p, &args); @@ -514,7 +512,7 @@ msdosfs_mountfs(devvp, mp, p, argp) * in the directory entry where we could put uid's and gid's. */ #endif - devvp->v_specflags |= SI_MOUNTEDON; + devvp->v_specmountpoint = mp; return (0); @@ -561,7 +559,7 @@ msdosfs_unmount(mp, mntflags, p) if ((error = vflush(mp, NULLVP, flags)) != 0) return (error); pmp = VFSTOMSDOSFS(mp); - pmp->pm_devvp->v_specflags &= ~SI_MOUNTEDON; + pmp->pm_devvp->v_specmountpoint = NULL; #ifdef MSDOSFS_DEBUG printf("msdosfs_umount(): just before calling VOP_CLOSE()\n"); printf("flag %08x, usecount %d, writecount %d, holdcnt %d\n", @@ -605,22 +603,6 @@ msdosfs_root(mp, vpp) } int -msdosfs_quotactl(mp, cmds, uid, arg, p) - struct mount *mp; - int cmds; - uid_t uid; - caddr_t arg; - struct proc *p; -{ - -#ifdef QUOTA - return (EOPNOTSUPP); -#else - return (EOPNOTSUPP); -#endif -} - -int msdosfs_statfs(mp, sbp, p) struct mount *mp; struct statfs *sbp; @@ -645,7 +627,7 @@ msdosfs_statfs(mp, sbp, p) bcopy(mp->mnt_stat.f_mntonname, sbp->f_mntonname, MNAMELEN); bcopy(mp->mnt_stat.f_mntfromname, sbp->f_mntfromname, MNAMELEN); } - strncpy(sbp->f_fstypename, mp->mnt_op->vfs_name, MFSNAMELEN); + strncpy(sbp->f_fstypename, mp->mnt_vfc->vfc_name, MFSNAMELEN); return (0); } @@ -689,9 +671,9 @@ loop: dep = VTODE(vp); if (((dep->de_flag & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0) - && (vp->v_dirtyblkhd.lh_first == NULL)) + && (vp->v_dirtyblkhd.lh_first == NULL || waitfor == MNT_LAZY)) continue; - if (vget(vp, 1)) + if (vget(vp, LK_EXCLUSIVE, p)) goto loop; if ((error = VOP_FSYNC(vp, cred, waitfor, p)) != 0) allerror = error; @@ -753,18 +735,16 @@ msdosfs_vptofh(vp, fhp) return (0); } -int -msdosfs_vget(mp, ino, vpp) - struct mount *mp; - ino_t ino; - struct vnode **vpp; -{ +#define msdosfs_vget ((int (*) __P((struct mount *, ino_t, struct vnode **))) \ + eopnotsupp) - return (EOPNOTSUPP); -} +#define msdosfs_quotactl ((int (*) __P((struct mount *, int, uid_t, caddr_t, \ + struct proc *)))eopnotsupp) + +#define msdosfs_sysctl ((int (*) __P((int *, u_int, void *, size_t *, void *, \ + size_t, struct proc *)))eopnotsupp) struct vfsops msdosfs_vfsops = { - MOUNT_MSDOS, msdosfs_mount, msdosfs_start, msdosfs_unmount, @@ -775,5 +755,6 @@ struct vfsops msdosfs_vfsops = { msdosfs_vget, msdosfs_fhtovp, msdosfs_vptofh, - msdosfs_init + msdosfs_init, + msdosfs_sysctl }; diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 3bc08890817..adfc01c9591 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vnops.c,v 1.12 1997/10/06 20:21:00 deraadt Exp $ */ +/* $OpenBSD: msdosfs_vnops.c,v 1.13 1997/11/06 05:58:58 csapuntz Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.48 1996/03/20 00:45:43 thorpej Exp $ */ /*- @@ -225,7 +225,7 @@ msdosfs_close(v) struct denode *dep = VTODE(vp); struct timespec ts; - if (vp->v_usecount > 1 && !(dep->de_flag & DE_LOCKED)) { + if (vp->v_usecount > 1 && !VOP_ISLOCKED(vp)) { TIMEVAL_TO_TIMESPEC(&time, &ts); DETIMES(dep, &ts, &ts, &ts); } @@ -949,6 +949,7 @@ msdosfs_rename(v) register struct vnode *fdvp = ap->a_fdvp; register struct componentname *tcnp = ap->a_tcnp; register struct componentname *fcnp = ap->a_fcnp; + struct proc *p = curproc; /* XXX */ register struct denode *ip, *xp, *dp, *zp; u_char toname[11], oldname[11]; u_long from_diroffset, to_diroffset; @@ -989,7 +990,7 @@ abortit: } /* */ - if ((error = VOP_LOCK(fvp)) != 0) + if ((error = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, p)) != 0) goto abortit; dp = VTODE(fdvp); ip = VTODE(fvp); @@ -1009,7 +1010,7 @@ abortit: (fcnp->cn_flags & ISDOTDOT) || (tcnp->cn_flags & ISDOTDOT) || (ip->de_flag & DE_RENAME)) { - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); error = EINVAL; goto abortit; } @@ -1040,7 +1041,7 @@ abortit: * call to doscheckpath(). */ error = VOP_ACCESS(fvp, VWRITE, tcnp->cn_cred, tcnp->cn_proc); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster) newparent = 1; vrele(fdvp); @@ -1106,7 +1107,7 @@ abortit: if ((fcnp->cn_flags & SAVESTART) == 0) panic("msdosfs_rename: lost from startdir"); if (!newparent) - VOP_UNLOCK(tdvp); + VOP_UNLOCK(tdvp, 0, p); (void) relookup(fdvp, &fvp, fcnp); if (fvp == NULL) { /* @@ -1116,7 +1117,7 @@ abortit: panic("rename: lost dir entry"); vrele(ap->a_fvp); if (newparent) - VOP_UNLOCK(tdvp); + VOP_UNLOCK(tdvp, 0, p); vrele(tdvp); return 0; } @@ -1136,9 +1137,9 @@ abortit: if (doingdirectory) panic("rename: lost dir entry"); vrele(ap->a_fvp); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); if (newparent) - VOP_UNLOCK(fdvp); + VOP_UNLOCK(fdvp, 0, p); xp = NULL; } else { vrele(fvp); @@ -1160,8 +1161,8 @@ abortit: if (error) { bcopy(oldname, ip->de_Name, 11); if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fvp, 0, p); goto bad; } ip->de_refcnt++; @@ -1169,8 +1170,8 @@ abortit: if ((error = removede(zp, ip)) != 0) { /* XXX should really panic here, fs is corrupt */ if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fvp, 0, p); goto bad; } if (!doingdirectory) { @@ -1179,8 +1180,8 @@ abortit: if (error) { /* XXX should really panic here, fs is corrupt */ if (newparent) - VOP_UNLOCK(fdvp); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fdvp, 0, p); + VOP_UNLOCK(fvp, 0, p); goto bad; } if (ip->de_dirclust != MSDOSFSROOT) @@ -1188,7 +1189,7 @@ abortit: } reinsert(ip); if (newparent) - VOP_UNLOCK(fdvp); + VOP_UNLOCK(fdvp, 0, p); } /* @@ -1207,19 +1208,19 @@ abortit: if (error) { /* XXX should really panic here, fs is corrupt */ brelse(bp); - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); goto bad; } dotdotp = (struct direntry *)bp->b_data + 1; putushort(dotdotp->deStartCluster, dp->de_StartCluster); if ((error = bwrite(bp)) != 0) { /* XXX should really panic here, fs is corrupt */ - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); goto bad; } } - VOP_UNLOCK(fvp); + VOP_UNLOCK(fvp, 0, p); bad: if (xp) vput(tvp); @@ -1463,8 +1464,8 @@ msdosfs_readdir(v) struct uio *a_uio; struct ucred *a_cred; int *a_eofflag; - u_long *a_cookies; - int a_ncookies; + u_long **a_cookies; + int *a_ncookies; } */ *ap = v; int error = 0; int diff; @@ -1483,8 +1484,8 @@ msdosfs_readdir(v) struct direntry *dentp; struct dirent dirbuf; struct uio *uio = ap->a_uio; - u_long *cookies; - int ncookies; + u_long *cookies = NULL; + int ncookies = 0; off_t offset; int chksum = -1; @@ -1520,8 +1521,13 @@ msdosfs_readdir(v) lost = uio->uio_resid - count; uio->uio_resid = count; - cookies = ap->a_cookies; - ncookies = ap->a_ncookies; + if (ap->a_ncookies) { + ncookies = uio->uio_resid / sizeof(struct direntry) + 3; + MALLOC(cookies, u_long *, ncookies * sizeof(u_long), M_TEMP, + M_WAITOK); + *ap->a_cookies = cookies; + *ap->a_ncookies = ncookies; + } /* * If they are reading from the root directory then, we simulate @@ -1681,6 +1687,10 @@ msdosfs_readdir(v) } out: + /* Subtract unused cookies */ + if (ap->a_ncookies) + *ap->a_ncookies -= ncookies; + uio->uio_offset = offset; uio->uio_resid += lost; if (dep->de_FileSize - (offset - bias) <= 0) @@ -1728,47 +1738,13 @@ msdosfs_lock(v) { struct vop_lock_args /* { struct vnode *a_vp; + int a_flags; + struct proc *a_p; } */ *ap = v; - register struct vnode *vp = ap->a_vp; - register struct denode *dep; -#ifdef DIAGNOSTIC - struct proc *p = curproc; /* XXX */ -#endif + struct vnode *vp = ap->a_vp; -start: - while (vp->v_flag & VXLOCK) { - vp->v_flag |= VXWANT; - sleep((caddr_t)vp, PINOD); - } - if (vp->v_tag == VT_NON) - return (ENOENT); - dep = VTODE(vp); - if (dep->de_flag & DE_LOCKED) { - dep->de_flag |= DE_WANTED; -#ifdef DIAGNOSTIC - if (p) { - if (p->p_pid == dep->de_lockholder) - panic("locking against myself"); - dep->de_lockwaiter = p->p_pid; - } else - dep->de_lockwaiter = -1; -#endif - (void) sleep((caddr_t)dep, PINOD); - goto start; - } -#ifdef DIAGNOSTIC - dep->de_lockwaiter = 0; - if (dep->de_lockholder != 0) - panic("lockholder (%d) != 0", dep->de_lockholder); - if (p && p->p_pid == 0) - printf("locking by process 0\n"); - if (p) - dep->de_lockholder = p->p_pid; - else - dep->de_lockholder = -1; -#endif - dep->de_flag |= DE_LOCKED; - return (0); + return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags, &vp->v_interlock, + ap->a_p)); } int @@ -1778,28 +1754,10 @@ msdosfs_unlock(v) struct vop_unlock_args /* { struct vnode *vp; } */ *ap = v; - register struct denode *dep = VTODE(ap->a_vp); -#ifdef DIAGNOSTIC - struct proc *p = curproc; /* XXX */ -#endif + struct vnode *vp = ap->a_vp; -#ifdef DIAGNOSTIC - if ((dep->de_flag & DE_LOCKED) == 0) { - vprint("msdosfs_unlock: unlocked denode", ap->a_vp); - panic("msdosfs_unlock NOT LOCKED"); - } - if (p && p->p_pid != dep->de_lockholder && p->p_pid > -1 && - dep->de_lockholder > -1/* && lockcount++ < 100*/) - panic("unlocker (%d) != lock holder (%d)", - p->p_pid, dep->de_lockholder); - dep->de_lockholder = 0; -#endif - dep->de_flag &= ~DE_LOCKED; - if (dep->de_flag & DE_WANTED) { - dep->de_flag &= ~DE_WANTED; - wakeup((caddr_t)dep); - } - return (0); + return (lockmgr(&VTODE(vp)->de_lock, ap->a_flags | LK_RELEASE, + &vp->v_interlock, ap->a_p)); } int @@ -1810,9 +1768,7 @@ msdosfs_islocked(v) struct vnode *a_vp; } */ *ap = v; - if (VTODE(ap->a_vp)->de_flag & DE_LOCKED) - return (1); - return (0); + return (lockstatus(&VTODE(ap->a_vp)->de_lock)); } /* @@ -1922,15 +1878,11 @@ msdosfs_print(v) dep->de_StartCluster, dep->de_dirclust, dep->de_diroffset); printf(" dev %d, %d, %s\n", major(dep->de_dev), minor(dep->de_dev), - dep->de_flag & DE_LOCKED ? "(LOCKED)" : ""); + VOP_ISLOCKED(ap->a_vp) ? "(LOCKED)" : ""); #ifdef DIAGNOSTIC - if (dep->de_lockholder) { - printf(" owner pid %d", dep->de_lockholder); - if (dep->de_lockwaiter) - printf(" waiting pid %d", dep->de_lockwaiter); - printf("\n"); - } + lockmgr_printinfo(&dep->de_lock); #endif + return (0); } diff --git a/sys/msdosfs/msdosfsmount.h b/sys/msdosfs/msdosfsmount.h index b76a4694152..b0f6a33aa6b 100644 --- a/sys/msdosfs/msdosfsmount.h +++ b/sys/msdosfs/msdosfsmount.h @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfsmount.h,v 1.7 1997/10/06 20:21:01 deraadt Exp $ */ +/* $OpenBSD: msdosfsmount.h,v 1.8 1997/11/06 05:58:59 csapuntz Exp $ */ /* $NetBSD: msdosfsmount.h,v 1.15 1996/12/22 10:31:41 cgd Exp $ */ /*- @@ -199,4 +199,4 @@ int msdosfs_statfs __P((struct mount *, struct statfs *, struct proc *)); int msdosfs_sync __P((struct mount *, int, struct ucred *, struct proc *)); int msdosfs_fhtovp __P((struct mount *, struct fid *, struct mbuf *, struct vnode **, int *, struct ucred **)); int msdosfs_vptofh __P((struct vnode *, struct fid *)); -void msdosfs_init __P((void)); +int msdosfs_init __P((struct vfsconf *)); |