]> Git Repo - linux.git/commitdiff
Merge tag '9p-6.3-for-linus-part1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <[email protected]>
Wed, 1 Mar 2023 16:52:49 +0000 (08:52 -0800)
committerLinus Torvalds <[email protected]>
Wed, 1 Mar 2023 16:52:49 +0000 (08:52 -0800)
Pull 9p updates from Eric Van Hensbergen:

 - some fixes and cleanup setting up for a larger set of performance
   patches I've been working on

 - a contributed fixes relating to 9p/rdma

 - some contributed fixes relating to 9p/xen

* tag '9p-6.3-for-linus-part1' of git://git.kernel.org/pub/scm/linux/kernel/git/ericvh/v9fs:
  fs/9p: fix error reporting in v9fs_dir_release
  net/9p: fix bug in client create for .L
  9p/rdma: unmap receive dma buffer in rdma_request()/post_recv()
  9p/xen: fix connection sequence
  9p/xen: fix version parsing
  fs/9p: Expand setup of writeback cache to all levels
  net/9p: Adjust maximum MSIZE to account for p9 header

1  2 
fs/9p/vfs_file.c
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
net/9p/trans_xen.c

diff --combined fs/9p/vfs_file.c
index b6ba229757818442b2a1db65692969f8421b3bc0,3b6458846a0b2bbe393385e5b60d14c944318442..44c15eb2b908b5720370d6f04575eecc05e626ed
@@@ -9,7 -9,6 +9,7 @@@
  #include <linux/module.h>
  #include <linux/errno.h>
  #include <linux/fs.h>
 +#include <linux/filelock.h>
  #include <linux/sched.h>
  #include <linux/file.h>
  #include <linux/stat.h>
@@@ -74,8 -73,7 +74,7 @@@ int v9fs_file_open(struct inode *inode
        }
  
        mutex_lock(&v9inode->v_mutex);
