Whamcloud - gitweb
LU-867 gss: adapt to 2.6.32 kernel changes cache_detail
[fs/lustre-release.git] / lustre / ptlrpc / gss / gss_svc_upcall.c
index 9877c9f..7622136 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Modifications for Lustre
  *
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  *
  * Author: Eric Mei <ericm@clusterfs.com>
  */
@@ -181,6 +181,13 @@ static void rsi_request(struct cache_detail *cd,
         (*bpp)[-1] = '\n';
 }
 
+#ifdef HAVE_CACHE_UPCALL
+static int rsi_upcall(struct cache_detail *cd, struct cache_head *h)
+{
+        return sunrpc_cache_pipe_upcall(cd, h, rsi_request);
+}
+#endif
+
 static inline void __rsi_init(struct rsi *new, struct rsi *item)
 {
         new->out_handle = RAWOBJ_EMPTY;
@@ -472,7 +479,11 @@ static struct cache_detail rsi_cache = {
         .hash_table     = rsi_table,
         .name           = "auth.sptlrpc.init",
         .cache_put      = rsi_put,
+#ifdef HAVE_CACHE_UPCALL
+        .cache_upcall   = rsi_upcall,
+#else
         .cache_request  = rsi_request,
+#endif
         .cache_parse    = rsi_parse,
 #ifdef HAVE_SUNRPC_CACHE_V2
         .match          = rsi_match,
@@ -671,6 +682,14 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen)
         }
         rsci.ctx.gsc_usr_mds = (tmp_int != 0);
 
+        /* oss user flag */
+        rv = get_int(&mesg, &tmp_int);
+        if (rv) {
+                CERROR("fail to get oss user flag\n");
+                goto out;
+        }
+        rsci.ctx.gsc_usr_oss = (tmp_int != 0);
+
         /* mapped uid */
         rv = get_int(&mesg, (int *) &rsci.ctx.gsc_mapped_uid);
         if (rv) {
@@ -822,6 +841,14 @@ static int rsc_parse(struct cache_detail *cd, char *mesg, int mlen)
         }
         rsci.ctx.gsc_usr_mds = (tmp_int != 0);
 
+        /* oss user flag */
+        rv = get_int(&mesg, &tmp_int);
+        if (rv) {
+                CERROR("fail to get oss user flag\n");
+                goto out;
+        }
+        rsci.ctx.gsc_usr_oss = (tmp_int != 0);
+
         /* mapped uid */
         rv = get_int(&mesg, (int *) &rsci.ctx.gsc_mapped_uid);
         if (rv) {
@@ -1069,10 +1096,12 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp,
         }
         rsci.h.expiry_time = (time_t) ctx_expiry;
 
-        /* FIXME */
-        rsci.ctx.gsc_usr_root = 1;
-        rsci.ctx.gsc_usr_mds= 1;
-        rsci.ctx.gsc_reverse = 1;
+        if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0)
+                rsci.ctx.gsc_usr_mds = 1;
+        else if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0)
+                rsci.ctx.gsc_usr_oss = 1;
+        else
+                rsci.ctx.gsc_usr_root = 1;
 
         rscp = rsc_update(&rsci, rscp);
         if (rscp == NULL)
@@ -1124,10 +1153,12 @@ int gss_svc_upcall_install_rvs_ctx(struct obd_import *imp,
         }
         rsci.h.expiry_time = (time_t) ctx_expiry;
 
-        /* FIXME */
-        rsci.ctx.gsc_usr_root = 1;
-        rsci.ctx.gsc_usr_mds= 1;
-        rsci.ctx.gsc_reverse = 1;
+        if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0)
+                rsci.ctx.gsc_usr_mds = 1;
+        else if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0)
+                rsci.ctx.gsc_usr_oss = 1;
+        else
+                rsci.ctx.gsc_usr_root = 1;
 
         rscp = rsc_lookup(&rsci, 1);
         if (rscp == NULL) {
@@ -1424,7 +1455,7 @@ int __init gss_init_svc_upcall(void)
          * sequence number checking, thus no chance to sent error notification
          * back to clients.
          */
-        ll_get_random_bytes(&__ctx_index, sizeof(__ctx_index));
+        cfs_get_random_bytes(&__ctx_index, sizeof(__ctx_index));
 
 
         cache_register(&rsi_cache);