Whamcloud - gitweb
LU-9183 ptlrpc: handle posix_acl: xattr representation cleanups 92/25892/17
authorDmitry Eremin <dmitry.eremin@intel.com>
Tue, 7 Mar 2017 18:03:53 +0000 (21:03 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 24 May 2017 15:05:50 +0000 (15:05 +0000)
In commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621 typedef of
posix_acl_xattr_{header,entry} was removed and replaced with
struct posix_acl_xattr_{header,entry} declaration. Also member
a_entries was removed from struct posix_acl_xattr_header.

Since we have to support older kernels this patch does the
opposite of what was done upstream in that we treat struct
posix_acl_xattr_{header,entry} of newer kernels as the typedef
used by older kernels.

Change-Id: I880f73d495dc6c35a1671b49e509350118f6e154
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/25892
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_compat.h
lustre/include/lustre_eacl.h
lustre/mdd/mdd_permission.c
lustre/ptlrpc/nodemap_handler.c
lustre/ptlrpc/wiretest.c

index 9a89cae..46d2ca8 100644 (file)
@@ -2446,6 +2446,27 @@ group_info_gid, [
 ]) # LC_GROUP_INFO_GID
 
 #
 ]) # LC_GROUP_INFO_GID
 
 #
+# LC_STRUCT_POSIX_ACL_XATTR
+#
+# Kernel version 4.8 commit 2211d5ba5c6c4e972ba6dbc912b2897425ea6621
+# posix_acl: xattr representation cleanups
+#
+AC_DEFUN([LC_STRUCT_POSIX_ACL_XATTR], [
+LB_CHECK_COMPILE([if 'struct posix_acl_xattr_{header,entry}' defined],
+struct_posix_acl_xattr, [
+       #include <linux/fs.h>
+       #include <linux/posix_acl_xattr.h>
+],[
+       struct posix_acl_xattr_header *h = NULL;
+       struct posix_acl_xattr_entry  *e;
+       e = (void *)(h + 1);
+],[
+       AC_DEFINE(HAVE_STRUCT_POSIX_ACL_XATTR, 1,
+               [struct posix_acl_xattr_{header,entry} defined])
+])
+]) # LC_STRUCT_POSIX_ACL_XATTR
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -2644,6 +2665,7 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_HAVE_POSIX_ACL_VALID_USER_NS
        LC_D_COMPARE_4ARGS
        LC_FULL_NAME_HASH_3ARGS
        LC_HAVE_POSIX_ACL_VALID_USER_NS
        LC_D_COMPARE_4ARGS
        LC_FULL_NAME_HASH_3ARGS
+       LC_STRUCT_POSIX_ACL_XATTR
 
        # 4.9
        LC_GROUP_INFO_GID
 
        # 4.9
        LC_GROUP_INFO_GID
index 6d039ea..8eff04d 100644 (file)
@@ -434,4 +434,12 @@ static inline void truncate_inode_pages_final(struct address_space *map)
 # define ll_full_name_hash(salt, name, len) full_name_hash(name, len)
 #endif
 
 # define ll_full_name_hash(salt, name, len) full_name_hash(name, len)
 #endif
 
+#ifdef HAVE_STRUCT_POSIX_ACL_XATTR
+# define posix_acl_xattr_header struct posix_acl_xattr_header
+# define posix_acl_xattr_entry  struct posix_acl_xattr_entry
+# define GET_POSIX_ACL_XATTR_ENTRY(head) ((void *)((head) + 1))
+#else
+# define GET_POSIX_ACL_XATTR_ENTRY(head) ((head)->a_entries)
+#endif
+
 #endif /* _LUSTRE_COMPAT_H */
 #endif /* _LUSTRE_COMPAT_H */
index e8bcb25..3061be1 100644 (file)
@@ -71,6 +71,11 @@ struct lu_ucred;
 struct lu_attr;
 struct lustre_idmap_table;
 
 struct lu_attr;
 struct lustre_idmap_table;
 
