Whamcloud - gitweb
LU-9183 ptlrpc: handle changes in struct group_info 38/25838/12
authorDmitry Eremin <dmitry.eremin@intel.com>
Fri, 3 Mar 2017 17:51:22 +0000 (20:51 +0300)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 16 May 2017 05:46:19 +0000 (05:46 +0000)
In commit 81243eacfa400f5f7b89f4c2323d0de9982bb0fb few members of
struct group_info where changed.

Change-Id: Id8e5b483cf389eff41c63942cfd78303fff67a8c
Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-on: https://review.whamcloud.com/25838
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/lustre_idmap.h
lustre/obdclass/idmap.c
lustre/ptlrpc/sec.c

index 395e1cc..7ad54f3 100644 (file)
@@ -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 <linux/cred.h>
+],[
+       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
index 6e7f86b..70d647d 100644 (file)
 
 #include <libcfs/libcfs.h>
 
+#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;
 
index 7db6f46..b45c6d6 100644 (file)
@@ -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);
 
index 7037b91..92d39ec 100644 (file)
@@ -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;