Whamcloud - gitweb
LU-8151 obd: Show correct shadow mountpoints for server
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Thu, 14 Dec 2023 08:04:25 +0000 (00:04 -0800)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 14 Dec 2023 13:56:02 +0000 (13:56 +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.

Lustre-change: https://review.whamcloud.com/47131
Lustre-commit: 0171801df517988b0eb1023378c2c8c07a0a36f1

Test-Parameters: trivial testlist=conf-sanity
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: Ie92a686ae97dd62885f415b453bad6bdc0ed3d28
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53445
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Li Dongyang <dongyangli@ddn.com>
lustre/obdclass/obd_mount_server.c
lustre/tests/conf-sanity.sh

index 0d7040b..666712b 100644 (file)
@@ -1738,10 +1738,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 != NULL && dentry != NULL);
        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 3f8329c..f0de8e2 100644 (file)
@@ -8645,6 +8645,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.14.0-ddn121" # 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