Merge tag 'for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Feb 2018 20:20:41 +0000 (12:20 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 8 Feb 2018 20:20:41 +0000 (12:20 -0800)
Pull orangefs updates from Mike Marshall:
 "Mostly cleanups, but three bug fixes:

   - don't pass garbage return codes back up the call chain (Mike
     Marshall)

   - fix stale inode test (Martin Brandenburg)

   - fix off-by-one errors (Xiongfeng Wang)

  Also add Martin as a reviewer in the Maintainers file"

* tag 'for-linus-4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux:
  orangefs: reverse sense of is-inode-stale test in d_revalidate
  orangefs: simplify orangefs_inode_is_stale
  Orangefs: don't propogate whacky error codes
  orangefs: use correct string length
  orangefs: make orangefs_make_bad_inode static
  orangefs: remove ORANGEFS_KERNEL_DEBUG
  orangefs: remove gossip_ldebug and gossip_lerr
  orangefs: make orangefs_client_debug_init static
  MAINTAINERS: update orangefs list and add myself as reviewer

MAINTAINERS
fs/orangefs/dcache.c
fs/orangefs/namei.c
fs/orangefs/orangefs-debugfs.c
fs/orangefs/orangefs-debugfs.h
fs/orangefs/orangefs-kernel.h
fs/orangefs/orangefs-utils.c
fs/orangefs/protocol.h
fs/orangefs/super.c

index 4c7a2fdc9b34314a863c77e9fc1fefbf0a626d03..e6c26cb47d02d4f206b80054a2c4cccc519e32bd 100644 (file)
@@ -10331,7 +10331,8 @@ F:      fs/ocfs2/
 
 ORANGEFS FILESYSTEM
 M:     Mike Marshall <hubcap@omnibond.com>
-L:     pvfs2-developers@beowulf-underground.org (subscribers-only)
+R:     Martin Brandenburg <martin@omnibond.com>
+L:     devel@lists.orangefs.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux.git
 S:     Supported
 F:     fs/orangefs/
index ae782df5c063e460918b149136dd396ad49d51b1..fe484cf93e5cd50e749091e2c46cb22f63f3c346 100644 (file)
@@ -33,7 +33,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
        new_op->upcall.req.lookup.parent_refn = parent->refn;
        strncpy(new_op->upcall.req.lookup.d_name,
                dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
 
        gossip_debug(GOSSIP_DCACHE_DEBUG,
                     "%s:%s:%d interrupt flag [%d]\n",
@@ -118,8 +118,12 @@ static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags)
                return 0;
 
        /* We do not need to continue with negative dentries. */
-       if (!dentry->d_inode)
-               goto out;
+       if (!dentry->d_inode) {
+               gossip_debug(GOSSIP_DCACHE_DEBUG,
+                   "%s: negative dentry or positive dentry and inode valid.\n",
+                   __func__);
+               return 1;
+       }
 
        /* Now we must perform a getattr to validate the inode contents. */
 
@@ -129,14 +133,7 @@ static int orangefs_d_revalidate(struct dentry *dentry, unsigned int flags)
                    __FILE__, __func__, __LINE__);
                return 0;
        }
-       if (ret == 0)
-               return 0;
-
-out:
-       gossip_debug(GOSSIP_DCACHE_DEBUG,
-           "%s: negative dentry or positive dentry and inode valid.\n",
-           __func__);
-       return 1;
+       return !ret;
 }
 
 const struct dentry_operations orangefs_dentry_operations = {
index c98bba2dbc94c3547782f7f485bbdd4793d354f4..6e3134e6d98a51c14a7c170ec6b98fdd7b78ff8e 100644 (file)
@@ -41,7 +41,7 @@ static int orangefs_create(struct inode *dir,
                               ORANGEFS_TYPE_METAFILE, mode);
 
        strncpy(new_op->upcall.req.create.d_name,
-               dentry->d_name.name, ORANGEFS_NAME_MAX);
+               dentry->d_name.name, ORANGEFS_NAME_MAX - 1);
 
        ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
 
