From 6ee90b7586d58b0df27a511472e38792baba4745 Mon Sep 17 00:00:00 2001 From: Qian Yingjin Date: Thu, 9 Nov 2017 15:24:58 -0500 Subject: [PATCH] LU-10028 obdclass: Export Lustre mount flags and options This patch help to export the information about Lustre special mount flags and options via '/proc/mounts'. The output for Lustre mounts by '/proc/mounts' is: /dev/loop0 /mnt/lustre-mds1 lustre ro,svname=lustre-MDT0000, mgs,osd=osd-ldiskfs,user_xattr,errors=remount-ro 0 0 /dev/loop1 /mnt/lustre-ost1 lustre ro,svname=lustre-OST0000, mgsnode=192.168.59.129@tcp,osd=osd-ldiskfs,errors=remount-ro 0 0 /dev/loop2 /mnt/lustre-ost2 lustre ro,svname=lustre-OST0001, mgsnode=192.168.59.129@tcp,osd=osd-ldiskfs,errors=remount-ro 0 0 192.168.59.129@tcp:/lustre /mnt/lustre lustre rw,flock, user_xattr,lazystatfs 0 0 Signed-off-by: Qian Yingjin Change-Id: I6cdbcaf4fd5a6a3621ed675b1c4485073e774d8c Reviewed-on: https://review.whamcloud.com/29228 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo --- lustre/obdclass/obd_mount.c | 2 ++ lustre/obdclass/obd_mount_server.c | 58 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index b8d3b76..7d757d7 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1400,6 +1400,8 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) s1 = options + strlen(options) - 1; while (s1 >= options && (*s1 == ',' || *s1 == ' ')) *s1-- = 0; + while (*options && (*options == ',' || *options == ' ')) + options++; if (*options != 0) { /* Freed in lustre_free_lsi */ OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1); diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index 194441c..c99bc64 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -1661,6 +1661,63 @@ static int server_statfs(struct dentry *dentry, struct kstatfs *buf) RETURN(0); } +#ifdef HAVE_SUPEROPS_USE_DENTRY +int server_show_options(struct seq_file *seq, struct dentry *dentry) +#else +int server_show_options(struct seq_file *seq, struct vfsmount *vfs) +#endif +{ + struct lustre_sb_info *lsi; + struct lustre_mount_data *lmd; + +#ifdef HAVE_SUPEROPS_USE_DENTRY + LASSERT(seq != NULL && dentry != NULL); + lsi = s2lsi(dentry->d_sb); +#else + LASSERT(seq != NULL && vfs != NULL); + lsi = s2lsi(vfs->mnt_sb); +#endif + + lmd = lsi->lsi_lmd; + seq_printf(seq, ",svname=%s", lmd->lmd_profile); + + if (lmd->lmd_flags & LMD_FLG_ABORT_RECOV) + seq_puts(seq, ",abort_recov"); + + if (lmd->lmd_flags & LMD_FLG_NOIR) + seq_puts(seq, ",noir"); + + if (lmd->lmd_flags & LMD_FLG_NOSVC) + seq_puts(seq, ",nosvc"); + + if (lmd->lmd_flags & LMD_FLG_NOMGS) + seq_puts(seq, ",nomgs"); + + if (lmd->lmd_flags & LMD_FLG_NOSCRUB) + seq_puts(seq, ",noscrub"); + if (lmd->lmd_flags & LMD_FLG_SKIP_LFSCK) + seq_puts(seq, ",skip_lfsck"); + + if (lmd->lmd_flags & LMD_FLG_DEV_RDONLY) + seq_puts(seq, ",rdonly_dev"); + + if (lmd->lmd_flags & LMD_FLG_MGS) + seq_puts(seq, ",mgs"); + + if (lmd->lmd_mgs != NULL) + seq_printf(seq, ",mgsnode=%s", lmd->lmd_mgs); + + if (lmd->lmd_osd_type != NULL) + seq_printf(seq, ",osd=%s", lmd->lmd_osd_type); + + if (lmd->lmd_opts != NULL) { + seq_putc(seq, ','); + seq_puts(seq, lmd->lmd_opts); + } + + RETURN(0); +} + /** The operations we support directly on the superblock: * mount, umount, and df. */ @@ -1668,6 +1725,7 @@ static struct super_operations server_ops = { .put_super = server_put_super, .umount_begin = server_umount_begin, /* umount -f */ .statfs = server_statfs, + .show_options = server_show_options, }; /* -- 1.8.3.1