X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmgs%2Flproc_mgs.c;h=691ad12af64016caac5b01cee6f3814aeb01e3e4;hb=c8df02cbe6626201eba7744625fafa030b1b466d;hp=1801c04845e9efdab606803b6d87e26052528f05;hpb=ac16c5819bdd944230c938dd3b14401b72556d9b;p=fs%2Flustre-release.git diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 1801c04..691ad12 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. @@ -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,41 +48,55 @@ 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; - - LASSERT(obd != NULL); - LASSERT(obd->u.mgs.mgs_vfsmnt->mnt_devname); - *eof = 1; + struct obd_device *obd = (struct obd_device *)data; - return snprintf(page, count, "%s\n",obd->u.mgs.mgs_vfsmnt->mnt_devname); + LASSERT(obd != NULL); +#if 0 + /* will be fixed in the subsequent patch */ + LASSERT(mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); + *eof = 1; + + return snprintf(page, count, "%s\n", + mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); +#else + return 0; +#endif } 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; - cfs_list_t dentry_list; - struct l_linux_dirent *dirent, *n; + struct mgs_device *mgs; + cfs_list_t list; + struct mgs_direntry *dirent, *n; + struct lu_env env; int rc, len; ENTRY; LASSERT(obd != NULL); - rc = class_dentry_readdir(obd, mgs->mgs_configs_dir, - mgs->mgs_vfsmnt, &dentry_list); + 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); + + rc = class_dentry_readdir(&env, mgs, &list); if (rc) { CERROR("Can't read config dir\n"); - RETURN(rc); + GOTO(out, rc); } - 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)) { - seq_printf(seq, "%.*s\n", len - 7, dirent->lld_name); - } - OBD_FREE(dirent, sizeof(*dirent)); + cfs_list_for_each_entry_safe(dirent, n, &list, list) { + cfs_list_del(&dirent->list); + len = strlen(dirent->name); + if (len > 7 && + strncmp(dirent->name + len - 7, "-client", len) == 0) + seq_printf(seq, "%.*s\n", len - 7, dirent->name); + mgs_direntry_free(dirent); } +out: + lu_env_fini(&env); RETURN(0); } @@ -121,24 +135,37 @@ 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; - rc = mgs_find_or_make_fsdb(obd, MGSSELF_NAME, &fsdb); + 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; + + rc = mgs_find_or_make_fsdb(&env, mgs, MGSSELF_NAME, &fsdb); if (rc) - return rc; + goto out; - cfs_down(&fsdb->fsdb_sem); + cfs_mutex_lock(&fsdb->fsdb_mutex); seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); - cfs_up(&fsdb->fsdb_sem); + cfs_mutex_unlock(&fsdb->fsdb_mutex); + +out: + lu_env_fini(&env); return 0; } LPROC_SEQ_FOPS_RO(mgsself_srpc); -int lproc_mgs_setup(struct obd_device *obd) +int lproc_mgs_setup(struct mgs_device *mgs) { - struct mgs_obd *mgs = &obd->u.mgs; + struct obd_device *obd = mgs->mgs_obd; int rc; rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, @@ -166,14 +193,13 @@ int lproc_mgs_setup(struct obd_device *obd) return rc; } -int lproc_mgs_cleanup(struct obd_device *obd) +int lproc_mgs_cleanup(struct mgs_device *mgs) { - struct mgs_obd *mgs; + struct obd_device *obd = mgs->mgs_obd; 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); @@ -193,7 +219,7 @@ static int mgs_live_seq_show(struct seq_file *seq, void *v) struct mgs_tgt_srpc_conf *srpc_tgt; int i; - cfs_down(&fsdb->fsdb_sem); + cfs_mutex_lock(&fsdb->fsdb_mutex); seq_printf(seq, "fsname: %s\n", fsdb->fsdb_name); seq_printf(seq, "flags: %#lx gen: %d\n", @@ -217,15 +243,28 @@ static int mgs_live_seq_show(struct seq_file *seq, void *v) } seq_show_srpc_rules(seq, fsdb->fsdb_name, &fsdb->fsdb_srpc_gen); - cfs_up(&fsdb->fsdb_sem); + lprocfs_rd_ir_state(seq, fsdb); + + 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; -int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb) + 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 mgs_device *mgs, struct fs_db *fsdb) { - struct mgs_obd *mgs = &obd->u.mgs; int rc; if (!mgs->mgs_proc_live) @@ -236,10 +275,8 @@ int lproc_mgs_add_live(struct obd_device *obd, struct fs_db *fsdb) return 0; } -int lproc_mgs_del_live(struct obd_device *obd, struct fs_db *fsdb) +int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) { - struct mgs_obd *mgs = &obd->u.mgs; - if (!mgs->mgs_proc_live) return 0; @@ -254,6 +291,7 @@ struct lprocfs_vars lprocfs_mgs_obd_vars[] = { { "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 } };