Take VBLK devices further out of their missery.
This should fix the panic I introduced in my previous commit on this topic.
This commit is contained in:
parent
4e457f4298
commit
1d7e3e42e7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=68259
@ -139,21 +139,14 @@ spec_open(ap)
|
||||
struct cdevsw *dsw;
|
||||
const char *cp;
|
||||
|
||||
if (vp->v_type == VBLK)
|
||||
return ENXIO;
|
||||
/*
|
||||
* Don't allow open if fs is mounted -nodev.
|
||||
*/
|
||||
if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV))
|
||||
return (ENXIO);
|
||||
|
||||
if (vp->v_type == VBLK) {
|
||||
if (*dev->si_name != '\0')
|
||||
printf("Device \"%s\" ", dev->si_name);
|
||||
else
|
||||
printf("Device char-major=%d minor=0x%x ",
|
||||
major(dev), minor(dev));
|
||||
printf("failed attempt to open in block mode\n");
|
||||
return ENXIO;
|
||||
}
|
||||
dsw = devsw(dev);
|
||||
if ( (dsw == NULL) || (dsw->d_open == NULL))
|
||||
return ENXIO;
|
||||
|
@ -2241,7 +2241,7 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo)
|
||||
if (vmio) {
|
||||
bp->b_flags |= B_VMIO;
|
||||
#if defined(VFS_BIO_DEBUG)
|
||||
if (vp->v_type != VREG && vp->v_type != VBLK)
|
||||
if (vp->v_type != VREG)
|
||||
printf("getblk: vmioing file type %d???\n", vp->v_type);
|
||||
#endif
|
||||
} else {
|
||||
|
@ -1234,7 +1234,6 @@ reassignbuf(bp, newvp)
|
||||
delay = dirdelay;
|
||||
break;
|
||||
case VCHR:
|
||||
case VBLK:
|
||||
if (newvp->v_rdev->si_mountpoint != NULL) {
|
||||
delay = metadelay;
|
||||
break;
|
||||
@ -1314,9 +1313,8 @@ reassignbuf(bp, newvp)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a vnode for a block device.
|
||||
* Create a vnode for a device.
|
||||
* Used for mounting the root file system.
|
||||
* XXX: This now changed to a VCHR due to the block/char merging.
|
||||
*/
|
||||
int
|
||||
bdevvp(dev, vpp)
|
||||
@ -1362,9 +1360,11 @@ addaliasu(nvp, nvp_rdev)
|
||||
vop_t **ops;
|
||||
dev_t dev;
|
||||
|
||||
if (nvp->v_type != VBLK && nvp->v_type != VCHR)
|
||||
if (nvp->v_type == VBLK)
|
||||
return (nvp);
|
||||
if (nvp->v_type != VCHR)
|
||||
panic("addaliasu on non-special vnode");
|
||||
dev = udev2dev(nvp_rdev, nvp->v_type == VBLK ? 1 : 0);
|
||||
dev = udev2dev(nvp_rdev, 0);
|
||||
/*
|
||||
* Check to see if we have a bdevvp vnode with no associated
|
||||
* filesystem. If so, we want to associate the filesystem of
|
||||
@ -1405,8 +1405,7 @@ addalias(nvp, dev)
|
||||
dev_t dev;
|
||||
{
|
||||
|
||||
KASSERT(nvp->v_type == VBLK || nvp->v_type == VCHR,
|
||||
("addalias on non-special vnode"));
|
||||
KASSERT(nvp->v_type == VCHR, ("addalias on non-special vnode"));
|
||||
nvp->v_rdev = dev;
|
||||
simple_lock(&spechash_slock);
|
||||
SLIST_INSERT_HEAD(&dev->si_hlist, nvp, v_specnext);
|
||||
@ -1682,7 +1681,7 @@ vflush(mp, skipvp, flags)
|
||||
*/
|
||||
if (flags & FORCECLOSE) {
|
||||
simple_unlock(&mntvnode_slock);
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR) {
|
||||
if (vp->v_type != VCHR) {
|
||||
vgonel(vp, p);
|
||||
} else {
|
||||
vclean(vp, 0, p);
|
||||
@ -1925,7 +1924,7 @@ vgonel(vp, p)
|
||||
* If special device, remove it from special device alias list
|
||||
* if it is on one.
|
||||
*/
|
||||
if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_rdev != NULL) {
|
||||
if (vp->v_type == VCHR && vp->v_rdev != NULL && vp->v_rdev != NODEV) {
|
||||
simple_lock(&spechash_slock);
|
||||
SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
|
||||
freedev(vp->v_rdev);
|
||||
@ -2932,13 +2931,13 @@ sync_print(ap)
|
||||
}
|
||||
|
||||
/*
|
||||
* extract the dev_t from a VBLK or VCHR
|
||||
* extract the dev_t from a VCHR
|
||||
*/
|
||||
dev_t
|
||||
vn_todev(vp)
|
||||
struct vnode *vp;
|
||||
{
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR)
|
||||
if (vp->v_type != VCHR)
|
||||
return (NODEV);
|
||||
return (vp->v_rdev);
|
||||
}
|
||||
@ -2953,7 +2952,7 @@ vn_isdisk(vp, errp)
|
||||
{
|
||||
struct cdevsw *cdevsw;
|
||||
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR) {
|
||||
if (vp->v_type != VCHR) {
|
||||
if (errp != NULL)
|
||||
*errp = ENOTBLK;
|
||||
return (0);
|
||||
|
@ -3189,7 +3189,7 @@ revoke(p, uap)
|
||||
return (error);
|
||||
vp = nd.ni_vp;
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||
if (vp->v_type != VCHR) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
@ -1234,7 +1234,6 @@ reassignbuf(bp, newvp)
|
||||
delay = dirdelay;
|
||||
break;
|
||||
case VCHR:
|
||||
case VBLK:
|
||||
if (newvp->v_rdev->si_mountpoint != NULL) {
|
||||
delay = metadelay;
|
||||
break;
|
||||
@ -1314,9 +1313,8 @@ reassignbuf(bp, newvp)
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a vnode for a block device.
|
||||
* Create a vnode for a device.
|
||||
* Used for mounting the root file system.
|
||||
* XXX: This now changed to a VCHR due to the block/char merging.
|
||||
*/
|
||||
int
|
||||
bdevvp(dev, vpp)
|
||||
@ -1362,9 +1360,11 @@ addaliasu(nvp, nvp_rdev)
|
||||
vop_t **ops;
|
||||
dev_t dev;
|
||||
|
||||
if (nvp->v_type != VBLK && nvp->v_type != VCHR)
|
||||
if (nvp->v_type == VBLK)
|
||||
return (nvp);
|
||||
if (nvp->v_type != VCHR)
|
||||
panic("addaliasu on non-special vnode");
|
||||
dev = udev2dev(nvp_rdev, nvp->v_type == VBLK ? 1 : 0);
|
||||
dev = udev2dev(nvp_rdev, 0);
|
||||
/*
|
||||
* Check to see if we have a bdevvp vnode with no associated
|
||||
* filesystem. If so, we want to associate the filesystem of
|
||||
@ -1405,8 +1405,7 @@ addalias(nvp, dev)
|
||||
dev_t dev;
|
||||
{
|
||||
|
||||
KASSERT(nvp->v_type == VBLK || nvp->v_type == VCHR,
|
||||
("addalias on non-special vnode"));
|
||||
KASSERT(nvp->v_type == VCHR, ("addalias on non-special vnode"));
|
||||
nvp->v_rdev = dev;
|
||||
simple_lock(&spechash_slock);
|
||||
SLIST_INSERT_HEAD(&dev->si_hlist, nvp, v_specnext);
|
||||
@ -1682,7 +1681,7 @@ vflush(mp, skipvp, flags)
|
||||
*/
|
||||
if (flags & FORCECLOSE) {
|
||||
simple_unlock(&mntvnode_slock);
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR) {
|
||||
if (vp->v_type != VCHR) {
|
||||
vgonel(vp, p);
|
||||
} else {
|
||||
vclean(vp, 0, p);
|
||||
@ -1925,7 +1924,7 @@ vgonel(vp, p)
|
||||
* If special device, remove it from special device alias list
|
||||
* if it is on one.
|
||||
*/
|
||||
if ((vp->v_type == VBLK || vp->v_type == VCHR) && vp->v_rdev != NULL) {
|
||||
if (vp->v_type == VCHR && vp->v_rdev != NULL && vp->v_rdev != NODEV) {
|
||||
simple_lock(&spechash_slock);
|
||||
SLIST_REMOVE(&vp->v_rdev->si_hlist, vp, vnode, v_specnext);
|
||||
freedev(vp->v_rdev);
|
||||
@ -2932,13 +2931,13 @@ sync_print(ap)
|
||||
}
|
||||
|
||||
/*
|
||||
* extract the dev_t from a VBLK or VCHR
|
||||
* extract the dev_t from a VCHR
|
||||
*/
|
||||
dev_t
|
||||
vn_todev(vp)
|
||||
struct vnode *vp;
|
||||
{
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR)
|
||||
if (vp->v_type != VCHR)
|
||||
return (NODEV);
|
||||
return (vp->v_rdev);
|
||||
}
|
||||
@ -2953,7 +2952,7 @@ vn_isdisk(vp, errp)
|
||||
{
|
||||
struct cdevsw *cdevsw;
|
||||
|
||||
if (vp->v_type != VBLK && vp->v_type != VCHR) {
|
||||
if (vp->v_type != VCHR) {
|
||||
if (errp != NULL)
|
||||
*errp = ENOTBLK;
|
||||
return (0);
|
||||
|
@ -3189,7 +3189,7 @@ revoke(p, uap)
|
||||
return (error);
|
||||
vp = nd.ni_vp;
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
if (vp->v_type != VCHR && vp->v_type != VBLK) {
|
||||
if (vp->v_type != VCHR) {
|
||||
error = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ vn_rdwr(rw, vp, base, len, offset, segflg, ioflg, cred, aresid, p)
|
||||
if ((ioflg & IO_NODELOCKED) == 0) {
|
||||
mp = NULL;
|
||||
if (rw == UIO_WRITE &&
|
||||
vp->v_type != VCHR && vp->v_type != VBLK &&
|
||||
vp->v_type != VCHR &&
|
||||
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
return (error);
|
||||
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
|
||||
@ -407,7 +407,7 @@ vn_write(fp, uio, cred, flags, p)
|
||||
(vp->v_mount && (vp->v_mount->mnt_flag & MNT_SYNCHRONOUS)))
|
||||
ioflag |= IO_SYNC;
|
||||
mp = NULL;
|
||||
if (vp->v_type != VCHR && vp->v_type != VBLK &&
|
||||
if (vp->v_type != VCHR &&
|
||||
(error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0)
|
||||
return (error);
|
||||
VOP_LEASE(vp, p, cred, LEASE_WRITE);
|
||||
|
@ -139,21 +139,14 @@ spec_open(ap)
|
||||
struct cdevsw *dsw;
|
||||
const char *cp;
|
||||
|
||||
if (vp->v_type == VBLK)
|
||||
return ENXIO;
|
||||
/*
|
||||
* Don't allow open if fs is mounted -nodev.
|
||||
*/
|
||||
if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV))
|
||||
return (ENXIO);
|
||||
|
||||
if (vp->v_type == VBLK) {
|
||||
if (*dev->si_name != '\0')
|
||||
printf("Device \"%s\" ", dev->si_name);
|
||||
else
|
||||
printf("Device char-major=%d minor=0x%x ",
|
||||
major(dev), minor(dev));
|
||||
printf("failed attempt to open in block mode\n");
|
||||
return ENXIO;
|
||||
}
|
||||
dsw = devsw(dev);
|
||||
if ( (dsw == NULL) || (dsw->d_open == NULL))
|
||||
return ENXIO;
|
||||
|
Loading…
Reference in New Issue
Block a user