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) 2011, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 * Lustre Management Client
39 * Author: Nathan Rutman <nathan@clusterfs.com>
42 /* Minimal MGC for liblustre: only used to read the config log from the MGS
43 at setup time, no updates. */
45 #define DEBUG_SUBSYSTEM S_MGC
47 #include <liblustre.h>
49 #include <obd_class.h>
50 #include <lustre_dlm.h>
51 #include <lustre_log.h>
52 #include <lustre_fsfilt.h>
53 #include <lustre_disk.h>
56 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
63 rc = client_obd_setup(obd, lcfg);
67 /* liblustre only support null flavor to MGS */
68 obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL;
70 rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
72 CERROR("failed to setup llogging subsystems\n");
73 GOTO(err_cleanup, rc);
79 client_obd_cleanup(obd);
85 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
91 case OBD_CLEANUP_EARLY:
92 case OBD_CLEANUP_EXPORTS:
93 obd_cleanup_client_import(obd);
94 rc = obd_llog_finish(obd, 0);
96 CERROR("failed to cleanup llogging subsystems\n");
102 static int mgc_cleanup(struct obd_device *obd)
104 struct client_obd *cli = &obd->u.cli;
108 LASSERT(cli->cl_mgc_vfsmnt == NULL);
112 rc = client_obd_cleanup(obd);
116 static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
117 struct obd_device *tgt, int *index)
119 struct llog_ctxt *ctxt;
123 LASSERT(olg == &obd->obd_olg);
124 rc = llog_setup(obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
127 ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT);
128 llog_initiator_connect(ctxt);
135 static int mgc_llog_finish(struct obd_device *obd, int count)
140 rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT));
145 struct obd_ops mgc_obd_ops = {
146 .o_owner = THIS_MODULE,
147 .o_setup = mgc_setup,
148 .o_precleanup = mgc_precleanup,
149 .o_cleanup = mgc_cleanup,
150 .o_add_conn = client_import_add_conn,
151 .o_del_conn = client_import_del_conn,
152 .o_connect = client_connect_import,
153 .o_disconnect = client_disconnect_export,
154 .o_llog_init = mgc_llog_init,
155 .o_llog_finish = mgc_llog_finish,
158 int __init mgc_init(void)
160 return class_register_type(&mgc_obd_ops, NULL,
161 NULL, LUSTRE_MGC_NAME, NULL);