1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/mgc/mgc_request.c
5 * Lustre Management Client
7 * Copyright (C) 2006 Cluster File Systems, Inc.
8 * Author: Nathan Rutman <nathan@clusterfs.com>
10 * This file is part of Lustre, http://www.lustre.org
12 * Lustre is free software; you can redistribute it and/or
13 * modify it under the terms of version 2 of the GNU General Public
14 * License as published by the Free Software Foundation.
16 * Lustre is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with Lustre; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* Minimal MGC for liblustre: only used to read the config log from the MGS
27 at setup time, no updates. */
30 # define EXPORT_SYMTAB
32 #define DEBUG_SUBSYSTEM S_MGC
34 #include <liblustre.h>
36 #include <obd_class.h>
37 #include <lustre_dlm.h>
38 #include <lustre_log.h>
39 #include <lustre_fsfilt.h>
40 #include <lustre_disk.h>
42 static int mgc_setup(struct obd_device *obd, obd_count len, void *buf)
49 rc = client_obd_setup(obd, len, buf);
53 rc = obd_llog_init(obd, obd, 0, NULL, NULL);
55 CERROR("failed to setup llogging subsystems\n");
56 GOTO(err_cleanup, rc);
62 client_obd_cleanup(obd);
68 static int mgc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
74 case OBD_CLEANUP_EARLY:
75 case OBD_CLEANUP_EXPORTS:
77 case OBD_CLEANUP_SELF_EXP:
78 rc = obd_llog_finish(obd, 0);
80 CERROR("failed to cleanup llogging subsystems\n");
88 static int mgc_cleanup(struct obd_device *obd)
90 struct client_obd *cli = &obd->u.cli;
94 LASSERT(cli->cl_mgc_vfsmnt == NULL);
98 rc = client_obd_cleanup(obd);
102 static int mgc_llog_init(struct obd_device *obd, struct obd_device *tgt,
103 int count, struct llog_catid *logid,
104 struct obd_uuid *uuid)
106 struct llog_ctxt *ctxt;
110 rc = llog_setup(obd, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
113 ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
114 ctxt->loc_imp = obd->u.cli.cl_import;
120 static int mgc_llog_finish(struct obd_device *obd, int count)
125 rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT));
130 struct obd_ops mgc_obd_ops = {
131 .o_owner = THIS_MODULE,
132 .o_setup = mgc_setup,
133 .o_precleanup = mgc_precleanup,
134 .o_cleanup = mgc_cleanup,
135 .o_add_conn = client_import_add_conn,
136 .o_del_conn = client_import_del_conn,
137 .o_connect = client_connect_import,
138 .o_disconnect = client_disconnect_export,
139 .o_llog_init = mgc_llog_init,
140 .o_llog_finish = mgc_llog_finish,
143 int __init mgc_init(void)
145 return class_register_type(&mgc_obd_ops, NULL, LUSTRE_MGC_NAME);