From: John L. Hammond Date: Tue, 20 Nov 2012 17:33:04 +0000 (-0600) Subject: LU-2358 procfs: Implement /proc/fs/lustre/mgs/MGS/fstype as symlink X-Git-Tag: 2.3.58~37 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=1a87510ec2aef550b5654f6edb05f6c7ee5ec78b LU-2358 procfs: Implement /proc/fs/lustre/mgs/MGS/fstype as symlink Add symlinks: /proc/fs/lustre/mgs/MGS/osd -> ../../osd-ldiskfs/lustre-MDT0000 /proc/fs/lustre/mgs/MGS/fstype -> osd/fstype /proc/fs/lustre/mgs/MGS/mntdev -> osd/mntdev Remove unused lprocfs_rd_fstype(). Change-Id: Ic5cce7cf31962c7d6ea97c5d3117fba81539cb68 Signed-off-by: John L. Hammond Reviewed-on: http://review.whamcloud.com/4635 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Emoly Liu Reviewed-by: Andreas Dilger --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index d0ae402..1c2b906 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -581,8 +581,6 @@ extern int lprocfs_rd_uuid(char *page, char **start, off_t off, int count, int *eof, void *data); extern int lprocfs_rd_name(char *page, char **start, off_t off, int count, int *eof, void *data); -extern int lprocfs_rd_fstype(char *page, char **start, off_t off, - int count, int *eof, void *data); extern int lprocfs_rd_server_uuid(char *page, char **start, off_t off, int count, int *eof, void *data); extern int lprocfs_rd_conn_uuid(char *page, char **start, off_t off, diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 9b0a4ad..3002e20 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -149,8 +149,7 @@ int lproc_mgs_setup(struct mgs_device *mgs, 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_suffix = strlen(osd_name) - strlen("-osd"); - char c = osd_name[osd_suffix]; + int osd_len = strlen(osd_name) - strlen("-osd"); int rc; rc = lprocfs_obd_seq_create(obd, "filesystems", 0444, @@ -175,16 +174,27 @@ int lproc_mgs_setup(struct mgs_device *mgs, char *osd_name) obd->obd_proc_exports_entry = NULL; } - osd_name[osd_suffix] = '\0'; /* Remove the "-osd" suffix. */ + mgs->mgs_proc_osd = lprocfs_add_symlink("osd", + obd->obd_proc_entry, + "../../%s/%.*s", + osd_obd->obd_type->typ_name, + osd_len, /* Strip "-osd". */ + osd_name); + if (mgs->mgs_proc_osd == NULL) + rc = -ENOMEM; + 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; + "osd/mntdev"); if (mgs->mgs_proc_mntdev == NULL) rc = -ENOMEM; + mgs->mgs_proc_fstype = lprocfs_add_symlink("fstype", + obd->obd_proc_entry, + "osd/fstype"); + if (mgs->mgs_proc_fstype == NULL) + rc = -ENOMEM; + return rc; } @@ -195,6 +205,12 @@ int lproc_mgs_cleanup(struct mgs_device *mgs) if (!obd) return -EINVAL; + if (mgs->mgs_proc_osd != NULL) + lprocfs_remove(&mgs->mgs_proc_osd); + + if (mgs->mgs_proc_fstype != NULL) + lprocfs_remove(&mgs->mgs_proc_fstype); + if (mgs->mgs_proc_mntdev) lprocfs_remove(&mgs->mgs_proc_mntdev); if (mgs->mgs_proc_live) { @@ -283,7 +299,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 }, { "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_internal.h b/lustre/mgs/mgs_internal.h index 89a9261..6ddfe13 100644 --- a/lustre/mgs/mgs_internal.h +++ b/lustre/mgs/mgs_internal.h @@ -166,6 +166,8 @@ struct mgs_device { cfs_list_t mgs_fs_db_list; spinlock_t mgs_lock; /* covers mgs_fs_db_list */ cfs_proc_dir_entry_t *mgs_proc_live; + cfs_proc_dir_entry_t *mgs_proc_osd; + cfs_proc_dir_entry_t *mgs_proc_fstype; cfs_proc_dir_entry_t *mgs_proc_mntdev; cfs_time_t mgs_start_time; struct obd_device *mgs_obd; diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 61f4915..5d4b3fb 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -595,18 +595,6 @@ int lprocfs_rd_name(char *page, char **start, off_t off, int count, } EXPORT_SYMBOL(lprocfs_rd_name); -int lprocfs_rd_fstype(char *page, char **start, off_t off, int count, int *eof, - void *data) -{ - struct obd_device *obd = data; - - LASSERT(obd != NULL); - LASSERT(obd->obd_fsops != NULL); - LASSERT(obd->obd_fsops->fs_type != NULL); - return snprintf(page, count, "%s\n", obd->obd_fsops->fs_type); -} -EXPORT_SYMBOL(lprocfs_rd_fstype); - int lprocfs_rd_blksize(char *page, char **start, off_t off, int count, int *eof, void *data) {