Linux 4.7 compat: handler->set() takes both dentry and inode

Counterpart to fd4c7b7, the same approach was taken to resolve
the compatibility issue.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes #4717
Issue #4665
This commit is contained in:
Brian Behlendorf 2016-06-01 18:10:06 -07:00 committed by Ned Bass
parent 7043281906
commit 01d9981349
2 changed files with 69 additions and 30 deletions

View File

@ -81,7 +81,7 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_GET], [
],[ ],[
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE, 1, AC_DEFINE(HAVE_XATTR_GET_DENTRY_INODE, 1,
[xattr_handler->get() wants xattr_handler]) [xattr_handler->get() wants both dentry and inode])
],[ ],[
dnl # dnl #
dnl # 4.4 API change, dnl # 4.4 API change,
@ -163,18 +163,18 @@ dnl # Supported xattr handler set() interfaces checked newest to oldest.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
dnl # dnl #
dnl # 4.4 API change, dnl # 4.7 API change,
dnl # The xattr_handler->set() callback was changed to take a dnl # The xattr_handler->set() callback was changed to take both
dnl # xattr_handler, and handler_flags argument was removed and dnl # dentry and inode.
dnl # should be accessed by handler->flags.
dnl # dnl #
AC_MSG_CHECKING([whether xattr_handler->set() wants xattr_handler]) AC_MSG_CHECKING([whether xattr_handler->set() wants both dentry and inode])
ZFS_LINUX_TRY_COMPILE([ ZFS_LINUX_TRY_COMPILE([
#include <linux/xattr.h> #include <linux/xattr.h>
int set(const struct xattr_handler *handler, int set(const struct xattr_handler *handler,
struct dentry *dentry, const char *name, struct dentry *dentry, struct inode *inode,
const void *buffer, size_t size, int flags) const char *name, const void *buffer,
size_t size, int flags)
{ return 0; } { return 0; }
static const struct xattr_handler static const struct xattr_handler
xops __attribute__ ((unused)) = { xops __attribute__ ((unused)) = {
@ -183,23 +183,23 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
],[ ],[
],[ ],[
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_SET_HANDLER, 1, AC_DEFINE(HAVE_XATTR_SET_DENTRY_INODE, 1,
[xattr_handler->set() wants xattr_handler]) [xattr_handler->set() wants both dentry and inode])
],[ ],[
dnl # dnl #
dnl # 2.6.33 API change, dnl # 4.4 API change,
dnl # The xattr_handler->set() callback was changed to take a dnl # The xattr_handler->set() callback was changed to take a
dnl # dentry instead of an inode, and a handler_flags dnl # xattr_handler, and handler_flags argument was removed and
dnl # argument was added. dnl # should be accessed by handler->flags.
dnl # dnl #
AC_MSG_RESULT(no) AC_MSG_CHECKING([whether xattr_handler->set() wants xattr_handler])
AC_MSG_CHECKING([whether xattr_handler->set() wants dentry])
ZFS_LINUX_TRY_COMPILE([ ZFS_LINUX_TRY_COMPILE([
#include <linux/xattr.h> #include <linux/xattr.h>
int set(struct dentry *dentry, const char *name, int set(const struct xattr_handler *handler,
const void *buffer, size_t size, int flags, struct dentry *dentry, const char *name,
int handler_flags) { return 0; } const void *buffer, size_t size, int flags)
{ return 0; }
static const struct xattr_handler static const struct xattr_handler
xops __attribute__ ((unused)) = { xops __attribute__ ((unused)) = {
.set = set, .set = set,
@ -207,21 +207,23 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
],[ ],[
],[ ],[
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_SET_DENTRY, 1, AC_DEFINE(HAVE_XATTR_SET_HANDLER, 1,
[xattr_handler->set() wants dentry]) [xattr_handler->set() wants xattr_handler])
],[ ],[
dnl # dnl #
dnl # 2.6.32 API dnl # 2.6.33 API change,
dnl # The xattr_handler->set() callback was changed to take a
dnl # dentry instead of an inode, and a handler_flags
dnl # argument was added.
dnl # dnl #
AC_MSG_RESULT(no) AC_MSG_RESULT(no)
AC_MSG_CHECKING( AC_MSG_CHECKING([whether xattr_handler->set() wants dentry])
[whether xattr_handler->set() wants inode])
ZFS_LINUX_TRY_COMPILE([ ZFS_LINUX_TRY_COMPILE([
#include <linux/xattr.h> #include <linux/xattr.h>
int set(struct inode *ip, const char *name, int set(struct dentry *dentry, const char *name,
const void *buffer, size_t size, int flags) const void *buffer, size_t size, int flags,
{ return 0; } int handler_flags) { return 0; }
static const struct xattr_handler static const struct xattr_handler
xops __attribute__ ((unused)) = { xops __attribute__ ((unused)) = {
.set = set, .set = set,
@ -229,10 +231,33 @@ AC_DEFUN([ZFS_AC_KERNEL_XATTR_HANDLER_SET], [
],[ ],[
],[ ],[
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_SET_INODE, 1, AC_DEFINE(HAVE_XATTR_SET_DENTRY, 1,
[xattr_handler->set() wants inode]) [xattr_handler->set() wants dentry])
],[ ],[
AC_MSG_ERROR([no; please file a bug report]) dnl #
dnl # 2.6.32 API
dnl #
AC_MSG_RESULT(no)
AC_MSG_CHECKING(
[whether xattr_handler->set() wants inode])
ZFS_LINUX_TRY_COMPILE([
#include <linux/xattr.h>
int set(struct inode *ip, const char *name,
const void *buffer, size_t size, int flags)
{ return 0; }
static const struct xattr_handler
xops __attribute__ ((unused)) = {
.set = set,
};
],[
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_XATTR_SET_INODE, 1,
[xattr_handler->set() wants inode])
],[
AC_MSG_ERROR([no; please file a bug report])
])
]) ])
]) ])
]) ])

View File

@ -153,13 +153,27 @@ fn(struct inode *ip, const char *name, void *buffer, size_t size) \
} }
#endif #endif
/*
* 4.7 API change,
* The xattr_handler->set() callback was changed to take a both dentry and
* inode, because the dentry might not be attached to an inode yet.
*/
#if defined(HAVE_XATTR_SET_DENTRY_INODE)
#define ZPL_XATTR_SET_WRAPPER(fn) \
static int \
fn(const struct xattr_handler *handler, struct dentry *dentry, \
struct inode *inode, const char *name, const void *buffer, \
size_t size, int flags) \
{ \
return (__ ## fn(inode, name, buffer, size, flags)); \
}
/* /*
* 4.4 API change, * 4.4 API change,
* The xattr_handler->set() callback was changed to take a xattr_handler, * The xattr_handler->set() callback was changed to take a xattr_handler,
* and handler_flags argument was removed and should be accessed by * and handler_flags argument was removed and should be accessed by
* handler->flags. * handler->flags.
*/ */
#if defined(HAVE_XATTR_SET_HANDLER) #elif defined(HAVE_XATTR_SET_HANDLER)
#define ZPL_XATTR_SET_WRAPPER(fn) \ #define ZPL_XATTR_SET_WRAPPER(fn) \
static int \ static int \
fn(const struct xattr_handler *handler, struct dentry *dentry, \ fn(const struct xattr_handler *handler, struct dentry *dentry, \