75
75
struct replicator_site *rsite;
76
76
struct replicator_device *rdev;
78
/* Check LV flags match first segment type */
80
if (lv_is_thin_volume(lv) &&
81
(!(seg2 = first_seg(lv)) || !seg_is_thin_volume(seg2))) {
82
log_error("LV %s is thin volume without first thin volume segment",
87
if (lv_is_thin_pool(lv) &&
88
(!(seg2 = first_seg(lv)) || !seg_is_thin_pool(seg2))) {
89
log_error("LV %s is thin pool without first thin pool segment",
94
if (lv_is_thin_pool_data(lv) &&
95
(!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
96
seg2->area_count != 1 || seg_type(seg2, 0) != AREA_LV ||
97
seg_lv(seg2, 0) != lv)) {
98
log_error("LV %s: segment 1 pool data LV does not point back to same LV",
103
if (lv_is_thin_pool_metadata(lv) &&
104
(!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
105
seg2->metadata_lv != lv)) {
106
log_error("LV %s: segment 1 pool metadata LV does not point back to same LV",
78
112
dm_list_iterate_items(seg, &lv->segments) {
80
114
if (seg->le != le) {
169
/* Check the various thin segment types */
171
if (seg_is_thin_pool(seg)) {
172
if (!lv_is_thin_pool(lv)) {
173
log_error("LV %s is missing thin pool flag for segment %u",
174
lv->name, seg_count);
178
if (lv_is_thin_volume(lv)) {
179
log_error("LV %s is a thin volume that must not contain thin pool segment %u",
180
lv->name, seg_count);
184
if (seg->area_count != 1 || seg_type(seg, 0) != AREA_LV) {
185
log_error("LV %s: thin pool segment %u is missing a pool data LV",
186
lv->name, seg_count);
188
} else if (!(seg2 = first_seg(seg_lv(seg, 0))) || find_pool_seg(seg2) != seg) {
189
log_error("LV %s: thin pool segment %u data LV does not refer back to pool LV",
190
lv->name, seg_count);
194
if (!seg->metadata_lv) {
195
log_error("LV %s: thin pool segment %u is missing a pool metadata LV",
196
lv->name, seg_count);
198
} else if (!(seg2 = first_seg(seg->metadata_lv)) ||
199
find_pool_seg(seg2) != seg) {
200
log_error("LV %s: thin pool segment %u metadata LV does not refer back to pool LV",
201
lv->name, seg_count);
205
if (seg->chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE ||
206
seg->chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) {
207
log_error("LV %s: thin pool segment %u chunk size %d is out of range",
208
lv->name, seg_count, seg->chunk_size);
212
if (seg->metadata_lv) {
213
log_error("LV %s: segment %u must not have thin pool metadata LV set",
214
lv->name, seg_count);
219
if (seg_is_thin_volume(seg)) {
220
if (!lv_is_thin_volume(lv)) {
221
log_error("LV %s is missing thin volume flag for segment %u",
222
lv->name, seg_count);
226
if (lv_is_thin_pool(lv)) {
227
log_error("LV %s is a thin pool that must not contain thin volume segment %u",
228
lv->name, seg_count);
233
log_error("LV %s: segment %u is missing thin pool LV",
234
lv->name, seg_count);
236
} else if (!lv_is_thin_pool(seg->pool_lv)) {
237
log_error("LV %s: thin volume segment %u pool LV is not flagged as a pool LV",
238
lv->name, seg_count);
242
if (seg->device_id > DM_THIN_MAX_DEVICE_ID) {
243
log_error("LV %s: thin volume segment %u has too large device id %d",
244
lv->name, seg_count, seg->device_id);
249
log_error("LV %s: segment %u must not have thin pool LV set",
250
lv->name, seg_count);
135
256
if (seg_is_snapshot(seg)) {
136
257
if (seg->cow && seg->cow == seg->origin) {
137
258
log_error("LV %s: segment %u has same LV %s for "
312
437
/* Clone the existing segment */
313
if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype,
438
if (!(split_seg = alloc_lv_segment(seg->segtype,
314
439
seg->lv, seg->le, seg->len,
315
440
seg->status, seg->stripe_size,
441
seg->log_lv, seg->pool_lv,
317
442
seg->area_count, seg->area_len,
318
443
seg->chunk_size, seg->region_size,
319
444
seg->extents_copied, seg->pvmove_source_seg))) {