1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2006 Cluster File Systems, Inc.
5 * Author: Eric Mei <ericm@clusterfs.com>
7 * This file is part of Lustre, http://www.lustre.org.
9 * Lustre is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * Lustre is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with Lustre; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #define DEBUG_SUBSYSTEM S_SEC
28 #include <libcfs/libcfs.h>
30 #include <liblustre.h>
31 #include <libcfs/list.h>
33 #include <linux/crypto.h>
37 #include <obd_class.h>
38 #include <obd_support.h>
39 #include <lustre_net.h>
40 #include <lustre_import.h>
41 #include <lustre_dlm.h>
42 #include <lustre_sec.h>
44 #include "ptlrpc_internal.h"
48 struct proc_dir_entry *sptlrpc_proc_root = NULL;
49 EXPORT_SYMBOL(sptlrpc_proc_root);
51 void sec_flags2str(unsigned long flags, char *buf, int bufsize)
55 if (flags & PTLRPC_SEC_FL_REVERSE)
56 strncat(buf, "reverse,", bufsize);
57 if (flags & PTLRPC_SEC_FL_ROOTONLY)
58 strncat(buf, "rootonly,", bufsize);
59 if (flags & PTLRPC_SEC_FL_BULK)
60 strncat(buf, "bulk,", bufsize);
62 strncat(buf, "-,", bufsize);
64 buf[strlen(buf) - 1] = '\0';
68 int sptlrpc_lprocfs_rd(char *page, char **start, off_t off, int count,
71 struct obd_device *obd = data;
72 struct sec_flavor_config *conf = &obd->u.cli.cl_sec_conf;
73 struct ptlrpc_sec *sec = NULL;
80 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
81 strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
82 strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) == 0);
83 LASSERT(conf->sfc_bulk_csum < BULK_CSUM_ALG_MAX);
84 LASSERT(conf->sfc_bulk_priv < BULK_PRIV_ALG_MAX);
86 if (obd->u.cli.cl_import)
87 sec = obd->u.cli.cl_import->imp_sec;
90 written = snprintf(page, count, "\n");
94 sec_flags2str(sec->ps_flags, flags_str, sizeof(flags_str));
96 written = snprintf(page, count,
97 "rpc msg flavor: %s\n"
101 "ctx cache busy %d\n"
104 sptlrpc_flavor2name(sec->ps_flavor),
105 sptlrpc_bulk_csum_alg2name(conf->sfc_bulk_csum),
106 sptlrpc_bulk_priv_alg2name(conf->sfc_bulk_priv),
108 atomic_read(&sec->ps_busy),
110 sec->ps_gc_interval ?
111 sec->ps_gc_next - cfs_time_current_sec() : 0
114 if (sec->ps_policy->sp_cops->display) {
115 written += sec->ps_policy->sp_cops->display(
116 sec, page + written, count - written);
122 EXPORT_SYMBOL(sptlrpc_lprocfs_rd);
124 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
125 { "enc_pool", sptlrpc_proc_read_enc_pool, NULL, NULL },
129 int sptlrpc_lproc_init(void)
133 LASSERT(sptlrpc_proc_root == NULL);
135 sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
136 sptlrpc_lprocfs_vars, NULL);
137 if (IS_ERR(sptlrpc_proc_root)) {
138 rc = PTR_ERR(sptlrpc_proc_root);
139 sptlrpc_proc_root = NULL;
145 void sptlrpc_lproc_fini(void)
147 if (sptlrpc_proc_root) {
148 lprocfs_remove(&sptlrpc_proc_root);
149 sptlrpc_proc_root = NULL;
153 #else /* !__KERNEL__ */
155 int sptlrpc_lproc_init(void)
160 void sptlrpc_lproc_fini(void)