From: Arshad Hussain Date: Thu, 20 Mar 2025 20:32:52 +0000 (+0530) Subject: LU-18833 ofd: Set OS_STATE_* flags correctly for read-only devices X-Git-Tag: 2.16.54~34 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F88%2F58488%2F4;p=fs%2Flustre-release.git LU-18833 ofd: Set OS_STATE_* flags correctly for read-only devices Set OS_STATE_* flags correctly for read-only devices which is set via obdfilter.*.readonly params. sanity/56ca added. Test-Parameters: trivial Fixes: 3483556684 ("LU-12515 ofd: allow setting a target to readonly") Signed-off-by: Arshad Hussain Change-Id: Ie35c5e71ced77ebf196d0f4b27e97721e1ea60b1 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58488 Reviewed-by: Alex Zhuravlev Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index d5cf3d84..5c8a7c1 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -745,6 +745,9 @@ int ofd_statfs(const struct lu_env *env, struct obd_export *exp, } /* OS_STATFS_READONLY can be set by OSD already, only add flags */ + if (ofd->ofd_readonly) + osfs->os_state |= OS_STATFS_READONLY; + if (ofd->ofd_raid_degraded) osfs->os_state |= OS_STATFS_DEGRADED; diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 02decdd..6b32d17 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -6957,6 +6957,29 @@ test_56c() { } run_test 56c "check 'lfs df' showing device status" +test_56ca() { + remote_ost_nodsh && skip "remote OST with nodsh" + (( $OST1_VERSION >= $(version_code 2.16.53) )) || + skip "Need OST1 >= 2.16.53 for this test" + + local o_idx=0 # Target OST which will be set to readonly + local ost_name=$(ostname_from_index $o_idx) + + stack_trap "do_facet ost${o_idx} $LCTL set_param -n \ + obdfilter.$ost_name.readonly=0" + + # Force set OST0 as readonly + do_facet ost${o_idx} $LCTL set_param -n obdfilter.$ost_name.readonly=1 + + sleep_maxage # Give time for sync + + local new_status=$(ost_dev_status $o_idx $MOUNT -v) # Get new stats + + [[ "$new_status" =~ "R" ]] || + error "$ost_name status is '$new_status', missing 'R'" +} +run_test 56ca "'lfs df -v' correctly reports 'R' flag when OST set as Readonly" + test_56d() { local mdts=$($LFS df -v $MOUNT | grep -c MDT) local osts=$($LFS df -v $MOUNT | grep -c OST)