summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--module/zfs/zfs_log.c52
-rw-r--r--module/zfs/zfs_replay.c328
2 files changed, 213 insertions, 167 deletions
diff --git a/module/zfs/zfs_log.c b/module/zfs/zfs_log.c
index 945b734ce..5cdbb6c8d 100644
--- a/module/zfs/zfs_log.c
+++ b/module/zfs/zfs_log.c
@@ -69,7 +69,11 @@
int
zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
{
+#ifdef HAVE_XVATTR
int isxvattr = (vap->va_mask & AT_XVATTR);
+#else
+ int isxvattr = 0;
+#endif /* HAVE_XVATTR */
switch (type) {
case Z_FILE:
if (vsecp == NULL && !isxvattr)
@@ -97,6 +101,7 @@ zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
return (TX_MAX_TYPE);
}
+#ifdef HAVE_XVATTR
/*
* build up the log data necessary for logging xvattr_t
* First lr_attr_t is initialized. following the lr_attr_t
@@ -210,6 +215,7 @@ zfs_log_fuid_domains(zfs_fuid_info_t *fuidp, void *start)
}
return (start);
}
+#endif /* HAVE_XVATTR */
/*
* zfs_log_create() is used to handle TX_CREATE, TX_CREATE_ATTR, TX_MKDIR,
@@ -238,11 +244,13 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
{
itx_t *itx;
lr_create_t *lr;
+#ifdef HAVE_XVATTR
lr_acl_create_t *lracl;
+ xvattr_t *xvap = (xvattr_t *)vap;
+#endif /* HAVE_XVATTR */
size_t aclsize;
size_t xvatsize = 0;
size_t txsize;
- xvattr_t *xvap = (xvattr_t *)vap;
void *end;
size_t lrsize;
size_t namesize = strlen(name) + 1;
@@ -260,8 +268,10 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
fuidsz += fuidp->z_fuid_cnt * sizeof (uint64_t);
}
+#ifdef HAVE_XVATTR
if (vap->va_mask & AT_XVATTR)
xvatsize = ZIL_XVAT_SIZE(xvap->xva_mapsize);
+#endif /* HAVE_XVATTR */
if ((int)txtype == TX_CREATE_ATTR || (int)txtype == TX_MKDIR_ATTR ||
(int)txtype == TX_CREATE || (int)txtype == TX_MKDIR ||
@@ -292,18 +302,19 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
} else {
lr->lr_gid = fuidp->z_fuid_group;
}
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(zp->z_zfsvfs), &lr->lr_gen,
+ (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
sizeof (uint64_t));
- (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(zp->z_zfsvfs),
+ (void) sa_lookup(zp->z_sa_hdl, SA_ZPL_CRTIME(ZTOZSB(zp)),
lr->lr_crtime, sizeof (uint64_t) * 2);
- if (sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(zp->z_zfsvfs), &lr->lr_rdev,
+ if (sa_lookup(zp->z_sa_hdl, SA_ZPL_RDEV(ZTOZSB(zp)), &lr->lr_rdev,
sizeof (lr->lr_rdev)) != 0)
lr->lr_rdev = 0;
/*
* Fill in xvattr info if any
*/
+#ifdef HAVE_XVATTR
if (vap->va_mask & AT_XVATTR) {
zfs_log_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), xvap);
end = (caddr_t)lr + lrsize + xvatsize;
@@ -333,6 +344,9 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
end = zfs_log_fuid_ids(fuidp, end);
end = zfs_log_fuid_domains(fuidp, end);
}
+#else
+ end = (caddr_t)lr + lrsize;
+#endif /* HAVE_XVATTR */
/*
* Now place file name in log record
*/
@@ -552,12 +566,14 @@ zfs_log_truncate(zilog_t *zilog, dmu_tx_t *tx, int txtype,
* zfs_log_setattr() handles TX_SETATTR transactions.
*/
void
-zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
- znode_t *zp, vattr_t *vap, uint_t mask_applied, zfs_fuid_info_t *fuidp)
+zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype, znode_t *zp,
+ struct iattr *attr, uint_t mask_applied, zfs_fuid_info_t *fuidp)
{
itx_t *itx;
lr_setattr_t *lr;
+#ifdef HAVE_XVATTR
xvattr_t *xvap = (xvattr_t *)vap;
+#endif /* HAVEXVATTR */
size_t recsize = sizeof (lr_setattr_t);
void *start;
@@ -569,32 +585,35 @@ zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
* for lr_attr_t + xvattr mask, mapsize and create time
* plus actual attribute values
*/
- if (vap->va_mask & AT_XVATTR)
+#ifdef HAVE_XVATTR
+ if (attr->ia_valid & AT_XVATTR)
recsize = sizeof (*lr) + ZIL_XVAT_SIZE(xvap->xva_mapsize);
if (fuidp)
recsize += fuidp->z_domain_str_sz;
+#endif /* HAVE_XVATTR */
itx = zil_itx_create(txtype, recsize);
lr = (lr_setattr_t *)&itx->itx_lr;
lr->lr_foid = zp->z_id;
lr->lr_mask = (uint64_t)mask_applied;
- lr->lr_mode = (uint64_t)vap->va_mode;
- if ((mask_applied & AT_UID) && IS_EPHEMERAL(vap->va_uid))
+ lr->lr_mode = (uint64_t)attr->ia_mode;
+ if ((mask_applied & ATTR_UID) && IS_EPHEMERAL(attr->ia_uid))
lr->lr_uid = fuidp->z_fuid_owner;
else
- lr->lr_uid = (uint64_t)vap->va_uid;
+ lr->lr_uid = (uint64_t)attr->ia_uid;
- if ((mask_applied & AT_GID) && IS_EPHEMERAL(vap->va_gid))
+ if ((mask_applied & ATTR_GID) && IS_EPHEMERAL(attr->ia_gid))
lr->lr_gid = fuidp->z_fuid_group;
else
- lr->lr_gid = (uint64_t)vap->va_gid;
+ lr->lr_gid = (uint64_t)attr->ia_gid;
- lr->lr_size = (uint64_t)vap->va_size;
- ZFS_TIME_ENCODE(&vap->va_atime, lr->lr_atime);
- ZFS_TIME_ENCODE(&vap->va_mtime, lr->lr_mtime);
+ lr->lr_size = (uint64_t)attr->ia_size;
+ ZFS_TIME_ENCODE(&attr->ia_atime, lr->lr_atime);
+ ZFS_TIME_ENCODE(&attr->ia_mtime, lr->lr_mtime);
start = (lr_setattr_t *)(lr + 1);
- if (vap->va_mask & AT_XVATTR) {
+#ifdef HAVE_XVATTR
+ if (attr->ia_valid & ATTR_XVATTR) {
zfs_log_xvattr((lr_attr_t *)start, xvap);
start = (caddr_t)start + ZIL_XVAT_SIZE(xvap->xva_mapsize);
}
@@ -605,6 +624,7 @@ zfs_log_setattr(zilog_t *zilog, dmu_tx_t *tx, int txtype,
if (fuidp)
(void) zfs_log_fuid_domains(fuidp, start);
+#endif /* HAVE_XVATTR */
itx->itx_sync = (zp->z_sync_cnt != 0);
zil_itx_assign(zilog, itx, tx);
diff --git a/module/zfs/zfs_replay.c b/module/zfs/zfs_replay.c
index 2c258948b..f02d5add3 100644
--- a/module/zfs/zfs_replay.c
+++ b/module/zfs/zfs_replay.c
@@ -22,8 +22,6 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
*/
-#ifdef HAVE_ZPL
-
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
@@ -56,26 +54,24 @@
*/
static void
-zfs_init_vattr(vattr_t *vap, uint64_t mask, uint64_t mode,
- uint64_t uid, uint64_t gid, uint64_t rdev, uint64_t nodeid)
+zfs_init_iattr(struct iattr *attr, uint64_t mask, uint64_t mode,
+ uint64_t uid, uint64_t gid)
{
- bzero(vap, sizeof (*vap));
- vap->va_mask = (uint_t)mask;
- vap->va_type = IFTOVT(mode);
- vap->va_mode = mode & MODEMASK;
- vap->va_uid = (uid_t)(IS_EPHEMERAL(uid)) ? -1 : uid;
- vap->va_gid = (gid_t)(IS_EPHEMERAL(gid)) ? -1 : gid;
- vap->va_rdev = zfs_cmpldev(rdev);
- vap->va_nodeid = nodeid;
+ memset(attr, 0, sizeof(*attr));
+ attr->ia_valid = (uint_t)mask;
+ attr->ia_mode = mode;
+ attr->ia_uid = (uid_t)(IS_EPHEMERAL(uid)) ? -1 : uid;
+ attr->ia_gid = (gid_t)(IS_EPHEMERAL(gid)) ? -1 : gid;
}
/* ARGSUSED */
static int
-zfs_replay_error(zfsvfs_t *zfsvfs, lr_t *lr, boolean_t byteswap)
+zfs_replay_error(zfs_sb_t *zsb, lr_t *lr, boolean_t byteswap)
{
return (ENOTSUP);
}
+#ifdef HAVE_XVATTR
static void
zfs_replay_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
{
@@ -136,6 +132,7 @@ zfs_replay_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
if (XVA_ISSET_REQ(xvap, XAT_SPARSE))
xoap->xoa_sparse = ((*attrs & XAT0_SPARSE) != 0);
}
+#endif /* HAVE_XVATTR */
static int
zfs_replay_domain_cnt(uint64_t uid, uint64_t gid)
@@ -264,16 +261,17 @@ zfs_replay_swap_attrs(lr_attr_t *lrattr)
* as option FUID information.
*/
static int
-zfs_replay_create_acl(zfsvfs_t *zfsvfs,
- lr_acl_create_t *lracl, boolean_t byteswap)
+zfs_replay_create_acl(zfs_sb_t *zsb, lr_acl_create_t *lracl, boolean_t byteswap)
{
char *name = NULL; /* location determined later */
lr_create_t *lr = (lr_create_t *)lracl;
znode_t *dzp;
- vnode_t *vp = NULL;
+ struct inode *ip = NULL;
+#ifdef HAVE_XVATTR
xvattr_t xva;
- int vflg = 0;
vsecattr_t vsec = { 0 };
+#endif /* HAVE_XVATTR */
+ int vflg = 0;
lr_attr_t *lrattr;
void *aclstart;
void *fuidstart;
@@ -301,12 +299,13 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
}
}
- if ((error = zfs_zget(zfsvfs, lr->lr_doid, &dzp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_doid, &dzp)) != 0)
return (error);
+#ifdef HAVE_XVATTR
xva_init(&xva);
- zfs_init_vattr(&xva.xva_vattr, AT_TYPE | AT_MODE | AT_UID | AT_GID,
- lr->lr_mode, lr->lr_uid, lr->lr_gid, lr->lr_rdev, lr->lr_foid);
+ zfs_init_iattr(&xva.xva_vattr, ATTR_MODE | ATTR_UID | ATTR_GID,
+ lr->lr_mode, lr->lr_uid, lr->lr_gid, /*lr->lr_rdev, lr->lr_foid*/);
/*
* All forms of zfs create (create, mkdir, mkxattrdir, symlink)
@@ -317,8 +316,9 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
*/
ZFS_TIME_DECODE(&xva.xva_vattr.va_ctime, lr->lr_crtime);
xva.xva_vattr.va_nblocks = lr->lr_gen;
+#endif /* HAVE_XVATTR */
- error = dmu_object_info(zfsvfs->z_os, lr->lr_foid, NULL);
+ error = dmu_object_info(zsb->z_os, lr->lr_foid, NULL);
if (error != ENOENT)
goto bail;
@@ -329,11 +329,12 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
aclstart = (caddr_t)(lracl + 1);
fuidstart = (caddr_t)aclstart +
ZIL_ACE_LENGTH(lracl->lr_acl_bytes);
- zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart,
+ zsb->z_fuid_replay = zfs_replay_fuids(fuidstart,
(void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt,
lr->lr_uid, lr->lr_gid);
/*FALLTHROUGH*/
case TX_CREATE_ACL_ATTR:
+#ifdef HAVE_XVATTR
if (name == NULL) {
lrattr = (lr_attr_t *)(caddr_t)(lracl + 1);
xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize);
@@ -345,27 +346,29 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
vsec.vsa_aclcnt = lracl->lr_aclcnt;
vsec.vsa_aclentsz = lracl->lr_acl_bytes;
vsec.vsa_aclflags = lracl->lr_acl_flags;
- if (zfsvfs->z_fuid_replay == NULL) {
+ if (zsb->z_fuid_replay == NULL) {
fuidstart = (caddr_t)(lracl + 1) + xvatlen +
ZIL_ACE_LENGTH(lracl->lr_acl_bytes);
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuids(fuidstart,
(void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt,
lr->lr_uid, lr->lr_gid);
}
- error = zfs_create(ZTOV(dzp), name, &xva.xva_vattr,
- 0, 0, &vp, kcred, vflg, NULL, &vsec);
+ error = zfs_create(ZTOI(dzp), name, &xva.xva_vattr,
+ 0, 0, &ip, kcred, vflg, NULL, &vsec);
+#endif /* HAVE_XVATTR */
break;
case TX_MKDIR_ACL:
aclstart = (caddr_t)(lracl + 1);
fuidstart = (caddr_t)aclstart +
ZIL_ACE_LENGTH(lracl->lr_acl_bytes);
- zfsvfs->z_fuid_replay = zfs_replay_fuids(fuidstart,
+ zsb->z_fuid_replay = zfs_replay_fuids(fuidstart,
(void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt,
lr->lr_uid, lr->lr_gid);
/*FALLTHROUGH*/
case TX_MKDIR_ACL_ATTR:
+#ifdef HAVE_XVATTR
if (name == NULL) {
lrattr = (lr_attr_t *)(caddr_t)(lracl + 1);
xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize);
@@ -376,47 +379,50 @@ zfs_replay_create_acl(zfsvfs_t *zfsvfs,
vsec.vsa_aclcnt = lracl->lr_aclcnt;
vsec.vsa_aclentsz = lracl->lr_acl_bytes;
vsec.vsa_aclflags = lracl->lr_acl_flags;
- if (zfsvfs->z_fuid_replay == NULL) {
+ if (zsb->z_fuid_replay == NULL) {
fuidstart = (caddr_t)(lracl + 1) + xvatlen +
ZIL_ACE_LENGTH(lracl->lr_acl_bytes);
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuids(fuidstart,
(void *)&name, lracl->lr_fuidcnt, lracl->lr_domcnt,
lr->lr_uid, lr->lr_gid);
}
- error = zfs_mkdir(ZTOV(dzp), name, &xva.xva_vattr,
- &vp, kcred, NULL, vflg, &vsec);
+ error = zfs_mkdir(ZTOI(dzp), name, &xva.xva_vattr,
+ &ip, kcred, NULL, vflg, &vsec);
+#endif /* HAVE_XVATTR */
break;
default:
error = ENOTSUP;
}
bail:
- if (error == 0 && vp != NULL)
- VN_RELE(vp);
+ if (error == 0 && ip != NULL)
+ iput(ip);
- VN_RELE(ZTOV(dzp));
+ iput(ZTOI(dzp));
- if (zfsvfs->z_fuid_replay)
- zfs_fuid_info_free(zfsvfs->z_fuid_replay);
- zfsvfs->z_fuid_replay = NULL;
+ if (zsb->z_fuid_replay)
+ zfs_fuid_info_free(zsb->z_fuid_replay);
+ zsb->z_fuid_replay = NULL;
return (error);
}
static int
-zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap)
+zfs_replay_create(zfs_sb_t *zsb, lr_create_t *lr, boolean_t byteswap)
{
char *name = NULL; /* location determined later */
char *link; /* symlink content follows name */
znode_t *dzp;
- vnode_t *vp = NULL;
+ struct inode *ip = NULL;
xvattr_t xva;
int vflg = 0;
+#ifdef HAVE_XVATTR
size_t lrsize = sizeof (lr_create_t);
lr_attr_t *lrattr;
- void *start;
size_t xvatlen;
+#endif /* HAVE_XVATTR */
+ void *start;
uint64_t txtype;
int error;
@@ -428,12 +434,13 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap)
}
- if ((error = zfs_zget(zfsvfs, lr->lr_doid, &dzp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_doid, &dzp)) != 0)
return (error);
+#ifdef HAVE_XVATTR
xva_init(&xva);
- zfs_init_vattr(&xva.xva_vattr, AT_TYPE | AT_MODE | AT_UID | AT_GID,
- lr->lr_mode, lr->lr_uid, lr->lr_gid, lr->lr_rdev, lr->lr_foid);
+ zfs_init_iattr(&xva.xva_vattr, ATTR_MODE | ATTR_UID | ATTR_GID,
+ lr->lr_mode, lr->lr_uid, lr->lr_gid, /*lr->lr_rdev, lr->lr_foid*/);
/*
* All forms of zfs create (create, mkdir, mkxattrdir, symlink)
@@ -444,8 +451,9 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap)
*/
ZFS_TIME_DECODE(&xva.xva_vattr.va_ctime, lr->lr_crtime);
xva.xva_vattr.va_nblocks = lr->lr_gen;
+#endif /* HAVE_XVATTR */
- error = dmu_object_info(zfsvfs->z_os, lr->lr_foid, NULL);
+ error = dmu_object_info(zsb->z_os, lr->lr_foid, NULL);
if (error != ENOENT)
goto out;
@@ -462,75 +470,79 @@ zfs_replay_create(zfsvfs_t *zfsvfs, lr_create_t *lr, boolean_t byteswap)
(int)lr->lr_common.lrc_txtype != TX_MKDIR_ATTR &&
(int)lr->lr_common.lrc_txtype != TX_CREATE_ATTR) {
start = (lr + 1);
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuid_domain(start, &start,
lr->lr_uid, lr->lr_gid);
}
switch (txtype) {
case TX_CREATE_ATTR:
+#ifdef HAVE_XVATTR
lrattr = (lr_attr_t *)(caddr_t)(lr + 1);
xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize);
zfs_replay_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), &xva);
start = (caddr_t)(lr + 1) + xvatlen;
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuid_domain(start, &start,
lr->lr_uid, lr->lr_gid);
name = (char *)start;
+#endif /* HAVE_XVATTR */
/*FALLTHROUGH*/
case TX_CREATE:
if (name == NULL)
name = (char *)start;
- error = zfs_create(ZTOV(dzp), name, &xva.xva_vattr,
- 0, 0, &vp, kcred, vflg, NULL, NULL);
+ error = zfs_create(ZTOI(dzp), name, &xva.xva_vattr,
+ 0, 0, &ip, kcred, vflg, NULL);
break;
case TX_MKDIR_ATTR:
+#ifdef HAVE_XVATTR
lrattr = (lr_attr_t *)(caddr_t)(lr + 1);
xvatlen = ZIL_XVAT_SIZE(lrattr->lr_attr_masksize);
zfs_replay_xvattr((lr_attr_t *)((caddr_t)lr + lrsize), &xva);
start = (caddr_t)(lr + 1) + xvatlen;
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuid_domain(start, &start,
lr->lr_uid, lr->lr_gid);
name = (char *)start;
+#endif /* HAVE_XVATTR */
/*FALLTHROUGH*/
case TX_MKDIR:
if (name == NULL)
name = (char *)(lr + 1);
- error = zfs_mkdir(ZTOV(dzp), name, &xva.xva_vattr,
- &vp, kcred, NULL, vflg, NULL);
+ error = zfs_mkdir(ZTOI(dzp), name, &xva.xva_vattr,
+ &ip, kcred, vflg, NULL);
break;
case TX_MKXATTR:
- error = zfs_make_xattrdir(dzp, &xva.xva_vattr, &vp, kcred);
+ error = zfs_make_xattrdir(dzp, &xva.xva_vattr, &ip, kcred);
break;
case TX_SYMLINK:
name = (char *)(lr + 1);
link = name + strlen(name) + 1;
- error = zfs_symlink(ZTOV(dzp), name, &xva.xva_vattr,
- link, kcred, NULL, vflg);
+ error = zfs_symlink(ZTOI(dzp), name, &xva.xva_vattr,
+ link, &ip, kcred, vflg);
break;
default:
error = ENOTSUP;
}
out:
- if (error == 0 && vp != NULL)
- VN_RELE(vp);
+ if (error == 0 && ip != NULL)
+ iput(ip);
- VN_RELE(ZTOV(dzp));
+ iput(ZTOI(dzp));
- if (zfsvfs->z_fuid_replay)
- zfs_fuid_info_free(zfsvfs->z_fuid_replay);
- zfsvfs->z_fuid_replay = NULL;
+ if (zsb->z_fuid_replay)
+ zfs_fuid_info_free(zsb->z_fuid_replay);
+ zsb->z_fuid_replay = NULL;
return (error);
}
static int
-zfs_replay_remove(zfsvfs_t *zfsvfs, lr_remove_t *lr, boolean_t byteswap)
+zfs_replay_remove(zfs_sb_t *zsb, lr_remove_t *lr, boolean_t byteswap)
{
char *name = (char *)(lr + 1); /* name follows lr_remove_t */
znode_t *dzp;
@@ -540,60 +552,63 @@ zfs_replay_remove(zfsvfs_t *zfsvfs, lr_remove_t *lr, boolean_t byteswap)
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_doid, &dzp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_doid, &dzp)) != 0)
return (error);
+#ifdef HAVE_PN_UTILS
if (lr->lr_common.lrc_txtype & TX_CI)
vflg |= FIGNORECASE;
+#endif
switch ((int)lr->lr_common.lrc_txtype) {
case TX_REMOVE:
- error = zfs_remove(ZTOV(dzp), name, kcred, NULL, vflg);
+ error = zfs_remove(ZTOI(dzp), name, kcred);
break;
case TX_RMDIR:
- error = zfs_rmdir(ZTOV(dzp), name, NULL, kcred, NULL, vflg);
+ error = zfs_rmdir(ZTOI(dzp), name, NULL, kcred, vflg);
break;
default:
error = ENOTSUP;
}
- VN_RELE(ZTOV(dzp));
+ iput(ZTOI(dzp));
return (error);
}
static int
-zfs_replay_link(zfsvfs_t *zfsvfs, lr_link_t *lr, boolean_t byteswap)
+zfs_replay_link(zfs_sb_t *zsb, lr_link_t *lr, boolean_t byteswap)
{
char *name = (char *)(lr + 1); /* name follows lr_link_t */
znode_t *dzp, *zp;
int error;
- int vflg = 0;
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_doid, &dzp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_doid, &dzp)) != 0)
return (error);
- if ((error = zfs_zget(zfsvfs, lr->lr_link_obj, &zp)) != 0) {
- VN_RELE(ZTOV(dzp));
+ if ((error = zfs_zget(zsb, lr->lr_link_obj, &zp)) != 0) {
+ iput(ZTOI(dzp));
return (error);
}
+#ifdef HAVE_PN_UTILS
if (lr->lr_common.lrc_txtype & TX_CI)
vflg |= FIGNORECASE;
+#endif
- error = zfs_link(ZTOV(dzp), ZTOV(zp), name, kcred, NULL, vflg);
+ error = zfs_link(ZTOI(dzp), ZTOI(zp), name, kcred);
- VN_RELE(ZTOV(zp));
- VN_RELE(ZTOV(dzp));
+ iput(ZTOI(zp));
+ iput(ZTOI(dzp));
return (error);
}
static int
-zfs_replay_rename(zfsvfs_t *zfsvfs, lr_rename_t *lr, boolean_t byteswap)
+zfs_replay_rename(zfs_sb_t *zsb, lr_rename_t *lr, boolean_t byteswap)
{
char *sname = (char *)(lr + 1); /* sname and tname follow lr_rename_t */
char *tname = sname + strlen(sname) + 1;
@@ -604,39 +619,39 @@ zfs_replay_rename(zfsvfs_t *zfsvfs, lr_rename_t *lr, boolean_t byteswap)
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_sdoid, &sdzp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_sdoid, &sdzp)) != 0)
return (error);
- if ((error = zfs_zget(zfsvfs, lr->lr_tdoid, &tdzp)) != 0) {
- VN_RELE(ZTOV(sdzp));
+ if ((error = zfs_zget(zsb, lr->lr_tdoid, &tdzp)) != 0) {
+ iput(ZTOI(sdzp));
return (error);
}
if (lr->lr_common.lrc_txtype & TX_CI)
vflg |= FIGNORECASE;
- error = zfs_rename(ZTOV(sdzp), sname, ZTOV(tdzp), tname, kcred,
- NULL, vflg);
+ error = zfs_rename(ZTOI(sdzp), sname, ZTOI(tdzp), tname, kcred, vflg);
- VN_RELE(ZTOV(tdzp));
- VN_RELE(ZTOV(sdzp));
+ iput(ZTOI(tdzp));
+ iput(ZTOI(sdzp));
return (error);
}
static int
-zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
+zfs_replay_write(zfs_sb_t *zsb, lr_write_t *lr, boolean_t byteswap)
{
+#if 0
char *data = (char *)(lr + 1); /* data follows lr_write_t */
+#endif
znode_t *zp;
int error;
- ssize_t resid;
uint64_t eod, offset, length;
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0) {
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0) {
/*
* As we can log writes out of order, it's possible the
* file has been removed. In this case just drop the write
@@ -659,10 +674,10 @@ zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
* write needs to be there. So we write the whole block and
* reduce the eof. This needs to be done within the single dmu
* transaction created within vn_rdwr -> zfs_write. So a possible
- * new end of file is passed through in zfsvfs->z_replay_eof
+ * new end of file is passed through in zsb->z_replay_eof
*/
- zfsvfs->z_replay_eof = 0; /* 0 means don't change end of file */
+ zsb->z_replay_eof = 0; /* 0 means don't change end of file */
/* If it's a dmu_sync() block, write the whole block */
if (lr->lr_common.lrc_reclen == sizeof (lr_write_t)) {
@@ -672,14 +687,19 @@ zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
length = blocksize;
}
if (zp->z_size < eod)
- zfsvfs->z_replay_eof = eod;
+ zsb->z_replay_eof = eod;
}
- error = vn_rdwr(UIO_WRITE, ZTOV(zp), data, length, offset,
+ /*
+ * XXX: Use zfs_write() once uio types are removed
+ */
+#if 0
+ error = vn_rdwr(UIO_WRITE, ZTOI(zp), data, length, offset,
UIO_SYSSPACE, 0, RLIM64_INFINITY, kcred, &resid);
+#endif
- VN_RELE(ZTOV(zp));
- zfsvfs->z_replay_eof = 0; /* safety */
+ iput(ZTOI(zp));
+ zsb->z_replay_eof = 0; /* safety */
return (error);
}
@@ -691,7 +711,7 @@ zfs_replay_write(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
* the file is grown.
*/
static int
-zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
+zfs_replay_write2(zfs_sb_t *zsb, lr_write_t *lr, boolean_t byteswap)
{
znode_t *zp;
int error;
@@ -700,19 +720,19 @@ zfs_replay_write2(zfsvfs_t *zfsvfs, lr_write_t *lr, boolean_t byteswap)
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0)
return (error);
top:
end = lr->lr_offset + lr->lr_length;
if (end > zp->z_size) {
- dmu_tx_t *tx = dmu_tx_create(zfsvfs->z_os);
+ dmu_tx_t *tx = dmu_tx_create(zsb->z_os);
zp->z_size = end;
dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
error = dmu_tx_assign(tx, TXG_WAIT);
if (error) {
- VN_RELE(ZTOV(zp));
+ iput(ZTOI(zp));
if (error == ERESTART) {
dmu_tx_wait(tx);
dmu_tx_abort(tx);
@@ -721,22 +741,22 @@ top:
dmu_tx_abort(tx);
return (error);
}
- (void) sa_update(zp->z_sa_hdl, SA_ZPL_SIZE(zfsvfs),
+ (void) sa_update(zp->z_sa_hdl, SA_ZPL_SIZE(zsb),
(void *)&zp->z_size, sizeof (uint64_t), tx);
/* Ensure the replayed seq is updated */
- (void) zil_replaying(zfsvfs->z_log, tx);
+ (void) zil_replaying(zsb->z_log, tx);
dmu_tx_commit(tx);
}
- VN_RELE(ZTOV(zp));
+ iput(ZTOI(zp));
return (error);
}
static int
-zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
+zfs_replay_truncate(zfs_sb_t *zsb, lr_truncate_t *lr, boolean_t byteswap)
{
znode_t *zp;
flock64_t fl;
@@ -745,7 +765,7 @@ zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
if (byteswap)
byteswap_uint64_array(lr, sizeof (*lr));
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0)
return (error);
bzero(&fl, sizeof (fl));
@@ -754,68 +774,75 @@ zfs_replay_truncate(zfsvfs_t *zfsvfs, lr_truncate_t *lr, boolean_t byteswap)
fl.l_start = lr->lr_offset;
fl.l_len = lr->lr_length;
- error = zfs_space(ZTOV(zp), F_FREESP, &fl, FWRITE | FOFFMAX,
- lr->lr_offset, kcred, NULL);
+ error = zfs_space(ZTOI(zp), F_FREESP, &fl, FWRITE | FOFFMAX,
+ lr->lr_offset, kcred);
- VN_RELE(ZTOV(zp));
+ iput(ZTOI(zp));
return (error);
}
static int
-zfs_replay_setattr(zfsvfs_t *zfsvfs, lr_setattr_t *lr, boolean_t byteswap)
+zfs_replay_setattr(zfs_sb_t *zsb, lr_setattr_t *lr, boolean_t byteswap)
{
znode_t *zp;
+#ifdef HAVE_XVATTR
xvattr_t xva;
- vattr_t *vap = &xva.xva_vattr;
+#endif /* HAVE_XATTR */
+ struct iattr attr;
int error;
void *start;
+#ifdef HAVE_XVATTR
xva_init(&xva);
+#endif /* HAVE_XVATTR */
if (byteswap) {
byteswap_uint64_array(lr, sizeof (*lr));
+#ifdef HAVE_XVATTR
if ((lr->lr_mask & AT_XVATTR) &&
- zfsvfs->z_version >= ZPL_VERSION_INITIAL)
+ zsb->z_version >= ZPL_VERSION_INITIAL)
zfs_replay_swap_attrs((lr_attr_t *)(lr + 1));
+#endif /* HAVE_XVATTR */
}
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0)
return (error);
- zfs_init_vattr(vap, lr->lr_mask, lr->lr_mode,
- lr->lr_uid, lr->lr_gid, 0, lr->lr_foid);
+ zfs_init_iattr(&attr, lr->lr_mask, lr->lr_mode, lr->lr_uid, lr->lr_gid);
- vap->va_size = lr->lr_size;
- ZFS_TIME_DECODE(&vap->va_atime, lr->lr_atime);
- ZFS_TIME_DECODE(&vap->va_mtime, lr->lr_mtime);
+ attr.ia_size = lr->lr_size;
+ ZFS_TIME_DECODE(&attr.ia_atime, lr->lr_atime);
+ ZFS_TIME_DECODE(&attr.ia_mtime, lr->lr_mtime);
/*
* Fill in xvattr_t portions if necessary.
*/
start = (lr_setattr_t *)(lr + 1);
- if (vap->va_mask & AT_XVATTR) {
+#ifdef HAVE_XVATTR
+ if (iattr->ia_mask & AT_XVATTR) {
zfs_replay_xvattr((lr_attr_t *)start, &xva);
start = (caddr_t)start +
ZIL_XVAT_SIZE(((lr_attr_t *)start)->lr_attr_masksize);
} else
xva.xva_vattr.va_mask &= ~AT_XVATTR;
+#endif /* HAVE_XVATTR */
- zfsvfs->z_fuid_replay = zfs_replay_fuid_domain(start, &start,
+ zsb->z_fuid_replay = zfs_replay_fuid_domain(start, &start,
lr->lr_uid, lr->lr_gid);
- error = zfs_setattr(ZTOV(zp), vap, 0, kcred, NULL);
+ error = zfs_setattr(ZTOI(zp), &attr, 0, kcred);
- zfs_fuid_info_free(zfsvfs->z_fuid_replay);
- zfsvfs->z_fuid_replay = NULL;
- VN_RELE(ZTOV(zp));
+ zfs_fuid_info_free(zsb->z_fuid_replay);
+ zsb->z_fuid_replay = NULL;
+ iput(ZTOI(zp));
return (error);
}
static int
-zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap)
+zfs_replay_acl_v0(zfs_sb_t *zsb, lr_acl_v0_t *lr, boolean_t byteswap)
{
ace_t *ace = (ace_t *)(lr + 1); /* ace array follows lr_acl_t */
vsecattr_t vsa;
@@ -827,7 +854,7 @@ zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap)
zfs_oldace_byteswap(ace, lr->lr_aclcnt);
}
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0)
return (error);
bzero(&vsa, sizeof (vsa));
@@ -837,9 +864,9 @@ zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap)
vsa.vsa_aclflags = 0;
vsa.vsa_aclentp = ace;
- error = zfs_setsecattr(ZTOV(zp), &vsa, 0, kcred, NULL);
+ error = zfs_setsecattr(ZTOI(zp), &vsa, 0, kcred);
- VN_RELE(ZTOV(zp));
+ iput(ZTOI(zp));
return (error);
}
@@ -859,7 +886,7 @@ zfs_replay_acl_v0(zfsvfs_t *zfsvfs, lr_acl_v0_t *lr, boolean_t byteswap)
*
*/
static int
-zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap)
+zfs_replay_acl(zfs_sb_t *zsb, lr_acl_t *lr, boolean_t byteswap)
{
ace_t *ace = (ace_t *)(lr + 1);
vsecattr_t vsa;
@@ -876,7 +903,7 @@ zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap)
}
}
- if ((error = zfs_zget(zfsvfs, lr->lr_foid, &zp)) != 0)
+ if ((error = zfs_zget(zsb, lr->lr_foid, &zp)) != 0)
return (error);
bzero(&vsa, sizeof (vsa));
@@ -890,18 +917,18 @@ zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap)
void *fuidstart = (caddr_t)ace +
ZIL_ACE_LENGTH(lr->lr_acl_bytes);
- zfsvfs->z_fuid_replay =
+ zsb->z_fuid_replay =
zfs_replay_fuids(fuidstart, &fuidstart,
lr->lr_fuidcnt, lr->lr_domcnt, 0, 0);
}
- error = zfs_setsecattr(ZTOV(zp), &vsa, 0, kcred, NULL);
+ error = zfs_setsecattr(ZTOI(zp), &vsa, 0, kcred);
- if (zfsvfs->z_fuid_replay)
- zfs_fuid_info_free(zfsvfs->z_fuid_replay);
+ if (zsb->z_fuid_replay)
+ zfs_fuid_info_free(zsb->z_fuid_replay);
- zfsvfs->z_fuid_replay = NULL;
- VN_RELE(ZTOV(zp));
+ zsb->z_fuid_replay = NULL;
+ iput(ZTOI(zp));
return (error);
}
@@ -910,26 +937,25 @@ zfs_replay_acl(zfsvfs_t *zfsvfs, lr_acl_t *lr, boolean_t byteswap)
* Callback vectors for replaying records
*/
zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE] = {
- zfs_replay_error, /* 0 no such transaction type */
- zfs_replay_create, /* TX_CREATE */
- zfs_replay_create, /* TX_MKDIR */
- zfs_replay_create, /* TX_MKXATTR */
- zfs_replay_create, /* TX_SYMLINK */
- zfs_replay_remove, /* TX_REMOVE */
- zfs_replay_remove, /* TX_RMDIR */
- zfs_replay_link, /* TX_LINK */
- zfs_replay_rename, /* TX_RENAME */
- zfs_replay_write, /* TX_WRITE */
- zfs_replay_truncate, /* TX_TRUNCATE */
- zfs_replay_setattr, /* TX_SETATTR */
- zfs_replay_acl_v0, /* TX_ACL_V0 */
- zfs_replay_acl, /* TX_ACL */
- zfs_replay_create_acl, /* TX_CREATE_ACL */
- zfs_replay_create, /* TX_CREATE_ATTR */
- zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */
- zfs_replay_create_acl, /* TX_MKDIR_ACL */
- zfs_replay_create, /* TX_MKDIR_ATTR */
- zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */
- zfs_replay_write2, /* TX_WRITE2 */
+ (zil_replay_func_t *)zfs_replay_error, /* no such type */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_CREATE */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_MKDIR */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_MKXATTR */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_SYMLINK */
+ (zil_replay_func_t *)zfs_replay_remove, /* TX_REMOVE */
+ (zil_replay_func_t *)zfs_replay_remove, /* TX_RMDIR */
+ (zil_replay_func_t *)zfs_replay_link, /* TX_LINK */
+ (zil_replay_func_t *)zfs_replay_rename, /* TX_RENAME */
+ (zil_replay_func_t *)zfs_replay_write, /* TX_WRITE */
+ (zil_replay_func_t *)zfs_replay_truncate, /* TX_TRUNCATE */
+ (zil_replay_func_t *)zfs_replay_setattr, /* TX_SETATTR */
+ (zil_replay_func_t *)zfs_replay_acl_v0, /* TX_ACL_V0 */
+ (zil_replay_func_t *)zfs_replay_acl, /* TX_ACL */
+ (zil_replay_func_t *)zfs_replay_create_acl, /* TX_CREATE_ACL */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_CREATE_ATTR */
+ (zil_replay_func_t *)zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */
+ (zil_replay_func_t *)zfs_replay_create_acl, /* TX_MKDIR_ACL */
+ (zil_replay_func_t *)zfs_replay_create, /* TX_MKDIR_ATTR */
+ (zil_replay_func_t *)zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */
+ (zil_replay_func_t *)zfs_replay_write2, /* TX_WRITE2 */
};
-#endif /* HAVE_ZPL */