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.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2014, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ptlrpc/sec_lproc.c
38 * Author: Eric Mei <ericm@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_SEC
43 #include <libcfs/libcfs.h>
44 #include <linux/crypto.h>
47 #include <obd_class.h>
48 #include <obd_support.h>
49 #include <lustre_net.h>
50 #include <lustre_import.h>
51 #include <lustre_dlm.h>
52 #include <lustre_sec.h>
54 #include "ptlrpc_internal.h"
57 struct proc_dir_entry *sptlrpc_proc_root = NULL;
58 EXPORT_SYMBOL(sptlrpc_proc_root);
60 static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
64 if (flags & PTLRPC_SEC_FL_REVERSE)
65 strlcat(buf, "reverse,", bufsize);
66 if (flags & PTLRPC_SEC_FL_ROOTONLY)
67 strlcat(buf, "rootonly,", bufsize);
68 if (flags & PTLRPC_SEC_FL_UDESC)
69 strlcat(buf, "udesc,", bufsize);
70 if (flags & PTLRPC_SEC_FL_BULK)
71 strlcat(buf, "bulk,", bufsize);
73 strlcat(buf, "-,", bufsize);
78 static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v)
80 struct obd_device *dev = seq->private;
81 struct client_obd *cli = &dev->u.cli;
82 struct ptlrpc_sec *sec = NULL;
85 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
86 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
87 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
88 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
89 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
92 sec = sptlrpc_import_sec_ref(cli->cl_import);
96 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str));
98 seq_printf(seq, "rpc flavor: %s\n",
99 sptlrpc_flavor2name_base(sec->ps_flvr.sf_rpc));
100 seq_printf(seq, "bulk flavor: %s\n",
101 sptlrpc_flavor2name_bulk(&sec->ps_flvr, str, sizeof(str)));
102 seq_printf(seq, "flags: %s\n",
103 sec_flags2str(sec->ps_flvr.sf_flags, str, sizeof(str)));
104 seq_printf(seq, "id: %d\n", sec->ps_id);
105 seq_printf(seq, "refcount: %d\n",
106 atomic_read(&sec->ps_refcount));
107 seq_printf(seq, "nctx: %d\n", atomic_read(&sec->ps_nctx));
108 seq_printf(seq, "gc internal %ld\n", sec->ps_gc_interval);
109 seq_printf(seq, "gc next %ld\n",
110 sec->ps_gc_interval ?
111 sec->ps_gc_next - cfs_time_current_sec() : 0);
113 sptlrpc_sec_put(sec);
117 LPROC_SEQ_FOPS_RO(sptlrpc_info_lprocfs);
119 static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v)
121 struct obd_device *dev = seq->private;
122 struct client_obd *cli = &dev->u.cli;
123 struct ptlrpc_sec *sec = NULL;
125 LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 ||
126 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 ||
127 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 ||
128 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 ||
129 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0);
132 sec = sptlrpc_import_sec_ref(cli->cl_import);
136 if (sec->ps_policy->sp_cops->display)
137 sec->ps_policy->sp_cops->display(sec, seq);
139 sptlrpc_sec_put(sec);
143 LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
145 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
149 if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
150 strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
151 strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0 &&
152 strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) != 0 &&
153 strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) != 0) {
154 CERROR("can't register lproc for obd type %s\n",
155 dev->obd_type->typ_name);
159 rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444,
160 &sptlrpc_info_lprocfs_fops, dev);
162 CERROR("create proc entry srpc_info for %s: %d\n",
167 rc = lprocfs_obd_seq_create(dev, "srpc_contexts", 0444,
168 &sptlrpc_ctxs_lprocfs_fops, dev);
170 CERROR("create proc entry srpc_contexts for %s: %d\n",
177 EXPORT_SYMBOL(sptlrpc_lprocfs_cliobd_attach);
179 LPROC_SEQ_FOPS_RO(sptlrpc_proc_enc_pool);
180 static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
181 { .name = "encrypt_page_pools",
182 .fops = &sptlrpc_proc_enc_pool_fops },
186 int sptlrpc_lproc_init(void)
190 LASSERT(sptlrpc_proc_root == NULL);
192 sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
193 sptlrpc_lprocfs_vars, NULL);
194 if (IS_ERR(sptlrpc_proc_root)) {
195 rc = PTR_ERR(sptlrpc_proc_root);
196 sptlrpc_proc_root = NULL;
202 void sptlrpc_lproc_fini(void)
204 if (sptlrpc_proc_root) {
205 lprocfs_remove(&sptlrpc_proc_root);
206 sptlrpc_proc_root = NULL;