-       if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
-           !v9inode->writeback_fid &&
+       if ((v9ses->cache) && !v9inode->writeback_fid &&
            ((file->f_flags & O_ACCMODE) != O_RDONLY)) {
                /*
                 * clone a fid and add it to writeback_fid
                v9inode->writeback_fid = (void *) writeback_fid;
        }
        mutex_unlock(&v9inode->v_mutex);
-       if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
+ #ifdef CONFIG_9P_FSCACHE
+       if (v9ses->cache == CACHE_FSCACHE)
                fscache_use_cookie(v9fs_inode_cookie(v9inode),
                                   file->f_mode & FMODE_WRITE);
+ #endif
        v9fs_open_fid_add(inode, &fid);
        return 0;
  out_error:
diff --combined fs/9p/vfs_inode.c
index 4344e7a7865f8df3f15fde270446e6c36ba7bcd0,33e521c60e2ccbf5fc762571cc67fa6b437f118f..1d523bec0a94d03108f808b516fa793ace25f6b4
@@@ -260,7 -260,7 +260,7 @@@ int v9fs_init_inode(struct v9fs_session
  {
        int err = 0;
  
 -      inode_init_owner(&init_user_ns, inode, NULL, mode);
 +      inode_init_owner(&nop_mnt_idmap, inode, NULL, mode);
        inode->i_blocks = 0;
        inode->i_rdev = rdev;
        inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode);
@@@ -672,7 -672,7 +672,7 @@@ error
  
  /**
   * v9fs_vfs_create - VFS hook to create a regular file
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dir: The parent directory
   * @dentry: The name of file to be created
   * @mode: The UNIX file mode to set
   */
  
  static int
 -v9fs_vfs_create(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
                struct dentry *dentry, umode_t mode, bool excl)
  {
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
  
  /**
   * v9fs_vfs_mkdir - VFS mkdir hook to create a directory
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dir:  inode that is being unlinked
   * @dentry: dentry that is being unlinked
   * @mode: mode for new directory
   *
   */
  
 -static int v9fs_vfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
 +static int v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
                          struct dentry *dentry, umode_t mode)
  {
        int err;
@@@ -843,8 -843,7 +843,7 @@@ v9fs_vfs_atomic_open(struct inode *dir
        inode = d_inode(dentry);
        v9inode = V9FS_I(inode);
        mutex_lock(&v9inode->v_mutex);
-       if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
-           !v9inode->writeback_fid &&
+       if ((v9ses->cache) && !v9inode->writeback_fid &&
            ((flags & O_ACCMODE) != O_RDONLY)) {
                /*
                 * clone a fid and add it to writeback_fid
@@@ -908,7 -907,7 +907,7 @@@ int v9fs_vfs_rmdir(struct inode *i, str
  
  /**
   * v9fs_vfs_rename - VFS hook to rename an inode
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: The idmap of the mount
   * @old_dir:  old dir inode
   * @old_dentry: old dentry
   * @new_dir: new dir inode
   */
  
  int
 -v9fs_vfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
 +v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                struct dentry *old_dentry, struct inode *new_dir,
                struct dentry *new_dentry, unsigned int flags)
  {
@@@ -1018,7 -1017,7 +1017,7 @@@ error
  
  /**
   * v9fs_vfs_getattr - retrieve file metadata
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @path: Object to query
   * @stat: metadata structure to populate
   * @request_mask: Mask of STATX_xxx flags indicating the caller's interests
   */
  
  static int
 -v9fs_vfs_getattr(struct user_namespace *mnt_userns, const struct path *path,
 +v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path,
                 struct kstat *stat, u32 request_mask, unsigned int flags)
  {
        struct dentry *dentry = path->dentry;
        p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
        v9ses = v9fs_dentry2v9ses(dentry);
        if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
 -              generic_fillattr(&init_user_ns, d_inode(dentry), stat);
 +              generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
                return 0;
        }
        fid = v9fs_fid_lookup(dentry);
                return PTR_ERR(st);
  
        v9fs_stat2inode(st, d_inode(dentry), dentry->d_sb, 0);
 -      generic_fillattr(&init_user_ns, d_inode(dentry), stat);
 +      generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
  
        p9stat_free(st);
        kfree(st);
  
  /**
   * v9fs_vfs_setattr - set file metadata
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dentry: file whose metadata to set
   * @iattr: metadata assignment structure
   *
   */
  
 -static int v9fs_vfs_setattr(struct user_namespace *mnt_userns,
 +static int v9fs_vfs_setattr(struct mnt_idmap *idmap,
                            struct dentry *dentry, struct iattr *iattr)
  {
        int retval, use_dentry = 0;
        struct p9_wstat wstat;
  
        p9_debug(P9_DEBUG_VFS, "\n");
 -      retval = setattr_prepare(&init_user_ns, dentry, iattr);
 +      retval = setattr_prepare(&nop_mnt_idmap, dentry, iattr);
        if (retval)
                return retval;
  
  
        v9fs_invalidate_inode_attr(inode);
  
 -      setattr_copy(&init_user_ns, inode, iattr);
 +      setattr_copy(&nop_mnt_idmap, inode, iattr);
        mark_inode_dirty(inode);
        return 0;
  }
@@@ -1300,7 -1299,7 +1299,7 @@@ static int v9fs_vfs_mkspecial(struct in
  
  /**
   * v9fs_vfs_symlink - helper function to create symlinks
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dir: directory inode containing symlink
   * @dentry: dentry for symlink
   * @symname: symlink data
   */
  
  static int
 -v9fs_vfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
                 struct dentry *dentry, const char *symname)
  {
        p9_debug(P9_DEBUG_VFS, " %lu,%pd,%s\n",
@@@ -1356,7 -1355,7 +1355,7 @@@ v9fs_vfs_link(struct dentry *old_dentry
  
  /**
   * v9fs_vfs_mknod - create a special file
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dir: inode destination for new link
   * @dentry: dentry for file
   * @mode: mode for creation
   */
  
  static int
 -v9fs_vfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
               struct dentry *dentry, umode_t mode, dev_t rdev)
  {
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
diff --combined fs/9p/vfs_inode_dotl.c
index 3bed3eb3a0e270673289566bd4913db5079b0d1b,bff37a312e64a81ca5f3017c54a7bc7273879386..331ed60d8fcb571b5f791a05981fb6d353fc1b71
@@@ -30,7 -30,7 +30,7 @@@
  #include "acl.h"
  
  static int
 -v9fs_vfs_mknod_dotl(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
                    struct dentry *dentry, umode_t omode, dev_t rdev);
  
  /**
@@@ -211,7 -211,7 +211,7 @@@ int v9fs_open_to_dotl_flags(int flags
  
  /**
   * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: The user namespace of the mount
   * @dir: directory inode that is being created
   * @dentry:  dentry that is being deleted
   * @omode: create permissions
   *
   */
  static int
 -v9fs_vfs_create_dotl(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_create_dotl(struct mnt_idmap *idmap, struct inode *dir,
                     struct dentry *dentry, umode_t omode, bool excl)
  {
 -      return v9fs_vfs_mknod_dotl(mnt_userns, dir, dentry, omode, 0);
 +      return v9fs_vfs_mknod_dotl(idmap, dir, dentry, omode, 0);
  }
  
  static int
@@@ -316,8 -316,7 +316,7 @@@ v9fs_vfs_atomic_open_dotl(struct inode 
  
        v9inode = V9FS_I(inode);
        mutex_lock(&v9inode->v_mutex);
-       if ((v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) &&
-           !v9inode->writeback_fid &&
+       if ((v9ses->cache) && !v9inode->writeback_fid &&
            ((flags & O_ACCMODE) != O_RDONLY)) {
                /*
                 * clone a fid and add it to writeback_fid
        if (err)
                goto out;
        file->private_data = ofid;
-       if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE)
+ #ifdef CONFIG_9P_FSCACHE
+       if (v9ses->cache == CACHE_FSCACHE)
                fscache_use_cookie(v9fs_inode_cookie(v9inode),
                                   file->f_mode & FMODE_WRITE);
+ #endif
        v9fs_open_fid_add(inode, &ofid);
        file->f_mode |= FMODE_CREATED;
  out:
  
  /**
   * v9fs_vfs_mkdir_dotl - VFS mkdir hook to create a directory
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: The idmap of the mount
   * @dir:  inode that is being unlinked
   * @dentry: dentry that is being unlinked
   * @omode: mode for new directory
   *
   */
  
 -static int v9fs_vfs_mkdir_dotl(struct user_namespace *mnt_userns,
 +static int v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap,
                               struct inode *dir, struct dentry *dentry,
                               umode_t omode)
  {
@@@ -450,7 -451,7 +451,7 @@@ error
  }
  
  static int
 -v9fs_vfs_getattr_dotl(struct user_namespace *mnt_userns,
 +v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap,
                      const struct path *path, struct kstat *stat,
                      u32 request_mask, unsigned int flags)
  {
        p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry);
        v9ses = v9fs_dentry2v9ses(dentry);
        if (v9ses->cache == CACHE_LOOSE || v9ses->cache == CACHE_FSCACHE) {
 -              generic_fillattr(&init_user_ns, d_inode(dentry), stat);
 +              generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
                return 0;
        }
        fid = v9fs_fid_lookup(dentry);
                return PTR_ERR(st);
  
        v9fs_stat2inode_dotl(st, d_inode(dentry), 0);
 -      generic_fillattr(&init_user_ns, d_inode(dentry), stat);
 +      generic_fillattr(&nop_mnt_idmap, d_inode(dentry), stat);
        /* Change block size to what the server returned */
        stat->blksize = st->st_blksize;
  
@@@ -529,13 -530,13 +530,13 @@@ static int v9fs_mapped_iattr_valid(int 
  
  /**
   * v9fs_vfs_setattr_dotl - set file metadata
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: idmap of the mount
   * @dentry: file whose metadata to set
   * @iattr: metadata assignment structure
   *
   */
  
 -int v9fs_vfs_setattr_dotl(struct user_namespace *mnt_userns,
 +int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
                          struct dentry *dentry, struct iattr *iattr)
  {
        int retval, use_dentry = 0;
  
        p9_debug(P9_DEBUG_VFS, "\n");
  
 -      retval = setattr_prepare(&init_user_ns, dentry, iattr);
 +      retval = setattr_prepare(&nop_mnt_idmap, dentry, iattr);
        if (retval)
                return retval;
  
                truncate_setsize(inode, iattr->ia_size);
  
        v9fs_invalidate_inode_attr(inode);
 -      setattr_copy(&init_user_ns, inode, iattr);
 +      setattr_copy(&nop_mnt_idmap, inode, iattr);
        mark_inode_dirty(inode);
        if (iattr->ia_valid & ATTR_MODE) {
                /* We also want to update ACL when we update mode bits */
@@@ -687,7 -688,7 +688,7 @@@ v9fs_stat2inode_dotl(struct p9_stat_dot
  }
  
  static int
 -v9fs_vfs_symlink_dotl(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, const char *symname)
  {
        int err;
@@@ -817,7 -818,7 +818,7 @@@ v9fs_vfs_link_dotl(struct dentry *old_d
  
  /**
   * v9fs_vfs_mknod_dotl - create a special file
 - * @mnt_userns: The user namespace of the mount
 + * @idmap: The idmap of the mount
   * @dir: inode destination for new link
   * @dentry: dentry for file
   * @omode: mode for creation
   *
   */
  static int
 -v9fs_vfs_mknod_dotl(struct user_namespace *mnt_userns, struct inode *dir,
 +v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
                    struct dentry *dentry, umode_t omode, dev_t rdev)
  {
        int err;
diff --combined net/9p/trans_xen.c
index 82c7005ede65679bd528637ff029573a03e7776e,70aa613c4cfe49118521c7ac44f4141f561cd900..c64050e839ac6faccd7f9741654cfa74bf661836
@@@ -305,12 -305,13 +305,12 @@@ static void xen_9pfs_front_free(struct 
        kfree(priv);
  }
  
 -static int xen_9pfs_front_remove(struct xenbus_device *dev)
 +static void xen_9pfs_front_remove(struct xenbus_device *dev)
  {
        struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
  
        dev_set_drvdata(&dev->dev, NULL);
        xen_9pfs_front_free(priv);
 -      return 0;
  }
  
  static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
@@@ -372,19 -373,24 +372,24 @@@ out
        return ret;
  }
  
- static int xen_9pfs_front_probe(struct xenbus_device *dev,
-                               const struct xenbus_device_id *id)
+ static int xen_9pfs_front_init(struct xenbus_device *dev)
  {
        int ret, i;
        struct xenbus_transaction xbt;
-       struct xen_9pfs_front_priv *priv = NULL;
-       char *versions;
+       struct xen_9pfs_front_priv *priv = dev_get_drvdata(&dev->dev);
+       char *versions, *v;
        unsigned int max_rings, max_ring_order, len = 0;
  
        versions = xenbus_read(XBT_NIL, dev->otherend, "versions", &len);
        if (IS_ERR(versions))
                return PTR_ERR(versions);
-       if (strcmp(versions, "1")) {
+       for (v = versions; *v; v++) {
+               if (simple_strtoul(v, &v, 10) == 1) {
+                       v = NULL;
+                       break;
+               }
+       }
+       if (v) {
                kfree(versions);
                return -EINVAL;
        }
        if (p9_xen_trans.maxsize > XEN_FLEX_RING_SIZE(max_ring_order))
                p9_xen_trans.maxsize = XEN_FLEX_RING_SIZE(max_ring_order) / 2;
  
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv)
-               return -ENOMEM;
-       priv->dev = dev;
        priv->num_rings = XEN_9PFS_NUM_RINGS;
        priv->rings = kcalloc(priv->num_rings, sizeof(*priv->rings),
                              GFP_KERNEL);
                goto error;
        }
  
-       write_lock(&xen_9pfs_lock);
-       list_add_tail(&priv->list, &xen_9pfs_devs);
-       write_unlock(&xen_9pfs_lock);
-       dev_set_drvdata(&dev->dev, priv);
-       xenbus_switch_state(dev, XenbusStateInitialised);
        return 0;
  
   error_xenbus:
        xenbus_transaction_end(xbt, 1);
        xenbus_dev_fatal(dev, ret, "writing xenstore");
   error:
-       dev_set_drvdata(&dev->dev, NULL);
        xen_9pfs_front_free(priv);
        return ret;
  }
  
+ static int xen_9pfs_front_probe(struct xenbus_device *dev,
+                               const struct xenbus_device_id *id)
+ {
+       struct xen_9pfs_front_priv *priv = NULL;
+       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+       priv->dev = dev;
+       dev_set_drvdata(&dev->dev, priv);
+       write_lock(&xen_9pfs_lock);
+       list_add_tail(&priv->list, &xen_9pfs_devs);
+       write_unlock(&xen_9pfs_lock);
+       return 0;
+ }
  static int xen_9pfs_front_resume(struct xenbus_device *dev)
  {
        dev_warn(&dev->dev, "suspend/resume unsupported\n");
@@@ -497,6 -510,8 +509,8 @@@ static void xen_9pfs_front_changed(stru
                break;
  
        case XenbusStateInitWait:
+               if (!xen_9pfs_front_init(dev))
+                       xenbus_switch_state(dev, XenbusStateInitialised);
                break;
  
        case XenbusStateConnected:
This page took 0.10602 seconds and 4 git commands to generate.