1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-02-08 20:37:59 +00:00

Convert various pieces of code to use vn_isdisk() rather than checking

for vp->v_type == VBLK.

In ccd: we don't need to call VOP_GETATTR to find the type of a vnode.

Reviewed by:    sos
This commit is contained in:
Poul-Henning Kamp 1999-11-22 10:33:55 +00:00
parent 06adfd11a1
commit 38224dcd59
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=53577
10 changed files with 27 additions and 50 deletions

View File

@ -3691,8 +3691,8 @@ softdep_fsync_mountdev(vp)
struct buf *bp, *nbp;
struct worklist *wk;
if (vp->v_type != VBLK)
panic("softdep_fsync_mountdev: vnode not VBLK");
if (!vn_isdisk(vp))
panic("softdep_fsync_mountdev: vnode not a disk");
ACQUIRE_LOCK(&lk);
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
nbp = TAILQ_NEXT(bp, b_vnbufs);
@ -3753,7 +3753,7 @@ softdep_sync_metadata(ap)
* Check whether this vnode is involved in a filesystem
* that is doing soft dependency processing.
*/
if (vp->v_type != VBLK) {
if (!vn_isdisk(vp)) {
if (!DOINGSOFTDEP(vp))
return (0);
} else
@ -3978,7 +3978,7 @@ loop:
* way to accomplish this is to sync the entire filesystem (luckily
* this happens rarely).
*/
if (vp->v_type == VBLK && vp->v_specmountpoint && !VOP_ISLOCKED(vp) &&
if (vn_isdisk(vp) && vp->v_specmountpoint && !VOP_ISLOCKED(vp) &&
(error = VFS_SYNC(vp->v_specmountpoint, MNT_WAIT, ap->a_cred,
ap->a_p)) != 0)
return (error);

View File

@ -1603,18 +1603,7 @@ ccdlookup(path, p, vpp)
return (EBUSY);
}
if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) {
#ifdef DEBUG
if (ccddebug & CCDB_FOLLOW|CCDB_INIT)
printf("ccdlookup: getattr error = %d\n", error);
#endif
VOP_UNLOCK(vp, 0, p);
(void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
return (error);
}
/* XXX: eventually we should handle VREG, too. */
if (va.va_type != VBLK) {
if (!vn_isdisk(vp)) {
VOP_UNLOCK(vp, 0, p);
(void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
return (ENOTBLK);

View File

@ -1603,18 +1603,7 @@ ccdlookup(path, p, vpp)
return (EBUSY);
}
if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)) != 0) {
#ifdef DEBUG
if (ccddebug & CCDB_FOLLOW|CCDB_INIT)
printf("ccdlookup: getattr error = %d\n", error);
#endif
VOP_UNLOCK(vp, 0, p);
(void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
return (error);
}
/* XXX: eventually we should handle VREG, too. */
if (va.va_type != VBLK) {
if (!vn_isdisk(vp)) {
VOP_UNLOCK(vp, 0, p);
(void)vn_close(vp, FREAD|FWRITE, p->p_ucred, p);
return (ENOTBLK);

View File

@ -934,10 +934,7 @@ aio_qphysio(p, aiocbe)
vp = (struct vnode *)fp->f_data;
/* XXX: use vn_isdisk() when VBLK and VCHR are unified */
if (vp->v_type != VCHR)
return (-1);
if (!(devsw(vp->v_rdev)->d_flags & D_DISK))
if (!vn_isdisk(vp))
return (-1);
if (cb->aio_nbytes % vp->v_rdev->si_bsize_phys)

View File

@ -624,7 +624,7 @@ bwrite(struct buf * bp)
* filesystem (if any).
*/
if ((vp = bp->b_vp) != NULL) {
if (vp->v_type == VBLK)
if (vn_isdisk(vp))
mp = vp->v_specmountpoint;
else
mp = vp->v_mount;
@ -915,7 +915,7 @@ brelse(struct buf * bp)
*/
if ((bp->b_flags & B_VMIO)
&& !(bp->b_vp->v_tag == VT_NFS &&
bp->b_vp->v_type != VBLK &&
!vn_isdisk(bp->b_vp) &&
(bp->b_flags & B_DELWRI))
) {
@ -2103,7 +2103,7 @@ loop:
int bsize, maxsize, vmio;
off_t offset;
if (vp->v_type == VBLK)
if (vn_isdisk(vp))
bsize = DEV_BSIZE;
else if (vp->v_mountedhere)
bsize = vp->v_mountedhere->mnt_stat.f_iosize;
@ -2690,7 +2690,7 @@ biodone(register struct buf * bp)
(int) m->pindex, (int)(foff >> 32),
(int) foff & 0xffffffff, resid, i);
#endif
if (vp->v_type != VBLK)
if (!vn_isdisk(vp))
#if !defined(MAX_PERF)
printf(" iosize: %ld, lblkno: %d, flags: 0x%lx, npages: %d\n",
bp->b_vp->v_mount->mnt_stat.f_iosize,

View File

@ -1021,7 +1021,7 @@ sched_sync(void)
* slot we are safe.
*/
if (TAILQ_EMPTY(&vp->v_dirtyblkhd) &&
vp->v_type != VBLK)
!vn_isdisk(vp))
panic("sched_sync: fsync failed vp %p tag %d", vp, vp->v_tag);
/*
* Put us back on the worklist. The worklist
@ -1207,6 +1207,7 @@ reassignbuf(bp, newvp)
case VDIR:
delay = dirdelay;
break;
case VCHR:
case VBLK:
if (newvp->v_specmountpoint != NULL) {
delay = metadelay;
@ -2507,7 +2508,7 @@ vfs_object_create(vp, p, cred)
vm_object_t object;
int error = 0;
if (vp->v_type != VBLK && vn_canvmio(vp) == FALSE)
if (!vn_isdisk(vp) && vn_canvmio(vp) == FALSE)
return 0;
retry:
@ -2519,7 +2520,7 @@ retry:
} else if (devsw(vp->v_rdev) != NULL) {
/*
* This simply allocates the biggest object possible
* for a VBLK vnode. This should be fixed, but doesn't
* for a disk vnode. This should be fixed, but doesn't
* cause any problems (yet).
*/
object = vnode_pager_alloc(vp, IDX_TO_OFF(INT_MAX), 0, 0);

View File

@ -1021,7 +1021,7 @@ sched_sync(void)
* slot we are safe.
*/
if (TAILQ_EMPTY(&vp->v_dirtyblkhd) &&
vp->v_type != VBLK)
!vn_isdisk(vp))
panic("sched_sync: fsync failed vp %p tag %d", vp, vp->v_tag);
/*
* Put us back on the worklist. The worklist
@ -1207,6 +1207,7 @@ reassignbuf(bp, newvp)
case VDIR:
delay = dirdelay;
break;
case VCHR:
case VBLK:
if (newvp->v_specmountpoint != NULL) {
delay = metadelay;
@ -2507,7 +2508,7 @@ vfs_object_create(vp, p, cred)
vm_object_t object;
int error = 0;
if (vp->v_type != VBLK && vn_canvmio(vp) == FALSE)
if (!vn_isdisk(vp) && vn_canvmio(vp) == FALSE)
return 0;
retry:
@ -2519,7 +2520,7 @@ retry:
} else if (devsw(vp->v_rdev) != NULL) {
/*
* This simply allocates the biggest object possible
* for a VBLK vnode. This should be fixed, but doesn't
* for a disk vnode. This should be fixed, but doesn't
* cause any problems (yet).
*/
object = vnode_pager_alloc(vp, IDX_TO_OFF(INT_MAX), 0, 0);

View File

@ -3691,8 +3691,8 @@ softdep_fsync_mountdev(vp)
struct buf *bp, *nbp;
struct worklist *wk;
if (vp->v_type != VBLK)
panic("softdep_fsync_mountdev: vnode not VBLK");
if (!vn_isdisk(vp))
panic("softdep_fsync_mountdev: vnode not a disk");
ACQUIRE_LOCK(&lk);
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
nbp = TAILQ_NEXT(bp, b_vnbufs);
@ -3753,7 +3753,7 @@ softdep_sync_metadata(ap)
* Check whether this vnode is involved in a filesystem
* that is doing soft dependency processing.
*/
if (vp->v_type != VBLK) {
if (!vn_isdisk(vp)) {
if (!DOINGSOFTDEP(vp))
return (0);
} else
@ -3978,7 +3978,7 @@ loop:
* way to accomplish this is to sync the entire filesystem (luckily
* this happens rarely).
*/
if (vp->v_type == VBLK && vp->v_specmountpoint && !VOP_ISLOCKED(vp) &&
if (vn_isdisk(vp) && vp->v_specmountpoint && !VOP_ISLOCKED(vp) &&
(error = VFS_SYNC(vp->v_specmountpoint, MNT_WAIT, ap->a_cred,
ap->a_p)) != 0)
return (error);

View File

@ -436,7 +436,7 @@ ffs_reload(mp, cred, p)
* Only VMIO the backing device if the backing device is a real
* block device. See ffs_mountmfs() for more details.
*/
if (devvp->v_tag != VT_MFS && devvp->v_type == VBLK) {
if (devvp->v_tag != VT_MFS && vn_isdisk(devvp)) {
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
vfs_object_create(devvp, p, p->p_ucred);
simple_lock(&devvp->v_interlock);
@ -593,7 +593,7 @@ ffs_mountfs(devvp, mp, p, malloctype)
* Note that it is optional that the backing device be VMIOed. This
* increases the opportunity for metadata caching.
*/
if (devvp->v_tag != VT_MFS && devvp->v_type == VBLK) {
if (devvp->v_tag != VT_MFS && vn_isdisk(devvp)) {
vn_lock(devvp, LK_EXCLUSIVE | LK_RETRY, p);
vfs_object_create(devvp, p, p->p_ucred);
simple_lock(&devvp->v_interlock);

View File

@ -127,7 +127,7 @@ ffs_fsync(ap)
daddr_t lbn;
if (vp->v_type == VBLK) {
if (vn_isdisk(vp)) {
lbn = INT_MAX;
if (vp->v_specmountpoint != NULL &&
(vp->v_specmountpoint->mnt_flag & MNT_SOFTDEP))
@ -254,7 +254,7 @@ loop:
goto loop;
}
#ifdef DIAGNOSTIC
if (vp->v_type != VBLK)
if (!vn_isdisk(vp))
vprint("ffs_fsync: dirty", vp);
#endif
}