Whamcloud - gitweb
LU-9859 libcfs: move tgt_descs to standard Linux bitmaps.
[fs/lustre-release.git] / lustre / lod / lod_qos.c
index 249d3cf..7fe0826 100644 (file)
@@ -65,17 +65,17 @@ static inline int lod_statfs_check(struct lu_tgt_descs *ltd,
 {
        struct obd_statfs *sfs = &tgt->ltd_statfs;
 
-       if (((sfs->os_state & OS_STATE_ENOSPC) ||
-           (!ltd->ltd_is_mdt && sfs->os_state & OS_STATE_ENOINO &&
+       if (((sfs->os_state & OS_STATFS_ENOSPC) ||
+           (!ltd->ltd_is_mdt && sfs->os_state & OS_STATFS_ENOINO &&
             sfs->os_fprecreated == 0)))
                return -ENOSPC;
 
        /* If the OST is readonly then we can't allocate objects there */
-       if (sfs->os_state & OS_STATE_READONLY)
+       if (sfs->os_state & OS_STATFS_READONLY)
                return -EROFS;
 
        /* object precreation is skipped on the OST with max_create_count=0 */
-       if (!ltd->ltd_is_mdt && sfs->os_state & OS_STATE_NOPRECREATE)
+       if (!ltd->ltd_is_mdt && sfs->os_state & OS_STATFS_NOPRECREATE)
                return -ENOBUFS;
 
        return 0;
@@ -296,8 +296,8 @@ static int lod_qos_calc_rr(struct lod_device *lod, struct lu_tgt_descs *ltd,
                for (i = 0; i < lqr->lqr_pool.op_count; i++) {
                        int next;
 
-                       if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap,
-                                             src_pool->op_array[i]))
+                       if (!test_bit(src_pool->op_array[i],
+                                     ltd->ltd_tgt_bitmap))
                                continue;
 
                        tgt = LTD_TGT(ltd, src_pool->op_array[i]);
@@ -572,7 +572,7 @@ static inline bool lod_should_avoid_ost(struct lod_object *lo,
        bool used = false;
        int i;
 
-       if (!cfs_bitmap_check(lod->lod_ost_bitmap, index)) {
+       if (!test_bit(index, lod->lod_ost_bitmap)) {
                QOS_DEBUG("OST%d: been used in conflicting mirror component\n",
                          index);
                return true;
@@ -642,7 +642,7 @@ static int lod_check_and_reserve_ost(const struct lu_env *env,
        /*
         * try to use another OSP if this one is degraded
         */
-       if (ost->ltd_statfs.os_state & OS_STATE_DEGRADED && speed < 2) {
+       if (ost->ltd_statfs.os_state & OS_STATFS_DEGRADED && speed < 2) {
                QOS_DEBUG("#%d: degraded\n", ost_idx);
                RETURN(rc);
        }
@@ -808,7 +808,7 @@ repeat_find:
                          stripe_idx, array_idx, ost_idx);
 
                if ((ost_idx == LOV_QOS_EMPTY) ||
-                   !cfs_bitmap_check(m->lod_ost_bitmap, ost_idx))
+                   !test_bit(ost_idx, m->lod_ost_bitmap))
                        continue;
 
                /* Fail Check before osc_precreate() is called
@@ -890,7 +890,7 @@ lod_qos_mdt_in_use_init(const struct lu_env *env,
                for (j = 0; j < pool->op_count; j++) {
                        mdt_idx = pool->op_array[j];
 
-                       if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, mdt_idx))
+                       if (!test_bit(mdt_idx, ltd->ltd_tgt_bitmap))
                                continue;
 
                        mdt = LTD_TGT(ltd, mdt_idx);
@@ -993,7 +993,7 @@ repeat_find:
                          stripe_idx, pool_idx, mdt_idx);
 
                if (mdt_idx == LOV_QOS_EMPTY ||
-                   !cfs_bitmap_check(ltd->ltd_tgt_bitmap, mdt_idx))
+                   !test_bit(mdt_idx, ltd->ltd_tgt_bitmap))
                        continue;
 
                /* do not put >1 objects on one MDT */
@@ -1008,7 +1008,7 @@ repeat_find:
                }
 
                /* try to use another OSP if this one is degraded */
-               if (mdt->ltd_statfs.os_state & OS_STATE_DEGRADED &&
+               if (mdt->ltd_statfs.os_state & OS_STATFS_DEGRADED &&
                    !use_degraded) {
                        QOS_DEBUG("#%d: degraded\n", mdt_idx);
                        continue;
@@ -1132,7 +1132,7 @@ static int lod_alloc_ost_list(const struct lu_env *env, struct lod_object *lo,
             i++, array_idx = (array_idx + 1) % lod_comp->llc_stripe_count) {
                __u32 ost_idx = lod_comp->llc_ostlist.op_array[array_idx];
 
-               if (!cfs_bitmap_check(m->lod_ost_bitmap, ost_idx)) {
+               if (!test_bit(ost_idx, m->lod_ost_bitmap)) {
                        rc = -ENODEV;
                        break;
                }
@@ -1260,7 +1260,7 @@ repeat_find:
                        i++, array_idx = (array_idx + 1) % ost_count) {
                ost_idx = osts->op_array[array_idx];
 
-               if (!cfs_bitmap_check(m->lod_ost_bitmap, ost_idx))
+               if (!test_bit(ost_idx, m->lod_ost_bitmap))
                        continue;
 
                /* Fail Check before osc_precreate() is called
@@ -1458,7 +1458,7 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo,
        good_osts = 0;
        /* Find all the OSTs that are valid stripe candidates */
        for (i = 0; i < osts->op_count; i++) {
-               if (!cfs_bitmap_check(lod->lod_ost_bitmap, osts->op_array[i]))
+               if (!test_bit(osts->op_array[i], lod->lod_ost_bitmap))
                        continue;
 
                ost = OST_TGT(lod, osts->op_array[i]);
@@ -1470,7 +1470,7 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo,
                        continue;
                }
 
-               if (ost->ltd_statfs.os_state & OS_STATE_DEGRADED)
+               if (ost->ltd_statfs.os_state & OS_STATFS_DEGRADED)
                        continue;
 
                /* Fail Check before osc_precreate() is called
@@ -1702,7 +1702,7 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo,
        good_mdts = 0;
        /* Find all the MDTs that are valid stripe candidates */
        for (i = 0; i < pool->op_count; i++) {
-               if (!cfs_bitmap_check(ltd->ltd_tgt_bitmap, pool->op_array[i]))
+               if (!test_bit(pool->op_array[i], ltd->ltd_tgt_bitmap))
                        continue;
 
                mdt = LTD_TGT(ltd, pool->op_array[i]);
@@ -1712,7 +1712,7 @@ int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo,
                if (rc)
                        continue;
 
-               if (mdt->ltd_statfs.os_state & OS_STATE_DEGRADED)
+               if (mdt->ltd_statfs.os_state & OS_STATFS_DEGRADED)
                        continue;
 
                mdt->ltd_qos.ltq_usable = 1;
@@ -2306,8 +2306,7 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo)
        lag->lag_oaa_count = 0;
        if (lag->lag_oss_avoid_array &&
            lag->lag_oaa_size < lod->lod_ost_count) {
-               OBD_FREE(lag->lag_oss_avoid_array,
-                        sizeof(__u32) * lag->lag_oaa_size);
+               OBD_FREE_PTR_ARRAY(lag->lag_oss_avoid_array, lag->lag_oaa_size);
                lag->lag_oss_avoid_array = NULL;
                lag->lag_oaa_size = 0;
        }
@@ -2335,7 +2334,7 @@ int lod_prepare_avoidance(const struct lu_env *env, struct lod_object *lo)
                 * using OST count to allocate the array to store the OSS
                 * id.
                 */
-               OBD_ALLOC(new_oss, sizeof(*new_oss) * lod->lod_ost_count);
+               OBD_ALLOC_PTR_ARRAY(new_oss, lod->lod_ost_count);
                if (!new_oss) {
                        CFS_FREE_BITMAP(bitmap);
                        return -ENOMEM;
@@ -2494,10 +2493,10 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
                if (stripe_len == 0)
                        GOTO(out, rc = -ERANGE);
                lod_comp->llc_stripe_count = stripe_len;
-               OBD_ALLOC(stripe, sizeof(stripe[0]) * stripe_len);
+               OBD_ALLOC_PTR_ARRAY(stripe, stripe_len);
                if (stripe == NULL)
                        GOTO(out, rc = -ENOMEM);
-               OBD_ALLOC(ost_indices, sizeof(*ost_indices) * stripe_len);
+               OBD_ALLOC_PTR_ARRAY(ost_indices, stripe_len);
                if (!ost_indices)
                        GOTO(out, rc = -ENOMEM);
 
@@ -2576,10 +2575,9 @@ put_ldts:
 out:
        if (rc < 0) {
                if (stripe)
-                       OBD_FREE(stripe, sizeof(stripe[0]) * stripe_len);
+                       OBD_FREE_PTR_ARRAY(stripe, stripe_len);
                if (ost_indices)
-                       OBD_FREE(ost_indices,
-                                sizeof(*ost_indices) * stripe_len);
+                       OBD_FREE_PTR_ARRAY(ost_indices, stripe_len);
        }
        RETURN(rc);
 }