Changeset View
Changeset View
Standalone View
Standalone View
sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vnops_os.c
Show First 20 Lines • Show All 3,844 Lines • ▼ Show 20 Lines | zfs_space(znode_t *zp, int cmd, flock64_t *bfp, int flag, | ||||
offset_t offset, cred_t *cr) | offset_t offset, cred_t *cr) | ||||
{ | { | ||||
zfsvfs_t *zfsvfs = ZTOZSB(zp); | zfsvfs_t *zfsvfs = ZTOZSB(zp); | ||||
uint64_t off, len; | uint64_t off, len; | ||||
int error; | int error; | ||||
ZFS_ENTER(zfsvfs); | ZFS_ENTER(zfsvfs); | ||||
ZFS_VERIFY_ZP(zp); | ZFS_VERIFY_ZP(zp); | ||||
allanjude: Does this comment need updating to instead say what FreeBSD does in this case? | |||||
Not Done Inline ActionsThat seems necessary. I don't recall we have the same limitation like Solaris that VOP can only issued on opened files. khng: That seems necessary. I don't recall we have the same limitation like Solaris that VOP can only… | |||||
if (cmd != F_FREESP) { | if (cmd != F_FREESP) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (SET_ERROR(EINVAL)); | return (SET_ERROR(EINVAL)); | ||||
} | } | ||||
/* | /* | ||||
* Callers might not be able to detect properly that we are read-only, | * Callers might not be able to detect properly that we are read-only, | ||||
* so check it explicitly here. | * so check it explicitly here. | ||||
▲ Show 20 Lines • Show All 1,350 Lines • ▼ Show 20 Lines | zfs_freebsd_pathconf(struct vop_pathconf_args *ap) | ||||
} | } | ||||
if (error != EOPNOTSUPP) | if (error != EOPNOTSUPP) | ||||
return (error); | return (error); | ||||
switch (ap->a_name) { | switch (ap->a_name) { | ||||
case _PC_NAME_MAX: | case _PC_NAME_MAX: | ||||
*ap->a_retval = NAME_MAX; | *ap->a_retval = NAME_MAX; | ||||
return (0); | return (0); | ||||
case _PC_FDEALLOC_PRESENT: | |||||
*ap->a_retval = 1; | |||||
return (0); | |||||
case _PC_PIPE_BUF: | case _PC_PIPE_BUF: | ||||
if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) { | if (ap->a_vp->v_type == VDIR || ap->a_vp->v_type == VFIFO) { | ||||
*ap->a_retval = PIPE_BUF; | *ap->a_retval = PIPE_BUF; | ||||
return (0); | return (0); | ||||
} | } | ||||
return (EINVAL); | return (EINVAL); | ||||
default: | default: | ||||
return (vop_stdpathconf(ap)); | return (vop_stdpathconf(ap)); | ||||
▲ Show 20 Lines • Show All 580 Lines • ▼ Show 20 Lines | #endif | ||||
vput(covered_vp); | vput(covered_vp); | ||||
} | } | ||||
vn_lock(vp, ltype | LK_RETRY); | vn_lock(vp, ltype | LK_RETRY); | ||||
if (VN_IS_DOOMED(vp)) | if (VN_IS_DOOMED(vp)) | ||||
error = SET_ERROR(ENOENT); | error = SET_ERROR(ENOENT); | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | |||||
zfs_deallocate(struct vop_deallocate_args *ap) | |||||
{ | |||||
dmu_tx_t *tx; | |||||
vnode_t *vp; | |||||
znode_t *zp; | |||||
zfsvfs_t *zfsvfs; | |||||
zilog_t *zilog; | |||||
zfs_locked_range_t *lr; | |||||
uint64_t mtime[2], ctime[2]; | |||||
sa_bulk_attr_t bulk[3]; | |||||
off_t off, len; | |||||
int count = 0; | |||||
int error; | |||||
vp = ap->a_vp; | |||||
zp = VTOZ(vp); | |||||
zfsvfs = ZTOZSB(zp); | |||||
zilog = zfsvfs->z_log; | |||||
off = *ap->a_offset; | |||||
len = *ap->a_len; | |||||
ZFS_ENTER(zfsvfs); | |||||
ZFS_VERIFY_ZP(zp); | |||||
lr = zfs_rangelock_enter(&zp->z_rangelock, off, len, RL_WRITER); | |||||
if (off >= zp->z_size) { | |||||
*ap->a_len = 0; | |||||
error = 0; | |||||
goto out; | |||||
} | |||||
if (len > zp->z_size - off) | |||||
len = *ap->a_len = zp->z_size - off; | |||||
error = dmu_free_long_range_ofs(zfsvfs->z_os, zp->z_id, ap->a_offset, | |||||
ap->a_len); | |||||
if (error != 0) | |||||
goto out; | |||||
vnode_pager_purge_range(vp, off, off + len); | |||||
tx = dmu_tx_create(zfsvfs->z_os); | |||||
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE); | |||||
zfs_sa_upgrade_txholds(tx, zp); | |||||
error = dmu_tx_assign(tx, TXG_WAIT); | |||||
if (error) { | |||||
dmu_tx_abort(tx); | |||||
goto out; | |||||
} | |||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, mtime, 16); | |||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, ctime, 16); | |||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), | |||||
NULL, &zp->z_pflags, 8); | |||||
zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime); | |||||
error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx); | |||||
ASSERT(error == 0); | |||||
/* | |||||
* The log record is TX_TRUNCATE during replay. off + len has been | |||||
* truncated to fit within znode size to make sure the file size is not | |||||
* expanded. | |||||
*/ | |||||
zfs_log_truncate(zilog, tx, TX_TRUNCATE, zp, off, len); | |||||
dmu_tx_commit(tx); | |||||
out: | |||||
zfs_rangelock_exit(lr); | |||||
ZFS_EXIT(zfsvfs); | |||||
return (error); | |||||
} | |||||
struct vop_vector zfs_vnodeops; | struct vop_vector zfs_vnodeops; | ||||
struct vop_vector zfs_fifoops; | struct vop_vector zfs_fifoops; | ||||
struct vop_vector zfs_shareops; | struct vop_vector zfs_shareops; | ||||
struct vop_vector zfs_vnodeops = { | struct vop_vector zfs_vnodeops = { | ||||
.vop_default = &default_vnodeops, | .vop_default = &default_vnodeops, | ||||
.vop_inactive = zfs_freebsd_inactive, | .vop_inactive = zfs_freebsd_inactive, | ||||
#if __FreeBSD_version >= 1300042 | #if __FreeBSD_version >= 1300042 | ||||
.vop_need_inactive = zfs_freebsd_need_inactive, | .vop_need_inactive = zfs_freebsd_need_inactive, | ||||
#endif | #endif | ||||
.vop_reclaim = zfs_freebsd_reclaim, | .vop_reclaim = zfs_freebsd_reclaim, | ||||
#if __FreeBSD_version >= 1300102 | #if __FreeBSD_version >= 1300102 | ||||
.vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, | .vop_fplookup_vexec = zfs_freebsd_fplookup_vexec, | ||||
#endif | #endif | ||||
.vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, | .vop_fplookup_symlink = zfs_freebsd_fplookup_symlink, | ||||
.vop_access = zfs_freebsd_access, | .vop_access = zfs_freebsd_access, | ||||
.vop_allocate = VOP_EINVAL, | .vop_allocate = VOP_EINVAL, | ||||
.vop_deallocate = zfs_deallocate, | |||||
.vop_lookup = zfs_cache_lookup, | .vop_lookup = zfs_cache_lookup, | ||||
.vop_cachedlookup = zfs_freebsd_cachedlookup, | .vop_cachedlookup = zfs_freebsd_cachedlookup, | ||||
.vop_getattr = zfs_freebsd_getattr, | .vop_getattr = zfs_freebsd_getattr, | ||||
.vop_setattr = zfs_freebsd_setattr, | .vop_setattr = zfs_freebsd_setattr, | ||||
.vop_create = zfs_freebsd_create, | .vop_create = zfs_freebsd_create, | ||||
.vop_mknod = (vop_mknod_t *)zfs_freebsd_create, | .vop_mknod = (vop_mknod_t *)zfs_freebsd_create, | ||||
.vop_mkdir = zfs_freebsd_mkdir, | .vop_mkdir = zfs_freebsd_mkdir, | ||||
.vop_readdir = zfs_freebsd_readdir, | .vop_readdir = zfs_freebsd_readdir, | ||||
▲ Show 20 Lines • Show All 71 Lines • Show Last 20 Lines |
Does this comment need updating to instead say what FreeBSD does in this case?