+
+/* make sure fsgid is one of primary or supplementary groups
+ * fetched from identity upcall
+ */
+int has_proper_groups(struct lu_ucred *ucred)
+{
+ struct group_info *group_info = NULL;
+ int rc;
+
+ if (!ucred->uc_identity)
+ return 1;
+
+ if (ucred->uc_fsgid == ucred->uc_identity->mi_gid)
+ return 1;
+
+ group_info = ucred->uc_identity->mi_ginfo;
+ if (!group_info)
+ return 0;
+
+ get_group_info(group_info);
+ rc = lustre_groups_search(group_info, ucred->uc_fsgid);
+ put_group_info(group_info);
+
+ return rc;
+}
+EXPORT_SYMBOL(has_proper_groups);