Changeset View
Changeset View
Standalone View
Standalone View
sys/ufs/ffs/ffs_vnops.c
Show First 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) { | ||||
/* | /* | ||||
* Flush indirects in order, if requested. | * Flush indirects in order, if requested. | ||||
* | * | ||||
* Note that if only datasync is requested, we can | * Note that if only datasync is requested, we can | ||||
* skip indirect blocks when softupdates are not | * skip indirect blocks when softupdates are not | ||||
* active. Otherwise we must flush them with data, | * active. Otherwise we must flush them with data, | ||||
* since dependencies prevent data block writes. | * since dependencies prevent data block writes. | ||||
*/ | */ | ||||
if (waitfor == MNT_WAIT && bp->b_lblkno <= -NDADDR && | if (waitfor == MNT_WAIT && bp->b_lblkno <= -UFS_NDADDR && | ||||
(lbn_level(bp->b_lblkno) >= passes || | (lbn_level(bp->b_lblkno) >= passes || | ||||
((flags & DATA_ONLY) != 0 && !DOINGSOFTDEP(vp)))) | ((flags & DATA_ONLY) != 0 && !DOINGSOFTDEP(vp)))) | ||||
continue; | continue; | ||||
if (bp->b_lblkno > lbn) | if (bp->b_lblkno > lbn) | ||||
panic("ffs_syncvnode: syncing truncated data."); | panic("ffs_syncvnode: syncing truncated data."); | ||||
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) { | if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL) == 0) { | ||||
BO_UNLOCK(bo); | BO_UNLOCK(bo); | ||||
} else if (wait) { | } else if (wait) { | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | if ((flags & DATA_ONLY) == 0) { | ||||
still_dirty = true; | still_dirty = true; | ||||
} else { | } else { | ||||
/* | /* | ||||
* For data-only sync, dirty indirect buffers | * For data-only sync, dirty indirect buffers | ||||
* are ignored. | * are ignored. | ||||
*/ | */ | ||||
still_dirty = false; | still_dirty = false; | ||||
TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) { | TAILQ_FOREACH(bp, &bo->bo_dirty.bv_hd, b_bobufs) { | ||||
if (bp->b_lblkno > -NDADDR) { | if (bp->b_lblkno > -UFS_NDADDR) { | ||||
still_dirty = true; | still_dirty = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (still_dirty) { | if (still_dirty) { | ||||
/* Write the inode after sync passes to flush deps. */ | /* Write the inode after sync passes to flush deps. */ | ||||
if (wait && DOINGSOFTDEP(vp) && | if (wait && DOINGSOFTDEP(vp) && | ||||
(flags & NO_INO_UPDT) == 0) { | (flags & NO_INO_UPDT) == 0) { | ||||
BO_UNLOCK(bo); | BO_UNLOCK(bo); | ||||
ffs_update(vp, 1); | ffs_update(vp, 1); | ||||
BO_LOCK(bo); | BO_LOCK(bo); | ||||
} | } | ||||
/* switch between sync/async. */ | /* switch between sync/async. */ | ||||
wait = !wait; | wait = !wait; | ||||
if (wait || ++passes < NIADDR + 2) | if (wait || ++passes < UFS_NIADDR + 2) | ||||
goto loop; | goto loop; | ||||
#ifdef INVARIANTS | #ifdef INVARIANTS | ||||
if (!vn_isdisk(vp, NULL)) | if (!vn_isdisk(vp, NULL)) | ||||
vn_printf(vp, "ffs_fsync: dirty "); | vn_printf(vp, "ffs_fsync: dirty "); | ||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
BO_UNLOCK(bo); | BO_UNLOCK(bo); | ||||
▲ Show 20 Lines • Show All 612 Lines • ▼ Show 20 Lines | #ifdef INVARIANTS | ||||
if (uio->uio_rw != UIO_WRITE || fs->fs_magic != FS_UFS2_MAGIC) | if (uio->uio_rw != UIO_WRITE || fs->fs_magic != FS_UFS2_MAGIC) | ||||
panic("ffs_extwrite: mode"); | panic("ffs_extwrite: mode"); | ||||
#endif | #endif | ||||
if (ioflag & IO_APPEND) | if (ioflag & IO_APPEND) | ||||
uio->uio_offset = dp->di_extsize; | uio->uio_offset = dp->di_extsize; | ||||
KASSERT(uio->uio_offset >= 0, ("ffs_extwrite: uio->uio_offset < 0")); | KASSERT(uio->uio_offset >= 0, ("ffs_extwrite: uio->uio_offset < 0")); | ||||
KASSERT(uio->uio_resid >= 0, ("ffs_extwrite: uio->uio_resid < 0")); | KASSERT(uio->uio_resid >= 0, ("ffs_extwrite: uio->uio_resid < 0")); | ||||
if ((uoff_t)uio->uio_offset + uio->uio_resid > NXADDR * fs->fs_bsize) | if ((uoff_t)uio->uio_offset + uio->uio_resid > | ||||
UFS_NXADDR * fs->fs_bsize) | |||||
return (EFBIG); | return (EFBIG); | ||||
resid = uio->uio_resid; | resid = uio->uio_resid; | ||||
osize = dp->di_extsize; | osize = dp->di_extsize; | ||||
flags = IO_EXT; | flags = IO_EXT; | ||||
if (ioflag & IO_SYNC) | if (ioflag & IO_SYNC) | ||||
flags |= IO_SYNC; | flags |= IO_SYNC; | ||||
▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | ffs_rdextattr(u_char **p, struct vnode *vp, struct thread *td, int extra) | ||||
u_int easize; | u_int easize; | ||||
int error; | int error; | ||||
u_char *eae; | u_char *eae; | ||||
ip = VTOI(vp); | ip = VTOI(vp); | ||||
fs = ITOFS(ip); | fs = ITOFS(ip); | ||||
dp = ip->i_din2; | dp = ip->i_din2; | ||||
easize = dp->di_extsize; | easize = dp->di_extsize; | ||||
if ((uoff_t)easize + extra > NXADDR * fs->fs_bsize) | if ((uoff_t)easize + extra > UFS_NXADDR * fs->fs_bsize) | ||||
return (EFBIG); | return (EFBIG); | ||||
eae = malloc(easize + extra, M_TEMP, M_WAITOK); | eae = malloc(easize + extra, M_TEMP, M_WAITOK); | ||||
liovec.iov_base = eae; | liovec.iov_base = eae; | ||||
liovec.iov_len = easize; | liovec.iov_len = easize; | ||||
luio.uio_iov = &liovec; | luio.uio_iov = &liovec; | ||||
luio.uio_iovcnt = 1; | luio.uio_iovcnt = 1; | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
*/ | */ | ||||
{ | { | ||||
struct vnode *vp; | struct vnode *vp; | ||||
daddr_t lbn; | daddr_t lbn; | ||||
vp = ap->a_vp; | vp = ap->a_vp; | ||||
lbn = ap->a_bp->b_lblkno; | lbn = ap->a_bp->b_lblkno; | ||||
if (I_IS_UFS2(VTOI(vp)) && lbn < 0 && lbn >= -NXADDR) | if (I_IS_UFS2(VTOI(vp)) && lbn < 0 && lbn >= -UFS_NXADDR) | ||||
return (VOP_STRATEGY_APV(&ufs_vnodeops, ap)); | return (VOP_STRATEGY_APV(&ufs_vnodeops, ap)); | ||||
if (vp->v_type == VFIFO) | if (vp->v_type == VFIFO) | ||||
return (VOP_STRATEGY_APV(&ufs_fifoops, ap)); | return (VOP_STRATEGY_APV(&ufs_fifoops, ap)); | ||||
panic("spec nodes went here"); | panic("spec nodes went here"); | ||||
} | } | ||||
/* | /* | ||||
* Vnode extattr transaction commit/abort | * Vnode extattr transaction commit/abort | ||||
▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | */ | ||||
/* XXX Now unsupported API to delete EAs using NULL uio. */ | /* XXX Now unsupported API to delete EAs using NULL uio. */ | ||||
if (ap->a_uio == NULL) | if (ap->a_uio == NULL) | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) | if (ap->a_vp->v_mount->mnt_flag & MNT_RDONLY) | ||||
return (EROFS); | return (EROFS); | ||||
ealen = ap->a_uio->uio_resid; | ealen = ap->a_uio->uio_resid; | ||||
if (ealen < 0 || ealen > lblktosize(fs, NXADDR)) | if (ealen < 0 || ealen > lblktosize(fs, UFS_NXADDR)) | ||||
return (EINVAL); | return (EINVAL); | ||||
error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, | error = extattr_check_cred(ap->a_vp, ap->a_attrnamespace, | ||||
ap->a_cred, ap->a_td, VWRITE); | ap->a_cred, ap->a_td, VWRITE); | ||||
if (error) { | if (error) { | ||||
/* | /* | ||||
* ffs_lock_ea is not needed there, because the vnode | * ffs_lock_ea is not needed there, because the vnode | ||||
Show All 34 Lines | olen = ffs_findextattr(eae, easize, ap->a_attrnamespace, ap->a_name, | ||||
ul = eap->ea_length; | ul = eap->ea_length; | ||||
i = (u_char *)EXTATTR_NEXT(eap) - eae; | i = (u_char *)EXTATTR_NEXT(eap) - eae; | ||||
if (ul != ealength) { | if (ul != ealength) { | ||||
bcopy(EXTATTR_NEXT(eap), (u_char *)eap + ealength, | bcopy(EXTATTR_NEXT(eap), (u_char *)eap + ealength, | ||||
easize - i); | easize - i); | ||||
easize += (ealength - ul); | easize += (ealength - ul); | ||||
} | } | ||||
} | } | ||||
if (easize > lblktosize(fs, NXADDR)) { | if (easize > lblktosize(fs, UFS_NXADDR)) { | ||||
free(eae, M_TEMP); | free(eae, M_TEMP); | ||||
ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); | ffs_close_ea(ap->a_vp, 0, ap->a_cred, ap->a_td); | ||||
if (ip->i_ea_area != NULL && ip->i_ea_error == 0) | if (ip->i_ea_area != NULL && ip->i_ea_error == 0) | ||||
ip->i_ea_error = ENOSPC; | ip->i_ea_error = ENOSPC; | ||||
return (ENOSPC); | return (ENOSPC); | ||||
} | } | ||||
eap->ea_length = ealength; | eap->ea_length = ealength; | ||||
eap->ea_namespace = ap->a_attrnamespace; | eap->ea_namespace = ap->a_attrnamespace; | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |