Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / ptlrpc / gss / lproc_gss.c
index df50946..489c870 100644 (file)
@@ -1,27 +1,37 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  Copyright (C) 2001-2003 Cluster File Systems, Inc.
- *   Author Peter Braam <braam@clusterfs.com>
+ * GPL HEADER START
  *
- *   This file is part of the Lustre file system, http://www.lustre.org
- *   Lustre is a trademark of Cluster File Systems, Inc.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   You may have signed or agreed to another license before downloading
- *   this software.  If so, you are bound by the terms and conditions
- *   of that agreement, and the following does not apply to you.  See the
- *   LICENSE file included with this distribution for more information.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
  *
- *   If you did not agree to a different license, then this copy of Lustre
- *   is open source software; you can redistribute it and/or modify it
- *   under the terms of version 2 of the GNU General Public License as
- *   published by the Free Software Foundation.
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
  *
- *   In either case, Lustre is distributed in the hope that it will be
- *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
- *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   license text for more details.
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
  *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
 #ifndef EXPORT_SYMTAB
@@ -35,6 +45,7 @@
 #include <linux/dcache.h>
 #include <linux/fs.h>
 #include <linux/random.h>
+#include <linux/mutex.h>
 #else
 #include <liblustre.h>
 #endif
@@ -53,6 +64,7 @@
 #include "gss_api.h"
 
 static struct proc_dir_entry *gss_proc_root = NULL;
+static struct proc_dir_entry *gss_proc_lk = NULL;
 
 /*
  * statistic of "out-of-sequence-window"
@@ -64,7 +76,6 @@ static struct {
         atomic_t        oos_svc_replay[3];   /* server replay detected */
         atomic_t        oos_svc_pass[3];     /* server verified ok */
 } gss_stat_oos = {
-        .oos_lock       = SPIN_LOCK_UNLOCKED,
         .oos_cli_count  = ATOMIC_INIT(0),
         .oos_cli_behind = 0,
         .oos_svc_replay = { ATOMIC_INIT(0), },
@@ -136,30 +147,81 @@ static int gss_proc_write_secinit(struct file *file, const char *buffer,
 
 static struct lprocfs_vars gss_lprocfs_vars[] = {
         { "replays", gss_proc_read_oos, NULL },
-        { "init_channel", NULL, gss_proc_write_secinit, NULL },
+        { "init_channel", NULL, gss_proc_write_secinit, NULL, NULL, 0222 },
         { NULL }
 };
 
-int gss_init_lproc(void)
+/*
+ * for userspace helper lgss_keyring.
+ *
+ * debug_level: [0, 4], defined in utils/gss/lgss_utils.h
+ */
+static int gss_lk_debug_level = 1;
+
+static int gss_lk_proc_read_dl(char *page, char **start, off_t off,
+                               int count, int *eof, void *data)
 {
-        int rc;
-        gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root,
-                                         gss_lprocfs_vars, NULL);
+        return snprintf(page, count, "%u\n", gss_lk_debug_level);
+}
 
-        if (IS_ERR(gss_proc_root)) {
-                rc = PTR_ERR(gss_proc_root);
-                gss_proc_root = NULL;
-                CERROR("failed to initialize lproc entries: %d\n", rc);
+static int gss_lk_proc_write_dl(struct file *file, const char *buffer,
+                                unsigned long count, void *data)
+{
+        int     val, rc;
+
+        rc = lprocfs_write_helper(buffer, count, &val);
+        if (rc < 0)
                 return rc;
-        }
 
-        return 0;
+        if (val < 0 || val > 4)
+                return -ERANGE;
+
+        gss_lk_debug_level = val;
+        return count;
 }
 
+static struct lprocfs_vars gss_lk_lprocfs_vars[] = {
+        { "debug_level", gss_lk_proc_read_dl, gss_lk_proc_write_dl, NULL },
+        { NULL }
+};
+
 void gss_exit_lproc(void)
 {
+        if (gss_proc_lk) {
+                lprocfs_remove(&gss_proc_lk);
+                gss_proc_lk = NULL;
+        }
+
         if (gss_proc_root) {
                 lprocfs_remove(&gss_proc_root);
                 gss_proc_root = NULL;
         }
 }
+
+int gss_init_lproc(void)
+{
+        int     rc;
+
+        spin_lock_init(&gss_stat_oos.oos_lock);
+
+        gss_proc_root = lprocfs_register("gss", sptlrpc_proc_root,
+                                         gss_lprocfs_vars, NULL);
+        if (IS_ERR(gss_proc_root)) {
+                gss_proc_root = NULL;
+                GOTO(err_out, rc = PTR_ERR(gss_proc_root));
+        }
+
+        gss_proc_lk = lprocfs_register("lgss_keyring", gss_proc_root,
+                                       gss_lk_lprocfs_vars, NULL);
+        if (IS_ERR(gss_proc_lk)) {
+                gss_proc_lk = NULL;
+                GOTO(err_out, rc = PTR_ERR(gss_proc_root));
+        }
+
+        return 0;
+
+err_out:
+        CERROR("failed to initialize gss lproc entries: %d\n", rc);
+        gss_exit_lproc();
+        return rc;
+}