Whamcloud - gitweb
LU-17703 lod: check the inherited pool for conflicts
[fs/lustre-release.git] / lustre / lod / lod_qos.c
index c93cee8..8adc06c 100644 (file)
@@ -2339,8 +2339,7 @@ unlock:
        RETURN(rc);
 }
 
-static void lod_qos_set_pool(struct lod_object *lo, int pos, char *pool_name,
-                            struct lov_user_md_v1 *v1)
+void lod_qos_set_pool(struct lod_object *lo, int pos, const char *pool_name)
 {
        struct lod_device *d = lu2lod_dev(lod2lu_obj(lo)->lo_dev);
        struct lod_layout_component *lod_comp;
@@ -2353,46 +2352,40 @@ static void lod_qos_set_pool(struct lod_object *lo, int pos, char *pool_name,
        if (pool_name)
                pool = lod_find_pool(d, pool_name);
 
-       if (!pool)
-               goto out_setpool;
+       if (!pool) {
+               lod_obj_set_pool(lo, pos, pool_name);
+               return;
+       }
 
        lod_comp = &lo->ldo_comp_entries[pos];
-       if (lod_comp->llc_stripe_offset == LOV_OFFSET_DEFAULT)
-               goto out_checkcount;
-
-       if (v1->lmm_magic == LOV_USER_MAGIC_SPECIFIC) {
-               struct lov_user_md_v3 *v3;
-
-               v3 = (struct lov_user_md_v3 *)v1;
-               for (j = 0; j < v3->lmm_stripe_count; j++) {
-                       idx = lod_comp->llc_ostlist.op_array[j];
+       if (lod_comp->llc_stripe_offset != LOV_OFFSET_DEFAULT) {
+               if (lod_comp->llc_ostlist.op_count) {
+                       for (j = 0; j < lod_comp->llc_ostlist.op_count; j++) {
+                               idx = lod_comp->llc_ostlist.op_array[j];
+                               rc = lod_check_index_in_pool(idx, pool);
+                               if (rc)
+                                       break;
+                       }
+               } else {
+                       idx = lod_comp->llc_stripe_offset;
                        rc = lod_check_index_in_pool(idx, pool);
-                       if (rc)
-                               break;
                }
-       } else {
-               idx = lod_comp->llc_stripe_offset;
-               rc = lod_check_index_in_pool(idx, pool);
-       }
-
-       if (!rc)
-               goto out_checkcount;
 
-       CDEBUG(D_LAYOUT,
-              "%s: index %u is not in the pool %s, dropping the pool\n",
-              lod2obd(d)->obd_name, idx, pool_name);
-       pool_name = NULL;
-       goto out_putref;
+               if (rc) {
+                       CDEBUG(D_LAYOUT, "%s: index %u is not in the pool %s, "
+                              "dropping the pool\n", lod2obd(d)->obd_name,
+                              idx, pool_name);
+                       pool_name = NULL;
+               }
+       }
 
-out_checkcount:
-       if (lod_comp->llc_stripe_count > pool_tgt_count(pool) &&
+       if (pool_name &&
+           lod_comp->llc_stripe_count > pool_tgt_count(pool) &&
            !(lod_comp->llc_pattern & LOV_PATTERN_OVERSTRIPING))
                lod_comp->llc_stripe_count = pool_tgt_count(pool);
-out_putref:
+
        lod_pool_putref(pool);
-out_setpool:
        lod_obj_set_pool(lo, pos, pool_name);
-
 }
 
 /**
@@ -2616,7 +2609,7 @@ int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo,
                                             lod_comp->llc_stripe_size);
 
                lod_comp->llc_stripe_offset = v1->lmm_stripe_offset;
-               lod_qos_set_pool(lo, i, pool_name, v1);
+               lod_qos_set_pool(lo, i, pool_name);
        }
 
        RETURN(0);