From 7b124fef762f5adc4cf5fcf7fa21987655493e19 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 22 Nov 2013 17:53:43 -0700 Subject: [PATCH 1/1] LU-4277 lod: handle os_state as a flag, check READONLY Handle the osfs->os_state values as flags instead of as values. Otherwise, if an OSD has OS_STATE_DEGRADED and another flag set it will not match to skip the OST during object allocation. Similarly, there was no check for the OS_STATE_READONLY flag in the create path, which should be used to always skip an OST for object creation until it is cleared. These flags are not yet set by osd-zfs, only by osd-ldiskfs so far. Signed-off-by: Andreas Dilger Change-Id: I0ef59a9fd631a6942d963e37cfce2bfe183ebbe5 Reviewed-on: http://review.whamcloud.com/8378 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alex Zhuravlev Reviewed-by: Fan Yong Reviewed-by: Oleg Drokin --- lustre/lod/lod_qos.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index e7b1de0..51d6603 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -159,6 +159,10 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d, if (rc && rc != -ENOTCONN) CERROR("%s: statfs: rc = %d\n", lod2obd(d)->obd_name, rc); + /* If the OST is readonly then we can't allocate objects there */ + if (sfs->os_state & OS_STATE_READONLY) + rc = -EROFS; + /* check whether device has changed state (active, inactive) */ if (rc != 0 && ost->ltd_active) { /* turned inactive? */ @@ -771,7 +775,7 @@ repeat_find: /* * try to use another OSP if this one is degraded */ - if (sfs->os_state == OS_STATE_DEGRADED && speed < 2) { + if (sfs->os_state & OS_STATE_DEGRADED && speed < 2) { QOS_DEBUG("#%d: degraded\n", ost_idx); continue; } -- 1.8.3.1