mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
Linux 6.3 compat: idmapped mount API changes
Linux kernel 6.3 changed a bunch of APIs to use the dedicated idmap type for mounts (struct mnt_idmap), we need to detect these changes and make zfs work with the new APIs. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Youzhong Yang <yyang@mathworks.com> Closes #14682
This commit is contained in:
@@ -113,12 +113,12 @@ zpl_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
|
||||
|
||||
void
|
||||
zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr,
|
||||
zuserns_t *mnt_ns)
|
||||
zidmap_t *mnt_ns)
|
||||
{
|
||||
vap->va_mask = ATTR_MODE;
|
||||
vap->va_mode = mode;
|
||||
|
||||
vap->va_uid = zfs_vfsuid_to_uid((struct user_namespace *)mnt_ns,
|
||||
vap->va_uid = zfs_vfsuid_to_uid(mnt_ns,
|
||||
zfs_i_user_ns(dir), crgetuid(cr));
|
||||
|
||||
if (dir->i_mode & S_ISGID) {
|
||||
@@ -126,7 +126,7 @@ zpl_vap_init(vattr_t *vap, struct inode *dir, umode_t mode, cred_t *cr,
|
||||
if (S_ISDIR(mode))
|
||||
vap->va_mode |= S_ISGID;
|
||||
} else {
|
||||
vap->va_gid = zfs_vfsgid_to_gid((struct user_namespace *)mnt_ns,
|
||||
vap->va_gid = zfs_vfsgid_to_gid(mnt_ns,
|
||||
zfs_i_user_ns(dir), crgetgid(cr));
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,9 @@ static int
|
||||
#ifdef HAVE_IOPS_CREATE_USERNS
|
||||
zpl_create(struct user_namespace *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, bool flag)
|
||||
#elif defined(HAVE_IOPS_CREATE_IDMAP)
|
||||
zpl_create(struct mnt_idmap *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode, bool flag)
|
||||
#else
|
||||
zpl_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool flag)
|
||||
#endif
|
||||
@@ -144,8 +147,8 @@ zpl_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool flag)
|
||||
vattr_t *vap;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_IOPS_CREATE_USERNS
|
||||
zuserns_t *user_ns = kcred->user_ns;
|
||||
#if !(defined(HAVE_IOPS_CREATE_USERNS) || defined(HAVE_IOPS_CREATE_IDMAP))
|
||||
zidmap_t *user_ns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
crhold(cr);
|
||||
@@ -181,6 +184,9 @@ static int
|
||||
#ifdef HAVE_IOPS_MKNOD_USERNS
|
||||
zpl_mknod(struct user_namespace *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode,
|
||||
#elif defined(HAVE_IOPS_MKNOD_IDMAP)
|
||||
zpl_mknod(struct mnt_idmap *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode,
|
||||
#else
|
||||
zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
|
||||
#endif
|
||||
@@ -191,8 +197,8 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
|
||||
vattr_t *vap;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_IOPS_MKNOD_USERNS
|
||||
zuserns_t *user_ns = kcred->user_ns;
|
||||
#if !(defined(HAVE_IOPS_MKNOD_USERNS) || defined(HAVE_IOPS_MKNOD_IDMAP))
|
||||
zidmap_t *user_ns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -234,7 +240,10 @@ zpl_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,
|
||||
|
||||
#ifdef HAVE_TMPFILE
|
||||
static int
|
||||
#ifndef HAVE_TMPFILE_DENTRY
|
||||
#ifdef HAVE_TMPFILE_IDMAP
|
||||
zpl_tmpfile(struct mnt_idmap *userns, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
#elif !defined(HAVE_TMPFILE_DENTRY)
|
||||
zpl_tmpfile(struct user_namespace *userns, struct inode *dir,
|
||||
struct file *file, umode_t mode)
|
||||
#else
|
||||
@@ -251,8 +260,8 @@ zpl_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
vattr_t *vap;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_TMPFILE_USERNS
|
||||
zuserns_t *userns = kcred->user_ns;
|
||||
#if !(defined(HAVE_TMPFILE_USERNS) || defined(HAVE_TMPFILE_IDMAP))
|
||||
zidmap_t *userns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
crhold(cr);
|
||||
@@ -330,6 +339,9 @@ static int
|
||||
#ifdef HAVE_IOPS_MKDIR_USERNS
|
||||
zpl_mkdir(struct user_namespace *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode)
|
||||
#elif defined(HAVE_IOPS_MKDIR_IDMAP)
|
||||
zpl_mkdir(struct mnt_idmap *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, umode_t mode)
|
||||
#else
|
||||
zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
#endif
|
||||
@@ -339,8 +351,8 @@ zpl_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
znode_t *zp;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_IOPS_MKDIR_USERNS
|
||||
zuserns_t *user_ns = kcred->user_ns;
|
||||
#if !(defined(HAVE_IOPS_MKDIR_USERNS) || defined(HAVE_IOPS_MKDIR_IDMAP))
|
||||
zidmap_t *user_ns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
crhold(cr);
|
||||
@@ -403,6 +415,10 @@ static int
|
||||
zpl_getattr_impl(struct user_namespace *user_ns,
|
||||
const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
unsigned int query_flags)
|
||||
#elif defined(HAVE_IDMAP_IOPS_GETATTR)
|
||||
zpl_getattr_impl(struct mnt_idmap *user_ns,
|
||||
const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
unsigned int query_flags)
|
||||
#else
|
||||
zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
unsigned int query_flags)
|
||||
@@ -419,7 +435,7 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
* XXX query_flags currently ignored.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_USERNS_IOPS_GETATTR
|
||||
#if (defined(HAVE_USERNS_IOPS_GETATTR) || defined(HAVE_IDMAP_IOPS_GETATTR))
|
||||
error = -zfs_getattr_fast(user_ns, ip, stat);
|
||||
#else
|
||||
error = -zfs_getattr_fast(kcred->user_ns, ip, stat);
|
||||
@@ -458,9 +474,12 @@ zpl_getattr_impl(const struct path *path, struct kstat *stat, u32 request_mask,
|
||||
ZPL_GETATTR_WRAPPER(zpl_getattr);
|
||||
|
||||
static int
|
||||
#ifdef HAVE_SETATTR_PREPARE_USERNS
|
||||
#ifdef HAVE_USERNS_IOPS_SETATTR
|
||||
zpl_setattr(struct user_namespace *user_ns, struct dentry *dentry,
|
||||
struct iattr *ia)
|
||||
#elif defined(HAVE_IDMAP_IOPS_SETATTR)
|
||||
zpl_setattr(struct mnt_idmap *user_ns, struct dentry *dentry,
|
||||
struct iattr *ia)
|
||||
#else
|
||||
zpl_setattr(struct dentry *dentry, struct iattr *ia)
|
||||
#endif
|
||||
@@ -473,8 +492,10 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
|
||||
|
||||
#ifdef HAVE_SETATTR_PREPARE_USERNS
|
||||
error = zpl_setattr_prepare(user_ns, dentry, ia);
|
||||
#elif defined(HAVE_SETATTR_PREPARE_IDMAP)
|
||||
error = zpl_setattr_prepare(user_ns, dentry, ia);
|
||||
#else
|
||||
error = zpl_setattr_prepare(kcred->user_ns, dentry, ia);
|
||||
error = zpl_setattr_prepare(zfs_init_idmap, dentry, ia);
|
||||
#endif
|
||||
if (error)
|
||||
return (error);
|
||||
@@ -506,10 +527,12 @@ zpl_setattr(struct dentry *dentry, struct iattr *ia)
|
||||
ip->i_atime = zpl_inode_timestamp_truncate(ia->ia_atime, ip);
|
||||
|
||||
cookie = spl_fstrans_mark();
|
||||
#ifdef HAVE_SETATTR_PREPARE_USERNS
|
||||
#ifdef HAVE_USERNS_IOPS_SETATTR
|
||||
error = -zfs_setattr(ITOZ(ip), vap, 0, cr, user_ns);
|
||||
#elif defined(HAVE_IDMAP_IOPS_SETATTR)
|
||||
error = -zfs_setattr(ITOZ(ip), vap, 0, cr, user_ns);
|
||||
#else
|
||||
error = -zfs_setattr(ITOZ(ip), vap, 0, cr, kcred->user_ns);
|
||||
error = -zfs_setattr(ITOZ(ip), vap, 0, cr, zfs_init_idmap);
|
||||
#endif
|
||||
if (!error && (ia->ia_valid & ATTR_MODE))
|
||||
error = zpl_chmod_acl(ip);
|
||||
@@ -527,6 +550,10 @@ static int
|
||||
zpl_rename2(struct user_namespace *user_ns, struct inode *sdip,
|
||||
struct dentry *sdentry, struct inode *tdip, struct dentry *tdentry,
|
||||
unsigned int rflags)
|
||||
#elif defined(HAVE_IOPS_RENAME_IDMAP)
|
||||
zpl_rename2(struct mnt_idmap *user_ns, struct inode *sdip,
|
||||
struct dentry *sdentry, struct inode *tdip, struct dentry *tdentry,
|
||||
unsigned int rflags)
|
||||
#else
|
||||
zpl_rename2(struct inode *sdip, struct dentry *sdentry,
|
||||
struct inode *tdip, struct dentry *tdentry, unsigned int rflags)
|
||||
@@ -536,8 +563,8 @@ zpl_rename2(struct inode *sdip, struct dentry *sdentry,
|
||||
vattr_t *wo_vap = NULL;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_IOPS_RENAME_USERNS
|
||||
zuserns_t *user_ns = kcred->user_ns;
|
||||
#if !(defined(HAVE_IOPS_RENAME_USERNS) || defined(HAVE_IOPS_RENAME_IDMAP))
|
||||
zidmap_t *user_ns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
crhold(cr);
|
||||
@@ -561,7 +588,8 @@ zpl_rename2(struct inode *sdip, struct dentry *sdentry,
|
||||
|
||||
#if !defined(HAVE_IOPS_RENAME_USERNS) && \
|
||||
!defined(HAVE_RENAME_WANTS_FLAGS) && \
|
||||
!defined(HAVE_RENAME2)
|
||||
!defined(HAVE_RENAME2) && \
|
||||
!defined(HAVE_IOPS_RENAME_IDMAP)
|
||||
static int
|
||||
zpl_rename(struct inode *sdip, struct dentry *sdentry,
|
||||
struct inode *tdip, struct dentry *tdentry)
|
||||
@@ -574,6 +602,9 @@ static int
|
||||
#ifdef HAVE_IOPS_SYMLINK_USERNS
|
||||
zpl_symlink(struct user_namespace *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, const char *name)
|
||||
#elif defined(HAVE_IOPS_SYMLINK_IDMAP)
|
||||
zpl_symlink(struct mnt_idmap *user_ns, struct inode *dir,
|
||||
struct dentry *dentry, const char *name)
|
||||
#else
|
||||
zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
|
||||
#endif
|
||||
@@ -583,8 +614,8 @@ zpl_symlink(struct inode *dir, struct dentry *dentry, const char *name)
|
||||
znode_t *zp;
|
||||
int error;
|
||||
fstrans_cookie_t cookie;
|
||||
#ifndef HAVE_IOPS_SYMLINK_USERNS
|
||||
zuserns_t *user_ns = kcred->user_ns;
|
||||
#if !(defined(HAVE_IOPS_SYMLINK_USERNS) || defined(HAVE_IOPS_SYMLINK_IDMAP))
|
||||
zidmap_t *user_ns = kcred->user_ns;
|
||||
#endif
|
||||
|
||||
crhold(cr);
|
||||
@@ -802,6 +833,8 @@ const struct inode_operations zpl_dir_inode_operations = {
|
||||
.rename2 = zpl_rename2,
|
||||
#elif defined(HAVE_RENAME_WANTS_FLAGS) || defined(HAVE_IOPS_RENAME_USERNS)
|
||||
.rename = zpl_rename2,
|
||||
#elif defined(HAVE_IOPS_RENAME_IDMAP)
|
||||
.rename = zpl_rename2,
|
||||
#else
|
||||
.rename = zpl_rename,
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user