fs: port ->rename() to pass mnt_idmap
authorChristian Brauner <brauner@kernel.org>
Fri, 13 Jan 2023 11:49:17 +0000 (12:49 +0100)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Thu, 19 Jan 2023 08:24:26 +0000 (09:24 +0100)
Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b42 ("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.

Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.

Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.

Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
52 files changed:
Documentation/filesystems/locking.rst
Documentation/filesystems/vfs.rst
drivers/android/binderfs.c
fs/9p/v9fs.h
fs/9p/vfs_inode.c
fs/affs/affs.h
fs/affs/namei.c
fs/afs/dir.c
fs/bad_inode.c
fs/bfs/dir.c
fs/btrfs/inode.c
fs/ceph/dir.c
fs/cifs/cifsfs.h
fs/cifs/inode.c
fs/coda/dir.c
fs/debugfs/inode.c
fs/ecryptfs/inode.c
fs/exfat/namei.c
fs/ext2/namei.c
fs/ext4/namei.c
fs/f2fs/namei.c
fs/fat/namei_msdos.c
fs/fat/namei_vfat.c
fs/fuse/dir.c
fs/gfs2/inode.c
fs/hfs/dir.c
fs/hfsplus/dir.c
fs/hostfs/hostfs_kern.c
fs/hpfs/namei.c
fs/jffs2/dir.c
fs/jfs/namei.c
fs/kernfs/dir.c
fs/libfs.c
fs/minix/namei.c
fs/namei.c
fs/nfs/dir.c
fs/nfs/internal.h
fs/nilfs2/namei.c
fs/ntfs3/namei.c
fs/ocfs2/namei.c
fs/omfs/dir.c
fs/orangefs/namei.c
fs/overlayfs/dir.c
fs/reiserfs/namei.c
fs/sysv/namei.c
fs/ubifs/dir.c
fs/udf/namei.c
fs/ufs/namei.c
fs/vboxsf/dir.c
fs/xfs/xfs_iops.c
include/linux/fs.h
mm/shmem.c

index 9605928c11b5c1fd16f3a2215e0389ac9c0557dd..c63890845d95664361dcd6881df36552a4d6f3fe 100644 (file)
@@ -64,7 +64,7 @@ prototypes::
        int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
        int (*rmdir) (struct inode *,struct dentry *);
        int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
-       int (*rename) (struct inode *, struct dentry *,
+       int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
                        struct inode *, struct dentry *, unsigned int);
        int (*readlink) (struct dentry *, char __user *,int);
        const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
index e2cb36f15ce4fdb2c92488d2ba7e6c064c79e039..263fcc57b71f293499429aecae08bbe215e8eadf 100644 (file)
@@ -429,7 +429,7 @@ As of kernel 2.6.22, the following members are defined:
                int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
                int (*rmdir) (struct inode *,struct dentry *);
                int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
-               int (*rename) (struct user_namespace *, struct inode *, struct dentry *,
+               int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
                               struct inode *, struct dentry *, unsigned int);
                int (*readlink) (struct dentry *, char __user *,int);
                const char *(*get_link) (struct dentry *, struct inode *,
index 09b2ce7e4c345847eb0dd263c70e352d6e0ba35e..348d63d1e3d380fa795cdcf341ac221d9e570ab7 100644 (file)
@@ -352,7 +352,7 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
        return info->control_dentry == dentry;
 }
 
-static int binderfs_rename(struct user_namespace *mnt_userns,
+static int binderfs_rename(struct mnt_idmap *idmap,
                           struct inode *old_dir, struct dentry *old_dentry,
                           struct inode *new_dir, struct dentry *new_dentry,
                           unsigned int flags)
@@ -361,7 +361,7 @@ static int binderfs_rename(struct user_namespace *mnt_userns,
            is_binderfs_control_device(new_dentry))
                return -EPERM;
 
-       return simple_rename(&init_user_ns, old_dir, old_dentry, new_dir,
+       return simple_rename(idmap, old_dir, old_dentry, new_dir,
                             new_dentry, flags);
 }
 
index 6acabc2e7dc9dd513696dc3948a2fd90d058fd3d..f3f74d197b5d2e222f531367491422c1f91dc7cc 100644 (file)
@@ -151,7 +151,7 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
                                      unsigned int flags);
 extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
 extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
-extern int v9fs_vfs_rename(struct user_namespace *mnt_userns,
+extern int 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);
index 1a21b001f377b8b5ce1fc6d192d4256081975f4c..a714df142d05ef4fb1b124001da32398a4ab72a0 100644 (file)
@@ -908,7 +908,7 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
 
 /**
  * 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
@@ -918,7 +918,7 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
  */
 
 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)
 {
index 8f70a839c3119f696396c33869cd56423025c816..60685ec76d983523f15da7c7e97b38634b750c07 100644 (file)
@@ -177,7 +177,7 @@ extern int  affs_link(struct dentry *olddentry, struct inode *dir,
 extern int     affs_symlink(struct mnt_idmap *idmap,
                        struct inode *dir, struct dentry *dentry,
                        const char *symname);
-extern int     affs_rename2(struct user_namespace *mnt_userns,
+extern int     affs_rename2(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags);
index e0300f0b6fc35498f0139fd3bccbbc7ff9458887..d12ccfd2a83de802a4622998c84e54138807517c 100644 (file)
@@ -503,7 +503,7 @@ done:
        return retval;
 }
 
-int affs_rename2(struct user_namespace *mnt_userns, struct inode *old_dir,
+int affs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
                 struct dentry *old_dentry, struct inode *new_dir,
                 struct dentry *new_dentry, unsigned int flags)
 {
index c2ada2fc51b44aa21b9e6f99a102c773bc5504bd..82690d1dd49a026a93b33d2ebce71bbf7747774e 100644 (file)
@@ -38,7 +38,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
                    struct dentry *dentry);
 static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, const char *content);
-static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags);
 static bool afs_dir_release_folio(struct folio *folio, gfp_t gfp_flags);
