Skip to content

Commit b8169c2

Browse files
youzhongyangandrewc12
authored andcommitted
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 <[email protected]> Signed-off-by: Youzhong Yang <[email protected]> Closes openzfs#14682
1 parent c669f4b commit b8169c2

40 files changed

+821
-294
lines changed

config/kernel-acl.m4

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,22 @@ dnl #
236236
dnl # 6.2 API change,
237237
dnl # set_acl() second paramter changed to a struct dentry *
238238
dnl #
239+
dnl # 6.3 API change,
240+
dnl # set_acl() first parameter changed to struct mnt_idmap *
241+
dnl #
239242
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_OPERATIONS_SET_ACL], [
243+
ZFS_LINUX_TEST_SRC([inode_operations_set_acl_mnt_idmap_dentry], [
244+
#include <linux/fs.h>
245+
246+
int set_acl_fn(struct mnt_idmap *idmap,
247+
struct dentry *dent, struct posix_acl *acl,
248+
int type) { return 0; }
249+
250+
static const struct inode_operations
251+
iops __attribute__ ((unused)) = {
252+
.set_acl = set_acl_fn,
253+
};
254+
],[])
240255
ZFS_LINUX_TEST_SRC([inode_operations_set_acl_userns_dentry], [
241256
#include <linux/fs.h>
242257
@@ -281,17 +296,24 @@ AC_DEFUN([ZFS_AC_KERNEL_INODE_OPERATIONS_SET_ACL], [
281296
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
282297
AC_DEFINE(HAVE_SET_ACL_USERNS, 1, [iops->set_acl() takes 4 args])
283298
],[
284-
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns_dentry], [
299+
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_mnt_idmap_dentry], [
285300
AC_MSG_RESULT(yes)
286301
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
287-
AC_DEFINE(HAVE_SET_ACL_USERNS_DENTRY_ARG2, 1,
288-
[iops->set_acl() takes 4 args, arg2 is struct dentry *])
302+
AC_DEFINE(HAVE_SET_ACL_IDMAP_DENTRY, 1,
303+
[iops->set_acl() takes 4 args, arg1 is struct mnt_idmap *])
289304
],[
290-
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [
305+
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl_userns_dentry], [
291306
AC_MSG_RESULT(yes)
292-
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args])
307+
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists])
308+
AC_DEFINE(HAVE_SET_ACL_USERNS_DENTRY_ARG2, 1,
309+
[iops->set_acl() takes 4 args, arg2 is struct dentry *])
293310
],[
294-
ZFS_LINUX_REQUIRE_API([i_op->set_acl()], [3.14])
311+
ZFS_LINUX_TEST_RESULT([inode_operations_set_acl], [
312+
AC_MSG_RESULT(yes)
313+
AC_DEFINE(HAVE_SET_ACL, 1, [iops->set_acl() exists, takes 3 args])
314+
],[
315+
ZFS_LINUX_REQUIRE_API([i_op->set_acl()], [3.14])
316+
])
295317
])
296318
])
297319
])

config/kernel-generic_fillattr.m4

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ dnl #
44
dnl # generic_fillattr in linux/fs.h now requires a struct user_namespace*
55
dnl # as the first arg, to support idmapped mounts.
66
dnl #
7-
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR_USERNS], [
7+
dnl # 6.3 API
8+
dnl # generic_fillattr() now takes struct mnt_idmap* as the first argument
9+
dnl #
10+
AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR], [
811
ZFS_LINUX_TEST_SRC([generic_fillattr_userns], [
912
#include <linux/fs.h>
1013
],[
@@ -13,16 +16,32 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_GENERIC_FILLATTR_USERNS], [
1316
struct kstat *k = NULL;
1417
generic_fillattr(userns, in, k);
1518
])
19+
20+
ZFS_LINUX_TEST_SRC([generic_fillattr_mnt_idmap], [
21+
#include <linux/fs.h>
22+
],[
23+
struct mnt_idmap *idmap = NULL;
24+
struct inode *in = NULL;
25+
struct kstat *k = NULL;
26+
generic_fillattr(idmap, in, k);
27+
])
1628
])
1729

