svn commit: r212228 - stable/8/sys/fs/devfs
Konstantin Belousov
kib at FreeBSD.org
Sun Sep 5 14:20:34 UTC 2010
Author: kib
Date: Sun Sep 5 14:20:34 2010
New Revision: 212228
URL: http://svn.freebsd.org/changeset/base/212228
Log:
MFC r210921:
Enable shared locks for the devfs vnodes. Honor the locking mode
requested by lookup().
Modified:
stable/8/sys/fs/devfs/devfs.h
stable/8/sys/fs/devfs/devfs_vfsops.c
stable/8/sys/fs/devfs/devfs_vnops.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/fs/devfs/devfs.h
==============================================================================
--- stable/8/sys/fs/devfs/devfs.h Sun Sep 5 14:16:35 2010 (r212227)
+++ stable/8/sys/fs/devfs/devfs.h Sun Sep 5 14:20:34 2010 (r212228)
@@ -172,7 +172,7 @@ extern unsigned devfs_rule_depth;
void devfs_rules_apply(struct devfs_mount *dm, struct devfs_dirent *de);
void devfs_rules_cleanup (struct devfs_mount *dm);
int devfs_rules_ioctl(struct devfs_mount *dm, u_long cmd, caddr_t data, struct thread *td);
-int devfs_allocv (struct devfs_dirent *de, struct mount *mp,
+int devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode,
struct vnode **vpp);
void devfs_delete(struct devfs_mount *dm, struct devfs_dirent *de, int vp_locked);
void devfs_dirent_free(struct devfs_dirent *de);
Modified: stable/8/sys/fs/devfs/devfs_vfsops.c
==============================================================================
--- stable/8/sys/fs/devfs/devfs_vfsops.c Sun Sep 5 14:16:35 2010 (r212227)
+++ stable/8/sys/fs/devfs/devfs_vfsops.c Sun Sep 5 14:20:34 2010 (r212228)
@@ -155,7 +155,7 @@ devfs_root(struct mount *mp, int flags,
dmp = VFSTODEVFS(mp);
sx_xlock(&dmp->dm_lock);
- error = devfs_allocv(dmp->dm_rootdir, mp, &vp);
+ error = devfs_allocv(dmp->dm_rootdir, mp, LK_EXCLUSIVE, &vp);
if (error)
return (error);
vp->v_vflag |= VV_ROOT;
Modified: stable/8/sys/fs/devfs/devfs_vnops.c
==============================================================================
--- stable/8/sys/fs/devfs/devfs_vnops.c Sun Sep 5 14:16:35 2010 (r212227)
+++ stable/8/sys/fs/devfs/devfs_vnops.c Sun Sep 5 14:20:34 2010 (r212228)
@@ -331,7 +331,8 @@ devfs_insmntque_dtr(struct vnode *vp, vo
* it on return.
*/
int
-devfs_allocv(struct devfs_dirent *de, struct mount *mp, struct vnode **vpp)
+devfs_allocv(struct devfs_dirent *de, struct mount *mp, int lockmode,
+ struct vnode **vpp)
{
int error;
struct vnode *vp;
@@ -352,7 +353,7 @@ devfs_allocv(struct devfs_dirent *de, st
VI_LOCK(vp);
mtx_unlock(&devfs_de_interlock);
sx_xunlock(&dmp->dm_lock);
- error = vget(vp, LK_EXCLUSIVE | LK_INTERLOCK, curthread);
+ error = vget(vp, lockmode | LK_INTERLOCK, curthread);
sx_xlock(&dmp->dm_lock);
if (devfs_allocv_drop_refs(0, dmp, de)) {
if (error == 0)
@@ -408,6 +409,7 @@ devfs_allocv(struct devfs_dirent *de, st
} else {
vp->v_type = VBAD;
}
+ VN_LOCK_ASHARE(vp);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_NOWITNESS);
mtx_lock(&devfs_de_interlock);
vp->v_data = de;
@@ -747,7 +749,7 @@ devfs_lookupx(struct vop_lookup_args *ap
struct devfs_dirent **dde;
struct devfs_mount *dmp;
struct cdev *cdev;
- int error, flags, nameiop;
+ int error, flags, nameiop, dvplocked;
char specname[SPECNAMELEN + 1], *pname;
cnp = ap->a_cnp;
@@ -788,10 +790,12 @@ devfs_lookupx(struct vop_lookup_args *ap
de = devfs_parent_dirent(dd);
if (de == NULL)
return (ENOENT);
+ dvplocked = VOP_ISLOCKED(dvp);
VOP_UNLOCK(dvp, 0);
- error = devfs_allocv(de, dvp->v_mount, vpp);
+ error = devfs_allocv(de, dvp->v_mount,
+ cnp->cn_lkflags & LK_TYPE_MASK, vpp);
*dm_unlock = 0;
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
+ vn_lock(dvp, dvplocked | LK_RETRY);
return (error);
}
@@ -878,7 +882,8 @@ devfs_lookupx(struct vop_lookup_args *ap
return (0);
}
}
- error = devfs_allocv(de, dvp->v_mount, vpp);
+ error = devfs_allocv(de, dvp->v_mount, cnp->cn_lkflags & LK_TYPE_MASK,
+ vpp);
*dm_unlock = 0;
return (error);
}
@@ -936,7 +941,7 @@ devfs_mknod(struct vop_mknod_args *ap)
if (de == NULL)
goto notfound;
de->de_flags &= ~DE_WHITEOUT;
- error = devfs_allocv(de, dvp->v_mount, vpp);
+ error = devfs_allocv(de, dvp->v_mount, LK_EXCLUSIVE, vpp);
return (error);
notfound:
sx_xunlock(&dmp->dm_lock);
@@ -951,7 +956,7 @@ devfs_open(struct vop_open_args *ap)
struct vnode *vp = ap->a_vp;
struct cdev *dev = vp->v_rdev;
struct file *fp = ap->a_fp;
- int error;
+ int error, vlocked;
struct cdevsw *dsw;
struct file *fpop;
@@ -969,6 +974,7 @@ devfs_open(struct vop_open_args *ap)
if (dsw == NULL)
return (ENXIO);
+ vlocked = VOP_ISLOCKED(vp);
VOP_UNLOCK(vp, 0);
fpop = td->td_fpop;
@@ -983,18 +989,15 @@ devfs_open(struct vop_open_args *ap)
error = dsw->d_open(dev, ap->a_mode, S_IFCHR, td);
td->td_fpop = fpop;
- vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-
+ vn_lock(vp, vlocked | LK_RETRY);
dev_relthread(dev);
-
if (error)
return (error);
#if 0 /* /dev/console */
- KASSERT(fp != NULL,
- ("Could not vnode bypass device on NULL fp"));
+ KASSERT(fp != NULL, ("Could not vnode bypass device on NULL fp"));
#else
- if(fp == NULL)
+ if (fp == NULL)
return (error);
#endif
if (fp->f_ops == &badfileops)
@@ -1487,7 +1490,7 @@ devfs_symlink(struct vop_symlink_args *a
mac_devfs_create_symlink(ap->a_cnp->cn_cred, dmp->dm_mount, dd, de);
#endif
TAILQ_INSERT_TAIL(&dd->de_dlist, de, de_list);
- return (devfs_allocv(de, ap->a_dvp->v_mount, ap->a_vpp));
+ return (devfs_allocv(de, ap->a_dvp->v_mount, LK_EXCLUSIVE, ap->a_vpp));
}
static int
More information about the svn-src-all
mailing list