+#ifdef HAVE_STRUCT_POSIX_ACL_XATTR
+# define posix_acl_xattr_header struct posix_acl_xattr_header
+# define posix_acl_xattr_entry  struct posix_acl_xattr_entry
+#endif
+
 extern int lustre_posix_acl_permission(struct lu_ucred *mu,
                                        const struct lu_attr *la, int want,
                                        posix_acl_xattr_entry *entry,
 extern int lustre_posix_acl_permission(struct lu_ucred *mu,
                                        const struct lu_attr *la, int want,
                                        posix_acl_xattr_entry *entry,
index 5f9eceb..4b4f9b9 100644 (file)
@@ -73,7 +73,7 @@ int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
 
        buf.lb_len = rc;
        head = (posix_acl_xattr_header *)(buf.lb_buf);
 
        buf.lb_len = rc;
        head = (posix_acl_xattr_header *)(buf.lb_buf);
-       entry = head->a_entries;
+       entry = GET_POSIX_ACL_XATTR_ENTRY(head);
        entry_count = (buf.lb_len - sizeof(head->a_version)) /
                sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
        entry_count = (buf.lb_len - sizeof(head->a_version)) /
                sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
@@ -102,7 +102,7 @@ int mdd_acl_set(const struct lu_env *env, struct mdd_object *obj,
        ENTRY;
 
        head = (posix_acl_xattr_header *)(buf->lb_buf);
        ENTRY;
 
        head = (posix_acl_xattr_header *)(buf->lb_buf);
-       entry = head->a_entries;
+       entry = GET_POSIX_ACL_XATTR_ENTRY(head);
        entry_count = (buf->lb_len - sizeof(head->a_version)) /
                sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
        entry_count = (buf->lb_len - sizeof(head->a_version)) /
                sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
@@ -182,7 +182,7 @@ int __mdd_fix_mode_acl(const struct lu_env *env, struct lu_buf *buf,
        ENTRY;
 
        head = (posix_acl_xattr_header *)(buf->lb_buf);
        ENTRY;
 
        head = (posix_acl_xattr_header *)(buf->lb_buf);
-       entry = head->a_entries;
+       entry = GET_POSIX_ACL_XATTR_ENTRY(head);
        entry_count = (buf->lb_len - sizeof(head->a_version)) /
                      sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
        entry_count = (buf->lb_len - sizeof(head->a_version)) /
                      sizeof(posix_acl_xattr_entry);
        if (entry_count <= 0)
@@ -219,7 +219,7 @@ static int mdd_check_acl(const struct lu_env *env, struct mdd_object *obj,
 
        buf.lb_len = rc;
        head = (posix_acl_xattr_header *)(buf.lb_buf);
 
        buf.lb_len = rc;
        head = (posix_acl_xattr_header *)(buf.lb_buf);
-       entry = head->a_entries;
+       entry = GET_POSIX_ACL_XATTR_ENTRY(head);
        entry_count = posix_acl_xattr_count(buf.lb_len);
 
        /* Disregard empty ACLs and fall back to
        entry_count = posix_acl_xattr_count(buf.lb_len);
 
        /* Disregard empty ACLs and fall back to
index b438dda..1ea5c7c 100644 (file)
@@ -696,7 +696,7 @@ ssize_t nodemap_map_acl(struct lu_nodemap *nodemap, void *buf, size_t size,
                        enum nodemap_tree_type tree_type)
 {
        posix_acl_xattr_header  *header = buf;
                        enum nodemap_tree_type tree_type)
 {
        posix_acl_xattr_header  *header = buf;
-       posix_acl_xattr_entry   *entry = &header->a_entries[0];
+       posix_acl_xattr_entry   *entry = GET_POSIX_ACL_XATTR_ENTRY(header);
        posix_acl_xattr_entry   *new_entry = entry;
        posix_acl_xattr_entry   *end;
        int                      count;
        posix_acl_xattr_entry   *new_entry = entry;
        posix_acl_xattr_entry   *end;
        int                      count;
index ab393e3..dcb8838 100644 (file)
@@ -4366,10 +4366,12 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(posix_acl_xattr_header, a_version));
        LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n",
                 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_version));
                 (long long)(int)offsetof(posix_acl_xattr_header, a_version));
        LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_version) == 4, "found %lld\n",
                 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_version));
+#ifndef HAVE_STRUCT_POSIX_ACL_XATTR
        LASSERTF((int)offsetof(posix_acl_xattr_header, a_entries) == 4, "found %lld\n",
                 (long long)(int)offsetof(posix_acl_xattr_header, a_entries));
        LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_entries) == 0, "found %lld\n",
                 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_entries));
        LASSERTF((int)offsetof(posix_acl_xattr_header, a_entries) == 4, "found %lld\n",
                 (long long)(int)offsetof(posix_acl_xattr_header, a_entries));
        LASSERTF((int)sizeof(((posix_acl_xattr_header *)0)->a_entries) == 0, "found %lld\n",
                 (long long)(int)sizeof(((posix_acl_xattr_header *)0)->a_entries));
+#endif
 #endif /* CONFIG_FS_POSIX_ACL */
 
        /* Checks for struct link_ea_header */
 #endif /* CONFIG_FS_POSIX_ACL */
 
        /* Checks for struct link_ea_header */