Changeset View
Changeset View
Standalone View
Standalone View
sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
Show First 20 Lines • Show All 1,847 Lines • ▼ Show 20 Lines | if (zp == NULL) { | ||||
/* | /* | ||||
* Truncate regular files if requested. | * Truncate regular files if requested. | ||||
*/ | */ | ||||
if ((ZTOV(zp)->v_type == VREG) && | if ((ZTOV(zp)->v_type == VREG) && | ||||
(vap->va_mask & AT_SIZE) && (vap->va_size == 0)) { | (vap->va_mask & AT_SIZE) && (vap->va_size == 0)) { | ||||
/* we can't hold any locks when calling zfs_freesp() */ | /* we can't hold any locks when calling zfs_freesp() */ | ||||
zfs_dirent_unlock(dl); | zfs_dirent_unlock(dl); | ||||
dl = NULL; | dl = NULL; | ||||
error = zfs_freesp(zp, 0, 0, mode, TRUE); | error = zfs_freesp(zp, 0, 0, mode, TRUE, cr); | ||||
if (error == 0) { | if (error == 0) { | ||||
vnevent_create(ZTOV(zp), ct); | vnevent_create(ZTOV(zp), ct); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
out: | out: | ||||
getnewvnode_drop_reserve(); | getnewvnode_drop_reserve(); | ||||
if (dl) | if (dl) | ||||
▲ Show 20 Lines • Show All 1,295 Lines • ▼ Show 20 Lines | top: | ||||
if (mask & AT_SIZE) { | if (mask & AT_SIZE) { | ||||
/* | /* | ||||
* XXX - Note, we are not providing any open | * XXX - Note, we are not providing any open | ||||
* mode flags here (like FNDELAY), so we may | * mode flags here (like FNDELAY), so we may | ||||
* block if there are locks present... this | * block if there are locks present... this | ||||
* should be addressed in openat(). | * should be addressed in openat(). | ||||
*/ | */ | ||||
/* XXX - would it be OK to generate a log record here? */ | /* XXX - would it be OK to generate a log record here? */ | ||||
err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE); | err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE, cr); | ||||
if (err) { | if (err) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (err); | return (err); | ||||
} | } | ||||
} | } | ||||
if (mask & (AT_ATIME|AT_MTIME) || | if (mask & (AT_ATIME|AT_MTIME) || | ||||
((mask & AT_XVATTR) && (XVA_ISSET_REQ(xvap, XAT_HIDDEN) || | ((mask & AT_XVATTR) && (XVA_ISSET_REQ(xvap, XAT_HIDDEN) || | ||||
▲ Show 20 Lines • Show All 1,972 Lines • ▼ Show 20 Lines | zfs_delmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr, | ||||
if ((flags & MAP_SHARED) && (prot & PROT_WRITE) && | if ((flags & MAP_SHARED) && (prot & PROT_WRITE) && | ||||
vn_has_cached_data(vp)) | vn_has_cached_data(vp)) | ||||
(void) VOP_PUTPAGE(vp, off, len, B_ASYNC, cr, ct); | (void) VOP_PUTPAGE(vp, off, len, B_ASYNC, cr, ct); | ||||
return (0); | return (0); | ||||
} | } | ||||
#endif /* illumos */ | |||||
/* | /* | ||||
* Free or allocate space in a file. Currently, this function only | * Free space in a file. | ||||
* supports the `F_FREESP' command. However, this command is somewhat | |||||
* misnamed, as its functionality includes the ability to allocate as | |||||
* well as free space. | |||||
* | * | ||||
* IN: vp - vnode of file to free data in. | * IN: vp - vnode of file to free data in. | ||||
* cmd - action to take (only F_FREESP supported). | * off - start of the range to free. | ||||
* bfp - section of file to free/alloc. | * len - length of the range to free. | ||||
* flag - current file open mode flags. | * flag - current file open mode flags. | ||||
* offset - current file offset. | * cr - credentials of caller. | ||||
* cr - credentials of caller [UNUSED]. | |||||
* ct - caller context. | |||||
* | * | ||||
* RETURN: 0 on success, error code on failure. | * RETURN: 0 on success, error code on failure. | ||||
* | * | ||||
* Timestamps: | * Timestamps: | ||||
* vp - ctime|mtime updated | * vp - ctime|mtime updated | ||||
*/ | */ | ||||
/* ARGSUSED */ | /* ARGSUSED */ | ||||
static int | static int | ||||
zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag, | zfs_freespace(vnode_t *vp, uint64_t off, uint64_t len, int flag, cred_t *cr) | ||||
offset_t offset, cred_t *cr, caller_context_t *ct) | |||||
{ | { | ||||
znode_t *zp = VTOZ(vp); | znode_t *zp = VTOZ(vp); | ||||
zfsvfs_t *zfsvfs = zp->z_zfsvfs; | zfsvfs_t *zfsvfs = zp->z_zfsvfs; | ||||
uint64_t off, len; | |||||
int error; | int error; | ||||
ZFS_ENTER(zfsvfs); | ZFS_ENTER(zfsvfs); | ||||
ZFS_VERIFY_ZP(zp); | ZFS_VERIFY_ZP(zp); | ||||
if (cmd != F_FREESP) { | |||||
ZFS_EXIT(zfsvfs); | |||||
return (SET_ERROR(EINVAL)); | |||||
} | |||||
/* | /* | ||||
* In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our | * In a case vp->v_vfsp != zp->z_zfsvfs->z_vfs (e.g. snapshots) our | ||||
* 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. | ||||
*/ | */ | ||||
if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) { | if (zfsvfs->z_vfs->vfs_flag & VFS_RDONLY) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (SET_ERROR(EROFS)); | return (SET_ERROR(EROFS)); | ||||
} | } | ||||
#ifdef illumos | |||||
if (error = convoff(vp, bfp, 0, offset)) { | if (error = convoff(vp, bfp, 0, offset)) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (error); | return (error); | ||||
} | } | ||||
if (bfp->l_len < 0) { | if (bfp->l_len < 0) { | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (SET_ERROR(EINVAL)); | return (SET_ERROR(EINVAL)); | ||||
} | } | ||||
off = bfp->l_start; | off = bfp->l_start; | ||||
len = bfp->l_len; /* 0 means from off to end of file */ | len = bfp->l_len; /* 0 means from off to end of file */ | ||||
#else | |||||
if (off + len > zp->z_size) { | |||||
ZFS_EXIT(zfsvfs); | |||||
return (SET_ERROR(ENXIO)); | |||||
} | |||||
#endif | |||||
error = zfs_freesp(zp, off, len, flag, TRUE); | error = zfs_freesp(zp, off, len, flag, TRUE, cr); | ||||
ZFS_EXIT(zfsvfs); | ZFS_EXIT(zfsvfs); | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* illumos */ | |||||
CTASSERT(sizeof(struct zfid_short) <= sizeof(struct fid)); | CTASSERT(sizeof(struct zfid_short) <= sizeof(struct fid)); | ||||
CTASSERT(sizeof(struct zfid_long) <= sizeof(struct fid)); | CTASSERT(sizeof(struct zfid_long) <= sizeof(struct fid)); | ||||
/*ARGSUSED*/ | /*ARGSUSED*/ | ||||
static int | static int | ||||
zfs_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct) | zfs_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 820 Lines • ▼ Show 20 Lines | zfs_freebsd_putpages(ap) | ||||
} */ *ap; | } */ *ap; | ||||
{ | { | ||||
return (zfs_putpages(ap->a_vp, ap->a_m, ap->a_count, ap->a_sync, | return (zfs_putpages(ap->a_vp, ap->a_m, ap->a_count, ap->a_sync, | ||||
ap->a_rtvals)); | ap->a_rtvals)); | ||||
} | } | ||||
static int | static int | ||||
zfs_freebsd_allocate(ap) | |||||
struct vop_allocate_args *ap; | |||||
{ | |||||
int error; | |||||
uint64_t off, len; | |||||
if ((ap->a_mode & VNA_OP_DEALLOC) == 0) | |||||
cem: `if ((ap->a_mode & VNA_DEALLOC) == 0)` | |||||
Done Inline ActionsPing? style(9) issue cem: Ping? style(9) issue | |||||
return (vop_stdallocate(ap)); | |||||
off = *ap->a_offset; | |||||
len = *ap->a_len; | |||||
error = zfs_freespace(ap->a_vp, off, len, FWRITE | FOFFMAX, ap->a_cred); | |||||
if (error == 0) { | |||||
*ap->a_offset += len; | |||||
*ap->a_len = 0; | |||||
} | |||||
return (error); | |||||
} | |||||
static int | |||||
zfs_freebsd_bmap(ap) | zfs_freebsd_bmap(ap) | ||||
struct vop_bmap_args /* { | struct vop_bmap_args /* { | ||||
struct vnode *a_vp; | struct vnode *a_vp; | ||||
daddr_t a_bn; | daddr_t a_bn; | ||||
struct bufobj **a_bop; | struct bufobj **a_bop; | ||||
daddr_t *a_bnp; | daddr_t *a_bnp; | ||||
int *a_runp; | int *a_runp; | ||||
int *a_runb; | int *a_runb; | ||||
▲ Show 20 Lines • Show All 1,137 Lines • ▼ Show 20 Lines | #endif | ||||
.vop_deleteextattr = zfs_deleteextattr, | .vop_deleteextattr = zfs_deleteextattr, | ||||
.vop_setextattr = zfs_setextattr, | .vop_setextattr = zfs_setextattr, | ||||
.vop_listextattr = zfs_listextattr, | .vop_listextattr = zfs_listextattr, | ||||
.vop_getacl = zfs_freebsd_getacl, | .vop_getacl = zfs_freebsd_getacl, | ||||
.vop_setacl = zfs_freebsd_setacl, | .vop_setacl = zfs_freebsd_setacl, | ||||
.vop_aclcheck = zfs_freebsd_aclcheck, | .vop_aclcheck = zfs_freebsd_aclcheck, | ||||
.vop_getpages = zfs_freebsd_getpages, | .vop_getpages = zfs_freebsd_getpages, | ||||
.vop_putpages = zfs_freebsd_putpages, | .vop_putpages = zfs_freebsd_putpages, | ||||
.vop_allocate = zfs_freebsd_allocate, | |||||
}; | }; | ||||
struct vop_vector zfs_fifoops = { | struct vop_vector zfs_fifoops = { | ||||
.vop_default = &fifo_specops, | .vop_default = &fifo_specops, | ||||
.vop_fsync = zfs_freebsd_fsync, | .vop_fsync = zfs_freebsd_fsync, | ||||
.vop_access = zfs_freebsd_access, | .vop_access = zfs_freebsd_access, | ||||
.vop_getattr = zfs_freebsd_getattr, | .vop_getattr = zfs_freebsd_getattr, | ||||
.vop_inactive = zfs_freebsd_inactive, | .vop_inactive = zfs_freebsd_inactive, | ||||
Show All 22 Lines |
if ((ap->a_mode & VNA_DEALLOC) == 0)