Whamcloud - gitweb
LU-8151 obd: Show correct shadow mountpoints for server 31/47131/14
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Tue, 3 May 2022 08:27:09 +0000 (04:27 -0400)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Nov 2022 08:52:10 +0000 (08:52 +0000)
server_fill_super_common() preps the server for mounting
and forces "Read only" (SB_RDONLY) flag to restrict IO on
the server. This when running the mount command reflects
FS always as "ro" although they are "rw"

This patch double checks the obd statfs (FS) state for
"read only" flag (OS_STATFS_READONLY) and if not found
to be really "read only" toggles (removes) SB_RDONLY flag.

The client output remains unchanged.

Output before patch:
/dev/.../mds1_flakey on /mnt/lustre-mds1 type lustre (ro,svname=...)
/dev/.../ost1_flakey on /mnt/lustre-ost1 type lustre (ro,svname=...)

Output after patch:
/dev/.../mds1_flakey on /mnt/lustre-mds1 type lustre (rw,svname=...)
/dev/.../ost1_flakey on /mnt/lustre-ost1 type lustre (rw,svname=...)

Test case conf-sanity/113 added.

Test-Parameters: trivial fstype=zfs testlist=conf-sanity
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Ie92a686ae97dd62885f415b453bad6bdc0ed3d28
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47131
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/target/tgt_mount.c
lustre/tests/conf-sanity.sh

index feaa935..1e9b102 100644 (file)
@@ -1765,10 +1765,35 @@ int server_show_options(struct seq_file *seq, struct dentry *dentry)
 {
        struct lustre_sb_info *lsi;
        struct lustre_mount_data *lmd;
+       struct obd_statfs osfs;
+       struct super_block *sb;
+       int rc;
 
        LASSERT(seq && dentry);
        lsi = s2lsi(dentry->d_sb);
        lmd = lsi->lsi_lmd;
+       sb = dentry->d_sb;
+
+       if (lsi->lsi_dt_dev) {
+               rc = dt_statfs(NULL, lsi->lsi_dt_dev, &osfs);
+               if (!rc) {
+                       /* Check FS State for OS_STATFS_READONLY
+                        * (Read only) flag. If it is not set then
+                        * toggle back the s_flag's SB_RDONLY bit.
+                        * The SB_RDONLY bit is always set for OST/MDT
+                        * during server prep (server_fill_super_common())
+                        * call.
+                        *
+                        * Also, if server is mounted with "rdonly_dev"
+                        * (LMD_FLG_DEV_RDONLY) then force flag to be 'ro'
+                        */
+
+                       if (!(lmd->lmd_flags & LMD_FLG_DEV_RDONLY) &&
+                           !(osfs.os_state & OS_STATFS_READONLY))
+                               sb->s_flags &= ~SB_RDONLY;
+               }
+       }
+
        seq_printf(seq, ",svname=%s", lmd->lmd_profile);
 
        if  (lmd->lmd_flags & LMD_FLG_ABORT_RECOV)
index ac2784d..5fd625e 100644 (file)
@@ -8983,6 +8983,98 @@ test_112() {
 }
 run_test 112 "mount OST with nocreate option"
 
+# Global for 113
+SAVE_MGS_MOUNT_OPTS=$MGS_MOUNT_OPTS
+SAVE_MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS
+SAVE_OST_MOUNT_OPTS=$OST_MOUNT_OPTS
+
+cleanup_113() {
+       trap 0
+
+       stopall
+       MGS_MOUNT_OPTS=$SAVE_MGS_MOUNT_OPTS
+       MDS_MOUNT_OPTS=$SAVE_MDS_MOUNT_OPTS
+       OST_MOUNT_OPTS=$SAVE_OST_MOUNT_OPTS
+       # Revert old mount options back
+       setupall
+       # Subsequent following test requires
+       # conf-sanity to be in stopall state.
+       # Force 'stopall' so others following
+       # test can pass
+       stopall
+}
+
+# Error out with mount info
+error_113() {
+       local server_nodes=$(comma_list $(mdts_nodes) $(osts_nodes))
+       local err=$1
+
+       echo "--Client Mount Info--"
+       mount | grep -i lustre
+       echo "--Server Mount Info--"
+       do_nodes $server_nodes mount | grep -i lustre
+
+       error $err
+}
+
+test_113() {
+       local ost_version="2.15.51" # Minimum version required
+
+       (( OST1_VERSION >= $(version_code $ost_version) )) ||
+               skip "Need server version at least $ost_version"
+       sync; sleep 3
+       stack_trap cleanup_113 EXIT
+
+       # Reset before starting
+       stopall
+       setupall
+
+       # Verify MDS's should start with "rw"
+       do_facet $SINGLEMDS mount | grep "lustre.*rw,.*MDT" ||
+               error_113 "$SINGLEMDS should be read-write"
+
+       # Verify OST's should start with "rw"
+       for (( i=1; i <= OSTCOUNT; i++ )); do
+               do_facet ost$i mount | grep "lustre.*rw,.*OST" ||
+                       error_113 "ost$i should be read-write"
+       done
+
+       # rdonly_dev does not currently work for ldiskfs
+       # We skip the rdonly_dev check until then.
+       if [[ $ost1_FSTYPE == ldiskfs ]]; then
+               echo "Shadow Mountpoint correctly reports rw for ldiskfs"
+               return 0
+       fi
+
+       #
+       # Only ZFS specific tests below.
+       #
+
+       # Must stop all (server+client) and restart to verify new
+       # mount options
+       stopall
+
+       # add rdonly_dev to mount option
+       MGS_MOUNT_OPTS=$(csa_add "$MGS_MOUNT_OPTS" -o rdonly_dev)
+       MDS_MOUNT_OPTS=$(csa_add "$MDS_MOUNT_OPTS" -o rdonly_dev)
+       OST_MOUNT_OPTS=$(csa_add "$OST_MOUNT_OPTS" -o rdonly_dev)
+
+       # Only restart server(mds/ost). Sufficient for test
+       setupall server_only || error "Fail to start servers"
+
+       # Verify MDS's should be "ro"
+       do_facet $SINGLEMDS mount | grep "lustre.*ro,.*MDT.*rdonly_dev" ||
+               error_113 "$SINGLEMDS should be read-only"
+
+       # Verify OST's should be "ro"
+       for (( i=1; i <= OSTCOUNT; i++ )); do
+               do_facet ost$i mount | grep "lustre.*ro,.*OST.*rdonly_dev" ||
+                       error_113 "ost$i should be read-only"
+       done
+}
+run_test 113 "Shadow mountpoint correctly report ro/rw for mounts"
+
+
 cleanup_115()
 {
        trap 0