From: Dmitry Eremin Date: Tue, 7 Mar 2017 18:03:53 +0000 (+0300) Subject: LU-9183 ptlrpc: handle posix_acl: xattr representation cleanups X-Git-Tag: 2.9.59~80 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=f7df2365bc51a7b2804f9b497cbc6bc340dd9da1 LU-9183 ptlrpc: handle posix_acl: xattr representation cleanups 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 Reviewed-on: https://review.whamcloud.com/25892 Reviewed-by: Bob Glossman Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 9a89cae..46d2ca8 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2446,6 +2446,27 @@ 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 + #include +],[ + 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 @@ -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_STRUCT_POSIX_ACL_XATTR # 4.9 LC_GROUP_INFO_GID diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 6d039ea..8eff04d 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -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 +#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 */ diff --git a/lustre/include/lustre_eacl.h b/lustre/include/lustre_eacl.h index e8bcb25..3061be1 100644 --- a/lustre/include/lustre_eacl.h +++ b/lustre/include/lustre_eacl.h @@ -71,6 +71,11 @@ struct lu_ucred; 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, diff --git a/lustre/mdd/mdd_permission.c b/lustre/mdd/mdd_permission.c index 5f9eceb..4b4f9b9 100644 --- a/lustre/mdd/mdd_permission.c +++ b/lustre/mdd/mdd_permission.c @@ -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); - 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) @@ -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->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) @@ -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->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) @@ -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); - 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 diff --git a/lustre/ptlrpc/nodemap_handler.c b/lustre/ptlrpc/nodemap_handler.c index b438dda..1ea5c7c 100644 --- a/lustre/ptlrpc/nodemap_handler.c +++ b/lustre/ptlrpc/nodemap_handler.c @@ -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; - 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; diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index ab393e3..dcb8838 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -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)); +#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)); +#endif #endif /* CONFIG_FS_POSIX_ACL */ /* Checks for struct link_ea_header */