Exemple #1
0
static int _raid_text_import_area_count(const struct dm_config_node *sn,
					uint32_t *area_count)
{
	uint32_t stripe_count = 0, device_count = 0;
	int stripe_count_found, device_count_found;

	device_count_found = dm_config_get_uint32(sn, "device_count", &device_count);
	stripe_count_found = dm_config_get_uint32(sn, "stripe_count", &stripe_count);

	if (!device_count_found && !stripe_count_found) {
		log_error("Couldn't read 'device_count' or 'stripe_count' for "
			  "segment '%s'.", dm_config_parent_name(sn));
		return 0;
	}

	if (device_count_found && stripe_count_found) {
		log_error("Only one of 'device_count' and 'stripe_count' allowed for "
			  "segment '%s'.", dm_config_parent_name(sn));
		return 0;
	}

	*area_count = stripe_count + device_count;

	return 1;
}
Exemple #2
0
static int _raid_text_import_area_count(const struct dm_config_node *sn,
					uint32_t *area_count)
{
	if (!dm_config_get_uint32(sn, "device_count", area_count)) {
		log_error("Couldn't read 'device_count' for "
			  "segment '%s'.", dm_config_parent_name(sn));
		return 0;
	}
	return 1;
}
Exemple #3
0
static int _striped_text_import(struct lv_segment *seg, const struct dm_config_node *sn,
			struct dm_hash_table *pv_hash)
{
	const struct dm_config_value *cv;

	if ((seg->area_count != 1) &&
	    !dm_config_get_uint32(sn, "stripe_size", &seg->stripe_size)) {
		log_error("Couldn't read stripe_size for segment %s "
			  "of logical volume %s.", dm_config_parent_name(sn), seg->lv->name);
		return 0;
	}

	if (!dm_config_get_list(sn, "stripes", &cv)) {
		log_error("Couldn't find stripes array for segment %s "
			  "of logical volume %s.", dm_config_parent_name(sn), seg->lv->name);
		return 0;
	}

	seg->area_len /= seg->area_count;

	return text_import_areas(seg, sn, cv, pv_hash, 0);
}
Exemple #4
0
static int _raid_text_import_areas(struct lv_segment *seg,
				   const struct dm_config_node *sn,
				   const struct dm_config_value *cv)
{
	unsigned int s;
	struct logical_volume *lv;
	const char *seg_name = dm_config_parent_name(sn);

	if (!seg->area_count) {
		log_error("No areas found for segment %s", seg_name);
		return 0;
	}

	for (s = 0; cv && s < seg->area_count; s++, cv = cv->next) {
		if (cv->type != DM_CFG_STRING) {
			log_error("Bad volume name in areas array for segment %s.", seg_name);
			return 0;
		}

		/* Metadata device comes first. */
		if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
			log_error("Couldn't find volume '%s' for segment '%s'.",
				  cv->v.str ? : "NULL", seg_name);
			return 0;
		}

		if (strstr(lv->name, "_rmeta_")) {
			if (!set_lv_segment_area_lv(seg, s, lv, 0, RAID_META))
				return_0;
			cv = cv->next;
		}

		if (!cv) {
			log_error("Missing data device in areas array for segment %s.", seg_name);
			return 0;
		}

		/* Data device comes second */
		if (!(lv = find_lv(seg->lv->vg, cv->v.str))) {
			log_error("Couldn't find volume '%s' for segment '%s'.",
				  cv->v.str ? : "NULL", seg_name);
			return 0;
		}