Whamcloud - gitweb
LU-18833 ofd: Set OS_STATE_* flags correctly for read-only devices 88/58488/4
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Thu, 20 Mar 2025 20:32:52 +0000 (02:02 +0530)
committerOleg Drokin <green@whamcloud.com>
Mon, 31 Mar 2025 05:57:43 +0000 (05:57 +0000)
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 <arshad.hussain@aeoncomputing.com>
Change-Id: Ie35c5e71ced77ebf196d0f4b27e97721e1ea60b1
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58488
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/ofd/ofd_obd.c
lustre/tests/sanity.sh

index d5cf3d8..5c8a7c1 100644 (file)
@@ -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;
 
index 02decdd..6b32d17 100755 (executable)
@@ -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)