aboutsummaryrefslogtreecommitdiffstats
path: root/module/os/linux/zfs/zpl_xattr.c
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2019-12-11 11:53:57 -0800
committerBrian Behlendorf <[email protected]>2019-12-11 11:53:57 -0800
commit657ce253575295ef680eb33cf4ef698548212a46 (patch)
tree18d03f0887e857b1cbfdb9c1c8b4cac4e06985ed /module/os/linux/zfs/zpl_xattr.c
parentf0bf4351767ab95b1b5e9baa5445db20ffacd00d (diff)
Eliminate Linux specific inode usage from common code
Change many of the znops routines to take a znode rather than an inode so that zfs_replay code can be largely shared and in the future the much of the znops code may be shared. Reviewed-by: Jorgen Lundman <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #9708
Diffstat (limited to 'module/os/linux/zfs/zpl_xattr.c')
-rw-r--r--module/os/linux/zfs/zpl_xattr.c56
1 files changed, 32 insertions, 24 deletions
diff --git a/module/os/linux/zfs/zpl_xattr.c b/module/os/linux/zfs/zpl_xattr.c
index fdcd77541..956aed528 100644
--- a/module/os/linux/zfs/zpl_xattr.c
+++ b/module/os/linux/zfs/zpl_xattr.c
@@ -77,9 +77,9 @@
* largely avoids the issue except in the overflow case.
*/
+#include <sys/zfs_znode.h>
#include <sys/zfs_vfsops.h>
#include <sys/zfs_vnops.h>
-#include <sys/zfs_znode.h>
#include <sys/zap.h>
#include <sys/vfs.h>
#include <sys/zpl.h>
@@ -184,10 +184,12 @@ zpl_xattr_list_dir(xattr_filldir_t *xf, cred_t *cr)
{
struct inode *ip = xf->dentry->d_inode;
struct inode *dxip = NULL;
+ znode_t *dxzp;
int error;
/* Lookup the xattr directory */
- error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL);
+ error = -zfs_lookup(ITOZ(ip), NULL, &dxzp, LOOKUP_XATTR,
+ cr, NULL, NULL);
if (error) {
if (error == -ENOENT)
error = 0;
@@ -195,6 +197,7 @@ zpl_xattr_list_dir(xattr_filldir_t *xf, cred_t *cr)
return (error);
}
+ dxip = ZTOI(dxzp);
error = zpl_xattr_readdir(dxip, xf);
iput(dxip);
@@ -271,21 +274,24 @@ static int
zpl_xattr_get_dir(struct inode *ip, const char *name, void *value,
size_t size, cred_t *cr)
{
- struct inode *dxip = NULL;
struct inode *xip = NULL;
+ znode_t *dxzp = NULL;
+ znode_t *xzp = NULL;
loff_t pos = 0;
int error;
/* Lookup the xattr directory */
- error = -zfs_lookup(ip, NULL, &dxip, LOOKUP_XATTR, cr, NULL, NULL);
+ error = -zfs_lookup(ITOZ(ip), NULL, &dxzp, LOOKUP_XATTR,
+ cr, NULL, NULL);
if (error)
goto out;
/* Lookup a specific xattr name in the directory */
- error = -zfs_lookup(dxip, (char *)name, &xip, 0, cr, NULL, NULL);
+ error = -zfs_lookup(dxzp, (char *)name, &xzp, 0, cr, NULL, NULL);
if (error)
goto out;
+ xip = ZTOI(xzp);
if (!size) {
error = i_size_read(xip);
goto out;
@@ -298,11 +304,11 @@ zpl_xattr_get_dir(struct inode *ip, const char *name, void *value,
error = zpl_read_common(xip, value, size, &pos, UIO_SYSSPACE, 0, cr);
out:
- if (xip)
- iput(xip);
+ if (xzp)
+ zrele(xzp);
- if (dxip)
- iput(dxip);
+ if (dxzp)
+ zrele(dxzp);
return (error);
}
@@ -432,8 +438,8 @@ static int
zpl_xattr_set_dir(struct inode *ip, const char *name, const void *value,
size_t size, int flags, cred_t *cr)
{
- struct inode *dxip = NULL;
- struct inode *xip = NULL;
+ znode_t *dxzp = NULL;
+ znode_t *xzp = NULL;
vattr_t *vap = NULL;
ssize_t wrote;
int lookup_flags, error;
@@ -450,12 +456,13 @@ zpl_xattr_set_dir(struct inode *ip, const char *name, const void *value,
if (value != NULL)
lookup_flags |= CREATE_XATTR_DIR;
- error = -zfs_lookup(ip, NULL, &dxip, lookup_flags, cr, NULL, NULL);
+ error = -zfs_lookup(ITOZ(ip), NULL, &dxzp, lookup_flags,
+ cr, NULL, NULL);
if (error)
goto out;
/* Lookup a specific xattr name in the directory */
- error = -zfs_lookup(dxip, (char *)name, &xip, 0, cr, NULL, NULL);
+ error = -zfs_lookup(dxzp, (char *)name, &xzp, 0, cr, NULL, NULL);
if (error && (error != -ENOENT))
goto out;
@@ -463,33 +470,34 @@ zpl_xattr_set_dir(struct inode *ip, const char *name, const void *value,
/* Remove a specific name xattr when value is set to NULL. */
if (value == NULL) {
- if (xip)
- error = -zfs_remove(dxip, (char *)name, cr, 0);
+ if (xzp)
+ error = -zfs_remove(dxzp, (char *)name, cr, 0);
goto out;
}
/* Lookup failed create a new xattr. */
- if (xip == NULL) {
+ if (xzp == NULL) {
vap = kmem_zalloc(sizeof (vattr_t), KM_SLEEP);
vap->va_mode = xattr_mode;
vap->va_mask = ATTR_MODE;
vap->va_uid = crgetfsuid(cr);
vap->va_gid = crgetfsgid(cr);
- error = -zfs_create(dxip, (char *)name, vap, 0, 0644, &xip,
+ error = -zfs_create(dxzp, (char *)name, vap, 0, 0644, &xzp,
cr, 0, NULL);
if (error)
goto out;
}
- ASSERT(xip != NULL);
+ ASSERT(xzp != NULL);
- error = -zfs_freesp(ITOZ(xip), 0, 0, xattr_mode, TRUE);
+ error = -zfs_freesp(xzp, 0, 0, xattr_mode, TRUE);
if (error)
goto out;
- wrote = zpl_write_common(xip, value, size, &pos, UIO_SYSSPACE, 0, cr);
+ wrote = zpl_write_common(ZTOI(xzp), value, size, &pos,
+ UIO_SYSSPACE, 0, cr);
if (wrote < 0)
error = wrote;
@@ -503,11 +511,11 @@ out:
if (vap)
kmem_free(vap, sizeof (vattr_t));
- if (xip)
- iput(xip);
+ if (xzp)
+ zrele(xzp);
- if (dxip)
- iput(dxip);
+ if (dxzp)
+ zrele(dxzp);
if (error == -ENOENT)
error = -ENODATA;