From 51c4e893185088a0f0fbc4ed4327d216f26f9b5f Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Fri, 21 Mar 2025 02:02:52 +0530 Subject: [PATCH] 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 --- lustre/ofd/ofd_obd.c | 3 +++ lustre/tests/sanity.sh | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) 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) -- 1.8.3.1