/* Portions Copyright 2007 Jeremy Teo */
/* Portions Copyright 2010 Robert Milkowski */
+#ifdef HAVE_ZPL
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#include <sys/dirent.h>
#include <sys/policy.h>
#include <sys/sunddi.h>
-#include <sys/filio.h>
#include <sys/sid.h>
+#include <sys/mode.h>
#include "fs/fs_subr.h"
-#include <sys/zfs_ctldir.h>
#include <sys/zfs_fuid.h>
#include <sys/zfs_sa.h>
+#include <sys/zfs_vnops.h>
#include <sys/dnlc.h>
#include <sys/zfs_rlock.h>
#include <sys/extdirent.h>
return (ENOTTY);
}
+#if defined(_KERNEL) && defined(HAVE_UIO_RW)
/*
* Utility functions to map and unmap a single physical page. These
* are used to manage the mappable copies of ZFS file data, and therefore
ppmapout(addr);
}
}
+#endif /* _KERNEL && HAVE_UIO_RW */
/*
* When a file is memory mapped, we must keep the IO data synchronized
* vp - atime updated if byte count > 0
*/
/* ARGSUSED */
-static int
+int
zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
{
znode_t *zp = VTOZ(vp);
zfsvfs_t *zfsvfs = zp->z_zfsvfs;
objset_t *os;
ssize_t n, nbytes;
- int error;
+ int error = 0;
rl_t *rl;
xuio_t *xuio = NULL;
zfs_range_unlock(rl);
ZFS_ACCESSTIME_STAMP(zfsvfs, zp);
+ zfs_inode_update(zp);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_read);
/*
* Write the bytes to a file.
*/
/* ARGSUSED */
-static int
+int
zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
{
znode_t *zp = VTOZ(vp);
max_blksz);
ASSERT(abuf != NULL);
ASSERT(arc_buf_size(abuf) == max_blksz);
- if (error = uiocopy(abuf->b_data, max_blksz,
- UIO_WRITE, uio, &cbytes)) {
+ if ((error = uiocopy(abuf->b_data, max_blksz,
+ UIO_WRITE, uio, &cbytes))) {
dmu_return_arcbuf(abuf);
break;
}
zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, zp->z_id);
+ zfs_inode_update(zp);
ZFS_EXIT(zfsvfs);
return (0);
}
+EXPORT_SYMBOL(zfs_write);
void
zfs_get_done(zgd_t *zgd, int error)
* NA
*/
/* ARGSUSED */
-static int
+int
zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
int flags, vnode_t *rdir, cred_t *cr, caller_context_t *ct,
int *direntflags, pathname_t *realpnp)
return (EINVAL);
}
- if (error = zfs_get_xattrdir(VTOZ(dvp), vpp, cr, flags)) {
+ if ((error = zfs_get_xattrdir(VTOZ(dvp), vpp, cr, flags))) {
ZFS_EXIT(zfsvfs);
return (error);
}
* Do we have permission to get into attribute directory?
*/
- if (error = zfs_zaccess(VTOZ(*vpp), ACE_EXECUTE, 0,
- B_FALSE, cr)) {
+ if ((error = zfs_zaccess(VTOZ(*vpp), ACE_EXECUTE, 0,
+ B_FALSE, cr))) {
VN_RELE(*vpp);
*vpp = NULL;
}
* Check accessibility of directory.
*/
- if (error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr)) {
+ if ((error = zfs_zaccess(zdp, ACE_EXECUTE, 0, B_FALSE, cr))) {
ZFS_EXIT(zfsvfs);
return (error);
}
}
error = zfs_dirlook(zdp, nm, vpp, flags, direntflags, realpnp);
- if (error == 0)
+ if (error == 0) {
+ if (*vpp)
+ zfs_inode_update(VTOZ(*vpp));
+
error = specvp_check(vpp, cr);
+ }
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_lookup);
/*
* Attempt to create a new entry in a directory. If the entry
*/
/* ARGSUSED */
-static int
-zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
+int
+zfs_create(vnode_t *dvp, char *name, vattr_t *vap, int excl,
int mode, vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct,
vsecattr_t *vsecp)
{
int error;
ksid_t *ksid;
uid_t uid;
- gid_t gid = crgetgid(cr);
+ gid_t gid;
zfs_acl_ids_t acl_ids;
boolean_t fuid_dirtied;
boolean_t have_acl = B_FALSE;
* make sure file system is at proper version
*/
+ gid = crgetgid(cr);
ksid = crgetsid(cr, KSID_OWNER);
if (ksid)
uid = ksid_getid(ksid);
* Create a new file object and update the directory
* to reference it.
*/
- if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) {
+ if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) {
if (have_acl)
zfs_acl_ids_free(&acl_ids);
goto out;
if (zp)
VN_RELE(ZTOV(zp));
} else {
+ zfs_inode_update(dzp);
+ zfs_inode_update(zp);
*vpp = ZTOV(zp);
error = specvp_check(vpp, cr);
}
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_create);
/*
* Remove an entry from a directory.
uint64_t null_xattr = 0;
/*ARGSUSED*/
-static int
+int
zfs_remove(vnode_t *dvp, char *name, cred_t *cr, caller_context_t *ct,
int flags)
{
/*
* Attempt to lock directory; fail if entry doesn't exist.
*/
- if (error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg,
- NULL, realnmp)) {
+ if ((error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg,
+ NULL, realnmp))) {
if (realnmp)
pn_free(realnmp);
ZFS_EXIT(zfsvfs);
vp = ZTOV(zp);
- if (error = zfs_zaccess_delete(dzp, zp, cr)) {
+ if ((error = zfs_zaccess_delete(dzp, zp, cr))) {
goto out;
}
dnlc_remove(dvp, name);
mutex_enter(&vp->v_lock);
- may_delete_now = vp->v_count == 1 && !vn_has_cached_data(vp);
+ may_delete_now = ((vp->v_count == 1) && (!vn_has_cached_data(vp)));
mutex_exit(&vp->v_lock);
/*
pn_free(realnmp);
zfs_dirent_unlock(dl);
+ zfs_inode_update(dzp);
+ zfs_inode_update(zp);
+ if (xzp)
+ zfs_inode_update(xzp);
if (!delete_now)
VN_RELE(vp);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_remove);
/*
* Create a new directory and insert it into dvp using the name
* vp - ctime|mtime|atime updated
*/
/*ARGSUSED*/
-static int
+int
zfs_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr,
caller_context_t *ct, int flags, vsecattr_t *vsecp)
{
top:
*vpp = NULL;
- if (error = zfs_dirent_lock(&dl, dzp, dirname, &zp, zf,
- NULL, NULL)) {
+ if ((error = zfs_dirent_lock(&dl, dzp, dirname, &zp, zf,
+ NULL, NULL))) {
zfs_acl_ids_free(&acl_ids);
ZFS_EXIT(zfsvfs);
return (error);
}
- if (error = zfs_zaccess(dzp, ACE_ADD_SUBDIRECTORY, 0, B_FALSE, cr)) {
+ if ((error = zfs_zaccess(dzp, ACE_ADD_SUBDIRECTORY, 0, B_FALSE, cr))) {
zfs_acl_ids_free(&acl_ids);
zfs_dirent_unlock(dl);
ZFS_EXIT(zfsvfs);
if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, 0);
+ zfs_inode_update(dzp);
+ zfs_inode_update(zp);
ZFS_EXIT(zfsvfs);
return (0);
}
+EXPORT_SYMBOL(zfs_mkdir);
/*
* Remove a directory subdir entry. If the current working
* dvp - ctime|mtime updated
*/
/*ARGSUSED*/
-static int
+int
zfs_rmdir(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr,
caller_context_t *ct, int flags)
{
/*
* Attempt to lock directory; fail if entry doesn't exist.
*/
- if (error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg,
- NULL, NULL)) {
+ if ((error = zfs_dirent_lock(&dl, dzp, name, &zp, zflg,
+ NULL, NULL))) {
ZFS_EXIT(zfsvfs);
return (error);
}
vp = ZTOV(zp);
- if (error = zfs_zaccess_delete(dzp, zp, cr)) {
+ if ((error = zfs_zaccess_delete(dzp, zp, cr))) {
goto out;
}
if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, 0);
+ zfs_inode_update(dzp);
+ zfs_inode_update(zp);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_rmdir);
/*
* Read as many directory entries as will fit into the provided
ulong_t zfs_fsync_sync_cnt = 4;
-static int
+int
zfs_fsync(vnode_t *vp, int syncflag, cred_t *cr, caller_context_t *ct)
{
znode_t *zp = VTOZ(vp);
}
return (0);
}
+EXPORT_SYMBOL(zfs_fsync);
/*
* RETURN: 0 (always succeeds)
*/
/* ARGSUSED */
-static int
+int
zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
caller_context_t *ct)
{
*/
if (!(zp->z_pflags & ZFS_ACL_TRIVIAL) &&
(vap->va_uid != crgetuid(cr))) {
- if (error = zfs_zaccess(zp, ACE_READ_ATTRIBUTES, 0,
- skipaclchk, cr)) {
+ if ((error = zfs_zaccess(zp, ACE_READ_ATTRIBUTES, 0,
+ skipaclchk, cr))) {
ZFS_EXIT(zfsvfs);
return (error);
}
ZFS_EXIT(zfsvfs);
return (0);
}
+EXPORT_SYMBOL(zfs_getattr);
/*
* Set the file attributes to the values contained in the
* vp - ctime updated, mtime updated if size changed.
*/
/* ARGSUSED */
-static int
+int
zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
caller_context_t *ct)
{
} else {
err2 = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
dmu_tx_commit(tx);
+ zfs_inode_update(zp);
}
out2:
ZFS_EXIT(zfsvfs);
return (err);
}
+EXPORT_SYMBOL(zfs_setattr);
typedef struct zfs_zlock {
krwlock_t *zl_rwlock; /* lock we acquired */
* sdvp,tdvp - ctime|mtime updated
*/
/*ARGSUSED*/
-static int
+int
zfs_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr,
caller_context_t *ct, int flags)
{
* done in a single check.
*/
- if (error = zfs_zaccess_rename(sdzp, szp, tdzp, tzp, cr))
+ if ((error = zfs_zaccess_rename(sdzp, szp, tdzp, tzp, cr)))
goto out;
if (ZTOV(szp)->v_type == VDIR) {
* Check to make sure rename is valid.
* Can't do a move like this: /usr/a/b to /usr/a/b/c/d
*/
- if (error = zfs_rename_lock(szp, tdzp, sdzp, &zl))
+ if ((error = zfs_rename_lock(szp, tdzp, sdzp, &zl)))
goto out;
}
zfs_dirent_unlock(sdl);
zfs_dirent_unlock(tdl);
+ zfs_inode_update(sdzp);
if (sdzp == tdzp)
rw_exit(&sdzp->z_name_lock);
+ if (sdzp != tdzp)
+ zfs_inode_update(tdzp);
+ zfs_inode_update(szp);
VN_RELE(ZTOV(szp));
- if (tzp)
+ if (tzp) {
+ zfs_inode_update(tzp);
VN_RELE(ZTOV(tzp));
+ }
if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, 0);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_rename);
/*
* Insert the indicated symbolic reference entry into the directory.
* dvp - ctime|mtime updated
*/
/*ARGSUSED*/
-static int
+int
zfs_symlink(vnode_t *dvp, char *name, vattr_t *vap, char *link, cred_t *cr,
caller_context_t *ct, int flags)
{
return (error);
}
- if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) {
+ if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) {
zfs_acl_ids_free(&acl_ids);
zfs_dirent_unlock(dl);
ZFS_EXIT(zfsvfs);
txtype |= TX_CI;
zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link);
+ zfs_inode_update(dzp);
+ zfs_inode_update(zp);
+
zfs_acl_ids_free(&acl_ids);
dmu_tx_commit(tx);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_symlink);
/*
* Return, in the buffer contained in the provided uio structure,
* vp - atime updated
*/
/* ARGSUSED */
-static int
+int
zfs_readlink(vnode_t *vp, uio_t *uio, cred_t *cr, caller_context_t *ct)
{
znode_t *zp = VTOZ(vp);
ZFS_ACCESSTIME_STAMP(zfsvfs, zp);
+ zfs_inode_update(zp);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_readlink);
/*
* Insert a new entry into directory tdvp referencing svp.
* svp - ctime updated
*/
/* ARGSUSED */
-static int
+int
zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
caller_context_t *ct, int flags)
{
return (EPERM);
}
- if (error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr)) {
+ if ((error = zfs_zaccess(dzp, ACE_ADD_FILE, 0, B_FALSE, cr))) {
ZFS_EXIT(zfsvfs);
return (error);
}
if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
zil_commit(zilog, 0);
+ zfs_inode_update(dzp);
+ zfs_inode_update(szp);
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_link);
/*
* zfs_null_putapage() is used when the file system has been force
zfs_zinactive(zp);
rw_exit(&zfsvfs->z_teardown_inactive_lock);
}
+EXPORT_SYMBOL(zfs_inactive);
/*
* Bounds-check the seek operation.
* vp - ctime|mtime updated
*/
/* ARGSUSED */
-static int
+int
zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
offset_t offset, cred_t *cr, caller_context_t *ct)
{
return (EINVAL);
}
- if (error = convoff(vp, bfp, 0, offset)) {
+ if ((error = convoff(vp, bfp, 0, offset))) {
ZFS_EXIT(zfsvfs);
return (error);
}
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_space);
/*ARGSUSED*/
-static int
+int
zfs_fid(vnode_t *vp, fid_t *fidp, caller_context_t *ct)
{
znode_t *zp = VTOZ(vp);
ZFS_EXIT(zfsvfs);
return (0);
}
+EXPORT_SYMBOL(zfs_fid);
static int
zfs_pathconf(vnode_t *vp, int cmd, ulong_t *valp, cred_t *cr,
}
/*ARGSUSED*/
-static int
+int
zfs_getsecattr(vnode_t *vp, vsecattr_t *vsecp, int flag, cred_t *cr,
caller_context_t *ct)
{
return (error);
}
+EXPORT_SYMBOL(zfs_getsecattr);
/*ARGSUSED*/
-static int
+int
zfs_setsecattr(vnode_t *vp, vsecattr_t *vsecp, int flag, cred_t *cr,
caller_context_t *ct)
{
ZFS_EXIT(zfsvfs);
return (error);
}
+EXPORT_SYMBOL(zfs_setsecattr);
/*
* Tunable, both must be a power of 2.
VOPNAME_PATHCONF, { .vop_pathconf = zfs_pathconf },
NULL, NULL
};
+#endif /* HAVE_ZPL */