@@ -1897,7 +1897,7 @@ static const struct afs_operation_ops afs_rename_operation = {
 /*
  * rename a file in an AFS filesystem and/or move it between directories
  */
-static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index d1b075b4dce880968643abea0eb30546965e179d..1e24ce889a15a278ad40e3e22572b9177d72143b 100644 (file)
@@ -75,7 +75,7 @@ static int bad_inode_mknod(struct mnt_idmap *idmap, struct inode *dir,
        return -EIO;
 }
 
-static int bad_inode_rename2(struct user_namespace *mnt_userns,
+static int bad_inode_rename2(struct mnt_idmap *idmap,
                             struct inode *old_dir, struct dentry *old_dentry,
                             struct inode *new_dir, struct dentry *new_dentry,
                             unsigned int flags)
index f9d4ce5fff9faa156905dd85b1d0be76abfd1fad..fa3e66bc9be3e6fa57b623efb4f2b269ccd9bab5 100644 (file)
@@ -199,7 +199,7 @@ out_brelse:
        return error;
 }
 
-static int bfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index 438b5142be448a5476c3d0c53830c24fe0c34209..dbb6790d0268c697b3aa696da1014e9cb7a543cc 100644 (file)
@@ -9547,10 +9547,11 @@ out_fscrypt_names:
        return ret;
 }
 
-static int btrfs_rename2(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int btrfs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
                         struct dentry *old_dentry, struct inode *new_dir,
                         struct dentry *new_dentry, unsigned int flags)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        int ret;
 
        if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
index 7ad56d5a63b3c7e0b05b3a1cab3024207b196ea7..0ced8b570e424eb201434cf280c40d34c4cbe1ed 100644 (file)
@@ -1269,7 +1269,7 @@ out:
        return err;
 }
 
-static int ceph_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                       struct dentry *old_dentry, struct inode *new_dir,
                       struct dentry *new_dentry, unsigned int flags)
 {
index 14bb46ab0874b1f795d642d7fdab1a20f7ee179a..b58cd737b21e3c1e867baa7029d04a97598569fd 100644 (file)
@@ -62,7 +62,7 @@ extern int cifs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
 extern int cifs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *,
                      umode_t);
 extern int cifs_rmdir(struct inode *, struct dentry *);
