Index: sys/kern/vfs_vnops.c =================================================================== --- sys/kern/vfs_vnops.c +++ sys/kern/vfs_vnops.c @@ -1459,21 +1459,10 @@ /* generic FIOBMAP2 implementation */ static int -vn_ioc_bmap2(struct file *fp, struct fiobmap2_arg *arg, struct ucred *cred) +vn_ioc_bmap2(struct vnode *vp, daddr_t lbn, daddr_t *bn, int *runb, int *runp) { - struct vnode *vp = fp->f_vnode; - daddr_t lbn = arg->bn; - int error; - - vn_lock(vp, LK_SHARED | LK_RETRY); -#ifdef MAC - error = mac_vnode_check_read(cred, fp->f_cred, vp); - if (error == 0) -#endif - error = VOP_BMAP(vp, lbn, NULL, &arg->bn, &arg->runp, - &arg->runb); - VOP_UNLOCK(vp, 0); - return (error); + ASSERT_VOP_LOCKED(vp, "vn_ioc_bmap2 with no vp lock held"); + return( VOP_BMAP(vp, lbn, NULL, bn, runp, runb)); } /* @@ -1485,6 +1474,7 @@ { struct vattr vattr; struct vnode *vp; + struct fiobmap2_arg *bmarg; int error; vp = fp->f_vnode; @@ -1500,8 +1490,17 @@ *(int *)data = vattr.va_size - fp->f_offset; return (error); case FIOBMAP2: - return (vn_ioc_bmap2(fp, (struct fiobmap2_arg*)data, - active_cred)); + bmarg = (struct fiobmap2_arg *)data; + vn_lock(vp, LK_SHARED | LK_RETRY); +#ifdef MAC + error = mac_vnode_check_read(active_cred, fp->f_cred, + vp); + if (error == 0) +#endif + error = vn_ioc_bmap2(vp, bmarg->bn, &bmarg->bn, + &bmarg->runb, &bmarg->runp); + VOP_UNLOCK(vp, 0); + return (error); case FIONBIO: case FIOASYNC: return (0);