Whamcloud - gitweb
LU-10028 obdclass: Export Lustre mount flags and options 28/29228/10
authorQian Yingjin <qian@ddn.com>
Thu, 9 Nov 2017 20:24:58 +0000 (15:24 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 22 Nov 2017 03:55:46 +0000 (03:55 +0000)
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 <qian@ddn.com>
Change-Id: I6cdbcaf4fd5a6a3621ed675b1c4485073e774d8c
Reviewed-on: https://review.whamcloud.com/29228
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
lustre/obdclass/obd_mount.c
lustre/obdclass/obd_mount_server.c

index b8d3b76..7d757d7 100644 (file)
@@ -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);
index 194441c..c99bc64 100644 (file)
@@ -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,
 };
 
 /*