mirror of
https://github.com/torvalds/linux.git
synced 2024-11-24 21:21:41 +00:00
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: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
779a4b606c
commit
54275d8496
@ -922,7 +922,8 @@ xfs_attr_defer_add(
|
||||
*/
|
||||
int
|
||||
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_mount *mp = dp->i_mount;
|
||||
@ -1008,7 +1009,7 @@ xfs_attr_set(
|
||||
}
|
||||
|
||||
/* Pure create fails if the attr already exists */
|
||||
if (args->attr_flags & XATTR_CREATE)
|
||||
if (op == XFS_ATTRUPDATE_CREATE)
|
||||
goto out_trans_cancel;
|
||||
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_REPLACE);
|
||||
break;
|
||||
@ -1018,7 +1019,7 @@ xfs_attr_set(
|
||||
goto out_trans_cancel;
|
||||
|
||||
/* Pure replace fails if no existing attr to replace. */
|
||||
if (args->attr_flags & XATTR_REPLACE)
|
||||
if (op == XFS_ATTRUPDATE_REPLACE)
|
||||
goto out_trans_cancel;
|
||||
xfs_attr_defer_add(args, XFS_ATTRI_OP_FLAGS_SET);
|
||||
break;
|
||||
|
@ -544,7 +544,14 @@ int xfs_inode_hasattr(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(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_remove_iter(struct xfs_attr_intent *attr);
|
||||
bool xfs_attr_namecheck(const void *name, size_t length);
|
||||
|
@ -60,7 +60,6 @@ typedef struct xfs_da_args {
|
||||
void *value; /* set of bytes (maybe contain NULLs) */
|
||||
int valuelen; /* length of value */
|
||||
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_ino_t inumber; /* input/output inode number */
|
||||
struct xfs_inode *dp; /* directory inode to manipulate */
|
||||
|
@ -557,7 +557,6 @@ xrep_xattr_insert_rec(
|
||||
struct xfs_da_args args = {
|
||||
.dp = rx->sc->tempip,
|
||||
.attr_filter = key->flags,
|
||||
.attr_flags = XATTR_CREATE,
|
||||
.namelen = key->namelen,
|
||||
.valuelen = key->valuelen,
|
||||
.owner = rx->sc->ip->i_ino,
|
||||
@ -605,7 +604,7 @@ xrep_xattr_insert_rec(
|
||||
* xfs_attr_set creates and commits its own transaction. If the attr
|
||||
* 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)
|
||||
error = 0;
|
||||
|
||||
|
@ -203,7 +203,7 @@ __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
|
||||
xfs_acl_to_disk(args.value, acl);
|
||||
}
|
||||
|
||||
error = xfs_attr_change(&args);
|
||||
error = xfs_attr_change(&args, XFS_ATTRUPDATE_UPSERTR);
|
||||
kvfree(args.value);
|
||||
|
||||
/*
|
||||
|
@ -361,15 +361,15 @@ xfs_attr_filter(
|
||||
return 0;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
xfs_attr_flags(
|
||||
static inline enum xfs_attr_update
|
||||
xfs_xattr_flags(
|
||||
u32 ioc_flags)
|
||||
{
|
||||
if (ioc_flags & XFS_IOC_ATTR_CREATE)
|
||||
return XATTR_CREATE;
|
||||
return XFS_ATTRUPDATE_CREATE;
|
||||
if (ioc_flags & XFS_IOC_ATTR_REPLACE)
|
||||
return XATTR_REPLACE;
|
||||
return 0;
|
||||
return XFS_ATTRUPDATE_REPLACE;
|
||||
return XFS_ATTRUPDATE_UPSERTR;
|
||||
}
|
||||
|
||||
int
|
||||
@ -476,7 +476,6 @@ xfs_attrmulti_attr_get(
|
||||
struct xfs_da_args args = {
|
||||
.dp = XFS_I(inode),
|
||||
.attr_filter = xfs_attr_filter(flags),
|
||||
.attr_flags = xfs_attr_flags(flags),
|
||||
.name = name,
|
||||
.namelen = strlen(name),
|
||||
.valuelen = *len,
|
||||
@ -510,7 +509,6 @@ xfs_attrmulti_attr_set(
|
||||
struct xfs_da_args args = {
|
||||
.dp = XFS_I(inode),
|
||||
.attr_filter = xfs_attr_filter(flags),
|
||||
.attr_flags = xfs_attr_flags(flags),
|
||||
.name = name,
|
||||
.namelen = strlen(name),
|
||||
};
|
||||
@ -528,7 +526,7 @@ xfs_attrmulti_attr_set(
|
||||
args.valuelen = len;
|
||||
}
|
||||
|
||||
error = xfs_attr_change(&args);
|
||||
error = xfs_attr_change(&args, xfs_xattr_flags(flags));
|
||||
if (!error && (flags & XFS_IOC_ATTR_ROOT))
|
||||
xfs_forget_acl(inode, name);
|
||||
kfree(args.value);
|
||||
|
@ -63,7 +63,7 @@ xfs_initxattrs(
|
||||
.value = xattr->value,
|
||||
.valuelen = xattr->value_len,
|
||||
};
|
||||
error = xfs_attr_change(&args);
|
||||
error = xfs_attr_change(&args, XFS_ATTRUPDATE_UPSERTR);
|
||||
if (error < 0)
|
||||
break;
|
||||
}
|
||||
|
@ -1999,7 +1999,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
|
||||
__field(int, valuelen)
|
||||
__field(xfs_dahash_t, hashval)
|
||||
__field(unsigned int, attr_filter)
|
||||
__field(unsigned int, attr_flags)
|
||||
__field(uint32_t, op_flags)
|
||||
),
|
||||
TP_fast_assign(
|
||||
@ -2011,11 +2010,10 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
|
||||
__entry->valuelen = args->valuelen;
|
||||
__entry->hashval = args->hashval;
|
||||
__entry->attr_filter = args->attr_filter;
|
||||
__entry->attr_flags = args->attr_flags;
|
||||
__entry->op_flags = args->op_flags;
|
||||
),
|
||||
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),
|
||||
__entry->ino,
|
||||
__entry->namelen,
|
||||
@ -2025,9 +2023,6 @@ DECLARE_EVENT_CLASS(xfs_attr_class,
|
||||
__entry->hashval,
|
||||
__print_flags(__entry->attr_filter, "|",
|
||||
XFS_ATTR_FILTER_FLAGS),
|
||||
__print_flags(__entry->attr_flags, "|",
|
||||
{ XATTR_CREATE, "CREATE" },
|
||||
{ XATTR_REPLACE, "REPLACE" }),
|
||||
__print_flags(__entry->op_flags, "|", XFS_DA_OP_FLAGS))
|
||||
)
|
||||
|
||||
|
@ -73,7 +73,8 @@ xfs_attr_want_log_assist(
|
||||
*/
|
||||
int
|
||||
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;
|
||||
int error;
|
||||
@ -88,7 +89,7 @@ xfs_attr_change(
|
||||
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,
|
||||
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
|
||||
xfs_xattr_set(const struct xattr_handler *handler,
|
||||
struct mnt_idmap *idmap, struct dentry *unused,
|
||||
@ -124,7 +136,6 @@ xfs_xattr_set(const struct xattr_handler *handler,
|
||||
struct xfs_da_args args = {
|
||||
.dp = XFS_I(inode),
|
||||
.attr_filter = handler->flags,
|
||||
.attr_flags = flags,
|
||||
.name = name,
|
||||
.namelen = strlen(name),
|
||||
.value = (void *)value,
|
||||
@ -132,7 +143,7 @@ xfs_xattr_set(const struct xattr_handler *handler,
|
||||
};
|
||||
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))
|
||||
xfs_forget_acl(inode, name);
|
||||
return error;
|
||||
|
@ -6,7 +6,8 @@
|
||||
#ifndef __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[];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user