提交 30db202e 编写于 作者: L Linus Torvalds

Merge tag 'for-linus-4.14-ofs2' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux

Pull orangefs updates from Mike Marshall:
 "Some cleanups and a big bug fix for ACLs.

  When I was reviewing Jan Kara's ACL patch, I realized that Orangefs
  ACL code was busted, not just in the kernel module, but in the server
  as well. I've been working on the code in the server mostly, but
  here's one kernel patch, there will be more"

* tag 'for-linus-4.14-ofs2' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
  orangefs: Adjust three checks for null pointers
  orangefs: Use kcalloc() in orangefs_prepare_cdm_array()
  orangefs: Delete error messages for a failed memory allocation in five functions
  orangefs: constify xattr_handler structure
  orangefs: don't call filemap_write_and_wait from fsync
  orangefs: off by ones in xattr size checks
  orangefs: documentation clean up
  orangefs: react properly to posix_acl_update_mode's aftermath.
  orangefs: Don't clear SGID when inheriting ACLs
...@@ -45,14 +45,11 @@ upstream version of the kernel client. ...@@ -45,14 +45,11 @@ upstream version of the kernel client.
BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER
==================================================== ====================================================
When Orangefs is upstream, "--with-kernel" shouldn't be needed, but You can omit --prefix if you don't care that things are sprinkled around in
until then the path to where the kernel with the Orangefs kernel client /usr/local. As of version 2.9.6, Orangefs uses Berkeley DB by default, we
patch was built is needed to ensure that pvfs2-client-core (the bridge will probably be changing the default to lmdb soon.
between kernel space and user space) will build properly. You can omit
--prefix if you don't care that things are sprinkled around in
/usr/local.
./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel ./configure --prefix=/opt/ofs --with-db-backend=lmdb
make make
...@@ -82,9 +79,6 @@ prove things are working with: ...@@ -82,9 +79,6 @@ prove things are working with:
/opt/osf/bin/pvfs2-ls /mymountpoint /opt/osf/bin/pvfs2-ls /mymountpoint
You might not want to enforce selinux, it doesn't seem to matter by
linux 3.11...
If stuff seems to be working, turn on the client core: If stuff seems to be working, turn on the client core:
/opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core /opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
......
...@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type) ...@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
* I don't do that for now. * I don't do that for now.
*/ */
value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL); value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
if (value == NULL) if (!value)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
gossip_debug(GOSSIP_ACL_DEBUG, gossip_debug(GOSSIP_ACL_DEBUG,
...@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type) ...@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
return acl; return acl;
} }
int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) static int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl,
int type)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
int error = 0; int error = 0;
void *value = NULL; void *value = NULL;
size_t size = 0; size_t size = 0;
...@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
switch (type) { switch (type) {
case ACL_TYPE_ACCESS: case ACL_TYPE_ACCESS:
name = XATTR_NAME_POSIX_ACL_ACCESS; name = XATTR_NAME_POSIX_ACL_ACCESS;
if (acl) {
umode_t mode;
error = posix_acl_update_mode(inode, &mode, &acl);
if (error) {
gossip_err("%s: posix_acl_update_mode err: %d\n",
__func__,
error);
return error;
}
if (inode->i_mode != mode)
SetModeFlag(orangefs_inode);
inode->i_mode = mode;
mark_inode_dirty_sync(inode);
}
break; break;
case ACL_TYPE_DEFAULT: case ACL_TYPE_DEFAULT:
name = XATTR_NAME_POSIX_ACL_DEFAULT; name = XATTR_NAME_POSIX_ACL_DEFAULT;
...@@ -132,6 +116,42 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type) ...@@ -132,6 +116,42 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return error; return error;
} }
int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
int error;
struct iattr iattr;
int rc;
if (type == ACL_TYPE_ACCESS && acl) {
/*
* posix_acl_update_mode checks to see if the permissions
* described by the ACL can be encoded into the
* object's mode. If so, it sets "acl" to NULL
* and "mode" to the new desired value. It is up to
* us to propagate the new mode back to the server...
*/
error = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
if (error) {
gossip_err("%s: posix_acl_update_mode err: %d\n",
__func__,
error);
return error;
}
if (acl) {
rc = __orangefs_set_acl(inode, acl, type);
} else {
iattr.ia_valid = ATTR_MODE;
rc = orangefs_inode_setattr(inode, &iattr);
}
return rc;
} else {
return -EINVAL;
}
}
int orangefs_init_acl(struct inode *inode, struct inode *dir) int orangefs_init_acl(struct inode *inode, struct inode *dir)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
...@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir) ...@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
return error; return error;
if (default_acl) { if (default_acl) {
error = orangefs_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); error = __orangefs_set_acl(inode, default_acl,
ACL_TYPE_DEFAULT);
posix_acl_release(default_acl); posix_acl_release(default_acl);
} }
if (acl) { if (acl) {
if (!error) if (!error)
error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS); error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl); posix_acl_release(acl);
} }
......
...@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb, ...@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
if (op->downcall.type != ORANGEFS_VFS_OP_READDIR) if (op->downcall.type != ORANGEFS_VFS_OP_READDIR)
goto wakeup; goto wakeup;
op->downcall.trailer_buf = op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size);
vmalloc(op->downcall.trailer_size); if (!op->downcall.trailer_buf)
if (op->downcall.trailer_buf == NULL) {
gossip_err("%s: failed trailer vmalloc.\n",
__func__);
goto Enomem; goto Enomem;
}
memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size); memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
if (!copy_from_iter_full(op->downcall.trailer_buf, if (!copy_from_iter_full(op->downcall.trailer_buf,
op->downcall.trailer_size, iter)) { op->downcall.trailer_size, iter)) {
......
...@@ -646,14 +646,11 @@ static int orangefs_fsync(struct file *file, ...@@ -646,14 +646,11 @@ static int orangefs_fsync(struct file *file,
loff_t end, loff_t end,
int datasync) int datasync)
{ {
int ret = -EINVAL; int ret;
struct orangefs_inode_s *orangefs_inode = struct orangefs_inode_s *orangefs_inode =
ORANGEFS_I(file_inode(file)); ORANGEFS_I(file_inode(file));
struct orangefs_kernel_op_s *new_op = NULL; struct orangefs_kernel_op_s *new_op = NULL;
/* required call */
filemap_write_and_wait_range(file->f_mapping, start, end);
new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC); new_op = op_alloc(ORANGEFS_VFS_OP_FSYNC);
if (!new_op) if (!new_op)
return -ENOMEM; return -ENOMEM;
......
...@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc) ...@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
bufmap->buffer_index_array = bufmap->buffer_index_array =
kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL); kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL);
if (!bufmap->buffer_index_array) { if (!bufmap->buffer_index_array)
gossip_err("orangefs: could not allocate %d buffer indices\n",
bufmap->desc_count);
goto out_free_bufmap; goto out_free_bufmap;
}
bufmap->desc_array = bufmap->desc_array =
kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc), kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
GFP_KERNEL); GFP_KERNEL);
if (!bufmap->desc_array) { if (!bufmap->desc_array)
gossip_err("orangefs: could not allocate %d descriptors\n",
bufmap->desc_count);
goto out_free_index_array; goto out_free_index_array;
}
bufmap->page_count = bufmap->total_size / PAGE_SIZE; bufmap->page_count = bufmap->total_size / PAGE_SIZE;
......
...@@ -571,11 +571,8 @@ static int orangefs_prepare_cdm_array(char *debug_array_string) ...@@ -571,11 +571,8 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
goto out; goto out;
} }
cdm_array = cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
GFP_KERNEL);
if (!cdm_array) { if (!cdm_array) {
pr_info("malloc failed for cdm_array!\n");
rc = -ENOMEM; rc = -ENOMEM;
goto out; goto out;
} }
......
...@@ -98,7 +98,6 @@ static int __init orangefs_init(void) ...@@ -98,7 +98,6 @@ static int __init orangefs_init(void)
orangefs_htable_ops_in_progress = orangefs_htable_ops_in_progress =
kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL); kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
if (!orangefs_htable_ops_in_progress) { if (!orangefs_htable_ops_in_progress) {
gossip_err("Failed to initialize op hashtable");
ret = -ENOMEM; ret = -ENOMEM;
goto cleanup_inode; goto cleanup_inode;
} }
......
...@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb) ...@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
struct orangefs_inode_s *orangefs_inode; struct orangefs_inode_s *orangefs_inode;
orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL); orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
if (orangefs_inode == NULL) { if (!orangefs_inode)
gossip_err("Failed to allocate orangefs_inode\n");
return NULL; return NULL;
}
/* /*
* We want to clear everything except for rw_semaphore and the * We want to clear everything except for rw_semaphore and the
......
...@@ -76,7 +76,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name, ...@@ -76,7 +76,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
if (S_ISLNK(inode->i_mode)) if (S_ISLNK(inode->i_mode))
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
return -EINVAL; return -EINVAL;
fsuid = from_kuid(&init_user_ns, current_fsuid()); fsuid = from_kuid(&init_user_ns, current_fsuid());
...@@ -169,7 +169,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name, ...@@ -169,7 +169,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
struct orangefs_kernel_op_s *new_op = NULL; struct orangefs_kernel_op_s *new_op = NULL;
int ret = -ENOMEM; int ret = -ENOMEM;
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
return -EINVAL; return -EINVAL;
down_write(&orangefs_inode->xattr_sem); down_write(&orangefs_inode->xattr_sem);
...@@ -233,13 +233,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name, ...@@ -233,13 +233,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
if (size > ORANGEFS_MAX_XATTR_VALUELEN) if (size > ORANGEFS_MAX_XATTR_VALUELEN)
return -EINVAL; return -EINVAL;
if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN) if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
return -EINVAL; return -EINVAL;
internal_flag = convert_to_internal_xattr_flags(flags); internal_flag = convert_to_internal_xattr_flags(flags);
/* This is equivalent to a removexattr */ /* This is equivalent to a removexattr */
if (size == 0 && value == NULL) { if (size == 0 && !value) {
gossip_debug(GOSSIP_XATTR_DEBUG, gossip_debug(GOSSIP_XATTR_DEBUG,
"removing xattr (%s)\n", "removing xattr (%s)\n",
name); name);
...@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size) ...@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
int i = 0; int i = 0;
int returned_count = 0; int returned_count = 0;
if (size > 0 && buffer == NULL) { if (size > 0 && !buffer) {
gossip_err("%s: bogus NULL pointers\n", __func__); gossip_err("%s: bogus NULL pointers\n", __func__);
return -EINVAL; return -EINVAL;
} }
...@@ -442,7 +442,7 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler, ...@@ -442,7 +442,7 @@ static int orangefs_xattr_get_default(const struct xattr_handler *handler,
} }
static struct xattr_handler orangefs_xattr_default_handler = { static const struct xattr_handler orangefs_xattr_default_handler = {
.prefix = "", /* match any name => handlers called with full name */ .prefix = "", /* match any name => handlers called with full name */
.get = orangefs_xattr_get_default, .get = orangefs_xattr_get_default,
.set = orangefs_xattr_set_default, .set = orangefs_xattr_set_default,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册