Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / lov / lov_qos.c
index c6ff1eb..f3b9040 100644 (file)
@@ -243,7 +243,7 @@ out:
 static int qos_calc_weight(struct lov_obd *lov, int i)
 {
         __u64 temp, temp2;
-        
+
         /* Final ost weight = TGT_BAVAIL - ost_penalty - oss_penalty */
         temp = TGT_BAVAIL(i);
         temp2 = lov->lov_tgts[i]->ltd_qos.ltq_penalty + 
@@ -266,7 +266,7 @@ static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
         lov->lov_tgts[index]->ltd_qos.ltq_usable = 0;
 
         oss = lov->lov_tgts[index]->ltd_qos.ltq_oss;
-        
+
         /* Decay old penalty by half (we're adding max penalty, and don't
            want it to run away.) */
         lov->lov_tgts[index]->ltd_qos.ltq_penalty >>= 1;
@@ -278,7 +278,7 @@ static int qos_used(struct lov_obd *lov, __u32 index, __u64 *total_wt)
                 lov->desc.ld_active_tgt_count;
         oss->lqo_penalty += oss->lqo_penalty_per_obj * 
                 lov->lov_qos.lq_active_oss_count;
-        
+
         /* Decrease all OSS penalties */
         list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
                 if (oss->lqo_penalty < oss->lqo_penalty_per_obj) 
@@ -373,8 +373,8 @@ static int qos_calc_rr(struct lov_obd *lov)
         list_for_each_entry(oss, &lov->lov_qos.lq_oss_list, lqo_oss_list) {
                 int j = 0;
                 for (i = 0; i < ost_count; i++) {
-                      LASSERT(lov->lov_tgts[i] != NULL);
-                      if (lov->lov_tgts[i]->ltd_qos.ltq_oss == oss) {
+                        if(lov->lov_tgts[i] &&
+                           lov->lov_tgts[i]->ltd_qos.ltq_oss == oss) {
                               /* Evenly space these OSTs across arrayspace */
                               int next = j * ost_count / oss->lqo_ost_count;
                               LASSERT(next < ost_count);
@@ -384,7 +384,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);
         }
@@ -532,8 +532,7 @@ static int alloc_rr(struct lov_obd *lov, int *idx_arr, int *stripe_cnt,
                 /* If we have allocated from all of the OSTs, slowly
                    precess the next start */
                 lov->lov_start_idx %= ost_count;
-                if (stripe_cnt_min > 1 &&
-                    (ost_active_count % stripe_cnt_min) != 1)
+                if (*stripe_cnt > 1 && (ost_active_count % (*stripe_cnt)) != 1)
                         ++lov->lov_offset_idx;
         }
         down_read(&lov->lov_qos.lq_rw_sem);
@@ -567,8 +566,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;
@@ -614,8 +612,8 @@ 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) &&
+                    (i != 0 || speed < 2))
                         continue;
 
                 *idx_pos = ost_idx;
@@ -636,8 +634,9 @@ repeat_find:
          *
          * We can only get here if lsm_stripe_count was originally > 1.
          */
-        CERROR("can't lstripe objid "LPX64": have "LPSZ" want %u\n",
-               lsm->lsm_object_id, idx_pos - idx_arr, lsm->lsm_stripe_count);
+        CERROR("can't lstripe objid "LPX64": have %d want %u\n",
+               lsm->lsm_object_id, (int)(idx_pos - idx_arr),
+               lsm->lsm_stripe_count);
         RETURN(-EFBIG);
 }
 
@@ -683,9 +682,9 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
                 GOTO(out_up_write, rc = -EAGAIN);
 
         rc = qos_calc_ppo(exp->exp_obd);
-        if (rc) 
+        if (rc)
                 GOTO(out_up_write, rc);
-        
+
         total_bavail = 0;
         good_osts = 0;
         /* Warn users about zero available space/inode every 30 min */
@@ -694,7 +693,7 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
         /* Find all the OSTs that are valid stripe candidates */
         for (i = 0; i < ost_count; i++) {
                 __u64 bavail;
-                
+
                 if (!lov->lov_tgts[i] || !lov->lov_tgts[i]->ltd_active)
                         continue;
                 bavail = TGT_BAVAIL(i);
@@ -720,7 +719,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;
@@ -731,12 +730,12 @@ static int alloc_qos(struct obd_export *exp, int *idx_arr, int *stripe_cnt,
                 good_osts++;
         }
 
+        if (good_osts < stripe_cnt_min)
+                GOTO(out_up_write, rc = -EAGAIN);
+
         if (!total_bavail)
                 GOTO(out_up_write, rc = -ENOSPC);
 
-         if (good_osts < stripe_cnt_min)
-                GOTO(out_up_write, rc = -EAGAIN);
-
         /* We have enough osts */
         if (good_osts < *stripe_cnt)
                 *stripe_cnt = good_osts;
@@ -860,7 +859,7 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
         struct obdo *src_oa = set->set_oi->oi_oa;
         struct obd_trans_info *oti = set->set_oti;
         int i, stripes, rc = 0, newea = 0;
-        int *idx_arr, idx_cnt = 0;
+        int *idx_arr = NULL, idx_cnt = 0;
         int flag = LOV_USES_ASSIGNED_STRIPE;
         ENTRY;
 
@@ -975,7 +974,8 @@ int qos_prep_create(struct obd_export *exp, struct lov_request_set *set)
 out_err:
         if (newea && rc)
                 obd_free_memmd(exp, &set->set_oi->oi_md);
-        free_idx_array(idx_arr, idx_cnt);
+        if (idx_arr)
+                free_idx_array(idx_arr, idx_cnt);
         EXIT;
         return rc;
 }