vfs: drop the error parameter from vn_isdisk, introduce vn_isdisk_error
Most consumers pass NULL.
This commit is contained in:
parent
4b3208a97b
commit
7ad2a82da2
@ -2184,7 +2184,7 @@ again:
|
||||
be_lun->vn = nd.ni_vp;
|
||||
|
||||
/* We only support disks and files. */
|
||||
if (vn_isdisk(be_lun->vn, &error)) {
|
||||
if (vn_isdisk_error(be_lun->vn, &error)) {
|
||||
error = ctl_be_block_open_dev(be_lun, req);
|
||||
} else if (be_lun->vn->v_type == VREG) {
|
||||
error = ctl_be_block_open_file(be_lun, req);
|
||||
@ -2547,7 +2547,7 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req)
|
||||
control_softc->ha_mode == CTL_HA_MODE_SER_ONLY) {
|
||||
if (be_lun->vn == NULL)
|
||||
error = ctl_be_block_open(be_lun, req);
|
||||
else if (vn_isdisk(be_lun->vn, &error))
|
||||
else if (vn_isdisk_error(be_lun->vn, &error))
|
||||
error = ctl_be_block_open_dev(be_lun, req);
|
||||
else if (be_lun->vn->v_type == VREG) {
|
||||
vn_lock(be_lun->vn, LK_SHARED | LK_RETRY);
|
||||
|
@ -65,7 +65,7 @@ translate_vnhook_major_minor(struct vnode *vp, struct stat *sb)
|
||||
{
|
||||
int major, minor;
|
||||
|
||||
if (vn_isdisk(vp, NULL)) {
|
||||
if (vn_isdisk(vp)) {
|
||||
sb->st_mode &= ~S_IFMT;
|
||||
sb->st_mode |= S_IFBLK;
|
||||
}
|
||||
@ -131,7 +131,7 @@ translate_fd_major_minor(struct thread *td, int fd, struct stat *buf)
|
||||
fget(td, fd, &cap_no_rights, &fp) != 0)
|
||||
return;
|
||||
vp = fp->f_vnode;
|
||||
if (vp != NULL && vn_isdisk(vp, NULL)) {
|
||||
if (vp != NULL && vn_isdisk(vp)) {
|
||||
buf->st_mode &= ~S_IFMT;
|
||||
buf->st_mode |= S_IFBLK;
|
||||
}
|
||||
|
@ -2735,7 +2735,7 @@ xbb_open_backend(struct xbb_softc *xbb)
|
||||
xbb->vn = nd.ni_vp;
|
||||
|
||||
/* We only support disks and files. */
|
||||
if (vn_isdisk(xbb->vn, &error)) {
|
||||
if (vn_isdisk_error(xbb->vn, &error)) {
|
||||
error = xbb_open_dev(xbb);
|
||||
} else if (xbb->vn->v_type == VREG) {
|
||||
error = xbb_open_file(xbb);
|
||||
|
@ -165,7 +165,7 @@ cd9660_mount(struct mount *mp)
|
||||
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
||||
devvp = ndp.ni_vp;
|
||||
|
||||
if (!vn_isdisk(devvp, &error)) {
|
||||
if (!vn_isdisk_error(devvp, &error)) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ ext2_mount(struct mount *mp)
|
||||
NDFREE(ndp, NDF_ONLY_PNBUF);
|
||||
devvp = ndp->ni_vp;
|
||||
|
||||
if (!vn_isdisk(devvp, &error)) {
|
||||
if (!vn_isdisk_error(devvp, &error)) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ msdosfs_mount(struct mount *mp)
|
||||
devvp = ndp.ni_vp;
|
||||
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
||||
|
||||
if (!vn_isdisk(devvp, &error)) {
|
||||
if (!vn_isdisk_error(devvp, &error)) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ udf_mount(struct mount *mp)
|
||||
NDFREE(ndp, NDF_ONLY_PNBUF);
|
||||
devvp = ndp->ni_vp;
|
||||
|
||||
if (vn_isdisk(devvp, &error) == 0) {
|
||||
if (!vn_isdisk_error(devvp, &error)) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -1972,7 +1972,7 @@ sys_aio_cancel(struct thread *td, struct aio_cancel_args *uap)
|
||||
|
||||
if (fp->f_type == DTYPE_VNODE) {
|
||||
vp = fp->f_vnode;
|
||||
if (vn_isdisk(vp, &error)) {
|
||||
if (vn_isdisk(vp)) {
|
||||
fdrop(fp, td);
|
||||
td->td_retval[0] = AIO_NOTCANCELED;
|
||||
return (0);
|
||||
|
@ -2724,7 +2724,7 @@ brelse(struct buf *bp)
|
||||
if ((bp->b_flags & B_VMIO) && (bp->b_flags & B_NOCACHE ||
|
||||
(bp->b_ioflags & BIO_ERROR && bp->b_iocmd == BIO_READ)) &&
|
||||
(v_mnt == NULL || (v_mnt->mnt_vfc->vfc_flags & VFCF_NETWORK) == 0 ||
|
||||
vn_isdisk(bp->b_vp, NULL) || (bp->b_flags & B_DELWRI) == 0)) {
|
||||
vn_isdisk(bp->b_vp) || (bp->b_flags & B_DELWRI) == 0)) {
|
||||
vfs_vmio_invalidate(bp);
|
||||
allocbuf(bp, 0);
|
||||
}
|
||||
@ -3757,7 +3757,7 @@ bp_unmapped_get_kva(struct buf *bp, daddr_t blkno, int size, int gbflags)
|
||||
* Calculate the amount of the address space we would reserve
|
||||
* if the buffer was mapped.
|
||||
*/
|
||||
bsize = vn_isdisk(bp->b_vp, NULL) ? DEV_BSIZE : bp->b_bufobj->bo_bsize;
|
||||
bsize = vn_isdisk(bp->b_vp) ? DEV_BSIZE : bp->b_bufobj->bo_bsize;
|
||||
KASSERT(bsize != 0, ("bsize == 0, check bo->bo_bsize"));
|
||||
offset = blkno * bsize;
|
||||
maxsize = size + (offset & PAGE_MASK);
|
||||
@ -4013,7 +4013,7 @@ newbuf_unlocked:
|
||||
if (flags & GB_NOCREAT)
|
||||
return (EEXIST);
|
||||
|
||||
bsize = vn_isdisk(vp, NULL) ? DEV_BSIZE : bo->bo_bsize;
|
||||
bsize = vn_isdisk(vp) ? DEV_BSIZE : bo->bo_bsize;
|
||||
KASSERT(bsize != 0, ("bsize == 0, check bo->bo_bsize"));
|
||||
offset = blkno * bsize;
|
||||
vmio = vp->v_object != NULL;
|
||||
@ -4026,7 +4026,7 @@ newbuf_unlocked:
|
||||
}
|
||||
maxsize = imax(maxsize, bsize);
|
||||
if ((flags & GB_NOSPARSE) != 0 && vmio &&
|
||||
!vn_isdisk(vp, NULL)) {
|
||||
!vn_isdisk(vp)) {
|
||||
error = VOP_BMAP(vp, blkno, NULL, &d_blkno, 0, 0);
|
||||
KASSERT(error != EOPNOTSUPP,
|
||||
("GB_NOSPARSE from fs not supporting bmap, vp %p",
|
||||
|
@ -4977,8 +4977,8 @@ vn_need_pageq_flush(struct vnode *vp)
|
||||
/*
|
||||
* Check if vnode represents a disk device
|
||||
*/
|
||||
int
|
||||
vn_isdisk(struct vnode *vp, int *errp)
|
||||
bool
|
||||
vn_isdisk_error(struct vnode *vp, int *errp)
|
||||
{
|
||||
int error;
|
||||
|
||||
@ -4996,11 +4996,18 @@ vn_isdisk(struct vnode *vp, int *errp)
|
||||
error = ENOTBLK;
|
||||
dev_unlock();
|
||||
out:
|
||||
if (errp != NULL)
|
||||
*errp = error;
|
||||
*errp = error;
|
||||
return (error == 0);
|
||||
}
|
||||
|
||||
bool
|
||||
vn_isdisk(struct vnode *vp)
|
||||
{
|
||||
int error;
|
||||
|
||||
return (vn_isdisk_error(vp, &error));
|
||||
}
|
||||
|
||||
/*
|
||||
* VOP_FPLOOKUP_VEXEC routines are subject to special circumstances, see
|
||||
* the comment above cache_fplookup for details.
|
||||
|
@ -718,7 +718,8 @@ int vn_generic_copy_file_range(struct vnode *invp, off_t *inoffp,
|
||||
unsigned int flags, struct ucred *incred, struct ucred *outcred,
|
||||
struct thread *fsize_td);
|
||||
int vn_need_pageq_flush(struct vnode *vp);
|
||||
int vn_isdisk(struct vnode *vp, int *errp);
|
||||
bool vn_isdisk_error(struct vnode *vp, int *errp);
|
||||
bool vn_isdisk(struct vnode *vp);
|
||||
int _vn_lock(struct vnode *vp, int flags, const char *file, int line);
|
||||
#define vn_lock(vp, flags) _vn_lock(vp, flags, __FILE__, __LINE__)
|
||||
int vn_open(struct nameidata *ndp, int *flagp, int cmode, struct file *fp);
|
||||
|
@ -12723,7 +12723,7 @@ softdep_fsync_mountdev(vp)
|
||||
struct worklist *wk;
|
||||
struct bufobj *bo;
|
||||
|
||||
if (!vn_isdisk(vp, NULL))
|
||||
if (!vn_isdisk(vp))
|
||||
panic("softdep_fsync_mountdev: vnode not a disk");
|
||||
bo = &vp->v_bufobj;
|
||||
restart:
|
||||
|
@ -728,7 +728,7 @@ ffs_mount(struct mount *mp)
|
||||
return (error);
|
||||
NDFREE(&ndp, NDF_ONLY_PNBUF);
|
||||
devvp = ndp.ni_vp;
|
||||
if (!vn_isdisk(devvp, &error)) {
|
||||
if (!vn_isdisk_error(devvp, &error)) {
|
||||
vput(devvp);
|
||||
return (error);
|
||||
}
|
||||
|
@ -919,7 +919,7 @@ sysctl_swap_fragmentation(SYSCTL_HANDLER_ARGS)
|
||||
sbuf_new_for_sysctl(&sbuf, NULL, 128, req);
|
||||
mtx_lock(&sw_dev_mtx);
|
||||
TAILQ_FOREACH(sp, &swtailq, sw_list) {
|
||||
if (vn_isdisk(sp->sw_vp, NULL))
|
||||
if (vn_isdisk(sp->sw_vp))
|
||||
devname = devtoname(sp->sw_vp->v_rdev);
|
||||
else
|
||||
devname = "[file]";
|
||||
@ -2325,7 +2325,7 @@ sys_swapon(struct thread *td, struct swapon_args *uap)
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vp = nd.ni_vp;
|
||||
|
||||
if (vn_isdisk(vp, &error)) {
|
||||
if (vn_isdisk_error(vp, &error)) {
|
||||
error = swapongeom(vp);
|
||||
} else if (vp->v_type == VREG &&
|
||||
(vp->v_mount->mnt_vfc->vfc_flags & VFCF_NETWORK) != 0 &&
|
||||
@ -2548,7 +2548,7 @@ swapoff_all(void)
|
||||
mtx_lock(&sw_dev_mtx);
|
||||
TAILQ_FOREACH_SAFE(sp, &swtailq, sw_list, spt) {
|
||||
mtx_unlock(&sw_dev_mtx);
|
||||
if (vn_isdisk(sp->sw_vp, NULL))
|
||||
if (vn_isdisk(sp->sw_vp))
|
||||
devname = devtoname(sp->sw_vp->v_rdev);
|
||||
else
|
||||
devname = "[file]";
|
||||
@ -2596,7 +2596,7 @@ swap_dev_info(int name, struct xswdev *xs, char *devname, size_t len)
|
||||
xs->xsw_nblks = sp->sw_nblks;
|
||||
xs->xsw_used = sp->sw_used;
|
||||
if (devname != NULL) {
|
||||
if (vn_isdisk(sp->sw_vp, NULL))
|
||||
if (vn_isdisk(sp->sw_vp))
|
||||
tmp_devname = devtoname(sp->sw_vp->v_rdev);
|
||||
else
|
||||
tmp_devname = "[file]";
|
||||
|
@ -152,7 +152,7 @@ vnode_create_vobject(struct vnode *vp, off_t isize, struct thread *td)
|
||||
struct vattr va;
|
||||
bool last;
|
||||
|
||||
if (!vn_isdisk(vp, NULL) && vn_canvmio(vp) == FALSE)
|
||||
if (!vn_isdisk(vp) && vn_canvmio(vp) == FALSE)
|
||||
return (0);
|
||||
|
||||
object = vp->v_object;
|
||||
@ -160,7 +160,7 @@ vnode_create_vobject(struct vnode *vp, off_t isize, struct thread *td)
|
||||
return (0);
|
||||
|
||||
if (size == 0) {
|
||||
if (vn_isdisk(vp, NULL)) {
|
||||
if (vn_isdisk(vp)) {
|
||||
size = IDX_TO_OFF(INT_MAX);
|
||||
} else {
|
||||
if (VOP_GETATTR(vp, &va, td->td_ucred))
|
||||
|
Loading…
x
Reference in New Issue
Block a user