fs: port ->create() to pass mnt_idmap

Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b ("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>
This commit is contained in:
Christian Brauner
2023-01-13 12:49:13 +01:00
committed by Christian Brauner (Microsoft)
parent b74d24f7a7
commit 6c960e68aa
54 changed files with 71 additions and 62 deletions

View File

@@ -56,7 +56,7 @@ inode_operations
prototypes::
int (*create) (struct inode *,struct dentry *,umode_t, bool);
int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t, bool);
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);

View File

@@ -421,7 +421,7 @@ As of kernel 2.6.22, the following members are defined:
.. code-block:: c
struct inode_operations {
int (*create) (struct user_namespace *, struct inode *,struct dentry *, umode_t, bool);
int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t, bool);
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);

View File

@@ -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
@@ -684,7 +684,7 @@ error:
*/
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);

View File

@@ -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
@@ -219,9 +219,10 @@ int v9fs_open_to_dotl_flags(int flags)
*
*/
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)
{
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
return v9fs_vfs_mknod_dotl(mnt_userns, dir, dentry, omode, 0);
}

View File

@@ -167,7 +167,7 @@ extern const struct export_operations affs_export_ops;
extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int);
extern int affs_unlink(struct inode *dir, struct dentry *dentry);
extern int affs_create(struct user_namespace *mnt_userns, struct inode *dir,
extern int affs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool);
extern int affs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode);

View File

@@ -242,7 +242,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
}
int
affs_create(struct user_namespace *mnt_userns, struct inode *dir,
affs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct super_block *sb = dir->i_sb;

View File

@@ -28,7 +28,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, in
loff_t fpos, u64 ino, unsigned dtype);
static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
loff_t fpos, u64 ino, unsigned dtype);
static int afs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl);
static int afs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode);
@@ -1630,7 +1630,7 @@ static const struct afs_operation_ops afs_create_operation = {
/*
* create a regular file on an AFS filesystem
*/
static int afs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct afs_operation *op;

View File

@@ -27,7 +27,7 @@ static const struct file_operations bad_file_ops =
.open = bad_file_open,
};
static int bad_inode_create(struct user_namespace *mnt_userns,
static int bad_inode_create(struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t mode, bool excl)
{

View File

@@ -75,7 +75,7 @@ const struct file_operations bfs_dir_operations = {
.llseek = generic_file_llseek,
};
static int bfs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
int err;

View File

@@ -6739,9 +6739,10 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
return btrfs_create_common(dir, dentry, inode);
}
static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
struct inode *inode;
inode = new_inode(dir->i_sb);

View File

@@ -905,9 +905,10 @@ out:
return err;
}
static int ceph_create(struct user_namespace *mnt_userns, struct inode *dir,
static int ceph_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
return ceph_mknod(mnt_userns, dir, dentry, mode, 0);
}

View File

@@ -49,7 +49,7 @@ extern void cifs_sb_deactive(struct super_block *sb);
/* Functions related to inodes */
extern const struct inode_operations cifs_dir_inode_ops;
extern struct inode *cifs_root_iget(struct super_block *);
extern int cifs_create(struct user_namespace *, struct inode *,
extern int cifs_create(struct mnt_idmap *, struct inode *,
struct dentry *, umode_t, bool excl);
extern int cifs_atomic_open(struct inode *, struct dentry *,
struct file *, unsigned, umode_t);

View File

@@ -529,7 +529,7 @@ out_free_xid:
return rc;
}
int cifs_create(struct user_namespace *mnt_userns, struct inode *inode,
int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode, bool excl)
{
int rc;

View File

@@ -133,7 +133,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
}
/* creation routines: create, mknod, mkdir, link, symlink */
static int coda_create(struct user_namespace *mnt_userns, struct inode *dir,
static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *de, umode_t mode, bool excl)
{
int error;

View File

@@ -253,7 +253,7 @@ out:
* Returns zero on success; non-zero on error condition
*/
static int
ecryptfs_create(struct user_namespace *mnt_userns,
ecryptfs_create(struct mnt_idmap *idmap,
struct inode *directory_inode, struct dentry *ecryptfs_dentry,
umode_t mode, bool excl)
{

View File

@@ -70,7 +70,7 @@ bool efivarfs_valid_name(const char *str, int len)
return uuid_is_valid(s);
}
static int efivarfs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct inode *inode = NULL;

View File

@@ -551,7 +551,7 @@ out:
return ret;
}
static int exfat_create(struct user_namespace *mnt_userns, struct inode *dir,
static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct super_block *sb = dir->i_sb;

View File

@@ -99,7 +99,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
static int ext2_create (struct user_namespace * mnt_userns,
static int ext2_create (struct mnt_idmap * idmap,
struct inode * dir, struct dentry * dentry,
umode_t mode, bool excl)
{

View File

@@ -2792,9 +2792,10 @@ static int ext4_add_nondir(handle_t *handle,
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
static int ext4_create(struct user_namespace *mnt_userns, struct inode *dir,
static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
handle_t *handle;
struct inode *inode;
int err, credits, retries = 0;

View File

@@ -333,9 +333,10 @@ fail_drop:
return ERR_PTR(err);
}
static int f2fs_create(struct user_namespace *mnt_userns, struct inode *dir,
static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, bool excl)
{
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct inode *inode;
nid_t ino = 0;

Some files were not shown because too many files have changed in this diff Show More