MODULES := mgc
-mgc-objs := mgc_request.o
+mgc-objs := mgc_request.o lproc_mgc.o
@INCLUDE_RULES@
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ * Copyright (C) 2002 Cluster File Systems, Inc.
+ *
+ * This file is part of the Lustre file system, http://www.lustre.org
+ * Lustre is a trademark of Cluster File Systems, Inc.
+ *
+ * You may have signed or agreed to another license before downloading
+ * this software. If so, you are bound by the terms and conditions
+ * of that agreement, and the following does not apply to you. See the
+ * LICENSE file included with this distribution for more information.
+ *
+ * If you did not agree to a different license, then this copy of Lustre
+ * is open source software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * In either case, Lustre is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * license text for more details.
+ *
+ */
+#define DEBUG_SUBSYSTEM S_CLASS
+
+#include <linux/version.h>
+#include <linux/vfs.h>
+#include <obd_class.h>
+#include <lprocfs_status.h>
+
+#ifdef LPROCFS
+
+static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
+ { "uuid", lprocfs_rd_uuid, 0, 0 },
+ { "ping", 0, lprocfs_wr_ping, 0 },
+ { "connect_flags", lprocfs_rd_connect_flags, 0, 0 },
+ { "mgs_server_uuid", lprocfs_rd_server_uuid, 0, 0 },
+ { "mgs_conn_uuid", lprocfs_rd_conn_uuid, 0, 0 },
+ { 0 }
+};
+
+static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
+ { "num_refs", lprocfs_rd_numrefs, 0, 0 },
+ { 0 }
+};
+
+void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
+{
+ lvars->module_vars = lprocfs_mgc_module_vars;
+ lvars->obd_vars = lprocfs_mgc_obd_vars;
+}
+#endif /* LPROCFS */
--- /dev/null
+/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ */
+
+#ifndef _MGC_INTERNAL_H
+#define _MGC_INTERNAL_H
+
+#include <libcfs/kp30.h>
+#include <lustre/lustre_idl.h>
+#include <lustre_lib.h>
+#include <lustre_dlm.h>
+#include <lustre_log.h>
+#include <lustre_export.h>
+
+#ifdef LPROCFS
+void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
+#else
+static void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
+{
+ memset(lvars, 0, sizeof(*lvars));
+}
+#endif /* LPROCFS */
+
+#endif /* _MGC_INTERNAL_H */
#include <obd_class.h>
#include <lustre_dlm.h>
+#include <lprocfs_status.h>
#include <lustre_log.h>
#include <lustre_fsfilt.h>
#include <lustre_disk.h>
+#include "mgc_internal.h"
static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id)
{
static int mgc_process_log(struct obd_device *mgc,
struct config_llog_data *cld);
+static int mgc_requeue_add(struct config_llog_data *cld, int later);
static int mgc_requeue_thread(void *data)
{
/* Only for the last mgc */
class_del_profiles();
+ lprocfs_obd_cleanup(obd);
ptlrpcd_decref();
rc = client_obd_cleanup(obd);
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
+ struct lprocfs_static_vars lvars;
int rc;
ENTRY;
GOTO(err_cleanup, rc);
}
+ lprocfs_mgc_init_vars(&lvars);
+ lprocfs_obd_setup(obd, lvars.obd_vars);
+
spin_lock(&config_list_lock);
atomic_inc(&mgc_count);
if (atomic_read(&mgc_count) == 1) {
rc = lprocfs_obd_seq_create(obd, "filesystems", 0444,
&mgs_fs_fops, obd);
mgs->mgs_proc_live = proc_mkdir("live", obd->obd_proc_entry);
+ obd->obd_proc_exports = proc_mkdir("exports", obd->obd_proc_entry);
return rc;
}
+int lproc_mgs_cleanup(struct obd_device *obd)
+{
+ struct mgs_obd *mgs = &obd->u.mgs;
+
+ if (obd)
+ return -EINVAL;
+
+ if (mgs->mgs_proc_live) {
+ /* Should be no live entries */
+ LASSERT(mgs->mgs_proc_live->subdir == NULL);
+ lprocfs_remove(&mgs->mgs_proc_live);
+ mgs->mgs_proc_live = NULL;
+ }
+ lprocfs_free_obd_stats(obd);
+
+ return lprocfs_obd_cleanup(obd);
+}
+
static void seq_show_srpc_rule(struct seq_file *seq, const char *tgtname,
struct sptlrpc_rule_set *rset)
{
{ "fstype", lprocfs_rd_fstype, 0, 0 },
{ "mntdev", lprocfs_mgs_rd_mntdev, 0, 0 },
{ "num_exports", lprocfs_rd_num_exports, 0, 0 },
+ { "evict_client", 0, lprocfs_wr_evict_client, 0 },
{ 0 }
};
{ 0 }
};
+void mgs_counter_incr(struct obd_export *exp, int opcode)
+{
+ lprocfs_counter_incr(exp->exp_obd->obd_stats, opcode);
+ lprocfs_counter_incr(exp->exp_ops_stats, opcode);
+}
+
+void mgs_stats_counter_init(struct lprocfs_stats *stats)
+{
+ lprocfs_counter_init(stats, LPROC_MGS_CONNECT, 0, "connect", "reqs");
+ lprocfs_counter_init(stats, LPROC_MGS_DISCONNECT, 0, "disconnect",
+ "reqs");
+ lprocfs_counter_init(stats, LPROC_MGS_EXCEPTION, 0, "exception",
+ "reqs");
+ lprocfs_counter_init(stats, LPROC_MGS_TARGET_REG, 0, "tgtreg", "reqs");
+ lprocfs_counter_init(stats, LPROC_MGS_TARGET_DEL, 0, "tgtdel", "reqs");
+}
+
void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
{
lvars->module_vars = lprocfs_mgs_module_vars;
exp->exp_flvr.sf_rpc = SPTLRPC_FLVR_NULL;
+ mgs_counter_incr(exp, LPROC_MGS_CONNECT);
+
if (data != NULL) {
data->ocd_connect_flags &= MGS_CONNECT_SUPPORTED;
exp->exp_connect_flags = data->ocd_connect_flags;
ENTRY;
LASSERT(exp);
+
class_export_get(exp);
+ mgs_counter_incr(exp, LPROC_MGS_DISCONNECT);
/* Disconnect early so that clients can't keep using export */
rc = class_disconnect(exp);
ptlrpc_unregister_service(mgs->mgs_service);
mgs_cleanup_fsdb_list(obd);
-
- lprocfs_obd_cleanup(obd);
- mgs->mgs_proc_live = NULL;
-
+ lproc_mgs_cleanup(obd);
mgs_fs_cleanup(obd);
server_put_mount(obd->obd_name, mgs->mgs_vfsmnt);
int rc = 0, lockrc;
ENTRY;
+ mgs_counter_incr(req->rq_export, LPROC_MGS_TARGET_REG);
+
mti = req_capsule_client_get(&req->rq_pill, &RMF_MGS_TARGET_INFO);
if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 |
LDD_F_UPDATE))) {
RETURN(rc);
}
+/* Called whenever a target cleans up. */
+/* XXX - Currently unused */
+static int mgs_handle_target_del(struct ptlrpc_request *req)
+{
+ ENTRY;
+ mgs_counter_incr(req->rq_export, LPROC_MGS_TARGET_DEL);
+ RETURN(0);
+}
+
+/* XXX - Currently unused */
+static int mgs_handle_exception(struct ptlrpc_request *req)
+{
+ ENTRY;
+ mgs_counter_incr(req->rq_export, LPROC_MGS_EXCEPTION);
+ RETURN(0);
+}
+
/* TODO: handle requests in a similar way as MDT: see mdt_handle_common() */
int mgs_handle(struct ptlrpc_request *req)
{
rc = target_handle_disconnect(req);
req->rq_status = rc; /* superfluous? */
break;
+ case MGS_EXCEPTION:
+ DEBUG_REQ(D_MGS, req, "exception");
+ rc = mgs_handle_exception(req);
+ break;
case MGS_TARGET_REG:
DEBUG_REQ(D_MGS, req, "target add");
req_capsule_set(&req->rq_pill, &RQF_MGS_TARGET_REG);
break;
case MGS_TARGET_DEL:
DEBUG_REQ(D_MGS, req, "target del");
- //rc = mgs_handle_target_del(req);
+ rc = mgs_handle_target_del(req);
break;
case MGS_SET_INFO:
DEBUG_REQ(D_MGS, req, "set_info");
#define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix)))
#ifdef LPROCFS
int lproc_mgs_setup(struct obd_device *dev);
+int lproc_mgs_cleanup(struct obd_device *obd);
int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb);
int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb);
void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars);
#else
static inline int lproc_mgs_setup(struct obd_device *dev)
{return 0;}
-static int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb)
+static inline int lproc_mgs_cleanup(struct obd_device *obd)
{return 0;}
-static int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb)
+static inline int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb)
+{return 0;}
+static inline int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb)
{return 0;}
static void lprocfs_mgs_init_vars(struct lprocfs_static_vars *lvars)
{
}
#endif
-#endif /* _MGS_INTERNAL_H */
-
+/* mgs/lproc_mgs.c */
+enum {
+ LPROC_MGS_CONNECT = 0,
+ LPROC_MGS_DISCONNECT,
+ LPROC_MGS_EXCEPTION,
+ LPROC_MGS_TARGET_REG,
+ LPROC_MGS_TARGET_DEL,
+ LPROC_MGS_LAST
+};
+void mgs_counter_incr(struct obd_export *exp, int opcode);
+void mgs_stats_counter_init(struct lprocfs_stats *stats);
+#endif /* _MGS_INTERNAL_H */
* force shotdown set in umount_begin */
obd->obd_no_recov = 1;
- if (obd->u.cli.cl_mgc_mgsexp)
- obd_disconnect(obd->u.cli.cl_mgc_mgsexp);
+ if (obd->u.cli.cl_mgc_mgsexp) {
+ /* An error is not fatal, if we are unable to send the
+ disconnect mgs ping evictor cleans up the export */
+ rc = obd_disconnect(obd->u.cli.cl_mgc_mgsexp);
+ if (rc)
+ CDEBUG(D_MOUNT, "disconnect failed %d\n", rc);
+ }
/* Save the obdname for cleaning the nid uuids, which are
obdname_XX */