From 488f69f7e1fb55209ae65761f6e1a0fe9270587c Mon Sep 17 00:00:00 2001 From: bobijam Date: Mon, 10 Mar 2008 03:26:40 +0000 Subject: [PATCH] Branch HEAD b=14321 o=Brian Behlendorf(behlendorf1@llnl.gov) i=bobijam i=shadow add MGS handler statistics. --- lustre/mgc/Makefile.in | 2 +- lustre/mgc/lproc_mgc.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ lustre/mgc/mgc_internal.h | 24 ++++++++++++++++++++ lustre/mgc/mgc_request.c | 8 +++++++ lustre/mgs/lproc_mgs.c | 37 +++++++++++++++++++++++++++++++ lustre/mgs/mgs_handler.c | 34 ++++++++++++++++++++++++----- lustre/mgs/mgs_internal.h | 21 ++++++++++++++---- lustre/obdclass/obd_mount.c | 9 ++++++-- 8 files changed, 176 insertions(+), 12 deletions(-) create mode 100644 lustre/mgc/lproc_mgc.c create mode 100644 lustre/mgc/mgc_internal.h diff --git a/lustre/mgc/Makefile.in b/lustre/mgc/Makefile.in index 2d7cad5..8adca32 100644 --- a/lustre/mgc/Makefile.in +++ b/lustre/mgc/Makefile.in @@ -1,4 +1,4 @@ MODULES := mgc -mgc-objs := mgc_request.o +mgc-objs := mgc_request.o lproc_mgc.o @INCLUDE_RULES@ diff --git a/lustre/mgc/lproc_mgc.c b/lustre/mgc/lproc_mgc.c new file mode 100644 index 0000000..1b1fd12 --- /dev/null +++ b/lustre/mgc/lproc_mgc.c @@ -0,0 +1,53 @@ +/* -*- 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 +#include +#include +#include + +#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 */ diff --git a/lustre/mgc/mgc_internal.h b/lustre/mgc/mgc_internal.h new file mode 100644 index 0000000..1edf122 --- /dev/null +++ b/lustre/mgc/mgc_internal.h @@ -0,0 +1,24 @@ +/* -*- 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 +#include +#include +#include +#include +#include + +#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 */ diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index b4b44ce..39a5632 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -41,9 +41,11 @@ #include #include +#include #include #include #include +#include "mgc_internal.h" static int mgc_name2resid(char *name, int len, struct ldlm_res_id *res_id) { @@ -246,6 +248,7 @@ static cfs_waitq_t rq_waitq; 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) { @@ -490,6 +493,7 @@ static int mgc_cleanup(struct obd_device *obd) /* Only for the last mgc */ class_del_profiles(); + lprocfs_obd_cleanup(obd); ptlrpcd_decref(); rc = client_obd_cleanup(obd); @@ -498,6 +502,7 @@ static int mgc_cleanup(struct obd_device *obd) static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { + struct lprocfs_static_vars lvars; int rc; ENTRY; @@ -513,6 +518,9 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg) 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) { diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index e3d71ad..b3fae35 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -85,10 +85,29 @@ int lproc_mgs_setup(struct obd_device *obd) 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) { @@ -183,6 +202,7 @@ struct lprocfs_vars lprocfs_mgs_obd_vars[] = { { "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 } }; @@ -190,6 +210,23 @@ struct lprocfs_vars lprocfs_mgs_module_vars[] = { { 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; diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 3a1a6e6..4672540 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -67,6 +67,8 @@ static int mgs_connect(const struct lu_env *env, 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; @@ -93,7 +95,9 @@ static int mgs_disconnect(struct obd_export *exp) 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); @@ -295,10 +299,7 @@ static int mgs_cleanup(struct obd_device *obd) 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); @@ -386,6 +387,8 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req) 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))) { @@ -537,6 +540,23 @@ static int mgs_set_info_rpc(struct ptlrpc_request *req) 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) { @@ -577,6 +597,10 @@ 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); @@ -584,7 +608,7 @@ int mgs_handle(struct ptlrpc_request *req) 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"); diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index 5f0361f..f2a511b 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -73,15 +73,18 @@ int mgs_fs_cleanup(struct obd_device *obddev); #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) { @@ -89,6 +92,16 @@ 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 */ diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 572c4f4..9104459 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -778,8 +778,13 @@ static int lustre_stop_mgc(struct super_block *sb) * 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 */ -- 1.8.3.1