From 0171801df517988b0eb1023378c2c8c07a0a36f1 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 3 May 2022 04:27:09 -0400 Subject: [PATCH] LU-8151 obd: Show correct shadow mountpoints for server 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 Change-Id: Ie92a686ae97dd62885f415b453bad6bdc0ed3d28 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/47131 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jian Yu Reviewed-by: Oleg Drokin --- lustre/target/tgt_mount.c | 25 ++++++++++++ lustre/tests/conf-sanity.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/lustre/target/tgt_mount.c b/lustre/target/tgt_mount.c index feaa935..1e9b102 100644 --- a/lustre/target/tgt_mount.c +++ b/lustre/target/tgt_mount.c @@ -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) diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index ac2784d..5fd625e 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -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 -- 1.8.3.1