Whamcloud - gitweb
LU-2899 lod: get ldo_stripenr correctly
[fs/lustre-release.git] / lustre / lod / lod_qos.c
index 2b81ad8..29c582a 100644 (file)
@@ -175,7 +175,9 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d,
                spin_unlock(&d->lod_desc_lock);
        } else if (rc == 0 && ost->ltd_active == 0) {
                /* turned active? */
-               LASSERT(d->lod_desc.ld_active_tgt_count < d->lod_ostnr);
+               LASSERTF(d->lod_desc.ld_active_tgt_count < d->lod_ostnr,
+                        "active tgt count %d, ost nr %d\n",
+                        d->lod_desc.ld_active_tgt_count, d->lod_ostnr);
                spin_lock(&d->lod_desc_lock);
                if (ost->ltd_active == 0) {
                        ost->ltd_active = 1;
@@ -188,7 +190,7 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d,
                spin_unlock(&d->lod_desc_lock);
        }
 
-       return rc;
+       RETURN(rc);
 }
 
 static void lod_qos_statfs_update(const struct lu_env *env,
@@ -225,6 +227,7 @@ static void lod_qos_statfs_update(const struct lu_env *env,
 
 out:
        up_write(&lod->lod_qos.lq_rw_sem);
+       EXIT;
 }
 
 /* Recalculate per-object penalties for OSSs and OSTs,
@@ -1384,6 +1387,11 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
                 * no striping has been created so far
                 */
                LASSERT(lo->ldo_stripenr > 0);
+               /*
+                * statfs and check OST targets now, since ld_active_tgt_count
+                * could be changed if some OSTs are [de]activated manually.
+                */
+               lod_qos_statfs_update(env, d);
                lo->ldo_stripenr = lod_get_stripecnt(d, LOV_MAGIC,
                                lo->ldo_stripenr);
 
@@ -1394,8 +1402,9 @@ int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
 
                lod_getref(&d->lod_ost_descs);
                /* XXX: support for non-0 files w/o objects */
+               CDEBUG(D_OTHER, "tgt_count %d stripenr %d\n",
+                               d->lod_desc.ld_tgt_count, stripe_len);
                if (lo->ldo_def_stripe_offset >= d->lod_desc.ld_tgt_count) {
-                       lod_qos_statfs_update(env, d);
                        rc = lod_alloc_qos(env, lo, stripe, flag, th);
                        if (rc == -EAGAIN)
                                rc = lod_alloc_rr(env, lo, stripe, flag, th);