@@ -142,7 +142,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
        new_op->upcall.req.lookup.parent_refn = parent->refn;
 
        strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
 
        gossip_debug(GOSSIP_NAME_DEBUG,
                     "%s: doing lookup on %s under %pU,%d\n",
@@ -244,7 +244,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
 
        new_op->upcall.req.remove.parent_refn = parent->refn;
        strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
 
        ret = service_operation(new_op, "orangefs_unlink",
                                get_interruptible_flag(inode));
@@ -300,8 +300,8 @@ static int orangefs_symlink(struct inode *dir,
 
        strncpy(new_op->upcall.req.sym.entry_name,
                dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
-       strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
+       strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX - 1);
 
        ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
 
@@ -372,7 +372,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
                              ORANGEFS_TYPE_DIRECTORY, mode);
 
        strncpy(new_op->upcall.req.mkdir.d_name,
-               dentry->d_name.name, ORANGEFS_NAME_MAX);
+               dentry->d_name.name, ORANGEFS_NAME_MAX - 1);
 
        ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
 
@@ -453,10 +453,10 @@ static int orangefs_rename(struct inode *old_dir,
 
        strncpy(new_op->upcall.req.rename.d_old_name,
                old_dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
        strncpy(new_op->upcall.req.rename.d_new_name,
                new_dentry->d_name.name,
-               ORANGEFS_NAME_MAX);
+               ORANGEFS_NAME_MAX - 1);
 
        ret = service_operation(new_op,
                                "orangefs_rename",
index 1c59dff530dee5d10eadcb671798367ee40e173b..6e35f2f3c897b5da12ae115ef7642de3e0030b57 100644 (file)
@@ -328,7 +328,7 @@ static int help_show(struct seq_file *m, void *v)
 /*
  * initialize the client-debug file.
  */
-int orangefs_client_debug_init(void)
+static int orangefs_client_debug_init(void)
 {
 
        int rc = -ENOMEM;
@@ -1056,7 +1056,7 @@ int orangefs_debugfs_new_debug(void __user *arg)
                        client_debug_string,
                        llu(mask_info.mask_value));
        } else {
-               gossip_lerr("Invalid mask type....\n");
+               gossip_err("Invalid mask type....\n");
                return -EINVAL;
        }
 
index b5fd9cd4960f413bd234aaa59ab78fa95dd709b0..51147f9ce3d6a185acf919d8cc01b805dbca5460 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 int orangefs_debugfs_init(int);
 void orangefs_debugfs_cleanup(void);
-int orangefs_client_debug_init(void);
 int orangefs_prepare_debugfs_help_string(int);
 int orangefs_debugfs_new_client_mask(void __user *);
 int orangefs_debugfs_new_client_string(void __user *);
index 2595453fe7370ab078da275e9da48cdd18fa0e0f..eebbaece85ef735b231dbe835bc414669e204749 100644 (file)
 
 #include "orangefs-dev-proto.h"
 
-#ifdef ORANGEFS_KERNEL_DEBUG
-#define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS       10
-#else
 #define ORANGEFS_DEFAULT_OP_TIMEOUT_SECS       20
-#endif
 
 #define ORANGEFS_BUFMAP_WAIT_TIMEOUT_SECS   30
 
@@ -104,11 +100,11 @@ enum orangefs_vfs_op_states {
  * orangefs kernel memory related flags
  */
 
-#if ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB))
+#if (defined CONFIG_DEBUG_SLAB)
 #define ORANGEFS_CACHE_CREATE_FLAGS SLAB_RED_ZONE
 #else
 #define ORANGEFS_CACHE_CREATE_FLAGS 0
-#endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
+#endif
 
 extern int orangefs_init_acl(struct inode *inode, struct inode *dir);
 extern const struct xattr_handler *orangefs_xattr_handlers[];
@@ -471,8 +467,6 @@ int orangefs_inode_check_changed(struct inode *inode);
 
 int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr);
 
-void orangefs_make_bad_inode(struct inode *inode);
-
 int orangefs_unmount_sb(struct super_block *sb);
 
 bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
index 97fe93129f38872eb40e7828bf6824d3b348dfae..ea6256d136d1cde21b2c1ce732df14a56de84300 100644 (file)
@@ -230,25 +230,42 @@ static int orangefs_inode_type(enum orangefs_ds_type objtype)
                return -1;
 }
 
