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.
26 * Copyright (c) 2014, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
30 * Lustre is a trademark of Sun Microsystems, Inc.
32 * lustre/ptlrpc/sec_lproc.c
34 * Author: Eric Mei <ericm@clusterfs.com>
37 #define DEBUG_SUBSYSTEM S_SEC
39 #include <libcfs/libcfs.h>
40 #include <linux/crypto.h>
43 #include <obd_class.h>
44 #include <obd_support.h>
45 #include <lustre_net.h>
46 #include <lustre_import.h>
47 #include <lustre_dlm.h>
48 #include <lustre_sec.h>
50 #include "ptlrpc_internal.h"
53 struct proc_dir_entry *sptlrpc_proc_root = NULL;
54 EXPORT_SYMBOL(sptlrpc_proc_root);
56 static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
60 if (flags & PTLRPC_SEC_FL_REVERSE)
61 strlcat(buf, "reverse,", bufsize);
62 if (flags & PTLRPC_SEC_FL_ROOTONLY)
63 strlcat(buf, "rootonly,", bufsize);
64 if (flags & PTLRPC_SEC_FL_UDESC)
65 strlcat(buf, "udesc,", bufsize);
66 if (flags & PTLRPC_SEC_FL_BULK)
67 strlcat(buf, "bulk,", bufsize);
69 strlcat(buf, "-,", bufsize);
74 static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
76 struct obd_device *dev = seq->private;
77 struct client_obd *cli = &dev->u.cli;
78 struct ptlrpc_sec *sec = NULL;
81 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
82 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
83 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
84 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
85 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
88 sec = sptlrpc_import_sec_ref(cli->cl_import);
92 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str));
94 seq_printf(seq, "rpc flavor: %s\n",
95 sptlrpc_flavor2name_base(sec->ps_flvr.sf_rpc));
96 seq_printf(seq, "bulk flavor: %s\n",
97 sptlrpc_flavor2name_bulk(&sec->ps_flvr, str, sizeof(str)));
98 seq_printf(seq, "flags: %s\n",
99 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str)));
100 seq_printf(seq, "id: %d\n", sec->ps_id);
101 seq_printf(seq, "refcount: %d\n",
102 atomic_read(&sec->ps_refcount));
103 seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx));
104 seq_printf(seq, "gc internal %lld\n", sec->ps_gc_interval);
105 seq_printf(seq, "gc next %lld\n",
106 sec->ps_gc_interval ?
107 (s64)(sec->ps_gc_next - ktime_get_real_seconds()) : 0ll);
109 sptlrpc_sec_put(sec);
114 LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
116 static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
118 struct obd_device *dev = seq->private;
119 struct client_obd *cli = &dev->u.cli;
120 struct ptlrpc_sec *sec = NULL;
122 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
123 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
124 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
125 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
126 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
129 sec = sptlrpc_import_sec_ref(cli->cl_import);
133 if (sec->ps_policy->sp_cops->display)
134 sec->ps_policy->sp_cops->display(sec, seq);
136 sptlrpc_sec_put(sec);
141 LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
143 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
147 if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
148 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
149 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0 &&
150 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) != 0 &&
151 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) != 0) {
152 CERROR("can't register lproc for obd type %s\n",
153 dev->obd_type->typ_name);
157 rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "srpc_info", 0444,
158 &sptlrpc_info_lprocfs_fops, dev);
160 CERROR("create proc entry srpc_info for %s: %d\n",
165 rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "srpc_contexts",
166 0444, &sptlrpc_ctxs_lprocfs_fops, dev);
168 CERROR("create proc entry srpc_contexts for %s: %d\n",
175 EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
177 LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
178 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
179 { .name = "encrypt_page_pools",
180 .fops = &sptlrpc_proc_enc_pool_fops },
184 int sptlrpc_lproc_init(void)
188 LASSERT(sptlrpc_proc_root == NULL);
190 sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
191 sptlrpc_lprocfs_vars, NULL);
192 if (IS_ERR(sptlrpc_proc_root)) {
193 rc = PTR_ERR(sptlrpc_proc_root);
194 sptlrpc_proc_root = NULL;
200 void sptlrpc_lproc_fini(void)
202 if (sptlrpc_proc_root) {
203 lprocfs_remove(&sptlrpc_proc_root);
204 sptlrpc_proc_root = NULL;