X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Fmgs%2Flproc_mgs.c;h=fad189e4da285e2029c4c24c51308502c73cf8a2;hp=1457ce624edfc98273abfa8ec709b07f17975121;hb=725b8599bbf4c98173cc049d8a73920a31287d5c;hpb=70e80ade90af09300396706b8910e196a7928520 diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 1457ce6..fad189e 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -16,8 +14,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * 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 @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -48,20 +48,21 @@ static int lprocfs_mgs_rd_mntdev(char *page, char **start, off_t off, int count, int *eof, void *data) { - struct obd_device* obd = (struct obd_device *)data; + struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - LASSERT(obd->u.mgs.mgs_vfsmnt->mnt_devname); - *eof = 1; + LASSERT(obd != NULL); + LASSERT(mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); + *eof = 1; - return snprintf(page, count, "%s\n",obd->u.mgs.mgs_vfsmnt->mnt_devname); + return snprintf(page, count, "%s\n", + mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); } static int mgs_fs_seq_show(struct seq_file *seq, void *v) { struct obd_device *obd = seq->private; struct mgs_obd *mgs = &obd->u.mgs; - struct list_head dentry_list; + cfs_list_t dentry_list; struct l_linux_dirent *dirent, *n; int rc, len; ENTRY; @@ -73,8 +74,8 @@ static int mgs_fs_seq_show(struct seq_file *seq, void *v) CERROR("Can't read config dir\n"); RETURN(rc); } - list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) { - list_del(&dirent->lld_list); + cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) { + cfs_list_del(&dirent->lld_list); len = strlen(dirent->lld_name); if ((len > 7) && (strncmp(dirent->lld_name + len - 7, "-client", len) == 0)) { @@ -88,6 +89,54 @@ static int mgs_fs_seq_show(struct seq_file *seq, void *v) LPROC_SEQ_FOPS_RO(mgs_fs); +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]; + char flvrbuf[40]; + char *net; + int i; + + for (i = 0; i < rset->srs_nrule; i++) { + r = &rset->srs_rules[i]; + + if (r->sr_netid == LNET_NIDNET(LNET_NID_ANY)) + net = "default"; + else + net = libcfs_net2str(r->sr_netid); + + if (r->sr_from == LUSTRE_SP_ANY && r->sr_to == LUSTRE_SP_ANY) + dirbuf[0] = '\0'; + else + snprintf(dirbuf, sizeof(dirbuf), ".%s2%s", + sptlrpc_part2name(r->sr_from), + sptlrpc_part2name(r->sr_to)); + + sptlrpc_flavor2name(&r->sr_flvr, flvrbuf, sizeof(flvrbuf)); + seq_printf(seq, "%s.srpc.flavor.%s%s=%s\n", tgtname, + net, dirbuf, flvrbuf); + } +} + +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; + + cfs_mutex_lock(&fsdb->fsdb_mutex); + seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); + cfs_mutex_unlock(&fsdb->fsdb_mutex); + return 0; +} + +LPROC_SEQ_FOPS_RO(mgsself_srpc); + int lproc_mgs_setup(struct obd_device *obd) { struct mgs_obd *mgs = &obd->u.mgs; @@ -95,6 +144,8 @@ int lproc_mgs_setup(struct obd_device *obd) 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); @@ -121,7 +172,7 @@ int lproc_mgs_cleanup(struct obd_device *obd) struct mgs_obd *mgs; if (!obd) - RETURN(-EINVAL); + return -EINVAL; mgs = &obd->u.mgs; if (mgs->mgs_proc_live) { @@ -130,57 +181,29 @@ int lproc_mgs_cleanup(struct obd_device *obd) lprocfs_remove(&mgs->mgs_proc_live); mgs->mgs_proc_live = NULL; } + lprocfs_free_per_client_stats(obd); lprocfs_free_obd_stats(obd); + lprocfs_free_md_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) -{ - struct sptlrpc_rule *r; - char dirbuf[10]; - char flvrbuf[40]; - char *net; - int i; - - for (i = 0; i < rset->srs_nrule; i++) { - r = &rset->srs_rules[i]; - - if (r->sr_netid == LNET_NIDNET(LNET_NID_ANY)) - net = "default"; - else - net = libcfs_net2str(r->sr_netid); - - if (r->sr_from == LUSTRE_SP_ANY && r->sr_to == LUSTRE_SP_ANY) - dirbuf[0] = '\0'; - else - snprintf(dirbuf, sizeof(dirbuf), ".%s2%s", - sptlrpc_part2name(r->sr_from), - sptlrpc_part2name(r->sr_to)); - - sptlrpc_flavor2name(&r->sr_flvr, flvrbuf, sizeof(flvrbuf)); - seq_printf(seq, "%s.srpc.flavor.%s%s=%s\n", tgtname, - net, dirbuf, flvrbuf); - } -} - -static int mgs_live_seq_show(struct seq_file *seq, void *v) +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); + + cfs_mutex_lock(&fsdb->fsdb_mutex); seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); - seq_printf(seq, "flags: %#x gen: %d\n", + seq_printf(seq, "flags: %#lx 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 (cfs_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 (cfs_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"); @@ -190,25 +213,39 @@ 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); + + lprocfs_rd_ir_state(seq, fsdb); - up(&fsdb->fsdb_sem); + cfs_mutex_unlock(&fsdb->fsdb_mutex); return 0; } -LPROC_SEQ_FOPS_RO(mgs_live); +static ssize_t mgs_live_seq_write(struct file *file, const char *buf, + size_t len, loff_t *off) +{ + struct seq_file *seq = file->private_data; + struct fs_db *fsdb = seq->private; + ssize_t rc; + + rc = lprocfs_wr_ir_state(file, buf, len, fsdb); + if (rc >= 0) + rc = len; + return rc; +} +LPROC_SEQ_FOPS(mgs_live); 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; @@ -218,7 +255,7 @@ 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; lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); @@ -230,7 +267,9 @@ 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 }, + { "ir_timeout", lprocfs_rd_ir_timeout, lprocfs_wr_ir_timeout, 0 }, { 0 } };