18-
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_FILLATTR_USERNS], [
19-
AC_MSG_CHECKING([whether generic_fillattr requires struct user_namespace*])
20-
ZFS_LINUX_TEST_RESULT([generic_fillattr_userns], [
30+
AC_DEFUN([ZFS_AC_KERNEL_GENERIC_FILLATTR], [
31+
AC_MSG_CHECKING([whether generic_fillattr requires struct mnt_idmap*])
32+
ZFS_LINUX_TEST_RESULT([generic_fillattr_mnt_idmap], [
2133
AC_MSG_RESULT([yes])
22-
AC_DEFINE(HAVE_GENERIC_FILLATTR_USERNS, 1,
23-
[generic_fillattr requires struct user_namespace*])
34+
AC_DEFINE(HAVE_GENERIC_FILLATTR_IDMAP, 1,
35+
[generic_fillattr requires struct mnt_idmap*])
2436
],[
25-
AC_MSG_RESULT([no])
37+
AC_MSG_CHECKING([whether generic_fillattr requires struct user_namespace*])
38+
ZFS_LINUX_TEST_RESULT([generic_fillattr_userns], [
39+
AC_MSG_RESULT([yes])
40+
AC_DEFINE(HAVE_GENERIC_FILLATTR_USERNS, 1,
41+
[generic_fillattr requires struct user_namespace*])
42+
],[
43+
AC_MSG_RESULT([no])
44+
])
2645
])
2746
])
2847

config/kernel-inode-create.m4

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
AC_DEFUN([ZFS_AC_KERNEL_SRC_CREATE], [
2+
dnl #
3+
dnl # 6.3 API change
4+
dnl # The first arg is changed to struct mnt_idmap *
5+
dnl #
6+
ZFS_LINUX_TEST_SRC([create_mnt_idmap], [
7+
#include <linux/fs.h>
8+
#include <linux/sched.h>
9+
10+
int inode_create(struct mnt_idmap *idmap,
11+
struct inode *inode ,struct dentry *dentry,
12+
umode_t umode, bool flag) { return 0; }
13+
14+
static const struct inode_operations
15+
iops __attribute__ ((unused)) = {
16+
.create = inode_create,
17+
};
18+
],[])
19+
220
dnl #
321
dnl # 5.12 API change that added the struct user_namespace* arg
422
dnl # to the front of this function type's arg list.
@@ -35,19 +53,28 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_CREATE], [
3553
])
3654

3755
AC_DEFUN([ZFS_AC_KERNEL_CREATE], [
38-
AC_MSG_CHECKING([whether iops->create() takes struct user_namespace*])
39-
ZFS_LINUX_TEST_RESULT([create_userns], [
56+
AC_MSG_CHECKING([whether iops->create() takes struct mnt_idmap*])
57+
ZFS_LINUX_TEST_RESULT([create_mnt_idmap], [
4058
AC_MSG_RESULT(yes)
41-
AC_DEFINE(HAVE_IOPS_CREATE_USERNS, 1,
42-
[iops->create() takes struct user_namespace*])
59+
AC_DEFINE(HAVE_IOPS_CREATE_IDMAP, 1,
60+
[iops->create() takes struct mnt_idmap*])
4361
],[
4462
AC_MSG_RESULT(no)
4563
46-
AC_MSG_CHECKING([whether iops->create() passes flags])
47-
ZFS_LINUX_TEST_RESULT([create_flags], [
64+
AC_MSG_CHECKING([whether iops->create() takes struct user_namespace*])
65+
ZFS_LINUX_TEST_RESULT([create_userns], [
4866
AC_MSG_RESULT(yes)
67+
AC_DEFINE(HAVE_IOPS_CREATE_USERNS, 1,
68+
[iops->create() takes struct user_namespace*])
4969
],[
50-
ZFS_LINUX_TEST_ERROR([iops->create()])
70+
AC_MSG_RESULT(no)
71+
72+
AC_MSG_CHECKING([whether iops->create() passes flags])
73+
ZFS_LINUX_TEST_RESULT([create_flags], [
74+
AC_MSG_RESULT(yes)
75+
],[
76+
ZFS_LINUX_TEST_ERROR([iops->create()])
77+
])
5178
])
5279
])
5380
])

config/kernel-inode-getattr.m4

Lines changed: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_GETATTR], [
2+
dnl #
3+
dnl # Linux 6.3 API
4+
dnl # The first arg of getattr I/O operations handler type
5+
dnl # is changed to struct mnt_idmap*
6+
dnl #
7+
ZFS_LINUX_TEST_SRC([inode_operations_getattr_mnt_idmap], [
8+
#include <linux/fs.h>
9+
10+
int test_getattr(
11+
struct mnt_idmap *idmap,
12+
const struct path *p, struct kstat *k,
13+
u32 request_mask, unsigned int query_flags)
14+
{ return 0; }
15+
16+
static const struct inode_operations
17+
iops __attribute__ ((unused)) = {
18+
.getattr = test_getattr,
19+
};
20+
],[])
21+
222
dnl #
323
dnl # Linux 5.12 API
424
dnl # The getattr I/O operations handler type was extended to require
@@ -55,37 +75,48 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_GETATTR], [
5575

5676
AC_DEFUN([ZFS_AC_KERNEL_INODE_GETATTR], [
5777
dnl #
58-
dnl # Kernel 5.12 test
78+
dnl # Kernel 6.3 test
5979
dnl #
60-
AC_MSG_CHECKING([whether iops->getattr() takes user_namespace])
61-
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_userns], [
80+
AC_MSG_CHECKING([whether iops->getattr() takes mnt_idmap])
81+
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_mnt_idmap], [
6282
AC_MSG_RESULT(yes)
63-
AC_DEFINE(HAVE_USERNS_IOPS_GETATTR, 1,
64-
[iops->getattr() takes struct user_namespace*])
83+
AC_DEFINE(HAVE_IDMAP_IOPS_GETATTR, 1,
84+
[iops->getattr() takes struct mnt_idmap*])
6585
],[
6686
AC_MSG_RESULT(no)
67-
6887
dnl #
69-
dnl # Kernel 4.11 test
88+
dnl # Kernel 5.12 test
7089
dnl #
71-
AC_MSG_CHECKING([whether iops->getattr() takes a path])
72-
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_path], [
90+
AC_MSG_CHECKING([whether iops->getattr() takes user_namespace])
91+
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_userns], [
7392
AC_MSG_RESULT(yes)
74-
AC_DEFINE(HAVE_PATH_IOPS_GETATTR, 1,
75-
[iops->getattr() takes a path])
93+
AC_DEFINE(HAVE_USERNS_IOPS_GETATTR, 1,
94+
[iops->getattr() takes struct user_namespace*])
7695
],[
7796
AC_MSG_RESULT(no)
7897
7998
dnl #
80-
dnl # Kernel < 4.11 test
99+
dnl # Kernel 4.11 test
81100
dnl #
82-
AC_MSG_CHECKING([whether iops->getattr() takes a vfsmount])
83-
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_vfsmount], [
101+
AC_MSG_CHECKING([whether iops->getattr() takes a path])
102+
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_path], [
84103
AC_MSG_RESULT(yes)
85-
AC_DEFINE(HAVE_VFSMOUNT_IOPS_GETATTR, 1,
86-
[iops->getattr() takes a vfsmount])
104+
AC_DEFINE(HAVE_PATH_IOPS_GETATTR, 1,
105+
[iops->getattr() takes a path])
87106
],[
88107
AC_MSG_RESULT(no)
108+
109+
dnl #
110+
dnl # Kernel < 4.11 test
111+
dnl #
112+
AC_MSG_CHECKING([whether iops->getattr() takes a vfsmount])
113+
ZFS_LINUX_TEST_RESULT([inode_operations_getattr_vfsmount], [
114+
AC_MSG_RESULT(yes)
115+
AC_DEFINE(HAVE_VFSMOUNT_IOPS_GETATTR, 1,
116+
[iops->getattr() takes a vfsmount])
117+
],[
118+
AC_MSG_RESULT(no)
119+
])
89120
])
90121
])
91122
])

config/kernel-inode-permission.m4

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
11
AC_DEFUN([ZFS_AC_KERNEL_SRC_PERMISSION], [
2+
dnl #
3+
dnl # 6.3 API change
4+
dnl # iops->permission() now takes struct mnt_idmap*
5+
dnl # as its first arg
6+
dnl #
7+
ZFS_LINUX_TEST_SRC([permission_mnt_idmap], [
8+
#include <linux/fs.h>
9+
#include <linux/sched.h>
10+
11+
int inode_permission(struct mnt_idmap *idmap,
12+
struct inode *inode, int mask) { return 0; }
13+
14+
static const struct inode_operations
15+
iops __attribute__ ((unused)) = {
16+
.permission = inode_permission,
17+
};
18+
],[])
19+
220
dnl #
321
dnl # 5.12 API change that added the struct user_namespace* arg
422
dnl # to the front of this function type's arg list.
@@ -18,12 +36,19 @@ AC_DEFUN([ZFS_AC_KERNEL_SRC_PERMISSION], [
1836
])
1937

2038
AC_DEFUN([ZFS_AC_KERNEL_PERMISSION], [
21-
AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*])
22-
ZFS_LINUX_TEST_RESULT([permission_userns], [
39+
AC_MSG_CHECKING([whether iops->permission() takes struct mnt_idmap*])
40+
ZFS_LINUX_TEST_RESULT([permission_mnt_idmap], [
2341
AC_MSG_RESULT(yes)
24-
AC_DEFINE(HAVE_IOPS_PERMISSION_USERNS, 1,
25-
[iops->permission() takes struct user_namespace*])
42+
AC_DEFINE(HAVE_IOPS_PERMISSION_IDMAP, 1,
43+
[iops->permission() takes struct mnt_idmap*])
2644
],[
27-
AC_MSG_RESULT(no)
45+
AC_MSG_CHECKING([whether iops->permission() takes struct user_namespace*])
46+
ZFS_LINUX_TEST_RESULT([permission_userns], [
47+
AC_MSG_RESULT(yes)
48+
AC_DEFINE(HAVE_IOPS_PERMISSION_USERNS, 1,
49+
[iops->permission() takes struct user_namespace*])
50+
],[
51+
AC_MSG_RESULT(no)
52+
])
2853
])
2954
])

config/kernel-inode-setattr.m4

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
AC_DEFUN([ZFS_AC_KERNEL_SRC_INODE_SETATTR], [
2+
dnl #
3+
dnl # Linux 6.3 API
4+
dnl # The first arg of setattr I/O operations handler type
5+
dnl # is changed to struct mnt_idmap*
6+
dnl #
7+
ZFS_LINUX_TEST_SRC([inode_operations_setattr_mnt_idmap], [
8+
#include <linux/fs.h>
9+
10+
int test_setattr(
11+
struct mnt_idmap *idmap,
12+
struct dentry *de, struct iattr *ia)
13+
{ return 0; }
14+
15+
static const struct inode_operations
16+
iops __attribute__ ((unused)) = {
17+
.setattr = test_setattr,
18+
};
19+
],[])
20+
21+
dnl #
22+
dnl # Linux 5.12 API
23+
dnl # The setattr I/O operations handler type was extended to require
24+
dnl # a struct user_namespace* as its first arg, to support idmapped
25+
dnl # mounts.
26+
dnl #
27+
ZFS_LINUX_TEST_SRC([inode_operations_setattr_userns], [
28+
#include <linux/fs.h>
29+
30+
int test_setattr(
31+
struct user_namespace *userns,
32+
struct dentry *de, struct iattr *ia)
33+
{ return 0; }
34+
35+
static const struct inode_operations
36+
iops __attribute__ ((unused)) = {
37+
.setattr = test_setattr,
38+
};
39+
],[])
40+
41+
ZFS_LINUX_TEST_SRC([inode_operations_setattr], [
42+
#include <linux/fs.h>
43+
44+
int test_setattr(
45+
struct dentry *de, struct iattr *ia)
46+
{ return 0; }
47+
48+
static const struct inode_operations
49+
iops __attribute__ ((unused)) = {
50+
.setattr = test_setattr,
51+
};
52+
],[])
53+
])
54+
55+
AC_DEFUN([ZFS_AC_KERNEL_INODE_SETATTR], [
56+
dnl #
57+
dnl # Kernel 6.3 test
58+
dnl #
59+
AC_MSG_CHECKING([whether iops->setattr() takes mnt_idmap])
60+
ZFS_LINUX_TEST_RESULT([inode_operations_setattr_mnt_idmap], [
61+
AC_MSG_RESULT(yes)
62+
AC_DEFINE(HAVE_IDMAP_IOPS_SETATTR, 1,
63+
[iops->setattr() takes struct mnt_idmap*])
64+
],[
65+
AC_MSG_RESULT(no)
66+
dnl #
67+
dnl # Kernel 5.12 test
68+
dnl #
69+
AC_MSG_CHECKING([whether iops->setattr() takes user_namespace])
70+
ZFS_LINUX_TEST_RESULT([inode_operations_setattr_userns], [
71+
AC_MSG_RESULT(yes)
72+
AC_DEFINE(HAVE_USERNS_IOPS_SETATTR, 1,
73+
[iops->setattr() takes struct user_namespace*])
74+
],[
75+
AC_MSG_RESULT(no)
76+
77+
AC_MSG_CHECKING([whether iops->setattr() exists])
78+
ZFS_LINUX_TEST_RESULT([inode_operations_setattr], [
79+
AC_MSG_RESULT(yes)
80+
AC_DEFINE(HAVE_IOPS_SETATTR, 1,
81+
[iops->setattr() exists])
82+
],[
83+
AC_MSG_RESULT(no)
84+
])
85+
])
86+
])
87+
])

0 commit comments

Comments
 (0)