X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmgs%2Flproc_mgs.c;h=ffa2d0d1ffc53ea560eb51c9e7117e526eef77e1;hb=57649535fee8e92412db6806a30d2fa0752f762f;hp=06b8396c195d92a44c987a0af1bb24c3278bd843;hpb=08aa217ce49aba1ded52e0f7adb8a607035123fd;p=fs%2Flustre-release.git diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 06b8396..ffa2d0d 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -116,53 +116,48 @@ static void seq_show_srpc_rules(struct seq_file *seq, const char *tgtname, static int mgsself_srpc_seq_show(struct seq_file *seq, void *v) { - struct obd_device *obd = seq->private; - struct mgs_device *mgs; - struct fs_db *fsdb; - struct lu_env env; - int rc; - - LASSERT(obd != NULL); - LASSERT(obd->obd_lu_dev != NULL); - mgs = lu2mgs_dev(obd->obd_lu_dev); - - rc = lu_env_init(&env, LCT_MG_THREAD); - if (rc) - return rc; + struct obd_device *obd = seq->private; + struct mgs_device *mgs = lu2mgs_dev(obd->obd_lu_dev); + struct lu_target *tgt = &mgs->mgs_lut; - rc = mgs_find_or_make_fsdb(&env, mgs, MGSSELF_NAME, &fsdb); - if (rc) - goto out; + read_lock(&tgt->lut_sptlrpc_lock); + seq_show_srpc_rules(seq, MGSSELF_NAME, &tgt->lut_sptlrpc_rset); + read_unlock(&tgt->lut_sptlrpc_lock); - mutex_lock(&fsdb->fsdb_mutex); - seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); - mutex_unlock(&fsdb->fsdb_mutex); - -out: - lu_env_fini(&env); return 0; } LPROC_SEQ_FOPS_RO(mgsself_srpc); -int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) +int lproc_mgs_setup(struct mgs_device *mgs, const char *osd_name) { struct obd_device *obd = mgs->mgs_obd; struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd; int osd_len = strlen(osd_name) - strlen("-osd"); int rc; + struct lprocfs_static_vars lvars; + + lprocfs_mgs_init_vars(&lvars); + rc = lprocfs_obd_setup(obd, lvars.obd_vars); + if (rc != 0) + GOTO(out, 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); + if (rc != 0) + GOTO(out, rc); + + rc = lprocfs_obd_seq_create(obd, "srpc_rules", 0400, + &mgsself_srpc_fops, obd); + if (rc != 0) + GOTO(out, rc); 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; + GOTO(out, rc); } obd->obd_proc_exports_entry = lprocfs_register("exports", @@ -170,8 +165,8 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) 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; + GOTO(out, rc); } mgs->mgs_proc_osd = lprocfs_add_symlink("osd", @@ -181,29 +176,33 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) osd_len, /* Strip "-osd". */ osd_name); if (mgs->mgs_proc_osd == NULL) - rc = -ENOMEM; + GOTO(out, rc = -ENOMEM); mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev", obd->obd_proc_entry, "osd/mntdev"); if (mgs->mgs_proc_mntdev == NULL) - rc = -ENOMEM; + GOTO(out, rc = -ENOMEM); mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype", obd->obd_proc_entry, "osd/fstype"); if (mgs->mgs_proc_fstype == NULL) - rc = -ENOMEM; + GOTO(out, rc = -ENOMEM); + +out: + if (rc != 0) + lproc_mgs_cleanup(mgs); return rc; } -int lproc_mgs_cleanup(struct mgs_device *mgs) +void lproc_mgs_cleanup(struct mgs_device *mgs) { struct obd_device *obd = mgs->mgs_obd; - if (!obd) - return -EINVAL; + if (obd == NULL) + return; if (mgs->mgs_proc_osd != NULL) lprocfs_remove(&mgs->mgs_proc_osd); @@ -211,19 +210,20 @@ int lproc_mgs_cleanup(struct mgs_device *mgs) if (mgs->mgs_proc_fstype != NULL) lprocfs_remove(&mgs->mgs_proc_fstype); - if (mgs->mgs_proc_mntdev) + if (mgs->mgs_proc_mntdev != NULL) lprocfs_remove(&mgs->mgs_proc_mntdev); - 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; - } + + if (mgs->mgs_proc_live != NULL) { + /* 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_obd_cleanup(obd); lprocfs_free_obd_stats(obd); lprocfs_free_md_stats(obd); - - return lprocfs_obd_cleanup(obd); } static int mgs_live_seq_show(struct seq_file *seq, void *v) @@ -282,8 +282,8 @@ int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb) if (!mgs->mgs_proc_live) return 0; - rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0444, - &mgs_live_fops, fsdb); + rc = lprocfs_seq_create(mgs->mgs_proc_live, fsdb->fsdb_name, 0644, + &mgs_live_fops, fsdb); return 0; } @@ -293,7 +293,9 @@ int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) if (!mgs->mgs_proc_live) return 0; - lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); + /* didn't create the proc file for MGSSELF_NAME */ + if (!test_bit(FSDB_MGS_SELF, &fsdb->fsdb_flags)) + lprocfs_remove_proc_entry(fsdb->fsdb_name, mgs->mgs_proc_live); return 0; }