1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
From 66f494869c183a010a40397221e55c625e5d2e8b Mon Sep 17 00:00:00 2001
From: Jeff Mahoney <jeffm@suse.com>
Date: Wed, 20 Mar 2013 17:33:17 -0400
Subject: [PATCH 2/7] LU-2850 compat: posix_acl_{to,from}_xattr take
user_namespace
Commit 5f3a4a28 (v3.7) added a struct user_namespace argument to
posix_acl_{to,from}_xattr. Pretty much every caller just uses
&init_user_ns. We mask it off in user mode so we don't need to
create a fake structure only to ignore it.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Change-Id: I558a06941b364f241fd4423720957beeaf1d3cea
---
libcfs/include/libcfs/darwin/darwin-fs.h | 6 ++++--
libcfs/include/libcfs/linux/linux-fs.h | 10 ++++++++++
lustre/autoconf/lustre-core.m4 | 21 +++++++++++++++++++++
lustre/include/liblustre.h | 4 ++++
lustre/llite/xattr.c | 2 +-
lustre/mdc/mdc_request.c | 3 ++-
6 files changed, 42 insertions(+), 4 deletions(-)
diff --git a/libcfs/include/libcfs/darwin/darwin-fs.h b/libcfs/include/libcfs/darwin/darwin-fs.h
index 998823b..9f71d6a 100644
--- a/libcfs/include/libcfs/darwin/darwin-fs.h
+++ b/libcfs/include/libcfs/darwin/darwin-fs.h
@@ -171,11 +171,13 @@ struct posix_acl {
};
struct posix_acl *posix_acl_alloc(int count, int flags);
-static inline struct posix_acl *posix_acl_from_xattr(const void *value,
+static inline struct posix_acl *posix_acl_from_xattr(const void *value,
size_t size)
-{
+{
return posix_acl_alloc(0, 0);
}
+#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c)
+
static inline void posix_acl_release(struct posix_acl *acl) {};
static inline int posix_acl_valid(const struct posix_acl *acl) { return 0; }
static inline struct posix_acl * posix_acl_dup(struct posix_acl *acl)
diff --git a/libcfs/include/libcfs/linux/linux-fs.h b/libcfs/include/libcfs/linux/linux-fs.h
index 53975ab..fa4e4d4 100644
--- a/libcfs/include/libcfs/linux/linux-fs.h
+++ b/libcfs/include/libcfs/linux/linux-fs.h
@@ -53,6 +53,7 @@
#include <linux/stat.h>
#include <linux/mount.h>
#include <linux/backing-dev.h>
+#include <linux/posix_acl_xattr.h>
#define filp_size(f) \
(i_size_read((f)->f_dentry->d_inode))
@@ -102,4 +103,13 @@ ssize_t filp_user_write(struct file *filp, const void *buf, size_t count,
#define DTTOIF(dirtype) ((dirtype) << IFSHIFT)
#endif
+#ifndef HAVE_POSIXACL_USER_NS
+/*
+ * Mask out &init_user_ns so we don't jump
+ * through hoops to define it somehow only
+ * to have it ignored anyway.
+ */
+#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c)
+#define posix_acl_to_xattr(a,b,c,d) posix_acl_to_xattr(b,c,d)
+#endif
#endif
diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4
index 601155c..125bde7 100644
--- a/lustre/autoconf/lustre-core.m4
+++ b/lustre/autoconf/lustre-core.m4
@@ -2233,6 +2233,25 @@ LB_LINUX_TRY_COMPILE([
])
#
+# 3.7 posix_acl_{to,from}_xattr take struct user_namespace
+#
+AC_DEFUN([LC_HAVE_POSIXACL_USER_NS],
+[AC_MSG_CHECKING([if posix_acl_to_xattr takes struct user_namespace])
+LB_LINUX_TRY_COMPILE([
+ #include <linux/fs.h>
+ #include <linux/posix_acl_xattr.h>
+],[
+ posix_acl_to_xattr((struct user_namespace *)NULL, NULL, NULL, 0);
+],[
+ AC_DEFINE(HAVE_POSIXACL_USER_NS, 1,
+ [posix_acl_to_xattr takes struct user_namespace])
+ AC_MSG_RESULT([yes])
+],[
+ AC_MSG_RESULT([no])
+])
+])
+
+#
# LC_PROG_LINUX
#
# Lustre linux kernel checks
@@ -2414,6 +2433,8 @@ AC_DEFUN([LC_PROG_LINUX],
LC_DENTRY_OPEN_USE_PATH
LC_HAVE_IOP_ATOMIC_OPEN
+ # 3.7
+ LC_HAVE_POSIXACL_USER_NS
#
if test x$enable_server = xyes ; then
AC_DEFINE(HAVE_SERVER_SUPPORT, 1, [support server])
diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h
index 14f3ef6..eb62458 100644
--- a/lustre/include/liblustre.h
+++ b/lustre/include/liblustre.h
@@ -458,6 +458,10 @@ struct posix_acl * posix_acl_from_xattr(const void *value, size_t size)
return NULL;
}
+/* The kernel version takes 3 arguments, so strip that off first. */
+#define posix_acl_from_xattr(a,b,c) posix_acl_from_xattr(b,c)
+#define posix_acl_to_xattr(a,b,c) posix_acl_to_xattr(b,c)
+
static inline
int posix_acl_valid(const struct posix_acl *acl)
{
diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c
index 24a89eb..9575739 100644
--- a/lustre/llite/xattr.c
+++ b/lustre/llite/xattr.c
@@ -345,7 +345,7 @@ int ll_getxattr_common(struct inode *inode, const char *name,
if (!acl)
RETURN(-ENODATA);
- rc = posix_acl_to_xattr(acl, buffer, size);
+ rc = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
posix_acl_release(acl);
RETURN(rc);
}
diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c
index fd087a5..d67db9d 100644
--- a/lustre/mdc/mdc_request.c
+++ b/lustre/mdc/mdc_request.c
@@ -41,6 +41,7 @@
# include <linux/pagemap.h>
# include <linux/miscdevice.h>
# include <linux/init.h>
+# include <linux/utsname.h>
#else
# include <liblustre.h>
#endif
@@ -466,7 +467,7 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
if (!buf)
RETURN(-EPROTO);
- acl = posix_acl_from_xattr(buf, body->aclsize);
+ acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize);
if (IS_ERR(acl)) {
rc = PTR_ERR(acl);
CERROR("convert xattr to acl: %d\n", rc);
--
1.8.1.5
|