orangefs: Remove useless xattr prefix arguments

Mike,

On Fri, Jun 3, 2016 at 9:44 PM, Mike Marshall <hubcap@omnibond.com> wrote:
> We use the return value in this one line you changed, our userspace code gets
> ill when we send it (-ENOMEM +1) as a key length...

ah, my mistake.  Here's a fixed version.

Thanks,
Andreas

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
This commit is contained in:
Andreas Gruenbacher 2016-06-04 11:02:33 +02:00 committed by Mike Marshall
parent 2ce8272a10
commit d373a712c1
4 changed files with 30 additions and 66 deletions

View File

@ -43,11 +43,8 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
get_khandle_from_ino(inode), get_khandle_from_ino(inode),
key, key,
type); type);
ret = orangefs_inode_getxattr(inode, ret = orangefs_inode_getxattr(inode, key, value,
"", ORANGEFS_MAX_XATTR_VALUELEN);
key,
value,
ORANGEFS_MAX_XATTR_VALUELEN);
/* if the key exists, convert it to an in-memory rep */ /* if the key exists, convert it to an in-memory rep */
if (ret > 0) { if (ret > 0) {
acl = posix_acl_from_xattr(&init_user_ns, value, ret); acl = posix_acl_from_xattr(&init_user_ns, value, ret);
@ -131,7 +128,7 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
* will xlate to a removexattr. However, we don't want removexattr * will xlate to a removexattr. However, we don't want removexattr
* complain if attributes does not exist. * complain if attributes does not exist.
*/ */
error = orangefs_inode_setxattr(inode, "", name, value, size, 0); error = orangefs_inode_setxattr(inode, name, value, size, 0);
out: out:
kfree(value); kfree(value);

View File

@ -516,7 +516,6 @@ static long orangefs_ioctl(struct file *file, unsigned int cmd, unsigned long ar
if (cmd == FS_IOC_GETFLAGS) { if (cmd == FS_IOC_GETFLAGS) {
val = 0; val = 0;
ret = orangefs_inode_getxattr(file_inode(file), ret = orangefs_inode_getxattr(file_inode(file),
"",
"user.pvfs2.meta_hint", "user.pvfs2.meta_hint",
&val, sizeof(val)); &val, sizeof(val));
if (ret < 0 && ret != -ENODATA) if (ret < 0 && ret != -ENODATA)
@ -549,7 +548,6 @@ static long orangefs_ioctl(struct file *file, unsigned int cmd, unsigned long ar
"orangefs_ioctl: FS_IOC_SETFLAGS: %llu\n", "orangefs_ioctl: FS_IOC_SETFLAGS: %llu\n",
(unsigned long long)val); (unsigned long long)val);
ret = orangefs_inode_setxattr(file_inode(file), ret = orangefs_inode_setxattr(file_inode(file),
"",
"user.pvfs2.meta_hint", "user.pvfs2.meta_hint",
&val, sizeof(val), 0); &val, sizeof(val), 0);
} }

View File

@ -517,13 +517,11 @@ __s32 fsid_of_op(struct orangefs_kernel_op_s *op);
int orangefs_flush_inode(struct inode *inode); int orangefs_flush_inode(struct inode *inode);
ssize_t orangefs_inode_getxattr(struct inode *inode, ssize_t orangefs_inode_getxattr(struct inode *inode,
const char *prefix,
const char *name, const char *name,
void *buffer, void *buffer,
size_t size); size_t size);
int orangefs_inode_setxattr(struct inode *inode, int orangefs_inode_setxattr(struct inode *inode,
const char *prefix,
const char *name, const char *name,
const void *value, const void *value,
size_t size, size_t size,

View File

@ -59,8 +59,8 @@ static inline int convert_to_internal_xattr_flags(int setxattr_flags)
* unless the key does not exist for the file and/or if * unless the key does not exist for the file and/or if
* there were errors in fetching the attribute value. * there were errors in fetching the attribute value.
*/ */
ssize_t orangefs_inode_getxattr(struct inode *inode, const char *prefix, ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
const char *name, void *buffer, size_t size) void *buffer, size_t size)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
struct orangefs_kernel_op_s *new_op = NULL; struct orangefs_kernel_op_s *new_op = NULL;
@ -70,12 +70,12 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *prefix,
int fsgid; int fsgid;
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
"%s: prefix %s name %s, buffer_size %zd\n", "%s: name %s, buffer_size %zd\n",
__func__, prefix, name, size); __func__, name, size);
if ((strlen(name) + strlen(prefix)) >= ORANGEFS_MAX_XATTR_NAMELEN) { if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) {
gossip_err("Invalid key length (%d)\n", gossip_err("Invalid key length (%d)\n",
(int)(strlen(name) + strlen(prefix))); (int)strlen(name));
return -EINVAL; return -EINVAL;
} }
@ -97,15 +97,14 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *prefix,
goto out_unlock; goto out_unlock;
new_op->upcall.req.getxattr.refn = orangefs_inode->refn; new_op->upcall.req.getxattr.refn = orangefs_inode->refn;
ret = snprintf((char *)new_op->upcall.req.getxattr.key, strcpy(new_op->upcall.req.getxattr.key, name);
ORANGEFS_MAX_XATTR_NAMELEN, "%s%s", prefix, name);
/* /*
* NOTE: Although keys are meant to be NULL terminated textual * NOTE: Although keys are meant to be NULL terminated textual
* strings, I am going to explicitly pass the length just in case * strings, I am going to explicitly pass the length just in case
* we change this later on... * we change this later on...
*/ */
new_op->upcall.req.getxattr.key_sz = ret + 1; new_op->upcall.req.getxattr.key_sz = strlen(name) + 1;
ret = service_operation(new_op, "orangefs_inode_getxattr", ret = service_operation(new_op, "orangefs_inode_getxattr",
get_interruptible_flag(inode)); get_interruptible_flag(inode));
@ -163,10 +162,8 @@ out_unlock:
return ret; return ret;
} }
static int orangefs_inode_removexattr(struct inode *inode, static int orangefs_inode_removexattr(struct inode *inode, const char *name,
const char *prefix, int flags)
const char *name,
int flags)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
struct orangefs_kernel_op_s *new_op = NULL; struct orangefs_kernel_op_s *new_op = NULL;
@ -183,12 +180,8 @@ static int orangefs_inode_removexattr(struct inode *inode,
* textual strings, I am going to explicitly pass the * textual strings, I am going to explicitly pass the
* length just in case we change this later on... * length just in case we change this later on...
*/ */
ret = snprintf((char *)new_op->upcall.req.removexattr.key, strcpy(new_op->upcall.req.removexattr.key, name);
ORANGEFS_MAX_XATTR_NAMELEN, new_op->upcall.req.removexattr.key_sz = strlen(name) + 1;
"%s%s",
(prefix ? prefix : ""),
name);
new_op->upcall.req.removexattr.key_sz = ret + 1;
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
"orangefs_inode_removexattr: key %s, key_sz %d\n", "orangefs_inode_removexattr: key %s, key_sz %d\n",
@ -223,8 +216,8 @@ out_unlock:
* Returns a -ve number on error and 0 on success. Key is text, but value * Returns a -ve number on error and 0 on success. Key is text, but value
* can be binary! * can be binary!
*/ */
int orangefs_inode_setxattr(struct inode *inode, const char *prefix, int orangefs_inode_setxattr(struct inode *inode, const char *name,
const char *name, const void *value, size_t size, int flags) const void *value, size_t size, int flags)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
struct orangefs_kernel_op_s *new_op; struct orangefs_kernel_op_s *new_op;
@ -232,8 +225,8 @@ int orangefs_inode_setxattr(struct inode *inode, const char *prefix,
int ret = -ENOMEM; int ret = -ENOMEM;
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
"%s: prefix %s, name %s, buffer_size %zd\n", "%s: name %s, buffer_size %zd\n",
__func__, prefix, name, size); __func__, name, size);
if (size >= ORANGEFS_MAX_XATTR_VALUELEN || if (size >= ORANGEFS_MAX_XATTR_VALUELEN ||
flags < 0) { flags < 0) {
@ -245,29 +238,19 @@ int orangefs_inode_setxattr(struct inode *inode, const char *prefix,
internal_flag = convert_to_internal_xattr_flags(flags); internal_flag = convert_to_internal_xattr_flags(flags);
if (prefix) { if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) {
if (strlen(name) + strlen(prefix) >= ORANGEFS_MAX_XATTR_NAMELEN) { gossip_err
gossip_err ("orangefs_inode_setxattr: bogus key size (%d)\n",
("orangefs_inode_setxattr: bogus key size (%d)\n", (int)(strlen(name)));
(int)(strlen(name) + strlen(prefix))); return -EINVAL;
return -EINVAL;
}
} else {
if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN) {
gossip_err
("orangefs_inode_setxattr: bogus key size (%d)\n",
(int)(strlen(name)));
return -EINVAL;
}
} }
/* This is equivalent to a removexattr */ /* This is equivalent to a removexattr */
if (size == 0 && value == NULL) { if (size == 0 && value == NULL) {
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
"removing xattr (%s%s)\n", "removing xattr (%s)\n",
prefix,
name); name);
return orangefs_inode_removexattr(inode, prefix, name, flags); return orangefs_inode_removexattr(inode, name, flags);
} }
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
@ -288,11 +271,8 @@ int orangefs_inode_setxattr(struct inode *inode, const char *prefix,
* strings, I am going to explicitly pass the length just in * strings, I am going to explicitly pass the length just in
* case we change this later on... * case we change this later on...
*/ */
ret = snprintf((char *)new_op->upcall.req.setxattr.keyval.key, strcpy(new_op->upcall.req.setxattr.keyval.key, name);
ORANGEFS_MAX_XATTR_NAMELEN, new_op->upcall.req.setxattr.keyval.key_sz = strlen(name) + 1;
"%s%s",
prefix, name);
new_op->upcall.req.setxattr.keyval.key_sz = ret + 1;
memcpy(new_op->upcall.req.setxattr.keyval.val, value, size); memcpy(new_op->upcall.req.setxattr.keyval.val, value, size);
new_op->upcall.req.setxattr.keyval.val_sz = size; new_op->upcall.req.setxattr.keyval.val_sz = size;
@ -455,12 +435,7 @@ static int orangefs_xattr_set_default(const struct xattr_handler *handler,
size_t size, size_t size,
int flags) int flags)
{ {
return orangefs_inode_setxattr(inode, return orangefs_inode_setxattr(inode, name, buffer, size, flags);
"",
name,
buffer,
size,
flags);
} }
static int orangefs_xattr_get_default(const struct xattr_handler *handler, static int orangefs_xattr_get_default(const struct xattr_handler *handler,
@ -470,11 +445,7 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler,
void *buffer, void *buffer,
size_t size) size_t size)
{ {
return orangefs_inode_getxattr(inode, return orangefs_inode_getxattr(inode, name, buffer, size);
"",
name,
buffer,
size);
} }