Merge tag 'for-linus-4.14-ofs2' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Sep 2017 19:16:18 +0000 (12:16 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 15 Sep 2017 19:16:18 +0000 (12:16 -0700)
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

Documentation/filesystems/orangefs.txt
fs/orangefs/acl.c
fs/orangefs/devorangefs-req.c
fs/orangefs/file.c
fs/orangefs/orangefs-bufmap.c
fs/orangefs/orangefs-debugfs.c
fs/orangefs/orangefs-mod.c
fs/orangefs/super.c
fs/orangefs/xattr.c

index 1dfdec7909464650acd7786db4368e03223c0765..e2818b60a5c21739d65588cdcac350af0809e794 100644 (file)
@@ -45,14 +45,11 @@ upstream version of the kernel client.
 BUILDING THE USERSPACE FILESYSTEM ON A SINGLE SERVER
 ====================================================
 
-When Orangefs is upstream, "--with-kernel" shouldn't be needed, but
-until then the path to where the kernel with the Orangefs kernel client
-patch was built is needed to ensure that pvfs2-client-core (the bridge
-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.
+You can omit --prefix if you don't care that things are sprinkled around in
+/usr/local. As of version 2.9.6, Orangefs uses Berkeley DB by default, we
+will probably be changing the default to lmdb soon.
 
-./configure --prefix=/opt/ofs --with-kernel=/path/to/orangefs/kernel
+./configure --prefix=/opt/ofs --with-db-backend=lmdb
 
 make
 
@@ -82,9 +79,6 @@ prove things are working with:
 
 /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:
 /opt/osf/sbin/pvfs2-client -p /opt/osf/sbin/pvfs2-client-core
 
index 7a3754488312c650b3003f5cb23a06bb17a53aeb..9108ef433e6d7b09721360a4dc3c1e7f4f2caf3b 100644 (file)
@@ -35,7 +35,7 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
         * I don't do that for now.
         */
        value = kmalloc(ORANGEFS_MAX_XATTR_VALUELEN, GFP_KERNEL);
-       if (value == NULL)
+       if (!value)
                return ERR_PTR(-ENOMEM);
 
        gossip_debug(GOSSIP_ACL_DEBUG,
@@ -61,9 +61,9 @@ struct posix_acl *orangefs_get_acl(struct inode *inode, int type)
        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;
        void *value = NULL;
        size_t size = 0;
@@ -72,22 +72,6 @@ int orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
        switch (type) {
        case ACL_TYPE_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;
        case ACL_TYPE_DEFAULT:
                name = XATTR_NAME_POSIX_ACL_DEFAULT;
@@ -132,6 +116,42 @@ out:
        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)
 {
        struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
@@ -146,13 +166,14 @@ int orangefs_init_acl(struct inode *inode, struct inode *dir)
                return error;
 
        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);
        }
 
        if (acl) {
                if (!error)
-                       error = orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
+                       error = __orangefs_set_acl(inode, acl, ACL_TYPE_ACCESS);
                posix_acl_release(acl);
        }
 
index c19f0787c9c65bddfc8b82ca7fad2f88549f2f91..2826859bdc2cb12149c1eed219ec65a1f01ad5d9 100644 (file)
@@ -461,13 +461,10 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
        if (op->downcall.type != ORANGEFS_VFS_OP_READDIR)
                goto wakeup;
 
-       op->downcall.trailer_buf =
-               vmalloc(op->downcall.trailer_size);
-       if (op->downcall.trailer_buf == NULL) {
-               gossip_err("%s: failed trailer vmalloc.\n",
-                          __func__);
+       op->downcall.trailer_buf = vmalloc(op->downcall.trailer_size);
+       if (!op->downcall.trailer_buf)
                goto Enomem;
-       }
+
        memset(op->downcall.trailer_buf, 0, op->downcall.trailer_size);
        if (!copy_from_iter_full(op->downcall.trailer_buf,
                                 op->downcall.trailer_size, iter)) {
index 28f38d813ad23f69f24900a4e8bd6ee75e57659f..336ecbf8c2683a80b5a8a7b96a7fabe1e6a012b5 100644 (file)
@@ -646,14 +646,11 @@ static int orangefs_fsync(struct file *file,
                       loff_t end,
                       int datasync)
 {
-       int ret = -EINVAL;
+       int ret;
        struct orangefs_inode_s *orangefs_inode =
                ORANGEFS_I(file_inode(file));
        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);
        if (!new_op)
                return -ENOMEM;
index 038d67545d9f07c2a7a60db70eac368660f24f72..7ef473f3d64286d8d9e32ddf636bc955bee27b31 100644 (file)
@@ -244,20 +244,14 @@ orangefs_bufmap_alloc(struct ORANGEFS_dev_map_desc *user_desc)
 
        bufmap->buffer_index_array =
                kzalloc(DIV_ROUND_UP(bufmap->desc_count, BITS_PER_LONG), GFP_KERNEL);
-       if (!bufmap->buffer_index_array) {
-               gossip_err("orangefs: could not allocate %d buffer indices\n",
-                               bufmap->desc_count);
+       if (!bufmap->buffer_index_array)
                goto out_free_bufmap;
-       }
 
        bufmap->desc_array =
                kcalloc(bufmap->desc_count, sizeof(struct orangefs_bufmap_desc),
                        GFP_KERNEL);
-       if (!bufmap->desc_array) {
-               gossip_err("orangefs: could not allocate %d descriptors\n",
-                               bufmap->desc_count);
+       if (!bufmap->desc_array)
                goto out_free_index_array;
-       }
 
        bufmap->page_count = bufmap->total_size / PAGE_SIZE;
 
index 716ed337f1663ddfaf0729c5d8275b0366308f19..5f59917fd631ca8ed3952bd02ac86d4b2a0de8fb 100644 (file)
@@ -571,11 +571,8 @@ static int orangefs_prepare_cdm_array(char *debug_array_string)
                goto out;
        }
 
-       cdm_array =
-               kzalloc(cdm_element_count * sizeof(struct client_debug_mask),
-                       GFP_KERNEL);
+       cdm_array = kcalloc(cdm_element_count, sizeof(*cdm_array), GFP_KERNEL);
        if (!cdm_array) {
-               pr_info("malloc failed for cdm_array!\n");
                rc = -ENOMEM;
                goto out;
        }
index c1b5174cb5a9fd5fa0963c22478f1457503e6657..85ef87245a872e51de68a6ae84df88a1416ef3a3 100644 (file)
@@ -98,7 +98,6 @@ static int __init orangefs_init(void)
        orangefs_htable_ops_in_progress =
            kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
        if (!orangefs_htable_ops_in_progress) {
-               gossip_err("Failed to initialize op hashtable");
                ret = -ENOMEM;
                goto cleanup_inode;
        }
index 5a1bed6c8c6ae5b19eea666343347422b3f0dbbb..47f3fb9cbec405855289679272405a8302575919 100644 (file)
@@ -107,10 +107,8 @@ static struct inode *orangefs_alloc_inode(struct super_block *sb)
        struct orangefs_inode_s *orangefs_inode;
 
        orangefs_inode = kmem_cache_alloc(orangefs_inode_cache, GFP_KERNEL);
-       if (orangefs_inode == NULL) {
-               gossip_err("Failed to allocate orangefs_inode\n");
+       if (!orangefs_inode)
                return NULL;
-       }
 
        /*
         * We want to clear everything except for rw_semaphore and the
index 237c9c04dc3b49ffcaae3de63a752dbb4891fd0c..81ac88bb91ff9fc6d0d77dc555b8142c86a8040d 100644 (file)
@@ -76,7 +76,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
 
-       if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
+       if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
                return -EINVAL;
 
        fsuid = from_kuid(&init_user_ns, current_fsuid());
@@ -169,7 +169,7 @@ static int orangefs_inode_removexattr(struct inode *inode, const char *name,
        struct orangefs_kernel_op_s *new_op = NULL;
        int ret = -ENOMEM;
 
-       if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
+       if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
                return -EINVAL;
 
        down_write(&orangefs_inode->xattr_sem);
@@ -233,13 +233,13 @@ int orangefs_inode_setxattr(struct inode *inode, const char *name,
 
        if (size > ORANGEFS_MAX_XATTR_VALUELEN)
                return -EINVAL;
-       if (strlen(name) > ORANGEFS_MAX_XATTR_NAMELEN)
+       if (strlen(name) >= ORANGEFS_MAX_XATTR_NAMELEN)
                return -EINVAL;
 
        internal_flag = convert_to_internal_xattr_flags(flags);
 
        /* This is equivalent to a removexattr */
-       if (size == 0 && value == NULL) {
+       if (size == 0 && !value) {
                gossip_debug(GOSSIP_XATTR_DEBUG,
                             "removing xattr (%s)\n",
                             name);
@@ -311,7 +311,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
        int i = 0;
        int returned_count = 0;
 
-       if (size > 0 && buffer == NULL) {
+       if (size > 0 && !buffer) {
                gossip_err("%s: bogus NULL pointers\n", __func__);
                return -EINVAL;
        }
@@ -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 */
        .get = orangefs_xattr_get_default,
        .set = orangefs_xattr_set_default,