From: Alex Zhuravlev Date: Thu, 9 Aug 2012 18:52:17 +0000 (+0400) Subject: LU-1301 mgs: Symlink mntdev procfs entry from osd X-Git-Tag: 2.3.51~6 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=83d42ef35ff05efab5f6aa13729dc836321267cc LU-1301 mgs: Symlink mntdev procfs entry from osd MGS won't be able to get device names directly on top of OSD. Change-Id: Ief808f058a785cc4bacf1743ff534a81be234544 Signed-off-by: Alex Zhuravlev Signed-off-by: Li Wei Reviewed-on: http://review.whamcloud.com/3672 Tested-by: Hudson Reviewed-by: Andreas Dilger Reviewed-by: Mike Pershin Tested-by: Maloo --- diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 691ad12..0f7fc26 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -45,24 +45,6 @@ #ifdef LPROCFS -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); -#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; @@ -163,10 +145,13 @@ out: LPROC_SEQ_FOPS_RO(mgsself_srpc); -int lproc_mgs_setup(struct mgs_device *mgs) +int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) { struct obd_device *obd = mgs->mgs_obd; - int rc; + struct obd_device *osd_obd = mgs->mgs_bottom->dd_lu_dev.ld_obd; + int osd_suffix = strlen(osd_name) - strlen("-osd"); + char c = osd_name[osd_suffix]; + int rc; rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, &mgs_fs_fops, obd); @@ -190,7 +175,17 @@ int lproc_mgs_setup(struct mgs_device *mgs) obd->obd_proc_exports_entry = NULL; } - return rc; + osd_name[osd_suffix] = '\0'; /* Remove the "-osd" suffix. */ + mgs->mgs_proc_mntdev = lprocfs_add_symlink("mntdev", + obd->obd_proc_entry, + "../../%s/%s/mntdev", + osd_obd->obd_type->typ_name, + osd_name); + osd_name[osd_suffix] = c; + if (mgs->mgs_proc_mntdev == NULL) + rc = -ENOMEM; + + return rc; } int lproc_mgs_cleanup(struct mgs_device *mgs) @@ -200,6 +195,8 @@ int lproc_mgs_cleanup(struct mgs_device *mgs) if (!obd) return -EINVAL; + if (mgs->mgs_proc_mntdev) + lprocfs_remove(&mgs->mgs_proc_mntdev); if (mgs->mgs_proc_live) { /* Should be no live entries */ LASSERT(mgs->mgs_proc_live->subdir == NULL); @@ -287,7 +284,6 @@ int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb) struct lprocfs_vars lprocfs_mgs_obd_vars[] = { { "uuid", lprocfs_rd_uuid, 0, 0 }, { "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 }, diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index b1804c3..5bb016f 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -1076,7 +1076,7 @@ static int mgs_init0(const struct lu_env *env, struct mgs_device *mgs, /* Setup proc */ lprocfs_mgs_init_vars(&lvars); if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) { - lproc_mgs_setup(mgs); + lproc_mgs_setup(mgs, lustre_cfg_string(lcfg, 3)); rc = lprocfs_alloc_md_stats(obd, LPROC_MGS_LAST); if (rc) GOTO(err_llog, rc); diff --git a/lustre/mgs/mgs_internal.h b/lustre/mgs/mgs_internal.h index a13a301..9ad6174 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -166,6 +166,7 @@ struct mgs_device { cfs_list_t mgs_fs_db_list; cfs_spinlock_t mgs_lock; /* covers mgs_fs_db_list */ cfs_proc_dir_entry_t *mgs_proc_live; + cfs_proc_dir_entry_t *mgs_proc_mntdev; cfs_time_t mgs_start_time; struct obd_device *mgs_obd; struct local_oid_storage *mgs_los; @@ -237,7 +238,7 @@ int mgs_fs_cleanup(const struct lu_env *env, struct mgs_device *m); #define strsuf(buf, suffix) (strcmp((buf)+strlen(buf)-strlen(suffix), (suffix))) #ifdef LPROCFS -int lproc_mgs_setup(struct mgs_device *mgs); +int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name); int lproc_mgs_cleanup(struct mgs_device *mgs); int lproc_mgs_add_live(struct mgs_device *mgs, struct fs_db *fsdb); int lproc_mgs_del_live(struct mgs_device *mgs, struct fs_db *fsdb);