Whamcloud - gitweb
LU-6952 mount: Mount options parsing problem 06/15906/26
authorHongchao Zhang <hongchao.zhang@intel.com>
Thu, 13 Apr 2017 10:51:23 +0000 (18:51 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 16 May 2017 05:45:01 +0000 (05:45 +0000)
The code which parse the mount option expect that the default
mount options come first and then the user given options. But
actually the default options are appended after the user given
option. Because of this user given options are cleared.
Following code fix this bug.

Added a conf-sanity test 104 to verify this fix.

Seagate-bug-id: MRP-2193
Signed-off-by: Pratik Shinde <pratik.shinde@seagate.com>
Signed-off-by: Rahul Deshmukh <rahul.deshmukh@seagate.com>
Signed-off-by: Hongchao Zhang <hongchao.zhang@intel.com>
Change-Id: I1a22e5d559e01d8bcba0ceebba5544e92d39bb19
Reviewed-on: https://review.whamcloud.com/15906
Reviewed-by: Jian Yu <jian.yu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Grégoire Pichon <gregoire.pichon@bull.net>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/tests/cfg/local.sh
lustre/tests/conf-sanity.sh
lustre/tests/test-framework.sh
lustre/utils/mount_lustre.c

index 486801e..baa7d18 100644 (file)
@@ -35,11 +35,15 @@ MDSSIZE=${MDSSIZE:-200000}
 MDSOPT=${MDSOPT:-}
 MDS_FS_MKFS_OPTS=${MDS_FS_MKFS_OPTS:-}
 MDS_MOUNT_OPTS=${MDS_MOUNT_OPTS:-}
+# <facet_type>_MOUNT_FS_OPTS is the mount options specified when formatting
+# the underlying device by argument "--mountfsoptions"
+MDS_MOUNT_FS_OPTS=${MDS_MOUNT_FS_OPTS:-}
 
 MGSSIZE=${MGSSIZE:-$MDSSIZE}
 MGSOPT=${MGSOPT:-}
 MGS_FS_MKFS_OPTS=${MGS_FS_MKFS_OPTS:-}
 MGS_MOUNT_OPTS=${MGS_MOUNT_OPTS:-}
+MGS_MOUNT_FS_OPTS=${MGS_MOUNT_FS_OPTS:-}
 
 OSTCOUNT=${OSTCOUNT:-2}
 OSTDEVBASE=${OSTDEVBASE:-$TMP/${FSNAME}-ost}
@@ -47,6 +51,7 @@ OSTSIZE=${OSTSIZE:-400000}
 OSTOPT=${OSTOPT:-}
 OST_FS_MKFS_OPTS=${OST_FS_MKFS_OPTS:-}
 OST_MOUNT_OPTS=${OST_MOUNT_OPTS:-}
+OST_MOUNT_FS_OPTS=${OST_MOUNT_FS_OPTS:-}
 OST_INDEX_LIST=${OST_INDEX_LIST:-}
 # Can specify individual ost devs with
 # OSTDEV1="/dev/sda"
index 2eed882..0a8957e 100755 (executable)
@@ -7335,6 +7335,57 @@ test_103() {
 }
 run_test 103 "rename filesystem name"
 
+test_104() { # LU-6952
+       local mds_mountopts=$MDS_MOUNT_OPTS
+       local ost_mountopts=$OST_MOUNT_OPTS
+       local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
+       local lctl_ver=$(do_facet $SINGLEMDS $LCTL --version |
+                       awk '{ print $2 }')
+
+       [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
+               { skip "this test needs utils above 2.9.55" && return 0; }
+
+       # specify "acl" in mount options used by mkfs.lustre
+       if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
+               MDS_MOUNT_FS_OPTS="acl,user_xattr"
+       else
+
+               MDS_MOUNT_FS_OPTS="${MDS_MOUNT_FS_OPTS},acl,user_xattr"
+       fi
+
+       echo "mountfsopt: $MDS_MOUNT_FS_OPTS"
+
+       #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
+       formatall
+       if [ -z "$MDS_MOUNT_OPTS" ]; then
+               MDS_MOUNT_OPTS="-o noacl"
+       else
+               MDS_MOUNT_OPTS="${MDS_MOUNT_OPTS},noacl"
+       fi
+
+       for num in $(seq $MDSCOUNT); do
+               start mds$num $(mdsdevname $num) $MDS_MOUNT_OPTS ||
+                       error "Failed to start MDS"
+       done
+
+       for num in $(seq $OSTCOUNT); do
+               start ost$num $(ostdevname $num) $OST_MOUNT_OPTS ||
+                       error "Failed to start OST"
+       done
+
+       mount_client $MOUNT
+       setfacl -m "d:$RUNAS_ID:rwx" $MOUNT &&
+               error "ACL is applied when FS is mounted with noacl."
+
+       MDS_MOUNT_OPTS=$mds_mountopts
+       OST_MOUNT_OPTS=$ost_mountopts
+       MDS_MOUNT_FS_OPTS=$mds_mountfsopts
+
+       formatall
+       setupall
+}
+run_test 104 "Make sure user defined options are reflected in mount"
+
 if ! combined_mgs_mds ; then
        stop mgs
 fi
index e67078e..d69e988 100755 (executable)
@@ -3619,6 +3619,17 @@ mkfs_opts() {
        echo -n "$opts"
 }
 
+mountfs_opts() {
+       local facet=$1
+       local type=$(facet_type $facet)
+       local var=${type}_MOUNT_FS_OPTS
+       local opts=""
+       if [ -n "${!var}" ]; then
+               opts+=" --mountfsoptions=${!var}"
+       fi
+       echo -n "$opts"
+}
+
 check_ost_indices() {
        local index_count=${#OST_INDICES[@]}
        [[ $index_count -eq 0 || $OSTCOUNT -le $index_count ]] && return 0
@@ -3645,7 +3656,7 @@ format_mgs() {
        fi
        echo "Format mgs: $(mgsdevname)"
        reformat_external_journal mgs
-       add mgs $(mkfs_opts mgs $(mgsdevname)) --reformat \
+       add mgs $(mkfs_opts mgs $(mgsdevname)) $(mountfs_opts mgs) --reformat \
                $(mgsdevname) $(mgsvdevname) ${quiet:+>/dev/null} || exit 10
 }
 
@@ -3659,8 +3670,8 @@ format_mdt() {
        echo "Format mds$num: $(mdsdevname $num)"
        reformat_external_journal mds$num
        add mds$num $(mkfs_opts mds$num $(mdsdevname ${num})) \
-               --reformat $(mdsdevname $num) $(mdsvdevname $num) \
-               ${quiet:+>/dev/null} || exit 10
+               $(mountfs_opts mds$num) --reformat $(mdsdevname $num) \
+               $(mdsvdevname $num) ${quiet:+>/dev/null} || exit 10
 }
 
 format_ost() {
@@ -3672,8 +3683,8 @@ format_ost() {
        echo "Format ost$num: $(ostdevname $num)"
        reformat_external_journal ost$num
        add ost$num $(mkfs_opts ost$num $(ostdevname ${num})) \
-               --reformat $(ostdevname $num) $(ostvdevname ${num}) \
-               ${quiet:+>/dev/null} || exit 10
+               $(mountfs_opts ost$num) --reformat $(ostdevname $num) \
+               $(ostvdevname ${num}) ${quiet:+>/dev/null} || exit 10
 }
 
 formatall() {
index 588ebaf..7fb5467 100644 (file)
@@ -439,6 +439,7 @@ static int parse_ldd(char *source, struct mount_opts *mop,
 {
        struct lustre_disk_data *ldd = &mop->mo_ldd;
        char *cur, *start;
+       char *temp_options;
        int rc = 0;
 
        rc = osd_is_lustre(source, &ldd->ldd_mount_type);
@@ -477,6 +478,19 @@ static int parse_ldd(char *source, struct mount_opts *mop,
        /* Since we never rewrite ldd, ignore temp flags */
        ldd->ldd_flags &= ~(LDD_F_VIRGIN | LDD_F_WRITECONF);
 
+       /* This is to make sure default options go first */
+       temp_options = strdup(options);
+       if (temp_options == NULL) {
+               fprintf(stderr, "%s: can't allocate memory for temp_options\n",
+                       progname);
+               return ENOMEM;
+       }
+       strncpy(options, ldd->ldd_mount_opts, options_len);
+       rc = append_option(options, options_len, temp_options, NULL);
+       free(temp_options);
+       if (rc != 0)
+               return rc;
+
        /* svname of the form lustre:OST1234 means never registered */
        rc = strlen(ldd->ldd_svname);
        if (strcmp(ldd->ldd_svname, "MGS") != 0) {
@@ -498,10 +512,6 @@ static int parse_ldd(char *source, struct mount_opts *mop,
        if (rc != 0)
                return rc;
 
-       rc = append_option(options, options_len, ldd->ldd_mount_opts, NULL);
-       if (rc != 0)
-               return rc;
-
        if (!mop->mo_have_mgsnid) {
                /* Only use disk data if mount -o mgsnode=nid wasn't
                 * specified */