-extern int cifs_rename2(struct user_namespace *, struct inode *,
+extern int cifs_rename2(struct mnt_idmap *, struct inode *,
                        struct dentry *, struct inode *, struct dentry *,
                        unsigned int);
 extern int cifs_revalidate_file_attr(struct file *filp);
index ce4f086db2dfa334414b937ce95b153251ca2ae6..11cdc7cfe0bafd69e0da2cce736aedb276df06ac 100644 (file)
@@ -2138,7 +2138,7 @@ do_rename_exit:
 }
 
 int
-cifs_rename2(struct user_namespace *mnt_userns, struct inode *source_dir,
+cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
             struct dentry *source_dentry, struct inode *target_dir,
             struct dentry *target_dentry, unsigned int flags)
 {
index ff90117f1eec5753092dd96e3442a8255088d527..7fdf8e37a1df6af695aebd9d60390893ab25e2a7 100644 (file)
@@ -295,7 +295,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
 }
 
 /* rename */
-static int coda_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int coda_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                       struct dentry *old_dentry, struct inode *new_dir,
                       struct dentry *new_dentry, unsigned int flags)
 {
index ac76e6c6ac56aae532419031235a12c4312a56fd..bf397f6a6a33f4525d53c996ebfee6e03cdf192b 100644 (file)
@@ -837,7 +837,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
 
        take_dentry_name_snapshot(&old_name, old_dentry);
 
-       error = simple_rename(&init_user_ns, d_inode(old_dir), old_dentry,
+       error = simple_rename(&nop_mnt_idmap, d_inode(old_dir), old_dentry,
                              d_inode(new_dir), dentry, 0);
        if (error) {
                release_dentry_name_snapshot(&old_name);
index 6a2052d234b2d3766696eb2055e668b8cb723554..cf85901d7a5de9a96b8cd97098db1a3290346530 100644 (file)
@@ -574,7 +574,7 @@ out:
 }
 
 static int
-ecryptfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+ecryptfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                struct dentry *old_dentry, struct inode *new_dir,
                struct dentry *new_dentry, unsigned int flags)
 {
index 99e86caba54496d74b3bd75bada0763a8e53e319..02aab4c3a5f734c0308419111ca1c972610c8f89 100644 (file)
@@ -1285,7 +1285,7 @@ out:
        return ret;
 }
 
-static int exfat_rename(struct user_namespace *mnt_userns,
+static int exfat_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
index 91219a6a5739d25fd586b5b9e897492492842634..8b5dfa46bcc87fc42726ac7f82aad144723215ba 100644 (file)
@@ -315,7 +315,7 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
        return err;
 }
 
-static int ext2_rename (struct user_namespace * mnt_userns,
+static int ext2_rename (struct mnt_idmap * idmap,
                        struct inode * old_dir, struct dentry * old_dentry,
                        struct inode * new_dir, struct dentry * new_dentry,
                        unsigned int flags)
index 0aa190e03b864770e8096550c14f7a8df8b897b5..feb58508978e0d278b717733acc6b11b8348a9ea 100644 (file)
@@ -4162,11 +4162,12 @@ end_rename:
        return retval;
 }
 
-static int ext4_rename2(struct user_namespace *mnt_userns,
+static int ext4_rename2(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        int err;
 
        if (unlikely(ext4_forced_shutdown(EXT4_SB(old_dir->i_sb))))
index 39f76a1d8b90e0e0f23198d5c257f1920d000bb6..a87b9fcaf923f25294982346cc1735ab28abf4c6 100644 (file)
@@ -1299,11 +1299,12 @@ out:
        return err;
 }
 
-static int f2fs_rename2(struct user_namespace *mnt_userns,
+static int f2fs_rename2(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        int err;
 
        if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
index b98025f21d9bc75f5930b7d83d5e594af9557fa6..2116c486843b7d6525a045c47c45470451af0828 100644 (file)
@@ -594,7 +594,7 @@ error_inode:
 }
 
 /***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
-static int msdos_rename(struct user_namespace *mnt_userns,
+static int msdos_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
index f5f4caff75e27dd940d54a8f0728d257101fde98..fceda1de480554d52182b5a691504fc9b06d4035 100644 (file)
@@ -1158,7 +1158,7 @@ error_exchange:
        goto out;
 }
 
-static int vfat_rename2(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int vfat_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
                        struct dentry *old_dentry, struct inode *new_dir,
                        struct dentry *new_dentry, unsigned int flags)
 {
index f6aa799fb584ddcb02776e336ed24a97a8f28962..c95d610fa63fd17def6ce18fb4c990c7819077f5 100644 (file)
@@ -998,7 +998,7 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent,
        return err;
 }
 
-static int fuse_rename2(struct user_namespace *mnt_userns, struct inode *olddir,
+static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir,
                        struct dentry *oldent, struct inode *newdir,
                        struct dentry *newent, unsigned int flags)
 {
index ed015ab6628780b81814f402e6f2cdc70fe624d0..f4af5580780883c82b7163aedb8b71ef1360b6d7 100644 (file)
@@ -1766,7 +1766,7 @@ out:
        return error;
 }
 
-static int gfs2_rename2(struct user_namespace *mnt_userns, struct inode *odir,
+static int gfs2_rename2(struct mnt_idmap *idmap, struct inode *odir,
                        struct dentry *odentry, struct inode *ndir,
                        struct dentry *ndentry, unsigned int flags)
 {
index f8141c407d5521c0dc1cb12d74d490c1470859e6..3e1e3dcf0b48816d5d32f20377b1c04a4353cd5b 100644 (file)
@@ -280,7 +280,7 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
  * new file/directory.
  * XXX: how do you handle must_be dir?
  */
-static int hfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index 19caa2d953a7825d0348037402f05e7c9a84bcf9..56fb5f1312e71c4af9d41f83ace79cbe360bff38 100644 (file)
@@ -529,7 +529,7 @@ static int hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir,
        return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFDIR, 0);
 }
 
-static int hfsplus_rename(struct user_namespace *mnt_userns,
+static int hfsplus_rename(struct mnt_idmap *idmap,
                          struct inode *old_dir, struct dentry *old_dentry,
                          struct inode *new_dir, struct dentry *new_dentry,
                          unsigned int flags)
index b7f512d2c66920f3aec9110d008f3f5c9e5ba0b3..65dfc7457034b64568ac49bb7cb2f3a8620ffe5d 100644 (file)
@@ -734,7 +734,7 @@ static int hostfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
        return err;
 }
 
-static int hostfs_rename2(struct user_namespace *mnt_userns,
+static int hostfs_rename2(struct mnt_idmap *idmap,
                          struct inode *old_dir, struct dentry *old_dentry,
                          struct inode *new_dir, struct dentry *new_dentry,
                          unsigned int flags)
index 8415137a064d8b7760b80b4e1b8d0c0f94950ab8..69fb40b2c99a93aca980e42b9ecf16d8b839a635 100644 (file)
@@ -512,7 +512,7 @@ const struct address_space_operations hpfs_symlink_aops = {
        .read_folio     = hpfs_symlink_read_folio
 };
 
-static int hpfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int hpfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                       struct dentry *old_dentry, struct inode *new_dir,
                       struct dentry *new_dentry, unsigned int flags)
 {
index 9e1110de6f0b223d0ef67207ef3970fc11d59ed5..5075a0a6d594e773698a3d7054d0693423eaf15d 100644 (file)
@@ -37,7 +37,7 @@ static int jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *,
 static int jffs2_rmdir (struct inode *,struct dentry *);
 static int jffs2_mknod (struct mnt_idmap *, struct inode *,struct dentry *,
                        umode_t,dev_t);
-static int jffs2_rename (struct user_namespace *, struct inode *,
+static int jffs2_rename (struct mnt_idmap *, struct inode *,
                         struct dentry *, struct inode *, struct dentry *,
                         unsigned int);
 
@@ -762,7 +762,7 @@ static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
        return ret;
 }
 
-static int jffs2_rename (struct user_namespace *mnt_userns,
+static int jffs2_rename (struct mnt_idmap *idmap,
                         struct inode *old_dir_i, struct dentry *old_dentry,
                         struct inode *new_dir_i, struct dentry *new_dentry,
                         unsigned int flags)
index 917c1237cf9342bbfb96b6d92433418508d779bf..b29d68b5eec53039b91152824c9dacdc8e70e4ad 100644 (file)
@@ -1059,7 +1059,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
  *
  * FUNCTION:   rename a file or directory
  */
-static int jfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index 4f2d521bedabba7c3167c3e4a96202397872af24..e3181c3e198866cf81f649daf1c019c1866ab97b 100644 (file)
@@ -1238,7 +1238,7 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
        return ret;
 }
 
-static int kernfs_iop_rename(struct user_namespace *mnt_userns,
+static int kernfs_iop_rename(struct mnt_idmap *idmap,
                             struct inode *old_dir, struct dentry *old_dentry,
                             struct inode *new_dir, struct dentry *new_dentry,
                             unsigned int flags)
index aae36b224508f1af72968ef46ccd53bc3265cc8e..152405c00f89ded4c1503a2469f30141e5d21304 100644 (file)
@@ -473,7 +473,7 @@ int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
 }
 EXPORT_SYMBOL_GPL(simple_rename_exchange);
 
-int simple_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+int simple_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                  struct dentry *old_dentry, struct inode *new_dir,
                  struct dentry *new_dentry, unsigned int flags)
 {
index b6b4b0a1608e613963134eff3f35978f7cd3e40b..aa308b12f40d3f9bcc00cb08f2ee29f4b7f86a04 100644 (file)
@@ -184,7 +184,7 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
        return err;
 }
 
-static int minix_rename(struct user_namespace *mnt_userns,
+static int minix_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
index 74c194c0ceab1bcac32fc667fd6b4bf0a823d589..3be66e8b418fea8fda7e5f8ff85ee889ab1b5dd0 100644 (file)
@@ -4786,7 +4786,7 @@ int vfs_rename(struct renamedata *rd)
                if (error)
                        goto out;
        }
-       error = old_dir->i_op->rename(new_mnt_userns, old_dir, old_dentry,
+       error = old_dir->i_op->rename(rd->new_mnt_idmap, old_dir, old_dentry,
                                      new_dir, new_dentry, flags);
        if (error)
                goto out;
index 19b4926b93cbcfccee91c18978edea6ea9495286..01eeae59599bee701010ac8e7ce4e73018050f39 100644 (file)
@@ -2642,7 +2642,7 @@ nfs_unblock_rename(struct rpc_task *task, struct nfs_renamedata *data)
  * If these conditions are met, we can drop the dentries before doing
  * the rename.
  */
-int nfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+int nfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
               struct dentry *old_dentry, struct inode *new_dir,
               struct dentry *new_dentry, unsigned int flags)
 {
index d6df06d61f2828d824a5379a17e278ab0282512e..41468c21291d49db19b49946dab10d8b89a383a7 100644 (file)
@@ -395,7 +395,7 @@ int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
 int nfs_link(struct dentry *, struct inode *, struct dentry *);
 int nfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
              dev_t);
-int nfs_rename(struct user_namespace *, struct inode *, struct dentry *,
+int nfs_rename(struct mnt_idmap *, struct inode *, struct dentry *,
               struct inode *, struct dentry *, unsigned int);
 
 #ifdef CONFIG_NFS_V4_2
index 9cc52d8fa02289f1ac0597f73896c5890fb4de8a..c7024da8f1e256f39d41d448a6ce23c1896f94eb 100644 (file)
@@ -340,7 +340,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
        return err;
 }
 
-static int nilfs_rename(struct user_namespace *mnt_userns,
+static int nilfs_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
index 3cd1a18c6c02dd636d3f704127dca5fc80977060..13731de390104dc59e2bac4afc0b2bb196a1cf65 100644 (file)
@@ -233,7 +233,7 @@ static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
 /*
  * ntfs_rename - inode_operations::rename
  */
-static int ntfs_rename(struct user_namespace *mnt_userns, struct inode *dir,
+static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, struct inode *new_dir,
                       struct dentry *new_dentry, u32 flags)
 {
index e588009cb04e18ed82574a0026fcec74ea4d83f2..13433e774e3d15fecb864bb615d4cba7f0aba55d 100644 (file)
@@ -1194,7 +1194,7 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
                ocfs2_inode_unlock(inode2, 1);
 }
 
-static int ocfs2_rename(struct user_namespace *mnt_userns,
+static int ocfs2_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir,
                        struct dentry *old_dentry,
                        struct inode *new_dir,
index 34138f46f7e731a243b459bf430e9e0b9a11c5b1..82cf7e9a665faa33a31af53352b4a599bfc55ee8 100644 (file)
@@ -370,7 +370,7 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
        return true;
 }
 
-static int omfs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int omfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                       struct dentry *old_dentry, struct inode *new_dir,
                       struct dentry *new_dentry, unsigned int flags)
 {
index 9243c35fb478e56f9305f64685e5518282f971e5..77518e248cf79e87e9b3bd500dbb5c1cb08aef1b 100644 (file)
@@ -375,7 +375,7 @@ out:
        return ret;
 }
 
-static int orangefs_rename(struct user_namespace *mnt_userns,
+static int orangefs_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir,
                        struct dentry *old_dentry,
                        struct inode *new_dir,
index ff18a6a16b01e79be76ae92834dd2f97f733dbc8..17d5091562156db838268a9be14cd52a2834fe8d 100644 (file)
@@ -1075,7 +1075,7 @@ static int ovl_set_redirect(struct dentry *dentry, bool samedir)
        return err;
 }
 
-static int ovl_rename(struct user_namespace *mnt_userns, struct inode *olddir,
+static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
                      struct dentry *old, struct inode *newdir,
                      struct dentry *new, unsigned int flags)
 {
index 4c3da7ccca345babd1a5545f7d63f230df889a4a..f80b4a6ecf51edd20c6313988fb664e09b4c6c30 100644 (file)
@@ -1311,7 +1311,7 @@ static void set_ino_in_dir_entry(struct reiserfs_dir_entry *de,
  * one path. If it holds 2 or more, it can get into endless waiting in
  * get_empty_nodes or its clones
  */
-static int reiserfs_rename(struct user_namespace *mnt_userns,
+static int reiserfs_rename(struct mnt_idmap *idmap,
                           struct inode *old_dir, struct dentry *old_dentry,
                           struct inode *new_dir, struct dentry *new_dentry,
                           unsigned int flags)
index e44c5f5f5b0ceea2b1dcbbf571700fcb6f52e0ce..ecd424461511ffc2fba99b53df8b271947ceced8 100644 (file)
@@ -189,7 +189,7 @@ static int sysv_rmdir(struct inode * dir, struct dentry * dentry)
  * Anybody can rename anything with this: the permission checks are left to the
  * higher-level routines.
  */
-static int sysv_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int sysv_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                       struct dentry *old_dentry, struct inode *new_dir,
                       struct dentry *new_dentry, unsigned int flags)
 {
index 9f521a8edebfd45c9a6512f078f017e8e214128f..e11a2d76fb0e55df1614e9eb6fe6dcdf07eea2d5 100644 (file)
@@ -1606,7 +1606,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
        return err;
 }
 
-static int ubifs_rename(struct user_namespace *mnt_userns,
+static int ubifs_rename(struct mnt_idmap *idmap,
                        struct inode *old_dir, struct dentry *old_dentry,
                        struct inode *new_dir, struct dentry *new_dentry,
                        unsigned int flags)
index 7ecfeaad41b17d3d1633cdabfa55a50f2549fbb3..c93b10513babe511d544baaca3d0653b255ba1c6 100644 (file)
@@ -1073,7 +1073,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
 /* Anybody can rename anything with this: the permission checks are left to the
  * higher-level routines.
  */
-static int udf_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index 85afc26d559dd8f21e6d7b4579b7e45ff8ae6af0..36154b5aca6dcaa078c7c38476b6fa9d09f914c2 100644 (file)
@@ -243,7 +243,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
        return err;
 }
 
-static int ufs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
+static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
                      struct dentry *old_dentry, struct inode *new_dir,
                      struct dentry *new_dentry, unsigned int flags)
 {
index 4ec79548e9f09dbb7e206ef1c76298104a799a1d..075f15c43c7806baf9240cc65aa952d0cd12c9d2 100644 (file)
@@ -387,7 +387,7 @@ static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)
        return 0;
 }
 
-static int vboxsf_dir_rename(struct user_namespace *mnt_userns,
+static int vboxsf_dir_rename(struct mnt_idmap *idmap,
                             struct inode *old_parent,
                             struct dentry *old_dentry,
                             struct inode *new_parent,
index 249b0d8fcd844ef96797d3791087d3674fae47e7..fd0c62e0ddd264c3696dd695dda7ad6448852c36 100644 (file)
@@ -446,13 +446,14 @@ xfs_vn_symlink(
 
 STATIC int
 xfs_vn_rename(
-       struct user_namespace   *mnt_userns,
+       struct mnt_idmap        *idmap,
        struct inode            *odir,
        struct dentry           *odentry,
        struct inode            *ndir,
        struct dentry           *ndentry,
        unsigned int            flags)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode    *new_inode = d_inode(ndentry);
        int             omode = 0;
        int             error;
index a28117398e71baf5a1c97135f2c3b833f8dd7637..8d287bd2bf9be949be048f79785782c0a07cefe4 100644 (file)
@@ -2150,7 +2150,7 @@ struct inode_operations {
        int (*rmdir) (struct inode *,struct dentry *);
        int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,
                      umode_t,dev_t);
-       int (*rename) (struct user_namespace *, struct inode *, struct dentry *,
+       int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
                        struct inode *, struct dentry *, unsigned int);
        int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
        int (*getattr) (struct mnt_idmap *, const struct path *,
@@ -3323,7 +3323,7 @@ extern int simple_unlink(struct inode *, struct dentry *);
 extern int simple_rmdir(struct inode *, struct dentry *);
 extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
                                  struct inode *new_dir, struct dentry *new_dentry);
-extern int simple_rename(struct user_namespace *, struct inode *,
+extern int simple_rename(struct mnt_idmap *, struct inode *,
                         struct dentry *, struct inode *, struct dentry *,
                         unsigned int);
 extern void simple_recursive_removal(struct dentry *,
index d66f75c5e85e53d3287af4e1bce911cfd8e9f5e7..c9998c2220d35ad213151202b0b8d92e33478a91 100644 (file)
@@ -3045,7 +3045,7 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
        return shmem_unlink(dir, dentry);
 }
 
-static int shmem_whiteout(struct user_namespace *mnt_userns,
+static int shmem_whiteout(struct mnt_idmap *idmap,
                          struct inode *old_dir, struct dentry *old_dentry)
 {
        struct dentry *whiteout;
@@ -3078,7 +3078,7 @@ static int shmem_whiteout(struct user_namespace *mnt_userns,
  * it exists so that the VFS layer correctly free's it when it
  * gets overwritten.
  */
-static int shmem_rename2(struct user_namespace *mnt_userns,
+static int shmem_rename2(struct mnt_idmap *idmap,
                         struct inode *old_dir, struct dentry *old_dentry,
                         struct inode *new_dir, struct dentry *new_dentry,
                         unsigned int flags)
@@ -3098,7 +3098,7 @@ static int shmem_rename2(struct user_namespace *mnt_userns,
        if (flags & RENAME_WHITEOUT) {
                int error;
 
-               error = shmem_whiteout(&init_user_ns, old_dir, old_dentry);
+               error = shmem_whiteout(&nop_mnt_idmap, old_dir, old_dentry);
                if (error)
                        return error;
        }