-static int orangefs_inode_is_stale(struct inode *inode, int new,
+static void orangefs_make_bad_inode(struct inode *inode)
+{
+       if (is_root_handle(inode)) {
+               /*
+                * if this occurs, the pvfs2-client-core was killed but we
+                * can't afford to lose the inode operations and such
+                * associated with the root handle in any case.
+                */
+               gossip_debug(GOSSIP_UTILS_DEBUG,
+                            "*** NOT making bad root inode %pU\n",
+                            get_khandle_from_ino(inode));
+       } else {
+               gossip_debug(GOSSIP_UTILS_DEBUG,
+                            "*** making bad inode %pU\n",
+                            get_khandle_from_ino(inode));
+               make_bad_inode(inode);
+       }
+}
+
+static int orangefs_inode_is_stale(struct inode *inode,
     struct ORANGEFS_sys_attr_s *attrs, char *link_target)
 {
        struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
        int type = orangefs_inode_type(attrs->objtype);
-       if (!new) {
-               /*
-                * If the inode type or symlink target have changed then this
-                * inode is stale.
-                */
-               if (type == -1 || !(inode->i_mode & type)) {
-                       orangefs_make_bad_inode(inode);
-                       return 1;
-               }
-               if (type == S_IFLNK && strncmp(orangefs_inode->link_target,
-                   link_target, ORANGEFS_NAME_MAX)) {
-                       orangefs_make_bad_inode(inode);
-                       return 1;
-               }
+       /*
+        * If the inode type or symlink target have changed then this
+        * inode is stale.
+        */
+       if (type == -1 || !(inode->i_mode & type)) {
+               orangefs_make_bad_inode(inode);
+               return 1;
+       }
+       if (type == S_IFLNK && strncmp(orangefs_inode->link_target,
+           link_target, ORANGEFS_NAME_MAX)) {
+               orangefs_make_bad_inode(inode);
+               return 1;
        }
        return 0;
 }
@@ -294,16 +311,18 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
        if (ret != 0)
                goto out;
 
-       type = orangefs_inode_type(new_op->
-           downcall.resp.getattr.attributes.objtype);
-       ret = orangefs_inode_is_stale(inode, new,
-           &new_op->downcall.resp.getattr.attributes,
-           new_op->downcall.resp.getattr.link_target);
-       if (ret) {
-               ret = -ESTALE;
-               goto out;
+       if (!new) {
+               ret = orangefs_inode_is_stale(inode,
+                   &new_op->downcall.resp.getattr.attributes,
+                   new_op->downcall.resp.getattr.link_target);
+               if (ret) {
+                       ret = -ESTALE;
+                       goto out;
+               }
        }
 
+       type = orangefs_inode_type(new_op->
+           downcall.resp.getattr.attributes.objtype);
        switch (type) {
        case S_IFREG:
                inode->i_flags = orangefs_inode_flags(&new_op->
@@ -348,6 +367,12 @@ int orangefs_inode_getattr(struct inode *inode, int new, int bypass,
                        inode->i_link = orangefs_inode->link_target;
                }
                break;
+       /* i.e. -1 */
+       default:
+               /* XXX: ESTALE?  This is what is done if it is not new. */
+               orangefs_make_bad_inode(inode);
+               ret = -ESTALE;
+               goto out;
        }
 
        inode->i_uid = make_kuid(&init_user_ns, new_op->
@@ -401,7 +426,7 @@ int orangefs_inode_check_changed(struct inode *inode)
        if (ret != 0)
                goto out;
 
-       ret = orangefs_inode_is_stale(inode, 0,
+       ret = orangefs_inode_is_stale(inode,
            &new_op->downcall.resp.getattr.attributes,
            new_op->downcall.resp.getattr.link_target);
 out:
@@ -444,25 +469,6 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr)
        return ret;
 }
 
-void orangefs_make_bad_inode(struct inode *inode)
-{
-       if (is_root_handle(inode)) {
-               /*
-                * if this occurs, the pvfs2-client-core was killed but we
-                * can't afford to lose the inode operations and such
-                * associated with the root handle in any case.
-                */
-               gossip_debug(GOSSIP_UTILS_DEBUG,
-                            "*** NOT making bad root inode %pU\n",
-                            get_khandle_from_ino(inode));
-       } else {
-               gossip_debug(GOSSIP_UTILS_DEBUG,
-                            "*** making bad inode %pU\n",
-                            get_khandle_from_ino(inode));
-               make_bad_inode(inode);
-       }
-}
-
 /*
  * The following is a very dirty hack that is now a permanent part of the
  * ORANGEFS protocol. See protocol.h for more error definitions.
@@ -537,6 +543,7 @@ int orangefs_normalize_to_errno(__s32 error_code)
         */
        } else {
                gossip_err("orangefs: orangefs_normalize_to_errno: got error code which is not from ORANGEFS.\n");
+               error_code = -EINVAL;
        }
        return error_code;
 }
index e0bf5e4dce0da164ed046fc7aa3915ecef58a1e3..dc6e3e6269c3854ff0af54d7c2252ca458ff1fff 100644 (file)
@@ -395,13 +395,6 @@ struct ORANGEFS_dev_map_desc {
 
 /* gossip.h *****************************************************************/
 
-#ifdef GOSSIP_DISABLE_DEBUG
-#define gossip_debug(mask, fmt, ...)                                   \
-do {                                                                   \
-       if (0)                                                          \
-               printk(KERN_DEBUG fmt, ##__VA_ARGS__);                  \
-} while (0)
-#else
 extern __u64 orangefs_gossip_debug_mask;
 
 /* try to avoid function call overhead by checking masks in macro */
@@ -410,13 +403,5 @@ do {                                                                       \
        if (orangefs_gossip_debug_mask & (mask))                        \
                printk(KERN_DEBUG fmt, ##__VA_ARGS__);                  \
 } while (0)
-#endif /* GOSSIP_DISABLE_DEBUG */
-
-/* do file and line number printouts w/ the GNU preprocessor */
-#define gossip_ldebug(mask, fmt, ...)                                  \
-       gossip_debug(mask, "%s: " fmt, __func__, ##__VA_ARGS__)
 
 #define gossip_err pr_err
-#define gossip_lerr(fmt, ...)                                          \
-       gossip_err("%s line %d: " fmt,                                  \
-                  __FILE__, __LINE__, ##__VA_ARGS__)
index 62d49e53061ca0d23a6b03562e091667b14466b4..3ae5fdba0225b5670491b9cbfbf68be7bccf84a9 100644 (file)
@@ -335,7 +335,7 @@ static int orangefs_encode_fh(struct inode *inode,
        struct orangefs_object_kref refn;
 
        if (*max_len < len) {
-               gossip_lerr("fh buffer is too small for encoding\n");
+               gossip_err("fh buffer is too small for encoding\n");
                *max_len = len;
                type = 255;
                goto out;
@@ -383,7 +383,7 @@ static int orangefs_unmount(int id, __s32 fs_id, const char *devname)
        op->upcall.req.fs_umount.id = id;
        op->upcall.req.fs_umount.fs_id = fs_id;
        strncpy(op->upcall.req.fs_umount.orangefs_config_server,
-           devname, ORANGEFS_MAX_SERVER_ADDR_LEN);
+           devname, ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
        r = service_operation(op, "orangefs_fs_umount", 0);
        /* Not much to do about an error here. */
        if (r)
@@ -478,7 +478,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
 
        strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
                devname,
-               ORANGEFS_MAX_SERVER_ADDR_LEN);
+               ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
 
        gossip_debug(GOSSIP_SUPER_DEBUG,
                     "Attempting ORANGEFS Mount via host %s\n",
@@ -520,7 +520,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
         */
        strncpy(ORANGEFS_SB(sb)->devname,
                devname,
-               ORANGEFS_MAX_SERVER_ADDR_LEN);
+               ORANGEFS_MAX_SERVER_ADDR_LEN - 1);
 
        /* mount_pending must be cleared */
        ORANGEFS_SB(sb)->mount_pending = 0;