Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lustre / lov / lov_qos.c
index 8f89e0d..19d0688 100644 (file)
@@ -369,7 +369,7 @@ static int qos_calc_rr(struct lov_obd *lov)
                               lov->lov_qos.lq_rr_array[next] = i;
                               j++;
                               placed++;
-                      }
+                        }
                 }
                 LASSERT(j == oss->lqo_ost_count);
         }
@@ -515,9 +515,11 @@ static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt,
         } else if (stripe_cnt_min >= ost_active_count ||
                    lov->lov_start_idx > ost_count) {
                 /* If we have allocated from all of the OSTs, slowly
-                   precess the next start */
+                 * precess the next start if the OST/stripe count isn't
+                 * already doing this for us. */
                 lov->lov_start_idx %= ost_count;
-                ++lov->lov_offset_idx;
+                if (*stripe_cnt > 1 && (ost_active_count % (*stripe_cnt)) != 1)
+                        ++lov->lov_offset_idx;
         }
         down_read(&lov->lov_qos.lq_rw_sem);
         ost_start_idx_temp = lov->lov_start_idx;
@@ -526,9 +528,10 @@ repeat_find :
         array_idx = (lov->lov_start_idx + lov->lov_offset_idx) % ost_count;
         idx_pos = idx_arr;
 #ifdef QOS_DEBUG
-        CDEBUG(D_QOS, "want %d startidx %d startcnt %d offset %d arrayidx %d\n",
-               stripe_cnt_min, lov->lov_start_idx, lov->lov_start_count,
-               lov->lov_offset_idx, array_idx);
+        CDEBUG(D_QOS, "want %d startidx %d startcnt %d offset %d active %d "
+               "count %d arrayidx %d\n",
+               stripe_cnt, lov->lov_start_idx, lov->lov_start_count,
+               lov->lov_offset_idx, ost_active_count, ost_count, array_idx);
 #endif
 
         for (i = 0; i < ost_count; i++, array_idx=(array_idx + 1) % ost_count) {
@@ -551,8 +554,7 @@ repeat_find :
                         continue;
 
                 /* Drop slow OSCs if we can */
-                if (obd_precreate(lov->lov_tgts[ost_idx]->ltd_exp, speed == 0) >
-                    speed)
+                if (obd_precreate(lov->lov_tgts[ost_idx]->ltd_exp) > speed)
                         continue;
 
                 *idx_pos = ost_idx;
@@ -597,9 +599,9 @@ repeat_find:
                 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OSC_PRECREATE) && ost_idx == 0)
                         continue;
 
-                /* Drop slow OSCs if we can */
-                if (obd_precreate(lov->lov_tgts[ost_idx]->ltd_exp, speed == 0) >
-                    speed)
+                /* Drop slow OSCs if we can, but not for requested start idx */
+                if (obd_precreate(lov->lov_tgts[ost_idx]->ltd_exp) > speed &&
+                    (i != 0 || speed < 2))
                         continue;
 
                 *idx_pos = ost_idx;
@@ -690,7 +692,7 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
                 if (OBD_FAIL_CHECK(OBD_FAIL_MDS_OSC_PRECREATE) && i == 0)
                         continue;
 
-                if (obd_precreate(lov->lov_tgts[i]->ltd_exp, 1) >= 2)
+                if (obd_precreate(lov->lov_tgts[i]->ltd_exp) > 2)
                         continue;
 
                 lov->lov_tgts[i]->ltd_qos.ltq_usable = 1;
@@ -701,12 +703,12 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
                 good_osts++;
         }
 
-        if (!total_bavail)
-                GOTO(out, rc = -ENOSPC);
-
         if (good_osts < stripe_cnt_min)
                 GOTO(out, rc = -EAGAIN);
 
+        if (!total_bavail)
+                GOTO(out, rc = -ENOSPC);
+
         /* We have enough osts */
         if (good_osts < *stripe_cnt)
                 *stripe_cnt = good_osts;
@@ -829,7 +831,7 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
         struct obd_trans_info *oti = set->set_oti;
         int i, stripes, rc = 0, newea = 0;
         int flag = LOV_USES_ASSIGNED_STRIPE;
-        int *idx_arr, idx_cnt = 0;
+        int *idx_arr = NULL, idx_cnt = 0;
         ENTRY;
 
         LASSERT(src_oa->o_valid & OBD_MD_FLID);