From: Dmitry Eremin Date: Fri, 3 Mar 2017 17:51:22 +0000 (+0300) Subject: LU-9183 ptlrpc: handle changes in struct group_info X-Git-Tag: 2.9.58~25 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F38%2F25838%2F12;p=fs%2Flustre-release.git LU-9183 ptlrpc: handle changes in struct group_info In commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb few members of struct group_info where changed. Change-Id: Id8e5b483cf389eff41c63942cfd78303fff67a8c Signed-off-by: Dmitry Eremin Reviewed-on: https://review.whamcloud.com/25838 Reviewed-by: Bob Glossman Reviewed-by: James Simmons Reviewed-by: John L. Hammond Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 395e1cc..7ad54f3 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -2427,6 +2427,25 @@ full_name_hash_3args, [ ]) # LC_FULL_NAME_HASH_3ARGS # +# LC_GROUP_INFO_GID +# +# Kernel version 4.9 commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb +# cred: simpler, 1D supplementary groups +# +AC_DEFUN([LC_GROUP_INFO_GID], [ +LB_CHECK_COMPILE([if 'struct group_info' has member 'gid'], +group_info_gid, [ + #include +],[ + kgid_t *p; + p = ((struct group_info *)0)->gid; +],[ + AC_DEFINE(HAVE_GROUP_INFO_GID, 1, + [struct group_info has member gid]) +]) +]) # LC_GROUP_INFO_GID + +# # LC_PROG_LINUX # # Lustre linux kernel checks @@ -2626,6 +2645,9 @@ AC_DEFUN([LC_PROG_LINUX], [ LC_D_COMPARE_4ARGS LC_FULL_NAME_HASH_3ARGS + # 4.9 + LC_GROUP_INFO_GID + # AS_IF([test "x$enable_server" != xno], [ LC_FUNC_DEV_SET_RDONLY diff --git a/lustre/include/lustre_idmap.h b/lustre/include/lustre_idmap.h index 6e7f86b..70d647d 100644 --- a/lustre/include/lustre_idmap.h +++ b/lustre/include/lustre_idmap.h @@ -45,11 +45,18 @@ #include +#ifdef HAVE_GROUP_INFO_GID + +#define CFS_GROUP_AT(gi, i) ((gi)->gid[(i)]) + +#else /* !HAVE_GROUP_INFO_GID */ + #define CFS_NGROUPS_PER_BLOCK ((int)(PAGE_SIZE / sizeof(gid_t))) #define CFS_GROUP_AT(gi, i) \ ((gi)->blocks[(i) / CFS_NGROUPS_PER_BLOCK][(i) % CFS_NGROUPS_PER_BLOCK]) +#endif /* HAVE_GROUP_INFO_GID */ struct lu_ucred; diff --git a/lustre/obdclass/idmap.c b/lustre/obdclass/idmap.c index 7db6f46..b45c6d6 100644 --- a/lustre/obdclass/idmap.c +++ b/lustre/obdclass/idmap.c @@ -87,6 +87,9 @@ static int lustre_groups_search(struct group_info *group_info, void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist) { +#ifdef HAVE_GROUP_INFO_GID + memcpy(ginfo->gid, glist, ginfo->ngroups * sizeof(__u32)); +#else int i; int count = ginfo->ngroups; @@ -99,6 +102,7 @@ void lustre_groups_from_list(struct group_info *ginfo, gid_t *glist) memcpy(ginfo->blocks[i], glist + off, len); count -= cp_count; } +#endif } EXPORT_SYMBOL(lustre_groups_from_list); diff --git a/lustre/ptlrpc/sec.c b/lustre/ptlrpc/sec.c index 7037b91..92d39ec 100644 --- a/lustre/ptlrpc/sec.c +++ b/lustre/ptlrpc/sec.c @@ -2434,8 +2434,13 @@ int sptlrpc_pack_user_desc(struct lustre_msg *msg, int offset) task_lock(current); if (pud->pud_ngroups > current_ngroups) pud->pud_ngroups = current_ngroups; +#ifdef HAVE_GROUP_INFO_GID + memcpy(pud->pud_groups, current_cred()->group_info->gid, + pud->pud_ngroups * sizeof(__u32)); +#else /* !HAVE_GROUP_INFO_GID */ memcpy(pud->pud_groups, current_cred()->group_info->blocks[0], pud->pud_ngroups * sizeof(__u32)); +#endif /* HAVE_GROUP_INFO_GID */ task_unlock(current); return 0;