1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Implementation of the management/health monitoring service.
6 * Copyright (c) 2003 Cluster File Systems, Inc.
7 * Author: Mike Shaver <shaver@clusterfs.com>
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 # define EXPORT_SYMTAB
28 #define DEBUG_SUBSYSTEM S_MGMT
29 #include <linux/module.h>
30 #include <linux/init.h>
32 #include <linux/obd_class.h>
33 #include <linux/lustre_net.h>
35 #define MGMT_NBUFS 128UL
36 #define MGMT_BUFSIZE 8192
37 #define MGMT_MAXREQSIZE 512
38 #define MGMT_NUM_THREADS 4
39 #define MGMT_DEVICE_NAME "mgmt"
41 static int mgmt_initialized;
42 static struct ptlrpc_service *mgmt_service;
44 static int mgmt_ping(struct ptlrpc_request *req)
46 /* handle_incoming_request will have already updated the export's
47 * last_request_time, so we don't need to do anything else.
49 return lustre_pack_msg(0, NULL, NULL, &req->rq_replen, &req->rq_repmsg);
52 static int mgmt_handler(struct ptlrpc_request *req)
57 switch (req->rq_reqmsg->opc) {
59 DEBUG_REQ(D_RPCTRACE, req, "ping");
63 DEBUG_REQ(D_RPCTRACE, req, "connect");
64 rc = target_handle_connect(req);
67 DEBUG_REQ(D_RPCTRACE, req, "disconnect");
68 rc = target_handle_disconnect(req);
71 DEBUG_REQ(D_RPCTRACE, req, "UNKNOWN OP");
83 static int mgmt_setup(struct obd_device *obd, obd_count len, void *buf)
92 ptlrpc_init_svc(MGMT_NBUFS, MGMT_BUFSIZE, MGMT_MAXREQSIZE,
93 MGMT_REQUEST_PORTAL, MGMT_REPLY_PORTAL,
97 CERROR("Failed to start mgmt service\n");
101 rc = ptlrpc_start_n_threads(obd, mgmt_service, MGMT_NUM_THREADS,"mgmt");
105 mgmt_initialized = 1;
109 ptlrpc_unregister_service(mgmt_service);
113 static int mgmt_cleanup(struct obd_device *obd, int flags)
117 if (!mgmt_initialized)
120 ptlrpc_stop_all_threads(mgmt_service);
121 ptlrpc_unregister_service(mgmt_service);
123 mgmt_initialized = 0;
127 static struct obd_ops mgmt_obd_ops = {
128 .o_owner = THIS_MODULE,
129 .o_setup = mgmt_setup,
130 .o_cleanup = mgmt_cleanup,
131 .o_connect = class_connect,
132 .o_disconnect = class_disconnect
135 static int __init mgmt_init(void)
137 int rc = class_register_type(&mgmt_obd_ops, 0, MGMT_DEVICE_NAME);
142 static void __exit mgmt_exit(void)
144 class_unregister_type(MGMT_DEVICE_NAME);
148 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
149 MODULE_DESCRIPTION("Lustre monitoring service v0.1");
150 MODULE_LICENSE("GPL");
152 module_init(mgmt_init);
153 module_exit(mgmt_exit);