Whamcloud - gitweb
LU-6490 gss: handle struct key_type match replacement 04/15804/3
authorJames Simmons <uja.ornl@yahoo.com>
Mon, 3 Aug 2015 14:36:16 +0000 (10:36 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 5 Aug 2015 02:19:41 +0000 (02:19 +0000)
Starting with the 3.17 kernel the function match
used by struct key_type was replaced by a new
function match_preparse. This patch added support
for this change.

Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Change-Id: I2db0860cf089b0ba8f70bad9155f48e52ec8c4b5
Reviewed-on: http://review.whamcloud.com/15804
Tested-by: Jenkins
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Sebastien Buisson <sebastien.buisson@bull.net>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/ptlrpc/gss/gss_keyring.c

index b7dca3b..2ce6386 100644 (file)
@@ -1720,6 +1720,24 @@ file_function_iter, [
 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 
 #
 ]) # LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 
 #
+# LC_KEY_MATCH_DATA
+#
+# 3.17 replaces key_type::match with match_preparse
+#      and has new struct key_match_data
+#
+AC_DEFUN([LC_KEY_MATCH_DATA], [
+LB_CHECK_COMPILE([if struct key_match field exist],
+key_match, [
+       #include <linux/key-type.h>
+],[
+       struct key_match_data data;
+],[
+       AC_DEFINE(HAVE_KEY_MATCH_DATA, 1,
+               [struct key_match_data exist])
+])
+]) # LC_KEY_MATCH_DATA
+
+#
 # LC_NFS_FILLDIR_USE_CTX
 #
 # 3.18 kernel moved from void cookie to struct dir_context
 # LC_NFS_FILLDIR_USE_CTX
 #
 # 3.18 kernel moved from void cookie to struct dir_context
@@ -1939,6 +1957,9 @@ AC_DEFUN([LC_PROG_LINUX], [
        LC_HAVE_IOV_ITER_INIT_DIRECTION
        LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 
        LC_HAVE_IOV_ITER_INIT_DIRECTION
        LC_HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 
+       # 3.17
+       LC_KEY_MATCH_DATA
+
        # 3.18
        LC_NFS_FILLDIR_USE_CTX
 
        # 3.18
        LC_NFS_FILLDIR_USE_CTX
 
index 5256adc..e722d3c 100644 (file)
@@ -73,7 +73,7 @@ static int sec_install_rctx_kr(struct ptlrpc_sec *sec,
 /*
  * the timeout is only for the case that upcall child process die abnormally.
  * in any other cases it should finally update kernel key.
 /*
  * the timeout is only for the case that upcall child process die abnormally.
  * in any other cases it should finally update kernel key.
- * 
+ *
  * FIXME we'd better to incorporate the client & server side upcall timeouts
  * into the framework of Adaptive Timeouts, but we need to figure out how to
  * make sure that kernel knows the upcall processes is in-progress or died
  * FIXME we'd better to incorporate the client & server side upcall timeouts
  * into the framework of Adaptive Timeouts, but we need to figure out how to
  * make sure that kernel knows the upcall processes is in-progress or died
@@ -1408,11 +1408,31 @@ out:
         RETURN(0);
 }
 
         RETURN(0);
 }
 
-static
-int gss_kt_match(const struct key *key, const void *desc)
+#ifndef HAVE_KEY_MATCH_DATA
+static int
+gss_kt_match(const struct key *key, const void *desc)
+{
+       return (strcmp(key->description, (const char *) desc) == 0);
+}
+#else /* ! HAVE_KEY_MATCH_DATA */
+static bool
+gss_kt_match(const struct key *key, const struct key_match_data *match_data)
+{
+       const char *desc = match_data->raw_data;
+
+       return (strcmp(key->description, desc) == 0);
+}
+
+/*
+ * Preparse the match criterion.
+ */
+static int gss_kt_match_preparse(struct key_match_data *match_data)
 {
 {
-        return (strcmp(key->description, (const char *) desc) == 0);
+       match_data->lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT;
+       match_data->cmp = gss_kt_match;
+       return 0;
 }
 }
+#endif /* HAVE_KEY_MATCH_DATA */
 
 static
 void gss_kt_destroy(struct key *key)
 
 static
 void gss_kt_destroy(struct key *key)
@@ -1434,13 +1454,17 @@ void gss_kt_describe(const struct key *key, struct seq_file *s)
 
 static struct key_type gss_key_type =
 {
 
 static struct key_type gss_key_type =
 {
-        .name           = "lgssc",
-        .def_datalen    = 0,
-        .instantiate    = gss_kt_instantiate,
-        .update         = gss_kt_update,
-        .match          = gss_kt_match,
-        .destroy        = gss_kt_destroy,
-        .describe       = gss_kt_describe,
+       .name           = "lgssc",
+       .def_datalen    = 0,
+       .instantiate    = gss_kt_instantiate,
+       .update         = gss_kt_update,
+#ifdef HAVE_KEY_MATCH_DATA
+       .match_preparse = gss_kt_match_preparse,
+#else
+       .match          = gss_kt_match,
+#endif
+       .destroy        = gss_kt_destroy,
+       .describe       = gss_kt_describe,
 };
 
 /****************************************
 };
 
 /****************************************