Commit 54275d84 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: remove xfs_da_args.attr_flags

This field only ever contains XATTR_{CREATE,REPLACE}, and it only goes
as deep as xfs_attr_set.  Remove the field from the structure and
replace it with an enum specifying exactly what kind of change we want
to make to the xattr structure.  Upsert is the name that we'll give to
the flags==0 operation, because we're either updating an existing value
or inserting it, and the caller doesn't care.

Note: The "UPSERTR" name created here is to make userspace porting
easier.  It will be removed in the next patch.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 779a4b60
...@@ -922,7 +922,8 @@ xfs_attr_defer_add( ...@@ -922,7 +922,8 @@ xfs_attr_defer_add(
*/ */
int int
xfs_attr_set( xfs_attr_set(
struct xfs_da_args *args) struct xfs_da_args *args,
enum xfs_attr_update op)
{ {
struct xfs_inode *dp = args->dp; struct xfs_inode *dp = args->dp;
struct xfs_mount *mp = dp->i_mount; struct xfs_mount *mp = dp->i_mount;
...@@ -1008,7 +1009,7 @@ xfs_attr_set( ...@@ -1008,7 +1009,7 @@ xfs_attr_set(
} }
/* Pure create fails if the attr already exists */ /* Pure create fails if the attr already exists */
if (args->attr_flags & XATTR_CREATE) if (op == XFS_ATTRUPDATE_CREATE)
goto out_trans_cancel; goto out_trans_cancel;
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REPLACE); xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REPLACE);
break; break;
...@@ -1018,7 +1019,7 @@ xfs_attr_set( ...@@ -1018,7 +1019,7 @@ xfs_attr_set(
goto out_trans_cancel; goto out_trans_cancel;
/* Pure replace fails if no existing attr to replace. */ /* Pure replace fails if no existing attr to replace. */
if (args->attr_flags & XATTR_REPLACE) if (op == XFS_ATTRUPDATE_REPLACE)
goto out_trans_cancel; goto out_trans_cancel;
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_SET); xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_SET);
break; break;
......
...@@ -544,7 +544,14 @@ int xfs_inode_hasattr(struct xfs_inode *ip); ...@@ -544,7 +544,14 @@ int xfs_inode_hasattr(struct xfs_inode *ip);
bool xfs_attr_is_leaf(struct xfs_inode *ip); bool xfs_attr_is_leaf(struct xfs_inode *ip);
int xfs_attr_get_ilocked(struct xfs_da_args *args); int xfs_attr_get_ilocked(struct xfs_da_args *args);
int xfs_attr_get(struct xfs_da_args *args); int xfs_attr_get(struct xfs_da_args *args);
int xfs_attr_set(struct xfs_da_args *args);
enum xfs_attr_update {
XFS_ATTRUPDATE_UPSERTR, /* set/remove value, replace any existing attr */
XFS_ATTRUPDATE_CREATE, /* set value, fail if attr already exists */
XFS_ATTRUPDATE_REPLACE, /* set value, fail if attr does not exist */
};
int xfs_attr_set(struct xfs_da_args *args, enum xfs_attr_update op);
int xfs_attr_set_iter(struct xfs_attr_intent *attr); int xfs_attr_set_iter(struct xfs_attr_intent *attr);
int xfs_attr_remove_iter(struct xfs_attr_intent *attr); int xfs_attr_remove_iter(struct xfs_attr_intent *attr);
bool xfs_attr_namecheck(const void *name, size_t length); bool xfs_attr_namecheck(const void *name, size_t length);
......
...@@ -60,7 +60,6 @@ typedef struct xfs_da_args { ...@@ -60,7 +60,6 @@ typedef struct xfs_da_args {
void *value; /* set of bytes (maybe contain NULLs) */ void *value; /* set of bytes (maybe contain NULLs) */
int valuelen; /* length of value */ int valuelen; /* length of value */
unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */ unsigned int attr_filter; /* XFS_ATTR_{ROOT,SECURE,INCOMPLETE} */
unsigned int attr_flags; /* XATTR_{CREATE,REPLACE} */
xfs_dahash_t hashval; /* hash value of name */ xfs_dahash_t hashval; /* hash value of name */
xfs_ino_t inumber; /* input/output inode number */ xfs_ino_t inumber; /* input/output inode number */
struct xfs_inode *dp; /* directory inode to manipulate */ struct xfs_inode *dp; /* directory inode to manipulate */
......
...@@ -557,7 +557,6 @@ xrep_xattr_insert_rec( ...@@ -557,7 +557,6 @@ xrep_xattr_insert_rec(
struct xfs_da_args args = { struct xfs_da_args args = {
.dp = rx->sc->tempip, .dp = rx->sc->tempip,
.attr_filter = key->flags, .attr_filter = key->flags,
.attr_flags = XATTR_CREATE,
.namelen = key->namelen, .namelen = key->namelen,
.valuelen = key->valuelen, .valuelen = key->valuelen,
.owner = rx->sc->ip->i_ino, .owner = rx->sc->ip->i_ino,
...@@ -605,7 +604,7 @@ xrep_xattr_insert_rec( ...@@ -605,7 +604,7 @@ xrep_xattr_insert_rec(
* xfs_attr_set creates and commits its own transaction. If the attr * xfs_attr_set creates and commits its own transaction. If the attr
* already exists, we'll just drop it during the rebuild. * already exists, we'll just drop it during the rebuild.
*/ */
error = xfs_attr_set(&args); error = xfs_attr_set(&args, XFS_ATTRUPDATE_CREATE);
if (error == -EEXIST) if (error == -EEXIST)
error = 0; error = 0;
......
...@@ -203,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -203,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
xfs_acl_to_disk(args.value, acl); xfs_acl_to_disk(args.value, acl);
} }
error = xfs_attr_change(&args); error = xfs_attr_change(&args, XFS_ATTRUPDATE_UPSERTR);
kvfree(args.value); kvfree(args.value);
/* /*
......
...@@ -361,15 +361,15 @@ xfs_attr_filter( ...@@ -361,15 +361,15 @@ xfs_attr_filter(
return 0; return 0;
} }
static unsigned int static inline enum xfs_attr_update
xfs_attr_flags( xfs_xattr_flags(
u32 ioc_flags) u32 ioc_flags)
{ {
if (ioc_flags & XFS_IOC_ATTR_CREATE) if (ioc_flags & XFS_IOC_ATTR_CREATE)
return XATTR_CREATE; return XFS_ATTRUPDATE_CREATE;
if (ioc_flags & XFS_IOC_ATTR_REPLACE) if (ioc_flags & XFS_IOC_ATTR_REPLACE)
return XATTR_REPLACE; return XFS_ATTRUPDATE_REPLACE;
return 0; return XFS_ATTRUPDATE_UPSERTR;
} }
int int
...@@ -476,7 +476,6 @@ xfs_attrmulti_attr_get( ...@@ -476,7 +476,6 @@ xfs_attrmulti_attr_get(
struct xfs_da_args args = { struct xfs_da_args args = {
.dp = XFS_I(inode), .dp = XFS_I(inode),
.attr_filter = xfs_attr_filter(flags), .attr_filter = xfs_attr_filter(flags),
.attr_flags = xfs_attr_flags(flags),
.name = name, .name = name,
.namelen = strlen(name), .namelen = strlen(name),
.valuelen = *len, .valuelen = *len,
...@@ -510,7 +509,6 @@ xfs_attrmulti_attr_set( ...@@ -510,7 +509,6 @@ xfs_attrmulti_attr_set(
struct xfs_da_args args = { struct xfs_da_args args = {
.dp = XFS_I(inode), .dp = XFS_I(inode),
.attr_filter = xfs_attr_filter(flags), .attr_filter = xfs_attr_filter(flags),
.attr_flags = xfs_attr_flags(flags),
.name = name, .name = name,
.namelen = strlen(name), .namelen = strlen(name),
}; };
...@@ -528,7 +526,7 @@ xfs_attrmulti_attr_set( ...@@ -528,7 +526,7 @@ xfs_attrmulti_attr_set(
args.valuelen = len; args.valuelen = len;
} }
error = xfs_attr_change(&args); error = xfs_attr_change(&args, xfs_xattr_flags(flags));
if (!error && (flags & XFS_IOC_ATTR_ROOT)) if (!error && (flags & XFS_IOC_ATTR_ROOT))
xfs_forget_acl(inode, name); xfs_forget_acl(inode, name);
kfree(args.value); kfree(args.value);
......
...@@ -63,7 +63,7 @@ xfs_initxattrs( ...@@ -63,7 +63,7 @@ xfs_initxattrs(
.value = xattr->value, .value = xattr->value,
.valuelen = xattr->value_len, .valuelen = xattr->value_len,
}; };
error = xfs_attr_change(&args); error = xfs_attr_change(&args, XFS_ATTRUPDATE_UPSERTR);
if (error < 0) if (error < 0)
break; break;
} }
......
...@@ -1999,7 +1999,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class, ...@@ -1999,7 +1999,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
__field(int, valuelen) __field(int, valuelen)
__field(xfs_dahash_t, hashval) __field(xfs_dahash_t, hashval)
__field(unsigned int, attr_filter) __field(unsigned int, attr_filter)
__field(unsigned int, attr_flags)
__field(uint32_t, op_flags) __field(uint32_t, op_flags)
), ),
TP_fast_assign( TP_fast_assign(
...@@ -2011,11 +2010,10 @@ DECLARE_EVENT_CLASS(xfs_attr_class, ...@@ -2011,11 +2010,10 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
__entry->valuelen = args->valuelen; __entry->valuelen = args->valuelen;
__entry->hashval = args->hashval; __entry->hashval = args->hashval;
__entry->attr_filter = args->attr_filter; __entry->attr_filter = args->attr_filter;
__entry->attr_flags = args->attr_flags;
__entry->op_flags = args->op_flags; __entry->op_flags = args->op_flags;
), ),
TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d " TP_printk("dev %d:%d ino 0x%llx name %.*s namelen %d valuelen %d "
"hashval 0x%x filter %s flags %s op_flags %s", "hashval 0x%x filter %s op_flags %s",
MAJOR(__entry->dev), MINOR(__entry->dev), MAJOR(__entry->dev), MINOR(__entry->dev),
__entry->ino, __entry->ino,
__entry->namelen, __entry->namelen,
...@@ -2025,9 +2023,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class, ...@@ -2025,9 +2023,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
__entry->hashval, __entry->hashval,
__print_flags(__entry->attr_filter, "|", __print_flags(__entry->attr_filter, "|",
XFS_ATTR_FILTER_FLAGS), XFS_ATTR_FILTER_FLAGS),
__print_flags(__entry->attr_flags, "|",
{ XATTR_CREATE, "CREATE" },
{ XATTR_REPLACE, "REPLACE" }),
__print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS)) __print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
) )
......
...@@ -73,7 +73,8 @@ xfs_attr_want_log_assist( ...@@ -73,7 +73,8 @@ xfs_attr_want_log_assist(
*/ */
int int
xfs_attr_change( xfs_attr_change(
struct xfs_da_args *args) struct xfs_da_args *args,
enum xfs_attr_update op)
{ {
struct xfs_mount *mp = args->dp->i_mount; struct xfs_mount *mp = args->dp->i_mount;
int error; int error;
...@@ -88,7 +89,7 @@ xfs_attr_change( ...@@ -88,7 +89,7 @@ xfs_attr_change(
args->op_flags |= XFS_DA_OP_LOGGED; args->op_flags |= XFS_DA_OP_LOGGED;
} }
return xfs_attr_set(args); return xfs_attr_set(args, op);
} }
...@@ -115,6 +116,17 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused, ...@@ -115,6 +116,17 @@ xfs_xattr_get(const struct xattr_handler *handler, struct dentry *unused,
return args.valuelen; return args.valuelen;
} }
static inline enum xfs_attr_update
xfs_xattr_flags_to_op(
int flags)
{
if (flags & XATTR_CREATE)
return XFS_ATTRUPDATE_CREATE;
if (flags & XATTR_REPLACE)
return XFS_ATTRUPDATE_REPLACE;
return XFS_ATTRUPDATE_UPSERTR;
}
static int static int
xfs_xattr_set(const struct xattr_handler *handler, xfs_xattr_set(const struct xattr_handler *handler,
struct mnt_idmap *idmap, struct dentry *unused, struct mnt_idmap *idmap, struct dentry *unused,
...@@ -124,7 +136,6 @@ xfs_xattr_set(const struct xattr_handler *handler, ...@@ -124,7 +136,6 @@ xfs_xattr_set(const struct xattr_handler *handler,
struct xfs_da_args args = { struct xfs_da_args args = {
.dp = XFS_I(inode), .dp = XFS_I(inode),
.attr_filter = handler->flags, .attr_filter = handler->flags,
.attr_flags = flags,
.name = name, .name = name,
.namelen = strlen(name), .namelen = strlen(name),
.value = (void *)value, .value = (void *)value,
...@@ -132,7 +143,7 @@ xfs_xattr_set(const struct xattr_handler *handler, ...@@ -132,7 +143,7 @@ xfs_xattr_set(const struct xattr_handler *handler,
}; };
int error; int error;
error = xfs_attr_change(&args); error = xfs_attr_change(&args, xfs_xattr_flags_to_op(flags));
if (!error && (handler->flags & XFS_ATTR_ROOT)) if (!error && (handler->flags & XFS_ATTR_ROOT))
xfs_forget_acl(inode, name); xfs_forget_acl(inode, name);
return error; return error;
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#ifndef __XFS_XATTR_H__ #ifndef __XFS_XATTR_H__
#define __XFS_XATTR_H__ #define __XFS_XATTR_H__
int xfs_attr_change(struct xfs_da_args *args); enum xfs_attr_update;
int xfs_attr_change(struct xfs_da_args *args, enum xfs_attr_update op);
extern const struct xattr_handler * const xfs_xattr_handlers[]; extern const struct xattr_handler * const xfs_xattr_handlers[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment