]>
Commit | Line | Data |
---|---|---|
75b07eca FG |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Tony Hutter <hutter2@llnl.gov> | |
3 | Date: Thu, 22 Feb 2018 09:02:06 -0800 | |
4 | Subject: [PATCH] Linux 4.16 compat: use correct *_dec_and_test() | |
5 | MIME-Version: 1.0 | |
6 | Content-Type: text/plain; charset=UTF-8 | |
7 | Content-Transfer-Encoding: 8bit | |
8 | ||
9 | Use refcount_dec_and_test() on 4.16+ kernels, atomic_dec_and_test() | |
10 | on older kernels. https://lwn.net/Articles/714974/ | |
11 | ||
12 | Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov> | |
13 | Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> | |
14 | Signed-off-by: Tony Hutter <hutter2@llnl.gov> | |
15 | Closes: #7179 | |
16 | Closes: #7211 | |
17 | (cherry picked from commit e5ba614d05bde1e98ba46d5b75cf6b8a0701c2ca) | |
18 | Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com> | |
19 | --- | |
20 | include/linux/vfs_compat.h | 6 +++++- | |
21 | config/kernel-acl-refcount.m4 | 20 ++++++++++++++++++++ | |
22 | config/kernel.m4 | 1 + | |
23 | 3 files changed, 26 insertions(+), 1 deletion(-) | |
24 | create mode 100644 config/kernel-acl-refcount.m4 | |
25 | ||
26 | diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h | |
27 | index 7fcf3c055..6347268af 100644 | |
28 | --- a/include/linux/vfs_compat.h | |
29 | +++ b/include/linux/vfs_compat.h | |
30 | @@ -288,9 +288,13 @@ zpl_posix_acl_release(struct posix_acl *acl) | |
31 | { | |
32 | if ((acl == NULL) || (acl == ACL_NOT_CACHED)) | |
33 | return; | |
34 | - | |
35 | +#ifdef HAVE_ACL_REFCOUNT | |
36 | + if (refcount_dec_and_test(&acl->a_refcount)) | |
37 | + zpl_posix_acl_release_impl(acl); | |
38 | +#else | |
39 | if (atomic_dec_and_test(&acl->a_refcount)) | |
40 | zpl_posix_acl_release_impl(acl); | |
41 | +#endif | |
42 | } | |
43 | #endif /* HAVE_POSIX_ACL_RELEASE */ | |
44 | ||
45 | diff --git a/config/kernel-acl-refcount.m4 b/config/kernel-acl-refcount.m4 | |
46 | new file mode 100644 | |
47 | index 000000000..43e3c442d | |
48 | --- /dev/null | |
49 | +++ b/config/kernel-acl-refcount.m4 | |
50 | @@ -0,0 +1,20 @@ | |
51 | +dnl # | |
52 | +dnl # 4.16 kernel: check if struct posix_acl acl.a_refcount is a refcount_t. | |
53 | +dnl # It's an atomic_t on older kernels. | |
54 | +dnl # | |
55 | +AC_DEFUN([ZFS_AC_KERNEL_ACL_HAS_REFCOUNT], [ | |
56 | + AC_MSG_CHECKING([whether posix_acl has refcount_t]) | |
57 | + ZFS_LINUX_TRY_COMPILE([ | |
58 | + #include <linux/backing-dev.h> | |
59 | + #include <linux/refcount.h> | |
60 | + #include <linux/posix_acl.h> | |
61 | + ],[ | |
62 | + struct posix_acl acl; | |
63 | + refcount_t *r __attribute__ ((unused)) = &acl.a_refcount; | |
64 | + ],[ | |
65 | + AC_MSG_RESULT(yes) | |
66 | + AC_DEFINE(HAVE_ACL_REFCOUNT, 1, [posix_acl has refcount_t]) | |
67 | + ],[ | |
68 | + AC_MSG_RESULT(no) | |
69 | + ]) | |
70 | +]) | |
71 | diff --git a/config/kernel.m4 b/config/kernel.m4 | |
72 | index d4a84b2b2..7bb86a96e 100644 | |
73 | --- a/config/kernel.m4 | |
74 | +++ b/config/kernel.m4 | |
75 | @@ -124,6 +124,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ | |
76 | ZFS_AC_KERNEL_HAVE_GENERIC_SETXATTR | |
77 | ZFS_AC_KERNEL_CURRENT_TIME | |
78 | ZFS_AC_KERNEL_VM_NODE_STAT | |
79 | + ZFS_AC_KERNEL_ACL_HAS_REFCOUNT | |
80 | ||
81 | AS_IF([test "$LINUX_OBJ" != "$LINUX"], [ | |
82 | KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ" | |
83 | -- | |
84 | 2.14.2 | |
85 |