staging: lustre: Update module author to OpenSFS
[deliverable/linux.git] / drivers / staging / lustre / lnet / lnet / module.c
CommitLineData
d7e09d03
PT
1/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
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.
9 *
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).
15 *
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
19 *
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
22 * have any questions.
23 *
24 * GPL HEADER END
25 */
26/*
27 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
29 *
30 * Copyright (c) 2012, Intel Corporation.
31 */
32/*
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
35 */
36
37#define DEBUG_SUBSYSTEM S_LNET
9fdaf8c0 38#include "../../include/linux/lnet/lib-lnet.h"
d7e09d03 39
d62403d6 40static int config_on_load;
8cc7b4b9
PT
41module_param(config_on_load, int, 0444);
42MODULE_PARM_DESC(config_on_load, "configure network at module load");
d7e09d03
PT
43
44static struct mutex lnet_config_mutex;
45
f526b20a 46static int
eca5b881 47lnet_configure(void *arg)
d7e09d03
PT
48{
49 /* 'arg' only there so I can be passed to cfs_create_thread() */
7e7ab095 50 int rc = 0;
d7e09d03 51
bdd84a6f 52 mutex_lock(&lnet_config_mutex);
d7e09d03
PT
53
54 if (!the_lnet.ln_niinit_self) {
55 rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
56 if (rc >= 0) {
57 the_lnet.ln_niinit_self = 1;
58 rc = 0;
59 }
60 }
61
bdd84a6f 62 mutex_unlock(&lnet_config_mutex);
d7e09d03
PT
63 return rc;
64}
65
f526b20a 66static int
eca5b881 67lnet_unconfigure(void)
d7e09d03 68{
7e7ab095 69 int refcount;
d7e09d03 70
bdd84a6f 71 mutex_lock(&lnet_config_mutex);
d7e09d03
PT
72
73 if (the_lnet.ln_niinit_self) {
74 the_lnet.ln_niinit_self = 0;
75 LNetNIFini();
76 }
77
bdd84a6f 78 mutex_lock(&the_lnet.ln_api_mutex);
d7e09d03 79 refcount = the_lnet.ln_refcount;
bdd84a6f 80 mutex_unlock(&the_lnet.ln_api_mutex);
d7e09d03 81
bdd84a6f 82 mutex_unlock(&lnet_config_mutex);
d7e09d03
PT
83 return (refcount == 0) ? 0 : -EBUSY;
84}
85
f526b20a 86static int
d7e09d03
PT
87lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
88{
7e7ab095 89 int rc;
d7e09d03
PT
90
91 switch (cmd) {
92 case IOC_LIBCFS_CONFIGURE:
93 return lnet_configure(NULL);
94
95 case IOC_LIBCFS_UNCONFIGURE:
96 return lnet_unconfigure();
97
98 default:
99 /* Passing LNET_PID_ANY only gives me a ref if the net is up
100 * already; I'll need it to ensure the net can't go down while
101 * I'm called into it */
102 rc = LNetNIInit(LNET_PID_ANY);
103 if (rc >= 0) {
104 rc = LNetCtl(cmd, data);
105 LNetNIFini();
106 }
107 return rc;
108 }
109}
110
f3731cdb 111static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
d7e09d03 112
828ebb8f 113static int __init
d7e09d03
PT
114init_lnet(void)
115{
7e7ab095 116 int rc;
d7e09d03
PT
117
118 mutex_init(&lnet_config_mutex);
119
a9cf72b6 120 rc = lnet_init();
d7e09d03 121 if (rc != 0) {
a9cf72b6 122 CERROR("lnet_init: error %d\n", rc);
0a3bdb00 123 return rc;
d7e09d03
PT
124 }
125
126 rc = libcfs_register_ioctl(&lnet_ioctl_handler);
eca5b881 127 LASSERT(rc == 0);
d7e09d03
PT
128
129 if (config_on_load) {
130 /* Have to schedule a separate thread to avoid deadlocking
131 * in modload */
132 (void) kthread_run(lnet_configure, NULL, "lnet_initd");
133 }
134
0a3bdb00 135 return 0;
d7e09d03
PT
136}
137
828ebb8f 138static void __exit
d7e09d03
PT
139fini_lnet(void)
140{
141 int rc;
142
143 rc = libcfs_deregister_ioctl(&lnet_ioctl_handler);
eca5b881 144 LASSERT(rc == 0);
d7e09d03 145
a9cf72b6 146 lnet_fini();
d7e09d03
PT
147}
148
a0455471 149MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
92980ff9 150MODULE_DESCRIPTION("LNet v3.1");
d7e09d03 151MODULE_LICENSE("GPL");
6960736c 152MODULE_VERSION("1.0.0");
d7e09d03 153
6960736c
GKH
154module_init(init_lnet);
155module_exit(fini_lnet);
This page took 0.291728 seconds and 5 git commands to generate.