Skip to content

Commit 53841ab

Browse files
committed
Update the xattr_set() interface for the 5.12 user_namespace API changes
Some more additions that update the ZPL_XATTR_SET_WRAPPER() macro such that it will build interface functions that adopt the struct user_namespace* argument as the second arg, if that is the implementation required in the kernel (determined by configure). This was added to support idmapped FS mounts in Linux 5.12. Signed-off-by: Coleman Kane <[email protected]>
1 parent 6f526b2 commit 53841ab

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

config/kernel-xattr-handler.m4

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ dnl #
152152
dnl # Supported xattr handler set() interfaces checked newest to oldest.
153153
dnl #
154154
AC_DEFUN([ZFS_AC_KERNEL_SRC_XATTR_HANDLER_SET], [
155-
ZFS_LINUX_TEST_SRC([xattr_handler_set_dentry_inode_user_ns], [
155+
ZFS_LINUX_TEST_SRC([xattr_handler_set_userns], [
156156
#include <linux/xattr.h>
157157
158158
int set(const struct xattr_handler *handler,
@@ -214,16 +214,17 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
214214
dnl # struct user_namespace* was inserted as arg #2
215215
dnl #
216216
AC_MSG_CHECKING([whether xattr_handler->set() wants dentry, inode, and user_namespace])
217-
ZFS_LINUX_TEST_RESULT([xattr_handler_set_dentry_inode_user_ns], [
217+
ZFS_LINUX_TEST_RESULT([xattr_handler_set_userns], [
218218
AC_MSG_RESULT(yes)
219-
AC_DEFINE(HAVE_XATTR_SET_DENTRY_INODE_USER_NS, 1,
220-
[xattr_handler->set() wants dentry, inode, and user_namespace])
219+
AC_DEFINE(HAVE_XATTR_SET_USERNS, 1,
220+
[xattr_handler->set() takes user_namespace])
221221
],[
222222
dnl #
223223
dnl # 4.7 API change,
224224
dnl # The xattr_handler->set() callback was changed to take both
225225
dnl # dentry and inode.
226226
dnl #
227+
AC_MSG_RESULT(no)
227228
AC_MSG_CHECKING([whether xattr_handler->set() wants dentry and inode])
228229
ZFS_LINUX_TEST_RESULT([xattr_handler_set_dentry_inode], [
229230
AC_MSG_RESULT(yes)

include/os/linux/kernel/linux/xattr_compat.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,27 @@ fn(struct dentry *dentry, const char *name, void *buffer, size_t size, \
119119
#error "Unsupported kernel"
120120
#endif
121121

122+
/*
123+
* 5.12 API change,
124+
* The xattr_handler->set() callback was changed to take the
125+
* struct user_namespace* as the first arg, to support idmapped
126+
* mounts.
127+
*/
128+
#if defined(HAVE_XATTR_SET_USERNS)
129+
#define ZPL_XATTR_SET_WRAPPER(fn) \
130+
static int \
131+
fn(const struct xattr_handler *handler, struct user_namespace *user_ns, \
132+
struct dentry *dentry, struct inode *inode, const char *name, \
133+
const void *buffer, size_t size, int flags) \
134+
{ \
135+
return (__ ## fn(inode, name, buffer, size, flags)); \
136+
}
122137
/*
123138
* 4.7 API change,
124139
* The xattr_handler->set() callback was changed to take a both dentry and
125140
* inode, because the dentry might not be attached to an inode yet.
126141
*/
127-
#if defined(HAVE_XATTR_SET_DENTRY_INODE)
142+
#elif defined(HAVE_XATTR_SET_DENTRY_INODE)
128143
#define ZPL_XATTR_SET_WRAPPER(fn) \
129144
static int \
130145
fn(const struct xattr_handler *handler, struct dentry *dentry, \

0 commit comments

Comments
 (0)