X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmgs%2Flproc_mgs.c;h=b6732802fd212560ad4490479226dd73e4ad79ec;hb=38fd69573b69f8d6ab705f68862b9d4d593d7fcf;hp=e3d71ad66dbc0a9fad761db92a3bbc0eea111e57;hpb=3192e52a89946f12fd36d28a686c169d01d36e64;p=fs%2Flustre-release.git diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index e3d71ad..b673280 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -1,26 +1,37 @@ /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- * vim:expandtab:shiftwidth=8:tabstop=8: * - * Copyright (C) 2002 Cluster File Systems, Inc. + * GPL HEADER START * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * 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. + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * 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. + * This program 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 GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * 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. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + * + * GPL HEADER END + */ +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Use is subject to license terms. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. */ #define DEBUG_SUBSYSTEM S_CLASS @@ -77,20 +88,8 @@ static int mgs_fs_seq_show(struct seq_file *seq, void *v) LPROC_SEQ_FOPS_RO(mgs_fs); -int lproc_mgs_setup(struct obd_device *obd) -{ - struct mgs_obd *mgs = &obd->u.mgs; - int rc; - - rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, - &mgs_fs_fops, obd); - mgs->mgs_proc_live = proc_mkdir("live", obd->obd_proc_entry); - - return rc; -} - -static void seq_show_srpc_rule(struct seq_file *seq, const char *tgtname, - struct sptlrpc_rule_set *rset) +static void seq_show_srpc_rules(struct seq_file *seq, const char *tgtname, + struct sptlrpc_rule_set *rset) { struct sptlrpc_rule *r; char dirbuf[10]; @@ -119,22 +118,90 @@ static void seq_show_srpc_rule(struct seq_file *seq, const char *tgtname, } } -static int mgs_live_seq_show(struct seq_file *seq, void *v) +static int mgsself_srpc_seq_show(struct seq_file *seq, void *v) +{ + struct obd_device *obd = seq->private; + struct fs_db *fsdb; + int rc; + + rc = mgs_find_or_make_fsdb(obd, MGSSELF_NAME, &fsdb); + if (rc) + return rc; + + down(&fsdb->fsdb_sem); + seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); + up(&fsdb->fsdb_sem); + return 0; +} + +LPROC_SEQ_FOPS_RO(mgsself_srpc); + +int lproc_mgs_setup(struct obd_device *obd) +{ + struct mgs_obd *mgs = &obd->u.mgs; + int rc; + + rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, + &mgs_fs_fops, obd); + rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0600, + &mgsself_srpc_fops, obd); + + mgs->mgs_proc_live = lprocfs_register("live", obd->obd_proc_entry, + NULL, NULL); + if (IS_ERR(mgs->mgs_proc_live)) { + rc = PTR_ERR(mgs->mgs_proc_live); + CERROR("error %d setting up lprocfs for %s\n", rc, "live"); + mgs->mgs_proc_live = NULL; + } + + obd->obd_proc_exports_entry = lprocfs_register("exports", + obd->obd_proc_entry, + NULL, NULL); + if (IS_ERR(obd->obd_proc_exports_entry)) { + rc = PTR_ERR(obd->obd_proc_exports_entry); + CERROR("error %d setting up lprocfs for %s\n", rc, "exports"); + obd->obd_proc_exports_entry = NULL; + } + + return rc; +} + +int lproc_mgs_cleanup(struct obd_device *obd) +{ + struct mgs_obd *mgs; + + if (!obd) + return -EINVAL; + + mgs = &obd->u.mgs; + 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_per_client_stats(obd); + lprocfs_free_obd_stats(obd); + + return lprocfs_obd_cleanup(obd); +} + +static int mgs_live_seq_show(struct seq_file *seq, void *v) { struct fs_db *fsdb = seq->private; struct mgs_tgt_srpc_conf *srpc_tgt; int i; - + down(&fsdb->fsdb_sem); seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); - seq_printf(seq, "flags: %#x gen: %d\n", + seq_printf(seq, "flags: %#x gen: %d\n", fsdb->fsdb_flags, fsdb->fsdb_gen); for (i = 0; i < INDEX_MAP_SIZE * 8; i++) - if (test_bit(i, fsdb->fsdb_mdt_index_map)) + if (test_bit(i, fsdb->fsdb_mdt_index_map)) seq_printf(seq, "%s-MDT%04x\n", fsdb->fsdb_name, i); for (i = 0; i < INDEX_MAP_SIZE * 8; i++) - if (test_bit(i, fsdb->fsdb_ost_index_map)) + if (test_bit(i, fsdb->fsdb_ost_index_map)) seq_printf(seq, "%s-OST%04x\n", fsdb->fsdb_name, i); seq_printf(seq, "\nSecure RPC Config Rules:\n"); @@ -144,10 +211,10 @@ static int mgs_live_seq_show(struct seq_file *seq, void *v) #endif for (srpc_tgt = fsdb->fsdb_srpc_tgt; srpc_tgt; srpc_tgt = srpc_tgt->mtsc_next) { - seq_show_srpc_rule(seq, srpc_tgt->mtsc_tgt, - &srpc_tgt->mtsc_rset); + seq_show_srpc_rules(seq, srpc_tgt->mtsc_tgt, + &srpc_tgt->mtsc_rset); } - seq_show_srpc_rule(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); + seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); up(&fsdb->fsdb_sem); return 0; @@ -160,9 +227,9 @@ int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb) struct mgs_obd *mgs = &obd->u.mgs; int rc; - if (!mgs->mgs_proc_live) + if (!mgs->mgs_proc_live) return 0; - rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444, + rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444, &mgs_live_fops, fsdb); return 0; @@ -172,9 +239,10 @@ int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb) { struct mgs_obd *mgs = &obd->u.mgs; - if (!mgs->mgs_proc_live) + if (!mgs->mgs_proc_live) return 0; - remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); + + lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); return 0; } @@ -183,6 +251,8 @@ 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 }, + { "hash_stats", lprocfs_obd_rd_hash, 0, 0 }, + { "evict_client", 0, lprocfs_wr_evict_client, 0 }, { 0 } }; @@ -190,6 +260,24 @@ 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); + if (exp->exp_nid_stats && exp->exp_nid_stats->nid_stats != NULL) + lprocfs_counter_incr(exp->exp_nid_stats->nid_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;