summaryrefslogtreecommitdiffstats
path: root/module/zfs/zpl_inode.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-03-01 12:24:09 -0800
committerBrian Behlendorf <[email protected]>2011-03-02 11:44:34 -0800
commit5484965ab650a56871a62a3373859a7a36ddafcb (patch)
treeecf3a4c6a95b8dd5609a8b5039d5ad26295d0497 /module/zfs/zpl_inode.c
parent321a498b95f4a43a5553f53b435497f89fefc599 (diff)
Drop HAVE_XVATTR macros
When I began work on the Posix layer it immediately became clear to me that to integrate cleanly with the Linux VFS certain Solaris specific things would have to go. One of these things was to elimate as many Solaris specific types from the ZPL layer as possible. They would be replaced with their Linux equivalents. This would not only be good for performance, but for the general readability and health of the code. The Solaris and Linux VFS are different beasts and should be treated as such. Most of the code remains common for constructing transactions and such, but there are subtle and important differenced which need to be repsected. This policy went quite for for certain types such as the vnode_t, and it initially seemed to be working out well for the vattr_t. There was a relatively small amount of related xvattr_t code I was forced to comment out with HAVE_XVATTR. But it didn't look that hard to come back soon and replace it all with a native Linux type. However, after going doing this path with xvattr some distance it clear that this code was woven in the ZPL more deeply than I thought. In particular its hooks went very deep in to the ZPL replay code and replacing it would not be as easy as I originally thought. Rather than continue persuing replacing and removing this code I've taken a step back and reevaluted things. This commit reverts many of my previous commits which removed xvattr related code. It restores much of the code to its original upstream state and now relies on improved xvattr_t support in the zfs package itself. The result of this is that much of the code which I had commented out, which accidentally broke things like replay, is now back in place and working. However, there may be a small performance impact for getattr/setattr operations because they now require a translation from native Linux to Solaris types. For now that's a price I'm willing to pay. Once everything is completely functional we can revisting the issue of removing the vattr_t/xvattr_t types. Closes #111
Diffstat (limited to 'module/zfs/zpl_inode.c')
-rw-r--r--module/zfs/zpl_inode.c46
1 files changed, 41 insertions, 5 deletions
diff --git a/module/zfs/zpl_inode.c b/module/zfs/zpl_inode.c
index 888dc17cc..b7227675b 100644
--- a/module/zfs/zpl_inode.c
+++ b/module/zfs/zpl_inode.c
@@ -171,10 +171,33 @@ static int
zpl_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
{
cred_t *cr;
+ vattr_t *vap;
+ struct inode *ip;
int error;
+ ip = dentry->d_inode;
cr = (cred_t *)get_current_cred();
- error = -zfs_getattr(dentry->d_inode, stat, 0, cr);
+ vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+
+ error = -zfs_getattr(ip, vap, 0, cr);
+ if (error)
+ goto out;
+
+ stat->ino = ip->i_ino;
+ stat->dev = 0;
+ stat->mode = vap->va_mode;
+ stat->nlink = vap->va_nlink;
+ stat->uid = vap->va_uid;
+ stat->gid = vap->va_gid;
+ stat->rdev = vap->va_rdev;
+ stat->size = vap->va_size;
+ stat->atime = vap->va_atime;
+ stat->mtime = vap->va_mtime;
+ stat->ctime = vap->va_ctime;
+ stat->blksize = vap->va_blksize;
+ stat->blocks = vap->va_nblocks;
+out:
+ kmem_free(vap, sizeof(vattr_t));
put_cred(cr);
ASSERT3S(error, <=, 0);
@@ -182,21 +205,34 @@ zpl_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
}
static int
-zpl_setattr(struct dentry *dentry, struct iattr *attr)
+zpl_setattr(struct dentry *dentry, struct iattr *ia)
{
cred_t *cr;
+ vattr_t *vap;
int error;
- error = inode_change_ok(dentry->d_inode, attr);
+ error = inode_change_ok(dentry->d_inode, ia);
if (error)
return (error);
cr = (cred_t *)get_current_cred();
- error = -zfs_setattr(dentry->d_inode, attr, 0, cr);
+ vap = kmem_zalloc(sizeof(vattr_t), KM_SLEEP);
+ vap->va_mask = ia->ia_valid & ATTR_IATTR_MASK;
+ vap->va_mode = ia->ia_mode;
+ vap->va_uid = ia->ia_uid;
+ vap->va_gid = ia->ia_gid;
+ vap->va_size = ia->ia_size;
+ vap->va_atime = ia->ia_atime;
+ vap->va_mtime = ia->ia_mtime;
+ vap->va_ctime = ia->ia_ctime;
+
+ error = -zfs_setattr(dentry->d_inode, vap, 0, cr);
+
+ kmem_free(vap, sizeof(vattr_t));
put_cred(cr);
ASSERT3S(error, <=, 0);
- return (-error);
+ return (error);
}
static int