4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
27 * This file is part of Lustre, http://www.lustre.org/
28 * Lustre is a trademark of Sun Microsystems, Inc.
30 * lustre/ptlrpc/sec_lproc.c
32 * Author: Eric Mei <ericm@clusterfs.com>
35 #define DEBUG_SUBSYSTEM S_SEC
37 #include <linux/libcfs/libcfs.h>
38 #include <linux/crypto.h>
41 #include <obd_class.h>
42 #include <obd_support.h>
43 #include <lustre_net.h>
44 #include <lustre_import.h>
45 #include <lustre_dlm.h>
46 #include <lustre_sec.h>
48 #include "ptlrpc_internal.h"
50 static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
54 if (flags & PTLRPC_SEC_FL_REVERSE)
55 strlcat(buf, "reverse,", bufsize);
56 if (flags & PTLRPC_SEC_FL_ROOTONLY)
57 strlcat(buf, "rootonly,", bufsize);
58 if (flags & PTLRPC_SEC_FL_UDESC)
59 strlcat(buf, "udesc,", bufsize);
60 if (flags & PTLRPC_SEC_FL_BULK)
61 strlcat(buf, "bulk,", bufsize);
63 strlcat(buf, "-,", bufsize);
68 static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
70 struct obd_device *dev = seq->private;
71 struct client_obd *cli = &dev->u.cli;
72 struct ptlrpc_sec *sec = NULL;
75 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
76 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
77 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0);
80 sec = sptlrpc_import_sec_ref(cli->cl_import);
84 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str));
86 seq_printf(seq, "rpc flavor: %s\n",
87 sptlrpc_flavor2name_base(sec->ps_flvr.sf_rpc));
88 seq_printf(seq, "bulk flavor: %s\n",
89 sptlrpc_flavor2name_bulk(&sec->ps_flvr, str, sizeof(str)));
90 seq_printf(seq, "flags: %s\n",
91 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str)));
92 seq_printf(seq, "id: %d\n", sec->ps_id);
93 seq_printf(seq, "refcount: %d\n",
94 atomic_read(&sec->ps_refcount));
95 seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx));
96 seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval);
97 seq_printf(seq, "gc next %lld\n",
99 (s64)(sec->ps_gc_next - ktime_get_real_seconds()) : 0ll);
101 sptlrpc_sec_put(sec);
106 LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
108 static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
110 struct obd_device *dev = seq->private;
111 struct client_obd *cli = &dev->u.cli;
112 struct ptlrpc_sec *sec = NULL;
114 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
115 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
116 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0);
119 sec = sptlrpc_import_sec_ref(cli->cl_import);
123 if (sec->ps_policy->sp_cops->display)
124 sec->ps_policy->sp_cops->display(sec, seq);
126 sptlrpc_sec_put(sec);
131 LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
133 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
137 if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
138 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
139 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0) {
140 CERROR("can't register lproc for obd type %s\n",
141 dev->obd_type->typ_name);
145 rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444,
146 &sptlrpc_info_lprocfs_fops, dev);
148 CERROR("create proc entry srpc_info for %s: %d\n",
153 rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444,
154 &sptlrpc_ctxs_lprocfs_fops, dev);
156 CERROR("create proc entry srpc_contexts for %s: %d\n",
163 EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
165 LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
166 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
167 { "encrypt_page_pools", &sptlrpc_proc_enc_pool_fops },
171 static struct dentry *sptlrpc_debugfs_dir;
173 int sptlrpc_lproc_init(void)
177 LASSERT(!sptlrpc_debugfs_dir);
179 sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
180 sptlrpc_lprocfs_vars, NULL);
181 if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) {
182 rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir)
184 sptlrpc_debugfs_dir = NULL;
190 void sptlrpc_lproc_fini(void)
192 if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir))
193 ldebugfs_remove(&sptlrpc_debugfs_dir);