Whamcloud - gitweb
LU-6910 osp: add procfs values for OST reserved size
[fs/lustre-release.git] / lustre / lod / lod_qos.c
index d1985b8..9159b11 100644 (file)
@@ -199,6 +199,11 @@ static int lod_statfs_and_check(const struct lu_env *env, struct lod_device *d,
        LASSERT(ost);
 
        rc = dt_statfs(env, ost->ltd_ost, sfs);
+
+       if (rc == 0 && ((sfs->os_state & OS_STATE_ENOSPC) ||
+           (sfs->os_state & OS_STATE_ENOINO && sfs->os_fprecreated == 0)))
+               RETURN(-ENOSPC);
+
        if (rc && rc != -ENOTCONN)
                CERROR("%s: statfs: rc = %d\n", lod2obd(d)->obd_name, rc);
 
@@ -517,9 +522,9 @@ static int lod_qos_used(struct lod_device *lod, struct ost_pool *osts,
                if (ost->ltd_qos.ltq_usable)
                        *total_wt += ost->ltd_qos.ltq_weight;
 
-               QOS_DEBUG("recalc tgt %d usable=%d avail="LPU64
-                         " ostppo="LPU64" ostp="LPU64" ossppo="LPU64
-                         " ossp="LPU64" wt="LPU64"\n",
+               QOS_DEBUG("recalc tgt %d usable=%d avail=%llu"
+                         " ostppo=%llu ostp=%llu ossppo=%llu"
+                         " ossp=%llu wt=%llu\n",
                          i, ost->ltd_qos.ltq_usable, TGT_BAVAIL(i) >> 10,
                          ost->ltd_qos.ltq_penalty_per_obj >> 10,
                          ost->ltd_qos.ltq_penalty >> 10,
@@ -742,30 +747,6 @@ static int min_stripe_count(__u32 stripe_cnt, int flags)
 #define LOV_CREATE_RESEED_MIN  2000
 
 /**
- * Check if an OST is full.
- *
- * Check whether an OST should be considered full based
- * on the given statfs data.
- *
- * \param[in] msfs     statfs data
- *
- * \retval false       not full
- * \retval true                full
- */
-static int inline lod_qos_dev_is_full(struct obd_statfs *msfs)
-{
-       __u64 used;
-       int   bs = msfs->os_bsize;
-
-       LASSERT(((bs - 1) & bs) == 0);
-
-       /* the minimum of 0.1% used blocks and 1GB bytes. */
-       used = min_t(__u64, (msfs->os_blocks - msfs->os_bfree) >> 10,
-                       1 << (31 - ffs(bs)));
-       return (msfs->os_bavail < used);
-}
-
-/**
  * Initialize temporary OST-in-use array.
  *
  * Allocate or extend the array used to mark targets already assigned to a new
@@ -856,14 +837,6 @@ static int lod_check_and_reserve_ost(const struct lu_env *env,
        }
 
        /*
-        * skip full devices
-        */
-       if (lod_qos_dev_is_full(sfs)) {
-               QOS_DEBUG("#%d is full\n", ost_idx);
-               goto out_return;
-       }
-
-       /*
         * We expect number of precreated objects in f_ffree at
         * the first iteration, skip OSPs with no objects ready
         */
@@ -883,7 +856,7 @@ static int lod_check_and_reserve_ost(const struct lu_env *env,
        /*
         * do not put >1 objects on a single OST
         */
-       if (speed && lod_qos_is_ost_used(env, ost_idx, stripe_idx))
+       if (lod_qos_is_ost_used(env, ost_idx, stripe_idx))
                goto out_return;
 
        o = lod_qos_declare_object_on(env, m, ost_idx, th);
@@ -899,6 +872,7 @@ static int lod_check_and_reserve_ost(const struct lu_env *env,
         */
        lod_qos_ost_in_use(env, stripe_idx, ost_idx);
        stripe[stripe_idx] = o;
+       OBD_FAIL_TIMEOUT(OBD_FAIL_MDS_LOV_CREATE_RACE, 2);
        stripe_idx++;
        *s_idx = stripe_idx;
 
@@ -1437,10 +1411,7 @@ static int lod_alloc_qos(const struct lu_env *env, struct lod_object *lo,
                        continue;
                }
 
-               /*
-                * skip full devices
-                */
-               if (lod_qos_dev_is_full(sfs))
+               if (sfs->os_state & OS_STATE_DEGRADED)
                        continue;
 
                /* Fail Check before osc_precreate() is called
@@ -1513,8 +1484,8 @@ static int lod_alloc_qos(const struct lu_env *env, struct lod_object *lo,
                                continue;
 
                        cur_weight += ost->ltd_qos.ltq_weight;
-                       QOS_DEBUG("stripe_cnt=%d nfound=%d cur_weight="LPU64
-                                 " rand="LPU64" total_weight="LPU64"\n",
+                       QOS_DEBUG("stripe_cnt=%d nfound=%d cur_weight=%llu"
+                                 " rand=%llu total_weight=%llu\n",
                                  stripe_cnt, nfound, cur_weight, rand,
                                  total_weight);