1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
32 * Copyright (c) 2011, Whamcloud, Inc.
35 * This file is part of Lustre, http://www.lustre.org/
36 * Lustre is a trademark of Sun Microsystems, Inc.
40 * Lustre Management Client
41 * Author: Nathan Rutman <nathan@clusterfs.com>
44 /* Minimal MGC for liblustre: only used to read the config log from the MGS
45 at setup time, no updates. */
48 # define EXPORT_SYMTAB
50 #define DEBUG_SUBSYSTEM S_MGC
52 #include <liblustre.h>
54 #include <obd_class.h>
55 #include <lustre_dlm.h>
56 #include <lustre_log.h>
57 #include <lustre_fsfilt.h>
58 #include <lustre_disk.h>
61 static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
68 rc = client_obd_setup(obd, lcfg);
72 /* liblustre only support null flavor to MGS */
73 obd->u.cli.cl_flvr_mgc.sf_rpc = SPTLRPC_FLVR_NULL;
75 rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
77 CERROR("failed to setup llogging subsystems\n");
78 GOTO(err_cleanup, rc);
84 client_obd_cleanup(obd);
90 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
96 case OBD_CLEANUP_EARLY:
97 case OBD_CLEANUP_EXPORTS:
98 obd_cleanup_client_import(obd);
99 rc = obd_llog_finish(obd, 0);
101 CERROR("failed to cleanup llogging subsystems\n");
107 static int mgc_cleanup(struct obd_device *obd)
109 struct client_obd *cli = &obd->u.cli;
113 LASSERT(cli->cl_mgc_vfsmnt == NULL);
117 rc = client_obd_cleanup(obd);
121 static int mgc_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
122 struct obd_device *tgt, int *index)
124 struct llog_ctxt *ctxt;
128 LASSERT(olg == &obd->obd_olg);
129 rc = llog_setup(obd, olg, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
132 ctxt = llog_group_get_ctxt(olg, LLOG_CONFIG_REPL_CTXT);
133 llog_initiator_connect(ctxt);
140 static int mgc_llog_finish(struct obd_device *obd, int count)
145 rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT));
150 struct obd_ops mgc_obd_ops = {
151 .o_owner = THIS_MODULE,
152 .o_setup = mgc_setup,
153 .o_precleanup = mgc_precleanup,
154 .o_cleanup = mgc_cleanup,
155 .o_add_conn = client_import_add_conn,
156 .o_del_conn = client_import_del_conn,
157 .o_connect = client_connect_import,
158 .o_disconnect = client_disconnect_export,
159 .o_llog_init = mgc_llog_init,
160 .o_llog_finish = mgc_llog_finish,
163 int __init mgc_init(void)
165 return class_register_type(&mgc_obd_ops, NULL,
166 NULL, LUSTRE_MGC_NAME, NULL);