Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 56873 | Differences between
and this patch

Collapse All | Expand All

(-)LVM2.2.00.15.orig/lib/activate/activate.c (-29 / +29 lines)
Lines 180-186 Link Here
180
180
181
	if (!(cn = find_config_node(cmd->cft->root, "activation/volume_list"))) {
181
	if (!(cn = find_config_node(cmd->cft->root, "activation/volume_list"))) {
182
		/* If no hosts tags defined, activate */
182
		/* If no hosts tags defined, activate */
183
		if (list_empty(&cmd->tags))
183
		if (lvm_list_empty(&cmd->tags))
184
			return 1;
184
			return 1;
185
185
186
		/* If any host tag matches any LV or VG tag, activate */
186
		/* If any host tag matches any LV or VG tag, activate */
Lines 270-276 Link Here
270
270
271
	log_very_verbose("Getting driver version");
271
	log_very_verbose("Getting driver version");
272
	if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) {
272
	if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) {
273
		stack;
273
		STACK;
274
		return 0;
274
		return 0;
275
	}
275
	}
276
276
Lines 299-305 Link Here
299
299
300
	log_very_verbose("Getting target version for %s", target_name);
300
	log_very_verbose("Getting target version for %s", target_name);
301
	if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS))) {
301
	if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS))) {
302
		stack;
302
		STACK;
303
		return 0;
303
		return 0;
304
	}
304
	}
305
305
Lines 342-353 Link Here
342
		return 0;
342
		return 0;
343
343
344
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
344
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
345
		stack;
345
		STACK;
346
		return 0;
346
		return 0;
347
	}
347
	}
348
348
349
	if (!(r = dev_manager_info(dm, lv, mknodes, &dminfo)))
349
	if (!(r = dev_manager_info(dm, lv, mknodes, &dminfo)))
350
		stack;
350
		STACK;
351
351
352
	info->exists = dminfo.exists;
352
	info->exists = dminfo.exists;
353
	info->suspended = dminfo.suspended;
353
	info->suspended = dminfo.suspended;
Lines 388-399 Link Here
388
		return 0;
388
		return 0;
389
389
390
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
390
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
391
		stack;
391
		STACK;
392
		return 0;
392
		return 0;
393
	}
393
	}
394
394
395
	if (!(r = dev_manager_snapshot_percent(dm, lv, percent)))
395
	if (!(r = dev_manager_snapshot_percent(dm, lv, percent)))
396
		stack;
396
		STACK;
397
397
398
	dev_manager_destroy(dm);
398
	dev_manager_destroy(dm);
399
399
Lines 412-418 Link Here
412
		return 0;
412
		return 0;
413
413
414
	if (!lv_info(lv, &info)) {
414
	if (!lv_info(lv, &info)) {
415
		stack;
415
		STACK;
416
		return 0;
416
		return 0;
417
	}
417
	}
418
418
Lines 420-431 Link Here
420
		return 0;
420
		return 0;
421
421
422
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
422
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
423
		stack;
423
		STACK;
424
		return 0;
424
		return 0;
425
	}
425
	}
426
426
427
	if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr)))
427
	if (!(r = dev_manager_mirror_percent(dm, lv, wait, percent, event_nr)))
428
		stack;
428
		STACK;
429
429
430
	dev_manager_destroy(dm);
430
	dev_manager_destroy(dm);
431
431
Lines 437-443 Link Here
437
	struct lvinfo info;
437
	struct lvinfo info;
438
438
439
	if (!lv_info(lv, &info)) {
439
	if (!lv_info(lv, &info)) {
440
		stack;
440
		STACK;
441
		return -1;
441
		return -1;
442
	}
442
	}
443
443
Lines 449-455 Link Here
449
	struct lvinfo info;
449
	struct lvinfo info;
450
450
451
	if (!lv_info(lv, &info)) {
451
	if (!lv_info(lv, &info)) {
452
		stack;
452
		STACK;
453
		return -1;
453
		return -1;
454
	}
454
	}
455
455
Lines 463-474 Link Here
463
	struct dev_manager *dm;
463
	struct dev_manager *dm;
464
464
465
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
465
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
466
		stack;
466
		STACK;
467
		return 0;
467
		return 0;
468
	}
468
	}
469
469
470
	if (!(r = dev_manager_activate(dm, lv)))
470
	if (!(r = dev_manager_activate(dm, lv)))
471
		stack;
471
		STACK;
472
472
473
	dev_manager_destroy(dm);
473
	dev_manager_destroy(dm);
474
	return r;
474
	return r;
Lines 480-491 Link Here
480
	struct dev_manager *dm;
480
	struct dev_manager *dm;
481
481
482
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
482
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
483
		stack;
483
		STACK;
484
		return 0;
484
		return 0;
485
	}
485
	}
486
486
487
	if (!(r = dev_manager_deactivate(dm, lv)))
487
	if (!(r = dev_manager_deactivate(dm, lv)))
488
		stack;
488
		STACK;
489
489
490
	dev_manager_destroy(dm);
490
	dev_manager_destroy(dm);
491
	return r;
491
	return r;
Lines 497-508 Link Here
497
	struct dev_manager *dm;
497
	struct dev_manager *dm;
498
498
499
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
499
	if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
500
		stack;
500
		STACK;
501
		return 0;
501
		return 0;
502
	}
502
	}
503
503
504
	if (!(r = dev_manager_suspend(dm, lv)))
504
	if (!(r = dev_manager_suspend(dm, lv)))
505
		stack;
505
		STACK;
506
506
507
	dev_manager_destroy(dm);
507
	dev_manager_destroy(dm);
508
	return r;
508
	return r;
Lines 514-528 Link Here
514
 */
514
 */
515
int lvs_in_vg_activated(struct volume_group *vg)
515
int lvs_in_vg_activated(struct volume_group *vg)
516
{
516
{
517
	struct list *lvh;
517
	struct lvm_list *lvh;
518
	struct logical_volume *lv;
518
	struct logical_volume *lv;
519
	int count = 0;
519
	int count = 0;
520
520
521
	if (!activation())
521
	if (!activation())
522
		return 0;
522
		return 0;
523
523
524
	list_iterate(lvh, &vg->lvs) {
524
	lvm_list_iterate(lvh, &vg->lvs) {
525
		lv = list_item(lvh, struct lv_list)->lv;
525
		lv = lvm_list_item(lvh, struct lv_list)->lv;
526
		count += (_lv_active(lv) == 1);
526
		count += (_lv_active(lv) == 1);
527
	}
527
	}
528
528
Lines 531-545 Link Here
531
531
532
int lvs_in_vg_opened(struct volume_group *vg)
532
int lvs_in_vg_opened(struct volume_group *vg)
533
{
533
{
534
	struct list *lvh;
534
	struct lvm_list *lvh;
535
	struct logical_volume *lv;
535
	struct logical_volume *lv;
536
	int count = 0;
536
	int count = 0;
537
537
538
	if (!activation())
538
	if (!activation())
539
		return 0;
539
		return 0;
540
540
541
	list_iterate(lvh, &vg->lvs) {
541
	lvm_list_iterate(lvh, &vg->lvs) {
542
		lv = list_item(lvh, struct lv_list)->lv;
542
		lv = lvm_list_item(lvh, struct lv_list)->lv;
543
		count += (_lv_open_count(lv) > 0);
543
		count += (_lv_open_count(lv) > 0);
544
	}
544
	}
545
545
Lines 564-570 Link Here
564
	}
564
	}
565
565
566
	if (!lv_info(lv, &info)) {
566
	if (!lv_info(lv, &info)) {
567
		stack;
567
		STACK;
568
		return 0;
568
		return 0;
569
	}
569
	}
570
570
Lines 610-616 Link Here
610
	}
610
	}
611
611
612
	if (!lv_info(lv, &info)) {
612
	if (!lv_info(lv, &info)) {
613
		stack;
613
		STACK;
614
		return 0;
614
		return 0;
615
	}
615
	}
616
616
Lines 655-661 Link Here
655
	}
655
	}
656
656
657
	if (!lv_info(lv, &info)) {
657
	if (!lv_info(lv, &info)) {
658
		stack;
658
		STACK;
659
		return 0;
659
		return 0;
660
	}
660
	}
661
661
Lines 724-730 Link Here
724
	}
724
	}
725
725
726
	if (!lv_info(lv, &info)) {
726
	if (!lv_info(lv, &info)) {
727
		stack;
727
		STACK;
728
		return 0;
728
		return 0;
729
	}
729
	}
730
730
Lines 763-769 Link Here
763
	}
763
	}
764
764
765
	if (!_lv_info(lv, 1, &info)) {
765
	if (!_lv_info(lv, 1, &info)) {
766
		stack;
766
		STACK;
767
		return 0;
767
		return 0;
768
	}
768
	}
769
769
(-)LVM2.2.00.15.orig/lib/activate/dev_manager.c (-180 / +180 lines)
Lines 99-113 Link Here
99
	 * Devices that must be created before this one can be created.
99
	 * Devices that must be created before this one can be created.
100
	 * Reloads get propagated to this list.  Holds str_lists.
100
	 * Reloads get propagated to this list.  Holds str_lists.
101
	 */
101
	 */
102
	struct list pre_create;
102
	struct lvm_list pre_create;
103
103
104
	/* Inverse of pre_create */
104
	/* Inverse of pre_create */
105
	struct list pre_suspend;
105
	struct lvm_list pre_suspend;
106
106
107
};
107
};
108
108
109
struct dl_list {
109
struct dl_list {
110
	struct list list;
110
	struct lvm_list list;
111
	struct dev_layer *dl;
111
	struct dev_layer *dl;
112
};
112
};
113
113
Lines 128-149 Link Here
128
	 * list of struct lv_list, contains lvs that we wish to
128
	 * list of struct lv_list, contains lvs that we wish to
129
	 * be active after execution.
129
	 * be active after execution.
130
	 */
130
	 */
131
	struct list active_list;
131
	struct lvm_list active_list;
132
132
133
	/*
133
	/*
134
	 * Layers that need reloading.
134
	 * Layers that need reloading.
135
	 */
135
	 */
136
	struct list reload_list;
136
	struct lvm_list reload_list;
137
137
138
	/*
138
	/*
139
	 * Layers that need suspending.
139
	 * Layers that need suspending.
140
	 */
140
	 */
141
	struct list suspend_list;
141
	struct lvm_list suspend_list;
142
142
143
	/*
143
	/*
144
	 * Layers that will need removing after activation.
144
	 * Layers that will need removing after activation.
145
	 */
145
	 */
146
	struct list remove_list;
146
	struct lvm_list remove_list;
147
147
148
	struct hash_table *layers;
148
	struct hash_table *layers;
149
};
149
};
Lines 213-219 Link Here
213
	len += hyphens + 2;
213
	len += hyphens + 2;
214
214
215
	if (!(r = pool_alloc(mem, len))) {
215
	if (!(r = pool_alloc(mem, len))) {
216
		stack;
216
		STACK;
217
		return NULL;
217
		return NULL;
218
	}
218
	}
219
219
Lines 260-266 Link Here
260
	len = strlen(lvid) + strlen(layer) + 2;
260
	len = strlen(lvid) + strlen(layer) + 2;
261
261
262
	if (!(dlid = pool_alloc(mem, len))) {
262
	if (!(dlid = pool_alloc(mem, len))) {
263
		stack;
263
		STACK;
264
		return NULL;
264
		return NULL;
265
	}
265
	}
266
266
Lines 278-284 Link Here
278
	struct dm_task *dmt;
278
	struct dm_task *dmt;
279
279
280
	if (!(dmt = dm_task_create(task))) {
280
	if (!(dmt = dm_task_create(task))) {
281
		stack;
281
		STACK;
282
		return NULL;
282
		return NULL;
283
	}
283
	}
284
284
Lines 305-327 Link Here
305
	dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
305
	dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
306
306
307
	if (!(dmt = _setup_task(name, uuid, 0, dmtask))) {
307
	if (!(dmt = _setup_task(name, uuid, 0, dmtask))) {
308
		stack;
308
		STACK;
309
		return 0;
309
		return 0;
310
	}
310
	}
311
311
312
	if (!dm_task_run(dmt)) {
312
	if (!dm_task_run(dmt)) {
313
		stack;
313
		STACK;
314
		goto out;
314
		goto out;
315
	}
315
	}
316
316
317
	if (!dm_task_get_info(dmt, info)) {
317
	if (!dm_task_get_info(dmt, info)) {
318
		stack;
318
		STACK;
319
		goto out;
319
		goto out;
320
	}
320
	}
321
321
322
	if (info->exists && uuid_out) {
322
	if (info->exists && uuid_out) {
323
		if (!(u = dm_task_get_uuid(dmt))) {
323
		if (!(u = dm_task_get_uuid(dmt))) {
324
			stack;
324
			STACK;
325
			goto out;
325
			goto out;
326
		}
326
		}
327
		*uuid_out = pool_strdup(mem, u);
327
		*uuid_out = pool_strdup(mem, u);
Lines 359-370 Link Here
359
	char *params = NULL;
359
	char *params = NULL;
360
360
361
	if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS))) {
361
	if (!(dmt = _setup_task(name, uuid, 0, DM_DEVICE_STATUS))) {
362
		stack;
362
		STACK;
363
		return 0;
363
		return 0;
364
	}
364
	}
365
365
366
	if (!dm_task_run(dmt)) {
366
	if (!dm_task_run(dmt)) {
367
		stack;
367
		STACK;
368
		goto out;
368
		goto out;
369
	}
369
	}
370
370
Lines 428-434 Link Here
428
	char *type = NULL;
428
	char *type = NULL;
429
	char *params = NULL;
429
	char *params = NULL;
430
	float percent2;
430
	float percent2;
431
	struct list *segh = &lv->segments;
431
	struct lvm_list *segh = &lv->segments;
432
	struct lv_segment *seg = NULL;
432
	struct lv_segment *seg = NULL;
433
433
434
	uint64_t numerator, denominator;
434
	uint64_t numerator, denominator;
Lines 439-455 Link Here
439
	if (!(dmt = _setup_task(name, uuid, event_nr,
439
	if (!(dmt = _setup_task(name, uuid, event_nr,
440
				wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS)))
440
				wait ? DM_DEVICE_WAITEVENT : DM_DEVICE_STATUS)))
441
	{
441
	{
442
		stack;
442
		STACK;
443
		return 0;
443
		return 0;
444
	}
444
	}
445
445
446
	if (!dm_task_run(dmt)) {
446
	if (!dm_task_run(dmt)) {
447
		stack;
447
		STACK;
448
		goto out;
448
		goto out;
449
	}
449
	}
450
450
451
	if (!dm_task_get_info(dmt, &info) || !info.exists) {
451
	if (!dm_task_get_info(dmt, &info) || !info.exists) {
452
		stack;
452
		STACK;
453
		goto out;
453
		goto out;
454
	}
454
	}
455
455
Lines 460-471 Link Here
460
		next = dm_get_next_target(dmt, next, &start, &length, &type,
460
		next = dm_get_next_target(dmt, next, &start, &length, &type,
461
					  &params);
461
					  &params);
462
		if (lv) {
462
		if (lv) {
463
			if (!(segh = list_next(&lv->segments, segh))) {
463
			if (!(segh = lvm_list_next(&lv->segments, segh))) {
464
				log_error("Number of segments in active LV %s "
464
				log_error("Number of segments in active LV %s "
465
					  "does not match metadata", lv->name);
465
					  "does not match metadata", lv->name);
466
				goto out;
466
				goto out;
467
			}
467
			}
468
			seg = list_item(segh, struct lv_segment);
468
			seg = lvm_list_item(segh, struct lv_segment);
469
		}
469
		}
470
470
471
		if (!type || !params || strcmp(type, target_type))
471
		if (!type || !params || strcmp(type, target_type))
Lines 507-513 Link Here
507
		}
507
		}
508
	} while (next);
508
	} while (next);
509
509
510
	if (lv && (segh = list_next(&lv->segments, segh))) {
510
	if (lv && (segh = lvm_list_next(&lv->segments, segh))) {
511
		log_error("Number of segments in active LV %s does not "
511
		log_error("Number of segments in active LV %s does not "
512
			  "match metadata", lv->name);
512
			  "match metadata", lv->name);
513
		goto out;
513
		goto out;
Lines 551-562 Link Here
551
	log_verbose("Renaming %s to %s", dl->name, newname);
551
	log_verbose("Renaming %s to %s", dl->name, newname);
552
552
553
	if (!(dmt = _setup_task(dl->name, NULL, 0, DM_DEVICE_RENAME))) {
553
	if (!(dmt = _setup_task(dl->name, NULL, 0, DM_DEVICE_RENAME))) {
554
		stack;
554
		STACK;
555
		return 0;
555
		return 0;
556
	}
556
	}
557
557
558
	if (!dm_task_set_newname(dmt, newname)) {
558
	if (!dm_task_set_newname(dmt, newname)) {
559
		stack;
559
		STACK;
560
		r = 0;
560
		r = 0;
561
		goto out;
561
		goto out;
562
	}
562
	}
Lines 582-588 Link Here
582
	log_verbose("Loading %s", dl->name);
582
	log_verbose("Loading %s", dl->name);
583
	if (!(dmt = _setup_task(task == DM_DEVICE_CREATE ? dl->name : NULL,
583
	if (!(dmt = _setup_task(task == DM_DEVICE_CREATE ? dl->name : NULL,
584
				dl->dlid, 0, task))) {
584
				dl->dlid, 0, task))) {
585
		stack;
585
		STACK;
586
		return 0;
586
		return 0;
587
	}
587
	}
588
588
Lines 639-651 Link Here
639
	}
639
	}
640
640
641
	if (!dm_task_get_info(dmt, &dl->info)) {
641
	if (!dm_task_get_info(dmt, &dl->info)) {
642
		stack;
642
		STACK;
643
		r = 0;
643
		r = 0;
644
		goto out;
644
		goto out;
645
	}
645
	}
646
646
647
	if (!dl->info.exists || !dl->info.live_table) {
647
	if (!dl->info.exists || !dl->info.live_table) {
648
		stack;
648
		STACK;
649
		r = 0;
649
		r = 0;
650
		goto out;
650
		goto out;
651
	}
651
	}
Lines 674-680 Link Here
674
		log_very_verbose("Removing %s", dl->name);
674
		log_very_verbose("Removing %s", dl->name);
675
675
676
	if (!(dmt = _setup_task(dl->name, NULL, 0, DM_DEVICE_REMOVE))) {
676
	if (!(dmt = _setup_task(dl->name, NULL, 0, DM_DEVICE_REMOVE))) {
677
		stack;
677
		STACK;
678
		return 0;
678
		return 0;
679
	}
679
	}
680
680
Lines 705-711 Link Here
705
705
706
	log_very_verbose("%s %s", sus ? "Suspending" : "Resuming", name);
706
	log_very_verbose("%s %s", sus ? "Suspending" : "Resuming", name);
707
	if (!(dmt = _setup_task(name, NULL, 0, task))) {
707
	if (!(dmt = _setup_task(name, NULL, 0, task))) {
708
		stack;
708
		STACK;
709
		return 0;
709
		return 0;
710
	}
710
	}
711
711
Lines 723-729 Link Here
723
		return 1;
723
		return 1;
724
724
725
	if (!_suspend_or_resume(dl->name, SUSPEND)) {
725
	if (!_suspend_or_resume(dl->name, SUSPEND)) {
726
		stack;
726
		STACK;
727
		return 0;
727
		return 0;
728
	}
728
	}
729
729
Lines 737-743 Link Here
737
		return 1;
737
		return 1;
738
738
739
	if (!_suspend_or_resume(dl->name, RESUME)) {
739
	if (!_suspend_or_resume(dl->name, RESUME)) {
740
		stack;
740
		STACK;
741
		return 0;
741
		return 0;
742
	}
742
	}
743
743
Lines 858-864 Link Here
858
858
859
	if (!dm_task_add_target(dmt, esize * seg->le, esize * seg->len,
859
	if (!dm_task_add_target(dmt, esize * seg->le, esize * seg->len,
860
				target, params)) {
860
				target, params)) {
861
		stack;
861
		STACK;
862
		return 0;
862
		return 0;
863
	}
863
	}
864
864
Lines 887-893 Link Here
887
		dbg_free(params);
887
		dbg_free(params);
888
888
889
		if (!ret)
889
		if (!ret)
890
			stack;
890
			STACK;
891
891
892
		if (ret >= 0)
892
		if (ret >= 0)
893
			return ret;
893
			return ret;
Lines 902-915 Link Here
902
static int _populate_vanilla(struct dev_manager *dm,
902
static int _populate_vanilla(struct dev_manager *dm,
903
			     struct dm_task *dmt, struct dev_layer *dl)
903
			     struct dm_task *dmt, struct dev_layer *dl)
904
{
904
{
905
	struct list *segh;
905
	struct lvm_list *segh;
906
	struct lv_segment *seg;
906
	struct lv_segment *seg;
907
	struct logical_volume *lv = dl->lv;
907
	struct logical_volume *lv = dl->lv;
908
908
909
	dm->pvmove_mirror_count = 0u;
909
	dm->pvmove_mirror_count = 0u;
910
910
911
	list_iterate(segh, &lv->segments) {
911
	lvm_list_iterate(segh, &lv->segments) {
912
		seg = list_item(segh, struct lv_segment);
912
		seg = lvm_list_item(segh, struct lv_segment);
913
		if (!_emit_target(dm, dmt, seg)) {
913
		if (!_emit_target(dm, dmt, seg)) {
914
			log_error("Unable to build table for '%s'", lv->name);
914
			log_error("Unable to build table for '%s'", lv->name);
915
			return 0;
915
			return 0;
Lines 927-933 Link Here
927
	struct dev_layer *dlr;
927
	struct dev_layer *dlr;
928
928
929
	if (!(real = _build_dlid(dm->mem, dl->lv->lvid.s, "real"))) {
929
	if (!(real = _build_dlid(dm->mem, dl->lv->lvid.s, "real"))) {
930
		stack;
930
		STACK;
931
		return 0;
931
		return 0;
932
	}
932
	}
933
933
Lines 947-953 Link Here
947
		  dl->lv->size, params);
947
		  dl->lv->size, params);
948
	if (!dm_task_add_target(dmt, UINT64_C(0), dl->lv->size,
948
	if (!dm_task_add_target(dmt, UINT64_C(0), dl->lv->size,
949
				"snapshot-origin", params)) {
949
				"snapshot-origin", params)) {
950
		stack;
950
		STACK;
951
		return 0;
951
		return 0;
952
	}
952
	}
953
953
Lines 969-980 Link Here
969
	}
969
	}
970
970
971
	if (!(origin = _build_dlid(dm->mem, s->origin->lvid.s, "real"))) {
971
	if (!(origin = _build_dlid(dm->mem, s->origin->lvid.s, "real"))) {
972
		stack;
972
		STACK;
973
		return 0;
973
		return 0;
974
	}
974
	}
975
975
976
	if (!(cow = _build_dlid(dm->mem, s->cow->lvid.s, "cow"))) {
976
	if (!(cow = _build_dlid(dm->mem, s->cow->lvid.s, "cow"))) {
977
		stack;
977
		STACK;
978
		return 0;
978
		return 0;
979
	}
979
	}
980
980
Lines 1005-1011 Link Here
1005
1005
1006
	if (lvm_snprintf(params, sizeof(params), "%s %s P %d",
1006
	if (lvm_snprintf(params, sizeof(params), "%s %s P %d",
1007
			 devbufo, devbufc, s->chunk_size) == -1) {
1007
			 devbufo, devbufc, s->chunk_size) == -1) {
1008
		stack;
1008
		STACK;
1009
		return 0;
1009
		return 0;
1010
	}
1010
	}
1011
1011
Lines 1013-1019 Link Here
1013
		  s->origin->size, params);
1013
		  s->origin->size, params);
1014
	if (!dm_task_add_target
1014
	if (!dm_task_add_target
1015
	    (dmt, UINT64_C(0), s->origin->size, "snapshot", params)) {
1015
	    (dmt, UINT64_C(0), s->origin->size, "snapshot", params)) {
1016
		stack;
1016
		STACK;
1017
		return 0;
1017
		return 0;
1018
	}
1018
	}
1019
1019
Lines 1030-1041 Link Here
1030
	struct dev_manager *dm;
1030
	struct dev_manager *dm;
1031
1031
1032
	if (!(mem = pool_create(16 * 1024))) {
1032
	if (!(mem = pool_create(16 * 1024))) {
1033
		stack;
1033
		STACK;
1034
		return NULL;
1034
		return NULL;
1035
	}
1035
	}
1036
1036
1037
	if (!(dm = pool_alloc(mem, sizeof(*dm)))) {
1037
	if (!(dm = pool_alloc(mem, sizeof(*dm)))) {
1038
		stack;
1038
		STACK;
1039
		goto bad;
1039
		goto bad;
1040
	}
1040
	}
1041
1041
Lines 1056-1074 Link Here
1056
	dm->mirror_region_size = mirror_region_size;
1056
	dm->mirror_region_size = mirror_region_size;
1057
1057
1058
	if (!(dm->vg_name = pool_strdup(dm->mem, vg_name))) {
1058
	if (!(dm->vg_name = pool_strdup(dm->mem, vg_name))) {
1059
		stack;
1059
		STACK;
1060
		goto bad;
1060
		goto bad;
1061
	}
1061
	}
1062
1062
1063
	if (!(dm->layers = hash_create(32))) {
1063
	if (!(dm->layers = hash_create(32))) {
1064
		stack;
1064
		STACK;
1065
		goto bad;
1065
		goto bad;
1066
	}
1066
	}
1067
1067
1068
	list_init(&dm->active_list);
1068
	lvm_list_init(&dm->active_list);
1069
	list_init(&dm->reload_list);
1069
	lvm_list_init(&dm->reload_list);
1070
	list_init(&dm->remove_list);
1070
	lvm_list_init(&dm->remove_list);
1071
	list_init(&dm->suspend_list);
1071
	lvm_list_init(&dm->suspend_list);
1072
1072
1073
	return dm;
1073
	return dm;
1074
1074
Lines 1092-1098 Link Here
1092
	 * Build a name for the top layer.
1092
	 * Build a name for the top layer.
1093
	 */
1093
	 */
1094
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1094
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1095
		stack;
1095
		STACK;
1096
		return 0;
1096
		return 0;
1097
	}
1097
	}
1098
1098
Lines 1101-1107 Link Here
1101
	 */
1101
	 */
1102
	log_debug("Getting device info for %s", name);
1102
	log_debug("Getting device info for %s", name);
1103
	if (!_info(name, lv->lvid.s, mknodes, info, NULL, NULL)) {
1103
	if (!_info(name, lv->lvid.s, mknodes, info, NULL, NULL)) {
1104
		stack;
1104
		STACK;
1105
		return 0;
1105
		return 0;
1106
	}
1106
	}
1107
1107
Lines 1117-1123 Link Here
1117
	 * Build a name for the top layer.
1117
	 * Build a name for the top layer.
1118
	 */
1118
	 */
1119
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1119
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1120
		stack;
1120
		STACK;
1121
		return 0;
1121
		return 0;
1122
	}
1122
	}
1123
1123
Lines 1127-1133 Link Here
1127
	log_debug("Getting device status percentage for %s", name);
1127
	log_debug("Getting device status percentage for %s", name);
1128
	if (!(_percent(dm, name, lv->lvid.s, "snapshot", 0, NULL, percent,
1128
	if (!(_percent(dm, name, lv->lvid.s, "snapshot", 0, NULL, percent,
1129
		       NULL))) {
1129
		       NULL))) {
1130
		stack;
1130
		STACK;
1131
		return 0;
1131
		return 0;
1132
	}
1132
	}
1133
1133
Lines 1149-1155 Link Here
1149
	 * Build a name for the top layer.
1149
	 * Build a name for the top layer.
1150
	 */
1150
	 */
1151
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1151
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, NULL))) {
1152
		stack;
1152
		STACK;
1153
		return 0;
1153
		return 0;
1154
	}
1154
	}
1155
1155
Lines 1158-1164 Link Here
1158
	log_debug("Getting device mirror status percentage for %s", name);
1158
	log_debug("Getting device mirror status percentage for %s", name);
1159
	if (!(_percent(dm, name, lv->lvid.s, "mirror", wait, lv, percent,
1159
	if (!(_percent(dm, name, lv->lvid.s, "mirror", wait, lv, percent,
1160
		       event_nr))) {
1160
		       event_nr))) {
1161
		stack;
1161
		STACK;
1162
		return 0;
1162
		return 0;
1163
	}
1163
	}
1164
1164
Lines 1172-1178 Link Here
1172
	char *uuid;
1172
	char *uuid;
1173
1173
1174
	if (!(dl = pool_zalloc(dm->mem, sizeof(*dl)))) {
1174
	if (!(dl = pool_zalloc(dm->mem, sizeof(*dl)))) {
1175
		stack;
1175
		STACK;
1176
		return NULL;
1176
		return NULL;
1177
	}
1177
	}
1178
1178
Lines 1180-1186 Link Here
1180
1180
1181
	log_debug("Getting device info for %s", dl->name);
1181
	log_debug("Getting device info for %s", dl->name);
1182
	if (!_info(dl->name, dlid, 0, &dl->info, dm->mem, &uuid)) {
1182
	if (!_info(dl->name, dlid, 0, &dl->info, dm->mem, &uuid)) {
1183
		stack;
1183
		STACK;
1184
		return NULL;
1184
		return NULL;
1185
	}
1185
	}
1186
1186
Lines 1189-1199 Link Here
1189
	else
1189
	else
1190
		dl->dlid = dlid;
1190
		dl->dlid = dlid;
1191
1191
1192
	list_init(&dl->pre_create);
1192
	lvm_list_init(&dl->pre_create);
1193
	list_init(&dl->pre_suspend);
1193
	lvm_list_init(&dl->pre_suspend);
1194
1194
1195
	if (!hash_insert(dm->layers, dl->dlid, dl)) {
1195
	if (!hash_insert(dm->layers, dl->dlid, dl)) {
1196
		stack;
1196
		STACK;
1197
		return NULL;
1197
		return NULL;
1198
	}
1198
	}
1199
1199
Lines 1213-1230 Link Here
1213
	struct dev_layer *dl;
1213
	struct dev_layer *dl;
1214
1214
1215
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, layer))) {
1215
	if (!(name = _build_name(dm->mem, lv->vg->name, lv->name, layer))) {
1216
		stack;
1216
		STACK;
1217
		return NULL;
1217
		return NULL;
1218
	}
1218
	}
1219
1219
1220
	if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, layer))) {
1220
	if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, layer))) {
1221
		stack;
1221
		STACK;
1222
		return NULL;
1222
		return NULL;
1223
	}
1223
	}
1224
1224
1225
	if (!(dl = hash_lookup(dm->layers, dlid)) &&
1225
	if (!(dl = hash_lookup(dm->layers, dlid)) &&
1226
	    !(dl = _create_dev(dm, name, dlid))) {
1226
	    !(dl = _create_dev(dm, name, dlid))) {
1227
		stack;
1227
		STACK;
1228
		return NULL;
1228
		return NULL;
1229
	}
1229
	}
1230
1230
Lines 1246-1252 Link Here
1246
	struct dev_layer *dl;
1246
	struct dev_layer *dl;
1247
1247
1248
	if (!(dlid = _build_dlid(dm->mem, lvid, layer))) {
1248
	if (!(dlid = _build_dlid(dm->mem, lvid, layer))) {
1249
		stack;
1249
		STACK;
1250
		return NULL;
1250
		return NULL;
1251
	}
1251
	}
1252
1252
Lines 1262-1273 Link Here
1262
	 * only one layer.
1262
	 * only one layer.
1263
	 */
1263
	 */
1264
	struct dev_layer *dl, *dlr;
1264
	struct dev_layer *dl, *dlr;
1265
	struct list *segh;
1265
	struct lvm_list *segh;
1266
	struct lv_segment *seg;
1266
	struct lv_segment *seg;
1267
	uint32_t s;
1267
	uint32_t s;
1268
1268
1269
	if (!(dl = _create_layer(dm, NULL, lv))) {
1269
	if (!(dl = _create_layer(dm, NULL, lv))) {
1270
		stack;
1270
		STACK;
1271
		return 0;
1271
		return 0;
1272
	}
1272
	}
1273
	dl->populate = _populate_vanilla;
1273
	dl->populate = _populate_vanilla;
Lines 1280-1287 Link Here
1280
		_set_flag(dl, TOPLEVEL);
1280
		_set_flag(dl, TOPLEVEL);
1281
1281
1282
	/* Add dependencies for any LVs that segments refer to */
1282
	/* Add dependencies for any LVs that segments refer to */
1283
	list_iterate(segh, &lv->segments) {
1283
	lvm_list_iterate(segh, &lv->segments) {
1284
		seg = list_item(segh, struct lv_segment);
1284
		seg = lvm_list_item(segh, struct lv_segment);
1285
		if (seg->type != SEG_STRIPED && seg->type != SEG_MIRRORED)
1285
		if (seg->type != SEG_STRIPED && seg->type != SEG_MIRRORED)
1286
			continue;
1286
			continue;
1287
		for (s = 0; s < seg->area_count; s++) {
1287
		for (s = 0; s < seg->area_count; s++) {
Lines 1291-1297 Link Here
1291
					  _build_dlid(dm->mem,
1291
					  _build_dlid(dm->mem,
1292
						      seg->area[s].u.lv.
1292
						      seg->area[s].u.lv.
1293
						      lv->lvid.s, NULL))) {
1293
						      lv->lvid.s, NULL))) {
1294
				stack;
1294
				STACK;
1295
				return 0;
1295
				return 0;
1296
			}
1296
			}
1297
			_set_flag(dl, NOPROPAGATE);
1297
			_set_flag(dl, NOPROPAGATE);
Lines 1303-1309 Link Here
1303
1303
1304
	/* Deactivating the last snapshot */
1304
	/* Deactivating the last snapshot */
1305
	if (!(dlr = _create_layer(dm, "real", lv))) {
1305
	if (!(dlr = _create_layer(dm, "real", lv))) {
1306
		stack;
1306
		STACK;
1307
		return 0;
1307
		return 0;
1308
	}
1308
	}
1309
1309
Lines 1315-1321 Link Here
1315
	/* add the dependency on the real device */
1315
	/* add the dependency on the real device */
1316
	if (!str_list_add(dm->mem, &dl->pre_create,
1316
	if (!str_list_add(dm->mem, &dl->pre_create,
1317
			  pool_strdup(dm->mem, dlr->dlid))) {
1317
			  pool_strdup(dm->mem, dlr->dlid))) {
1318
		stack;
1318
		STACK;
1319
		return 0;
1319
		return 0;
1320
	}
1320
	}
1321
1321
Lines 1329-1335 Link Here
1329
	const char *real_dlid;
1329
	const char *real_dlid;
1330
1330
1331
	if (!(dl = _create_layer(dm, "real", lv))) {
1331
	if (!(dl = _create_layer(dm, "real", lv))) {
1332
		stack;
1332
		STACK;
1333
		return 0;
1333
		return 0;
1334
	}
1334
	}
1335
	dl->populate = _populate_vanilla;
1335
	dl->populate = _populate_vanilla;
Lines 1339-1345 Link Here
1339
	real_dlid = dl->dlid;
1339
	real_dlid = dl->dlid;
1340
1340
1341
	if (!(dl = _create_layer(dm, NULL, lv))) {
1341
	if (!(dl = _create_layer(dm, NULL, lv))) {
1342
		stack;
1342
		STACK;
1343
		return 0;
1343
		return 0;
1344
	}
1344
	}
1345
	dl->populate = _populate_origin;
1345
	dl->populate = _populate_origin;
Lines 1349-1355 Link Here
1349
	/* add the dependency on the real device */
1349
	/* add the dependency on the real device */
1350
	if (!str_list_add(dm->mem, &dl->pre_create,
1350
	if (!str_list_add(dm->mem, &dl->pre_create,
1351
			  pool_strdup(dm->mem, real_dlid))) {
1351
			  pool_strdup(dm->mem, real_dlid))) {
1352
		stack;
1352
		STACK;
1353
		return 0;
1353
		return 0;
1354
	}
1354
	}
1355
1355
Lines 1360-1373 Link Here
1360
{
1360
{
1361
	struct logical_volume *active;
1361
	struct logical_volume *active;
1362
	struct snapshot *s;
1362
	struct snapshot *s;
1363
	struct list *sh;
1363
	struct lvm_list *sh;
1364
1364
1365
	/*
1365
	/*
1366
	 * We only need to create an origin layer if one of our
1366
	 * We only need to create an origin layer if one of our
1367
	 * snapshots is in the active list
1367
	 * snapshots is in the active list
1368
	 */
1368
	 */
1369
	list_iterate(sh, &dm->active_list) {
1369
	lvm_list_iterate(sh, &dm->active_list) {
1370
		active = list_item(sh, struct lv_list)->lv;
1370
		active = lvm_list_item(sh, struct lv_list)->lv;
1371
		if ((s = find_cow(active)) && (s->origin == lv))
1371
		if ((s = find_cow(active)) && (s->origin == lv))
1372
			return _expand_origin_real(dm, lv);
1372
			return _expand_origin_real(dm, lv);
1373
	}
1373
	}
Lines 1389-1395 Link Here
1389
	const char *cow_dlid;
1389
	const char *cow_dlid;
1390
1390
1391
	if (!(dl = _create_layer(dm, "cow", lv))) {
1391
	if (!(dl = _create_layer(dm, "cow", lv))) {
1392
		stack;
1392
		STACK;
1393
		return 0;
1393
		return 0;
1394
	}
1394
	}
1395
	dl->populate = _populate_vanilla;
1395
	dl->populate = _populate_vanilla;
Lines 1400-1406 Link Here
1400
	cow_dlid = dl->dlid;
1400
	cow_dlid = dl->dlid;
1401
1401
1402
	if (!(dl = _create_layer(dm, NULL, lv))) {
1402
	if (!(dl = _create_layer(dm, NULL, lv))) {
1403
		stack;
1403
		STACK;
1404
		return 0;
1404
		return 0;
1405
	}
1405
	}
1406
	dl->populate = _populate_snapshot;
1406
	dl->populate = _populate_snapshot;
Lines 1410-1429 Link Here
1410
	/* add the dependency on the cow device */
1410
	/* add the dependency on the cow device */
1411
	if (!str_list_add(dm->mem, &dl->pre_create,
1411
	if (!str_list_add(dm->mem, &dl->pre_create,
1412
			  pool_strdup(dm->mem, cow_dlid))) {
1412
			  pool_strdup(dm->mem, cow_dlid))) {
1413
		stack;
1413
		STACK;
1414
		return 0;
1414
		return 0;
1415
	}
1415
	}
1416
1416
1417
	/* add the dependency on the real origin device */
1417
	/* add the dependency on the real origin device */
1418
	if (!str_list_add(dm->mem, &dl->pre_create,
1418
	if (!str_list_add(dm->mem, &dl->pre_create,
1419
			  _build_dlid(dm->mem, s->origin->lvid.s, "real"))) {
1419
			  _build_dlid(dm->mem, s->origin->lvid.s, "real"))) {
1420
		stack;
1420
		STACK;
1421
		return 0;
1421
		return 0;
1422
	}
1422
	}
1423
1423
1424
	/* add the dependency on the visible origin device */
1424
	/* add the dependency on the visible origin device */
1425
	if (!str_list_add(dm->mem, &dl->pre_suspend, s->origin->lvid.s)) {
1425
	if (!str_list_add(dm->mem, &dl->pre_suspend, s->origin->lvid.s)) {
1426
		stack;
1426
		STACK;
1427
		return 0;
1427
		return 0;
1428
	}
1428
	}
1429
1429
Lines 1469-1480 Link Here
1469
static int _trace_layer_marks(struct dev_manager *dm, struct dev_layer *dl,
1469
static int _trace_layer_marks(struct dev_manager *dm, struct dev_layer *dl,
1470
			      int flag)
1470
			      int flag)
1471
{
1471
{
1472
	struct list *sh;
1472
	struct lvm_list *sh;
1473
	const char *dlid;
1473
	const char *dlid;
1474
	struct dev_layer *dep;
1474
	struct dev_layer *dep;
1475
1475
1476
	list_iterate(sh, &dl->pre_create) {
1476
	lvm_list_iterate(sh, &dl->pre_create) {
1477
		dlid = list_item(sh, struct str_list)->str;
1477
		dlid = lvm_list_item(sh, struct str_list)->str;
1478
1478
1479
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1479
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1480
			log_error("Couldn't find device layer '%s'.", dlid);
1480
			log_error("Couldn't find device layer '%s'.", dlid);
Lines 1491-1497 Link Here
1491
		_set_flag(dep, flag);
1491
		_set_flag(dep, flag);
1492
1492
1493
		if (!_trace_layer_marks(dm, dep, flag)) {
1493
		if (!_trace_layer_marks(dm, dep, flag)) {
1494
			stack;
1494
			STACK;
1495
			return 0;
1495
			return 0;
1496
		}
1496
		}
1497
	}
1497
	}
Lines 1510-1516 Link Here
1510
	hash_iterate(hn, dm->layers) {
1510
	hash_iterate(hn, dm->layers) {
1511
		dl = hash_get_data(dm->layers, hn);
1511
		dl = hash_get_data(dm->layers, hn);
1512
		if (_get_flag(dl, flag) && !_trace_layer_marks(dm, dl, flag)) {
1512
		if (_get_flag(dl, flag) && !_trace_layer_marks(dm, dl, flag)) {
1513
			stack;
1513
			STACK;
1514
			return 0;
1514
			return 0;
1515
		}
1515
		}
1516
	}
1516
	}
Lines 1522-1538 Link Here
1522
 * Marks the top layers, then traces these through the
1522
 * Marks the top layers, then traces these through the
1523
 * dependencies.
1523
 * dependencies.
1524
 */
1524
 */
1525
static int _mark_lvs(struct dev_manager *dm, struct list *lvs, int flag)
1525
static int _mark_lvs(struct dev_manager *dm, struct lvm_list *lvs, int flag)
1526
{
1526
{
1527
	struct list *lvh;
1527
	struct lvm_list *lvh;
1528
	struct logical_volume *lv;
1528
	struct logical_volume *lv;
1529
	struct dev_layer *dl;
1529
	struct dev_layer *dl;
1530
1530
1531
	list_iterate(lvh, lvs) {
1531
	lvm_list_iterate(lvh, lvs) {
1532
		lv = list_item(lvh, struct lv_list)->lv;
1532
		lv = lvm_list_item(lvh, struct lv_list)->lv;
1533
1533
1534
		if (!(dl = _lookup(dm, lv->lvid.s, NULL))) {
1534
		if (!(dl = _lookup(dm, lv->lvid.s, NULL))) {
1535
			stack;
1535
			STACK;
1536
			return 0;
1536
			return 0;
1537
		}
1537
		}
1538
1538
Lines 1540-1546 Link Here
1540
	}
1540
	}
1541
1541
1542
	if (!_trace_all_marks(dm, flag)) {
1542
	if (!_trace_all_marks(dm, flag)) {
1543
		stack;
1543
		STACK;
1544
		return 0;
1544
		return 0;
1545
	}
1545
	}
1546
1546
Lines 1549-1560 Link Here
1549
1549
1550
static int _suspend_parents(struct dev_manager *dm, struct dev_layer *dl)
1550
static int _suspend_parents(struct dev_manager *dm, struct dev_layer *dl)
1551
{
1551
{
1552
	struct list *sh;
1552
	struct lvm_list *sh;
1553
	struct dev_layer *dep;
1553
	struct dev_layer *dep;
1554
	const char *dlid;
1554
	const char *dlid;
1555
1555
1556
	list_iterate(sh, &dl->pre_suspend) {
1556
	lvm_list_iterate(sh, &dl->pre_suspend) {
1557
		dlid = list_item(sh, struct str_list)->str;
1557
		dlid = lvm_list_item(sh, struct str_list)->str;
1558
1558
1559
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1559
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1560
			log_debug("_suspend_parents couldn't find device "
1560
			log_debug("_suspend_parents couldn't find device "
Lines 1568-1579 Link Here
1568
		}
1568
		}
1569
1569
1570
		if (!_suspend_parents(dm, dep)) {
1570
		if (!_suspend_parents(dm, dep)) {
1571
			stack;
1571
			STACK;
1572
			return 0;
1572
			return 0;
1573
		}
1573
		}
1574
1574
1575
		if (dep->info.exists & !_suspend(dep)) {
1575
		if (dep->info.exists & !_suspend(dep)) {
1576
			stack;
1576
			STACK;
1577
			return 0;
1577
			return 0;
1578
		}
1578
		}
1579
	}
1579
	}
Lines 1583-1594 Link Here
1583
1583
1584
static int _resume_with_deps(struct dev_manager *dm, struct dev_layer *dl)
1584
static int _resume_with_deps(struct dev_manager *dm, struct dev_layer *dl)
1585
{
1585
{
1586
	struct list *sh;
1586
	struct lvm_list *sh;
1587
	struct dev_layer *dep;
1587
	struct dev_layer *dep;
1588
	const char *dlid;
1588
	const char *dlid;
1589
1589
1590
	list_iterate(sh, &dl->pre_create) {
1590
	lvm_list_iterate(sh, &dl->pre_create) {
1591
		dlid = list_item(sh, struct str_list)->str;
1591
		dlid = lvm_list_item(sh, struct str_list)->str;
1592
1592
1593
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1593
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1594
			log_debug("_resume_with_deps couldn't find device "
1594
			log_debug("_resume_with_deps couldn't find device "
Lines 1602-1614 Link Here
1602
		}
1602
		}
1603
1603
1604
		if (!_resume_with_deps(dm, dep)) {
1604
		if (!_resume_with_deps(dm, dep)) {
1605
			stack;
1605
			STACK;
1606
			return 0;
1606
			return 0;
1607
		}
1607
		}
1608
	}
1608
	}
1609
1609
1610
	if (dl->info.exists & !_get_flag(dl, SUSPENDED) && !_resume(dl)) {
1610
	if (dl->info.exists & !_get_flag(dl, SUSPENDED) && !_resume(dl)) {
1611
		stack;
1611
		STACK;
1612
		return 0;
1612
		return 0;
1613
	}
1613
	}
1614
1614
Lines 1621-1627 Link Here
1621
 */
1621
 */
1622
static int _create_rec(struct dev_manager *dm, struct dev_layer *dl)
1622
static int _create_rec(struct dev_manager *dm, struct dev_layer *dl)
1623
{
1623
{
1624
	struct list *sh;
1624
	struct lvm_list *sh;
1625
	struct dev_layer *dep;
1625
	struct dev_layer *dep;
1626
	const char *dlid;
1626
	const char *dlid;
1627
	char *newname, *suffix;
1627
	char *newname, *suffix;
Lines 1629-1640 Link Here
1629
	/* Suspend? */
1629
	/* Suspend? */
1630
	if (_get_flag(dl, SUSPENDED) &&
1630
	if (_get_flag(dl, SUSPENDED) &&
1631
	    (!_suspend_parents(dm, dl) || !_suspend(dl))) {
1631
	    (!_suspend_parents(dm, dl) || !_suspend(dl))) {
1632
		stack;
1632
		STACK;
1633
		return 0;
1633
		return 0;
1634
	}
1634
	}
1635
1635
1636
	list_iterate(sh, &dl->pre_create) {
1636
	lvm_list_iterate(sh, &dl->pre_create) {
1637
		dlid = list_item(sh, struct str_list)->str;
1637
		dlid = lvm_list_item(sh, struct str_list)->str;
1638
1638
1639
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1639
		if (!(dep = hash_lookup(dm->layers, dlid))) {
1640
			log_error("Couldn't find device layer '%s'.", dlid);
1640
			log_error("Couldn't find device layer '%s'.", dlid);
Lines 1647-1653 Link Here
1647
		}
1647
		}
1648
1648
1649
		if (!_create_rec(dm, dep)) {
1649
		if (!_create_rec(dm, dep)) {
1650
			stack;
1650
			STACK;
1651
			return 0;
1651
			return 0;
1652
		}
1652
		}
1653
	}
1653
	}
Lines 1661-1667 Link Here
1661
		if (strcmp(newname, dl->name)) {
1661
		if (strcmp(newname, dl->name)) {
1662
			if (!_suspend_parents(dm, dl) ||
1662
			if (!_suspend_parents(dm, dl) ||
1663
			    !_suspend(dl) || !_rename(dl, newname)) {
1663
			    !_suspend(dl) || !_rename(dl, newname)) {
1664
				stack;
1664
				STACK;
1665
				return 0;
1665
				return 0;
1666
			}
1666
			}
1667
		}
1667
		}
Lines 1671-1677 Link Here
1671
	if (!dl->info.exists) {
1671
	if (!dl->info.exists) {
1672
		if (!_suspend_parents(dm, dl) ||
1672
		if (!_suspend_parents(dm, dl) ||
1673
		    !_load(dm, dl, DM_DEVICE_CREATE)) {
1673
		    !_load(dm, dl, DM_DEVICE_CREATE)) {
1674
			stack;
1674
			STACK;
1675
			return 0;
1675
			return 0;
1676
		}
1676
		}
1677
		return 1;
1677
		return 1;
Lines 1681-1687 Link Here
1681
	if (_get_flag(dl, RELOAD) &&
1681
	if (_get_flag(dl, RELOAD) &&
1682
	    (!_suspend_parents(dm, dl) || !_suspend(dl) ||
1682
	    (!_suspend_parents(dm, dl) || !_suspend(dl) ||
1683
	     !_load(dm, dl, DM_DEVICE_RELOAD))) {
1683
	     !_load(dm, dl, DM_DEVICE_RELOAD))) {
1684
		stack;
1684
		STACK;
1685
		return 0;
1685
		return 0;
1686
	}
1686
	}
1687
1687
Lines 1691-1706 Link Here
1691
1691
1692
static int _build_all_layers(struct dev_manager *dm, struct volume_group *vg)
1692
static int _build_all_layers(struct dev_manager *dm, struct volume_group *vg)
1693
{
1693
{
1694
	struct list *lvh;
1694
	struct lvm_list *lvh;
1695
	struct logical_volume *lvt;
1695
	struct logical_volume *lvt;
1696
1696
1697
	/*
1697
	/*
1698
	 * Build layers for complete vg.
1698
	 * Build layers for complete vg.
1699
	 */
1699
	 */
1700
	list_iterate(lvh, &vg->lvs) {
1700
	lvm_list_iterate(lvh, &vg->lvs) {
1701
		lvt = list_item(lvh, struct lv_list)->lv;
1701
		lvt = lvm_list_item(lvh, struct lv_list)->lv;
1702
		if (!_expand_lv(dm, lvt)) {
1702
		if (!_expand_lv(dm, lvt)) {
1703
			stack;
1703
			STACK;
1704
			return 0;
1704
			return 0;
1705
		}
1705
		}
1706
	}
1706
	}
Lines 1723-1734 Link Here
1723
		if (!_get_flag(dl, ACTIVE)) {
1723
		if (!_get_flag(dl, ACTIVE)) {
1724
			dll = pool_alloc(dm->mem, sizeof(*dll));
1724
			dll = pool_alloc(dm->mem, sizeof(*dll));
1725
			if (!dll) {
1725
			if (!dll) {
1726
				stack;
1726
				STACK;
1727
				return 0;
1727
				return 0;
1728
			}
1728
			}
1729
1729
1730
			dll->dl = dl;
1730
			dll->dl = dl;
1731
			list_add(&dm->remove_list, &dll->list);
1731
			lvm_list_add(&dm->remove_list, &dll->list);
1732
		}
1732
		}
1733
	}
1733
	}
1734
1734
Lines 1739-1753 Link Here
1739
{
1739
{
1740
	struct hash_node *hn;
1740
	struct hash_node *hn;
1741
	struct dev_layer *dl;
1741
	struct dev_layer *dl;
1742
	struct list *sh;
1742
	struct lvm_list *sh;
1743
	const char *dlid;
1743
	const char *dlid;
1744
	struct dev_layer *dep;
1744
	struct dev_layer *dep;
1745
1745
1746
	hash_iterate(hn, dm->layers) {
1746
	hash_iterate(hn, dm->layers) {
1747
		dl = hash_get_data(dm->layers, hn);
1747
		dl = hash_get_data(dm->layers, hn);
1748
1748
1749
		list_iterate(sh, &dl->pre_suspend) {
1749
		lvm_list_iterate(sh, &dl->pre_suspend) {
1750
			dlid = list_item(sh, struct str_list)->str;
1750
			dlid = lvm_list_item(sh, struct str_list)->str;
1751
1751
1752
			if (!(dep = hash_lookup(dm->layers, dlid))) {
1752
			if (!(dep = hash_lookup(dm->layers, dlid))) {
1753
				log_debug("_populate_pre_suspend_lists: "
1753
				log_debug("_populate_pre_suspend_lists: "
Lines 1758-1770 Link Here
1758
1758
1759
			if (!str_list_add(dm->mem, &dep->pre_create,
1759
			if (!str_list_add(dm->mem, &dep->pre_create,
1760
					  dl->dlid)) {
1760
					  dl->dlid)) {
1761
				stack;
1761
				STACK;
1762
				return 0;
1762
				return 0;
1763
			}
1763
			}
1764
		}
1764
		}
1765
1765
1766
		list_iterate(sh, &dl->pre_create) {
1766
		lvm_list_iterate(sh, &dl->pre_create) {
1767
			dlid = list_item(sh, struct str_list)->str;
1767
			dlid = lvm_list_item(sh, struct str_list)->str;
1768
1768
1769
			if (!(dep = hash_lookup(dm->layers, dlid))) {
1769
			if (!(dep = hash_lookup(dm->layers, dlid))) {
1770
				log_debug("_populate_pre_suspend_lists: "
1770
				log_debug("_populate_pre_suspend_lists: "
Lines 1775-1781 Link Here
1775
1775
1776
			if (!str_list_add(dm->mem, &dep->pre_suspend,
1776
			if (!str_list_add(dm->mem, &dep->pre_suspend,
1777
					  dl->dlid)) {
1777
					  dl->dlid)) {
1778
				stack;
1778
				STACK;
1779
				return 0;
1779
				return 0;
1780
			}
1780
			}
1781
		}
1781
		}
Lines 1790-1819 Link Here
1790
static int _remove_old_layers(struct dev_manager *dm)
1790
static int _remove_old_layers(struct dev_manager *dm)
1791
{
1791
{
1792
	int change;
1792
	int change;
1793
	struct list *rh, *n;
1793
	struct lvm_list *rh, *n;
1794
	struct dev_layer *dl;
1794
	struct dev_layer *dl;
1795
1795
1796
	do {
1796
	do {
1797
		change = 0;
1797
		change = 0;
1798
		list_iterate_safe(rh, n, &dm->remove_list) {
1798
		lvm_list_iterate_safe(rh, n, &dm->remove_list) {
1799
			dl = list_item(rh, struct dl_list)->dl;
1799
			dl = lvm_list_item(rh, struct dl_list)->dl;
1800
1800
1801
			if (!dl->info.exists) {
1801
			if (!dl->info.exists) {
1802
				list_del(rh);
1802
				lvm_list_del(rh);
1803
				continue;
1803
				continue;
1804
			}
1804
			}
1805
1805
1806
			if (_remove(dl)) {
1806
			if (_remove(dl)) {
1807
				change = 1;
1807
				change = 1;
1808
				list_del(rh);
1808
				lvm_list_del(rh);
1809
			}
1809
			}
1810
		}
1810
		}
1811
1811
1812
	} while (change);
1812
	} while (change);
1813
1813
1814
	if (!list_empty(&dm->remove_list)) {
1814
	if (!lvm_list_empty(&dm->remove_list)) {
1815
		list_iterate(rh, &dm->remove_list) {
1815
		lvm_list_iterate(rh, &dm->remove_list) {
1816
			dl = list_item(rh, struct dl_list)->dl;
1816
			dl = lvm_list_item(rh, struct dl_list)->dl;
1817
			log_error("Couldn't deactivate device %s", dl->name);
1817
			log_error("Couldn't deactivate device %s", dl->name);
1818
		}
1818
		}
1819
		return 0;
1819
		return 0;
Lines 1833-1839 Link Here
1833
	struct dev_layer *dl;
1833
	struct dev_layer *dl;
1834
1834
1835
	if (!_build_all_layers(dm, vg)) {
1835
	if (!_build_all_layers(dm, vg)) {
1836
		stack;
1836
		STACK;
1837
		return 0;
1837
		return 0;
1838
	}
1838
	}
1839
1839
Lines 1842-1848 Link Here
1842
	 */
1842
	 */
1843
	_clear_marks(dm, RELOAD);
1843
	_clear_marks(dm, RELOAD);
1844
	if (!_mark_lvs(dm, &dm->reload_list, RELOAD)) {
1844
	if (!_mark_lvs(dm, &dm->reload_list, RELOAD)) {
1845
		stack;
1845
		STACK;
1846
		return 0;
1846
		return 0;
1847
	}
1847
	}
1848
1848
Lines 1851-1857 Link Here
1851
	 */
1851
	 */
1852
	_clear_marks(dm, ACTIVE);
1852
	_clear_marks(dm, ACTIVE);
1853
	if (!_mark_lvs(dm, &dm->active_list, ACTIVE)) {
1853
	if (!_mark_lvs(dm, &dm->active_list, ACTIVE)) {
1854
		stack;
1854
		STACK;
1855
		return 0;
1855
		return 0;
1856
	}
1856
	}
1857
1857
Lines 1860-1876 Link Here
1860
	 */
1860
	 */
1861
	_clear_marks(dm, SUSPENDED);
1861
	_clear_marks(dm, SUSPENDED);
1862
	if (!_mark_lvs(dm, &dm->suspend_list, SUSPENDED)) {
1862
	if (!_mark_lvs(dm, &dm->suspend_list, SUSPENDED)) {
1863
		stack;
1863
		STACK;
1864
		return 0;
1864
		return 0;
1865
	}
1865
	}
1866
1866
1867
	if (!_fill_in_remove_list(dm)) {
1867
	if (!_fill_in_remove_list(dm)) {
1868
		stack;
1868
		STACK;
1869
		return 0;
1869
		return 0;
1870
	}
1870
	}
1871
1871
1872
	if (!_populate_pre_suspend_lists(dm)) {
1872
	if (!_populate_pre_suspend_lists(dm)) {
1873
		stack;
1873
		STACK;
1874
		return 0;
1874
		return 0;
1875
	}
1875
	}
1876
1876
Lines 1882-1888 Link Here
1882
1882
1883
		if (_get_flag(dl, ACTIVE) && _get_flag(dl, TOPLEVEL))
1883
		if (_get_flag(dl, ACTIVE) && _get_flag(dl, TOPLEVEL))
1884
			if (!_create_rec(dm, dl)) {
1884
			if (!_create_rec(dm, dl)) {
1885
				stack;
1885
				STACK;
1886
				return 0;
1886
				return 0;
1887
			}
1887
			}
1888
	}
1888
	}
Lines 1892-1904 Link Here
1892
		dl = hash_get_data(dm->layers, hn);
1892
		dl = hash_get_data(dm->layers, hn);
1893
1893
1894
		if (!_resume_with_deps(dm, dl)) {
1894
		if (!_resume_with_deps(dm, dl)) {
1895
			stack;
1895
			STACK;
1896
			return 0;
1896
			return 0;
1897
		}
1897
		}
1898
	}
1898
	}
1899
1899
1900
	if (!_remove_old_layers(dm)) {
1900
	if (!_remove_old_layers(dm)) {
1901
		stack;
1901
		STACK;
1902
		return 0;
1902
		return 0;
1903
	}
1903
	}
1904
1904
Lines 1934-1945 Link Here
1934
	log_debug("Found existing layer '%s'", name);
1934
	log_debug("Found existing layer '%s'", name);
1935
1935
1936
	if (!(copy = pool_strdup(dm->mem, name))) {
1936
	if (!(copy = pool_strdup(dm->mem, name))) {
1937
		stack;
1937
		STACK;
1938
		return 0;
1938
		return 0;
1939
	}
1939
	}
1940
1940
1941
	if (!(dl = _create_dev(dm, copy, ""))) {
1941
	if (!(dl = _create_dev(dm, copy, ""))) {
1942
		stack;
1942
		STACK;
1943
		return 0;
1943
		return 0;
1944
	}
1944
	}
1945
1945
Lines 1971-1977 Link Here
1971
		names = (void *) names + next;
1971
		names = (void *) names + next;
1972
		if (_belong_to_vg(dm->vg_name, names->name) &&
1972
		if (_belong_to_vg(dm->vg_name, names->name) &&
1973
		    !_add_existing_layer(dm, names->name)) {
1973
		    !_add_existing_layer(dm, names->name)) {
1974
			stack;
1974
			STACK;
1975
			r = 0;
1975
			r = 0;
1976
			break;
1976
			break;
1977
		}
1977
		}
Lines 1984-2013 Link Here
1984
}
1984
}
1985
1985
1986
static int _add_lv(struct pool *mem,
1986
static int _add_lv(struct pool *mem,
1987
		   struct list *head, struct logical_volume *lv)
1987
		   struct lvm_list *head, struct logical_volume *lv)
1988
{
1988
{
1989
	struct lv_list *lvl;
1989
	struct lv_list *lvl;
1990
1990
1991
	if (!(lvl = pool_alloc(mem, sizeof(*lvl)))) {
1991
	if (!(lvl = pool_alloc(mem, sizeof(*lvl)))) {
1992
		stack;
1992
		STACK;
1993
		return 0;
1993
		return 0;
1994
	}
1994
	}
1995
1995
1996
	lvl->lv = lv;
1996
	lvl->lv = lv;
1997
	list_add(head, &lvl->list);
1997
	lvm_list_add(head, &lvl->list);
1998
1998
1999
	return 1;
1999
	return 1;
2000
}
2000
}
2001
2001
2002
static int _add_lvs(struct pool *mem,
2002
static int _add_lvs(struct pool *mem,
2003
		    struct list *head, struct logical_volume *origin)
2003
		    struct lvm_list *head, struct logical_volume *origin)
2004
{
2004
{
2005
	struct logical_volume *lv;
2005
	struct logical_volume *lv;
2006
	struct snapshot *s;
2006
	struct snapshot *s;
2007
	struct list *lvh;
2007
	struct lvm_list *lvh;
2008
2008
2009
	list_iterate(lvh, &origin->vg->lvs) {
2009
	lvm_list_iterate(lvh, &origin->vg->lvs) {
2010
		lv = list_item(lvh, struct lv_list)->lv;
2010
		lv = lvm_list_item(lvh, struct lv_list)->lv;
2011
		if ((s = find_cow(lv)) && s->origin == origin)
2011
		if ((s = find_cow(lv)) && s->origin == origin)
2012
			if (!_add_lv(mem, head, lv))
2012
			if (!_add_lv(mem, head, lv))
2013
				return 0;
2013
				return 0;
Lines 2016-2030 Link Here
2016
	return _add_lv(mem, head, origin);
2016
	return _add_lv(mem, head, origin);
2017
}
2017
}
2018
2018
2019
static void _remove_lv(struct list *head, struct logical_volume *lv)
2019
static void _remove_lv(struct lvm_list *head, struct logical_volume *lv)
2020
{
2020
{
2021
	struct list *lvh;
2021
	struct lvm_list *lvh;
2022
	struct lv_list *lvl;
2022
	struct lv_list *lvl;
2023
2023
2024
	list_iterate(lvh, head) {
2024
	lvm_list_iterate(lvh, head) {
2025
		lvl = list_item(lvh, struct lv_list);
2025
		lvl = lvm_list_item(lvh, struct lv_list);
2026
		if (lvl->lv == lv) {
2026
		if (lvl->lv == lv) {
2027
			list_del(lvh);
2027
			lvm_list_del(lvh);
2028
			break;
2028
			break;
2029
		}
2029
		}
2030
	}
2030
	}
Lines 2034-2046 Link Here
2034
{
2034
{
2035
	struct logical_volume *active, *old_origin;
2035
	struct logical_volume *active, *old_origin;
2036
	struct snapshot *s;
2036
	struct snapshot *s;
2037
	struct list *sh, *active_head;
2037
	struct lvm_list *sh, *active_head;
2038
2038
2039
	active_head = &dm->active_list;
2039
	active_head = &dm->active_list;
2040
2040
2041
	/* Remove any snapshots with given origin */
2041
	/* Remove any snapshots with given origin */
2042
	list_iterate(sh, active_head) {
2042
	lvm_list_iterate(sh, active_head) {
2043
		active = list_item(sh, struct lv_list)->lv;
2043
		active = lvm_list_item(sh, struct lv_list)->lv;
2044
		if ((s = find_cow(active)) && s->origin == lv) {
2044
		if ((s = find_cow(active)) && s->origin == lv) {
2045
			_remove_lv(active_head, active);
2045
			_remove_lv(active_head, active);
2046
		}
2046
		}
Lines 2054-2061 Link Here
2054
	old_origin = s->origin;
2054
	old_origin = s->origin;
2055
2055
2056
	/* Was this the last active snapshot with this origin? */
2056
	/* Was this the last active snapshot with this origin? */
2057
	list_iterate(sh, active_head) {
2057
	lvm_list_iterate(sh, active_head) {
2058
		active = list_item(sh, struct lv_list)->lv;
2058
		active = lvm_list_item(sh, struct lv_list)->lv;
2059
		if ((s = find_cow(active)) && s->origin == old_origin) {
2059
		if ((s = find_cow(active)) && s->origin == old_origin) {
2060
			return 1;
2060
			return 1;
2061
		}
2061
		}
Lines 2069-2081 Link Here
2069
{
2069
{
2070
	struct logical_volume *suspended;
2070
	struct logical_volume *suspended;
2071
	struct snapshot *s;
2071
	struct snapshot *s;
2072
	struct list *sh, *suspend_head;
2072
	struct lvm_list *sh, *suspend_head;
2073
2073
2074
	suspend_head = &dm->suspend_list;
2074
	suspend_head = &dm->suspend_list;
2075
2075
2076
	/* Remove from list any snapshots with given origin */
2076
	/* Remove from list any snapshots with given origin */
2077
	list_iterate(sh, suspend_head) {
2077
	lvm_list_iterate(sh, suspend_head) {
2078
		suspended = list_item(sh, struct lv_list)->lv;
2078
		suspended = lvm_list_item(sh, struct lv_list)->lv;
2079
		if ((s = find_cow(suspended)) && s->origin == lv) {
2079
		if ((s = find_cow(suspended)) && s->origin == lv) {
2080
			_remove_lv(suspend_head, suspended);
2080
			_remove_lv(suspend_head, suspended);
2081
		}
2081
		}
Lines 2089-2103 Link Here
2089
static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
2089
static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
2090
{
2090
{
2091
	char *dlid;
2091
	char *dlid;
2092
	struct list *lvh;
2092
	struct lvm_list *lvh;
2093
	struct logical_volume *lv;
2093
	struct logical_volume *lv;
2094
	struct dev_layer *dl;
2094
	struct dev_layer *dl;
2095
2095
2096
	list_iterate(lvh, &vg->lvs) {
2096
	lvm_list_iterate(lvh, &vg->lvs) {
2097
		lv = list_item(lvh, struct lv_list)->lv;
2097
		lv = lvm_list_item(lvh, struct lv_list)->lv;
2098
2098
2099
		if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, NULL))) {
2099
		if (!(dlid = _build_dlid(dm->mem, lv->lvid.s, NULL))) {
2100
			stack;
2100
			STACK;
2101
			return 0;
2101
			return 0;
2102
		}
2102
		}
2103
2103
Lines 2109-2121 Link Here
2109
				  dl->info.suspended ? " (suspended)" : "");
2109
				  dl->info.suspended ? " (suspended)" : "");
2110
2110
2111
			if (!_add_lv(dm->mem, &dm->active_list, lv)) {
2111
			if (!_add_lv(dm->mem, &dm->active_list, lv)) {
2112
				stack;
2112
				STACK;
2113
				return 0;
2113
				return 0;
2114
			}
2114
			}
2115
2115
2116
			if (dl->info.suspended) {
2116
			if (dl->info.suspended) {
2117
				if (!_add_lv(dm->mem, &dm->suspend_list, lv)) {
2117
				if (!_add_lv(dm->mem, &dm->suspend_list, lv)) {
2118
					stack;
2118
					STACK;
2119
					return 0;
2119
					return 0;
2120
				}
2120
				}
2121
			}
2121
			}
Lines 2129-2147 Link Here
2129
		   action_t action)
2129
		   action_t action)
2130
{
2130
{
2131
	if (!_scan_existing_devices(dm)) {
2131
	if (!_scan_existing_devices(dm)) {
2132
		stack;
2132
		STACK;
2133
		return 0;
2133
		return 0;
2134
	}
2134
	}
2135
2135
2136
	if (!_fill_in_active_list(dm, lv->vg)) {
2136
	if (!_fill_in_active_list(dm, lv->vg)) {
2137
		stack;
2137
		STACK;
2138
		return 0;
2138
		return 0;
2139
	}
2139
	}
2140
2140
2141
	if (action == ACTIVATE || action == DEACTIVATE)
2141
	if (action == ACTIVATE || action == DEACTIVATE)
2142
		/* Get into known state - remove from active list if present */
2142
		/* Get into known state - remove from active list if present */
2143
		if (!_remove_lvs(dm, lv)) {
2143
		if (!_remove_lvs(dm, lv)) {
2144
			stack;
2144
			STACK;
2145
			return 0;
2145
			return 0;
2146
		}
2146
		}
2147
2147
Lines 2149-2155 Link Here
2149
		/* Add to active & reload lists */
2149
		/* Add to active & reload lists */
2150
		if (!_add_lvs(dm->mem, &dm->reload_list, lv) ||
2150
		if (!_add_lvs(dm->mem, &dm->reload_list, lv) ||
2151
		    !_add_lvs(dm->mem, &dm->active_list, lv)) {
2151
		    !_add_lvs(dm->mem, &dm->active_list, lv)) {
2152
			stack;
2152
			STACK;
2153
			return 0;
2153
			return 0;
2154
		}
2154
		}
2155
	}
2155
	}
Lines 2157-2175 Link Here
2157
	if (action == SUSPEND || action == RESUME || action == ACTIVATE)
2157
	if (action == SUSPEND || action == RESUME || action == ACTIVATE)
2158
		/* Get into known state - remove from suspend list if present */
2158
		/* Get into known state - remove from suspend list if present */
2159
		if (!_remove_suspended_lvs(dm, lv)) {
2159
		if (!_remove_suspended_lvs(dm, lv)) {
2160
			stack;
2160
			STACK;
2161
			return 0;
2161
			return 0;
2162
		}
2162
		}
2163
2163
2164
	if (action == SUSPEND) {
2164
	if (action == SUSPEND) {
2165
		if (!_add_lvs(dm->mem, &dm->suspend_list, lv)) {
2165
		if (!_add_lvs(dm->mem, &dm->suspend_list, lv)) {
2166
			stack;
2166
			STACK;
2167
			return 0;
2167
			return 0;
2168
		}
2168
		}
2169
	}
2169
	}
2170
2170
2171
	if (!_execute(dm, lv->vg)) {
2171
	if (!_execute(dm, lv->vg)) {
2172
		stack;
2172
		STACK;
2173
		return 0;
2173
		return 0;
2174
	}
2174
	}
2175
2175
Lines 2197-2203 Link Here
2197
2197
2198
	if (!(name = _build_name(lv->vg->cmd->mem, lv->vg->name,
2198
	if (!(name = _build_name(lv->vg->cmd->mem, lv->vg->name,
2199
				 lv->name, NULL))) {
2199
				 lv->name, NULL))) {
2200
		stack;
2200
		STACK;
2201
		return 0;
2201
		return 0;
2202
	}
2202
	}
2203
2203
(-)LVM2.2.00.15.orig/lib/activate/fs.c (-11 / +11 lines)
Lines 231-254 Link Here
231
	case FS_ADD:
231
	case FS_ADD:
232
		if (!_mk_dir(dev_dir, vg_name) ||
232
		if (!_mk_dir(dev_dir, vg_name) ||
233
		    !_mk_link(dev_dir, vg_name, lv_name, dev)) {
233
		    !_mk_link(dev_dir, vg_name, lv_name, dev)) {
234
			stack;
234
			STACK;
235
			return 0;
235
			return 0;
236
		}
236
		}
237
		break;
237
		break;
238
	case FS_DEL:
238
	case FS_DEL:
239
		if (!_rm_link(dev_dir, vg_name, lv_name) ||
239
		if (!_rm_link(dev_dir, vg_name, lv_name) ||
240
		    !_rm_dir(dev_dir, vg_name)) {
240
		    !_rm_dir(dev_dir, vg_name)) {
241
			stack;
241
			STACK;
242
			return 0;
242
			return 0;
243
		}
243
		}
244
		break;
244
		break;
245
		/* FIXME Use rename() */
245
		/* FIXME Use rename() */
246
	case FS_RENAME:
246
	case FS_RENAME:
247
		if (old_lv_name && !_rm_link(dev_dir, vg_name, old_lv_name))
247
		if (old_lv_name && !_rm_link(dev_dir, vg_name, old_lv_name))
248
			stack;
248
			STACK;
249
249
250
		if (!_mk_link(dev_dir, vg_name, lv_name, dev))
250
		if (!_mk_link(dev_dir, vg_name, lv_name, dev))
251
			stack;
251
			STACK;
252
	}
252
	}
253
253
254
	return 1;
254
	return 1;
Lines 257-263 Link Here
257
static LIST_INIT(_fs_ops);
257
static LIST_INIT(_fs_ops);
258
258
259
struct fs_op_parms {
259
struct fs_op_parms {
260
	struct list list;
260
	struct lvm_list list;
261
	fs_op_t type;
261
	fs_op_t type;
262
	char *dev_dir;
262
	char *dev_dir;
263
	char *vg_name;
263
	char *vg_name;
Lines 297-317 Link Here
297
	_store_str(&pos, &fsp->dev, dev);
297
	_store_str(&pos, &fsp->dev, dev);
298
	_store_str(&pos, &fsp->old_lv_name, old_lv_name);
298
	_store_str(&pos, &fsp->old_lv_name, old_lv_name);
299
299
300
	list_add(&_fs_ops, &fsp->list);
300
	lvm_list_add(&_fs_ops, &fsp->list);
301
301
302
	return 1;
302
	return 1;
303
}
303
}
304
304
305
static void _pop_fs_ops(void)
305
static void _pop_fs_ops(void)
306
{
306
{
307
	struct list *fsph, *fspht;
307
	struct lvm_list *fsph, *fspht;
308
	struct fs_op_parms *fsp;
308
	struct fs_op_parms *fsp;
309
309
310
	list_iterate_safe(fsph, fspht, &_fs_ops) {
310
	lvm_list_iterate_safe(fsph, fspht, &_fs_ops) {
311
		fsp = list_item(fsph, struct fs_op_parms);
311
		fsp = lvm_list_item(fsph, struct fs_op_parms);
312
		_do_fs_op(fsp->type, fsp->dev_dir, fsp->vg_name, fsp->lv_name,
312
		_do_fs_op(fsp->type, fsp->dev_dir, fsp->vg_name, fsp->lv_name,
313
			  fsp->dev, fsp->old_lv_name);
313
			  fsp->dev, fsp->old_lv_name);
314
		list_del(&fsp->list);
314
		lvm_list_del(&fsp->list);
315
		dbg_free(fsp);
315
		dbg_free(fsp);
316
	}
316
	}
317
}
317
}
Lines 322-328 Link Here
322
	if (memlock()) {
322
	if (memlock()) {
323
		if (!_stack_fs_op(type, dev_dir, vg_name, lv_name, dev,
323
		if (!_stack_fs_op(type, dev_dir, vg_name, lv_name, dev,
324
				  old_lv_name)) {
324
				  old_lv_name)) {
325
			stack;
325
			STACK;
326
			return 0;
326
			return 0;
327
		}
327
		}
328
		return 1;
328
		return 1;
(-)LVM2.2.00.15.orig/lib/cache/lvmcache.c (-27 / +27 lines)
Lines 28-40 Link Here
28
static struct hash_table *_vgid_hash = NULL;
28
static struct hash_table *_vgid_hash = NULL;
29
static struct hash_table *_vgname_hash = NULL;
29
static struct hash_table *_vgname_hash = NULL;
30
static struct hash_table *_lock_hash = NULL;
30
static struct hash_table *_lock_hash = NULL;
31
static struct list _vginfos;
31
static struct lvm_list _vginfos;
32
static int _has_scanned = 0;
32
static int _has_scanned = 0;
33
static int _vgs_locked = 0;
33
static int _vgs_locked = 0;
34
34
35
int lvmcache_init(void)
35
int lvmcache_init(void)
36
{
36
{
37
	list_init(&_vginfos);
37
	lvm_list_init(&_vginfos);
38
38
39
	if (!(_vgname_hash = hash_create(128)))
39
	if (!(_vgname_hash = hash_create(128)))
40
		return 0;
40
		return 0;
Lines 166-172 Link Here
166
	struct label *label;
166
	struct label *label;
167
	struct dev_iter *iter;
167
	struct dev_iter *iter;
168
	struct device *dev;
168
	struct device *dev;
169
	struct list *fmth;
169
	struct lvm_list *fmth;
170
	struct format_type *fmt;
170
	struct format_type *fmt;
171
171
172
	static int _scanning_in_progress = 0;
172
	static int _scanning_in_progress = 0;
Lines 201-208 Link Here
201
	_has_scanned = 1;
201
	_has_scanned = 1;
202
202
203
	/* Perform any format-specific scanning e.g. text files */
203
	/* Perform any format-specific scanning e.g. text files */
204
	list_iterate(fmth, &cmd->formats) {
204
	lvm_list_iterate(fmth, &cmd->formats) {
205
		fmt = list_item(fmth, struct format_type);
205
		fmt = lvm_list_item(fmth, struct format_type);
206
		if (fmt->ops->scan && !fmt->ops->scan(fmt))
206
		if (fmt->ops->scan && !fmt->ops->scan(fmt))
207
			goto out;
207
			goto out;
208
	}
208
	}
Lines 215-223 Link Here
215
	return r;
215
	return r;
216
}
216
}
217
217
218
struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
218
struct lvm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan)
219
{
219
{
220
	struct list *vgnames;
220
	struct lvm_list *vgnames;
221
	struct lvmcache_vginfo *vgi;
221
	struct lvmcache_vginfo *vgi;
222
222
223
	lvmcache_label_scan(cmd, full_scan);
223
	lvmcache_label_scan(cmd, full_scan);
Lines 227-233 Link Here
227
		return NULL;
227
		return NULL;
228
	}
228
	}
229
229
230
	list_iterate_items(vgi, &_vginfos) {
230
	lvm_list_iterate_items(vgi, &_vginfos) {
231
		if (!str_list_add(cmd->mem, vgnames, 
231
		if (!str_list_add(cmd->mem, vgnames, 
232
				  pool_strdup(cmd->mem, vgi->vgname))) {
232
				  pool_strdup(cmd->mem, vgi->vgname))) {
233
			log_error("strlist allocation failed");
233
			log_error("strlist allocation failed");
Lines 282-299 Link Here
282
282
283
static void _drop_vginfo(struct lvmcache_info *info)
283
static void _drop_vginfo(struct lvmcache_info *info)
284
{
284
{
285
	if (!list_empty(&info->list)) {
285
	if (!lvm_list_empty(&info->list)) {
286
		list_del(&info->list);
286
		lvm_list_del(&info->list);
287
		list_init(&info->list);
287
		lvm_list_init(&info->list);
288
	}
288
	}
289
289
290
	if (info->vginfo && list_empty(&info->vginfo->infos)) {
290
	if (info->vginfo && lvm_list_empty(&info->vginfo->infos)) {
291
		hash_remove(_vgname_hash, info->vginfo->vgname);
291
		hash_remove(_vgname_hash, info->vginfo->vgname);
292
		if (info->vginfo->vgname)
292
		if (info->vginfo->vgname)
293
			dbg_free(info->vginfo->vgname);
293
			dbg_free(info->vginfo->vgname);
294
		if (*info->vginfo->vgid)
294
		if (*info->vginfo->vgid)
295
			hash_remove(_vgid_hash, info->vginfo->vgid);
295
			hash_remove(_vgid_hash, info->vginfo->vgid);
296
		list_del(&info->vginfo->list);
296
		lvm_list_del(&info->vginfo->list);
297
		dbg_free(info->vginfo);
297
		dbg_free(info->vginfo);
298
	}
298
	}
299
299
Lines 382-388 Link Here
382
			log_error("cache vgname alloc failed for %s", vgname);
382
			log_error("cache vgname alloc failed for %s", vgname);
383
			return 0;
383
			return 0;
384
		}
384
		}
385
		list_init(&vginfo->infos);
385
		lvm_list_init(&vginfo->infos);
386
		if (!hash_insert(_vgname_hash, vginfo->vgname, vginfo)) {
386
		if (!hash_insert(_vgname_hash, vginfo->vgname, vginfo)) {
387
			log_error("cache_update: vg hash insertion failed: %s",
387
			log_error("cache_update: vg hash insertion failed: %s",
388
				  vginfo->vgname);
388
				  vginfo->vgname);
Lines 392-404 Link Here
392
		}
392
		}
393
		/* Ensure orphans appear last on list_iterate */
393
		/* Ensure orphans appear last on list_iterate */
394
		if (!*vgname)
394
		if (!*vgname)
395
			list_add(&_vginfos, &vginfo->list);
395
			lvm_list_add(&_vginfos, &vginfo->list);
396
		else
396
		else
397
			list_add_h(&_vginfos, &vginfo->list);
397
			lvm_list_add_h(&_vginfos, &vginfo->list);
398
	}
398
	}
399
399
400
	info->vginfo = vginfo;
400
	info->vginfo = vginfo;
401
	list_add(&vginfo->infos, &info->list);
401
	lvm_list_add(&vginfo->infos, &info->list);
402
402
403
	/* FIXME Check consistency of list! */
403
	/* FIXME Check consistency of list! */
404
	vginfo->fmt = info->fmt;
404
	vginfo->fmt = info->fmt;
Lines 408-414 Link Here
408
408
409
int lvmcache_update_vg(struct volume_group *vg)
409
int lvmcache_update_vg(struct volume_group *vg)
410
{
410
{
411
	struct list *pvh;
411
	struct lvm_list *pvh;
412
	struct physical_volume *pv;
412
	struct physical_volume *pv;
413
	struct lvmcache_info *info;
413
	struct lvmcache_info *info;
414
	char pvid_s[ID_LEN + 1];
414
	char pvid_s[ID_LEN + 1];
Lines 416-423 Link Here
416
416
417
	pvid_s[sizeof(pvid_s) - 1] = '\0';
417
	pvid_s[sizeof(pvid_s) - 1] = '\0';
418
418
419
	list_iterate(pvh, &vg->pvs) {
419
	lvm_list_iterate(pvh, &vg->pvs) {
420
		pv = list_item(pvh, struct pv_list)->pv;
420
		pv = lvm_list_item(pvh, struct pv_list)->pv;
421
		strncpy(pvid_s, (char *) &pv->id, sizeof(pvid_s) - 1);
421
		strncpy(pvid_s, (char *) &pv->id, sizeof(pvid_s) - 1);
422
		/* FIXME Could pv->dev->pvid ever be different? */
422
		/* FIXME Could pv->dev->pvid ever be different? */
423
		if ((info = info_from_pvid(pvid_s))) {
423
		if ((info = info_from_pvid(pvid_s))) {
Lines 451-457 Link Here
451
	if (!(existing = info_from_pvid(pvid_s)) &&
451
	if (!(existing = info_from_pvid(pvid_s)) &&
452
	    !(existing = info_from_pvid(dev->pvid))) {
452
	    !(existing = info_from_pvid(dev->pvid))) {
453
		if (!(label = label_create(labeller))) {
453
		if (!(label = label_create(labeller))) {
454
			stack;
454
			STACK;
455
			return NULL;
455
			return NULL;
456
		}
456
		}
457
		if (!(info = dbg_malloc(sizeof(*info)))) {
457
		if (!(info = dbg_malloc(sizeof(*info)))) {
Lines 463-469 Link Here
463
463
464
		label->info = info;
464
		label->info = info;
465
		info->label = label;
465
		info->label = label;
466
		list_init(&info->list);
466
		lvm_list_init(&info->list);
467
		info->dev = dev;
467
		info->dev = dev;
468
	} else {
468
	} else {
469
		if (existing->dev != dev) {
469
		if (existing->dev != dev) {
Lines 492-498 Link Here
492
			label_destroy(info->label);
492
			label_destroy(info->label);
493
			if (!(info->label = label_create(labeller))) {
493
			if (!(info->label = label_create(labeller))) {
494
				/* FIXME leaves info without label! */
494
				/* FIXME leaves info without label! */
495
				stack;
495
				STACK;
496
				return NULL;
496
				return NULL;
497
			}
497
			}
498
			info->label->info = info;
498
			info->label->info = info;
Lines 523-537 Link Here
523
523
524
	if (!_lvmcache_update_vgid(info, vgid))
524
	if (!_lvmcache_update_vgid(info, vgid))
525
		/* Non-critical */
525
		/* Non-critical */
526
		stack;
526
		STACK;
527
527
528
	return info;
528
	return info;
529
}
529
}
530
530
531
static void _lvmcache_destroy_entry(struct lvmcache_info *info)
531
static void _lvmcache_destroy_entry(struct lvmcache_info *info)
532
{
532
{
533
	if (!list_empty(&info->list))
533
	if (!lvm_list_empty(&info->list))
534
		list_del(&info->list);
534
		lvm_list_del(&info->list);
535
	strcpy(info->dev->pvid, "");
535
	strcpy(info->dev->pvid, "");
536
	label_destroy(info->label);
536
	label_destroy(info->label);
537
	dbg_free(info);
537
	dbg_free(info);
Lines 577-581 Link Here
577
		_lock_hash = NULL;
577
		_lock_hash = NULL;
578
	}
578
	}
579
579
580
	list_init(&_vginfos);
580
	lvm_list_init(&_vginfos);
581
}
581
}
(-)LVM2.2.00.15.orig/lib/cache/lvmcache.h (-6 / +6 lines)
Lines 31-47 Link Here
31
/* Eventual replacement for struct physical_volume perhaps? */
31
/* Eventual replacement for struct physical_volume perhaps? */
32
32
33
struct lvmcache_vginfo {
33
struct lvmcache_vginfo {
34
	struct list list;	/* Join these vginfos together */
34
	struct lvm_list list;	/* Join these vginfos together */
35
	struct list infos;	/* List head for lvmcache_infos */
35
	struct lvm_list infos;	/* List head for lvmcache_infos */
36
	char *vgname;		/* "" == orphan */
36
	char *vgname;		/* "" == orphan */
37
	char vgid[ID_LEN + 1];
37
	char vgid[ID_LEN + 1];
38
	const struct format_type *fmt;
38
	const struct format_type *fmt;
39
};
39
};
40
40
41
struct lvmcache_info {
41
struct lvmcache_info {
42
	struct list list;	/* Join VG members together */
42
	struct lvm_list list;	/* Join VG members together */
43
	struct list mdas;	/* list head for metadata areas */
43
	struct lvm_list mdas;	/* list head for metadata areas */
44
	struct list das;	/* list head for data areas */
44
	struct lvm_list das;	/* list head for data areas */
45
	struct lvmcache_vginfo *vginfo;	/* NULL == unknown */
45
	struct lvmcache_vginfo *vginfo;	/* NULL == unknown */
46
	struct label *label;
46
	struct label *label;
47
	const struct format_type *fmt;
47
	const struct format_type *fmt;
Lines 79-84 Link Here
79
79
80
/* Returns list of struct str_lists containing pool-allocated copy of vgnames */
80
/* Returns list of struct str_lists containing pool-allocated copy of vgnames */
81
/* Set full_scan to 1 to reread every filtered device label */
81
/* Set full_scan to 1 to reread every filtered device label */
82
struct list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
82
struct lvm_list *lvmcache_get_vgnames(struct cmd_context *cmd, int full_scan);
83
83
84
#endif
84
#endif
(-)LVM2.2.00.15.orig/lib/commands/toolcontext.c (-19 / +19 lines)
Lines 205-211 Link Here
205
	char config_file[PATH_MAX] = "";
205
	char config_file[PATH_MAX] = "";
206
206
207
	if (!(cmd->cft = create_config_tree())) {
207
	if (!(cmd->cft = create_config_tree())) {
208
		stack;
208
		STACK;
209
		return 0;
209
		return 0;
210
	}
210
	}
211
211
Lines 244-250 Link Here
244
	struct config_value *cv;
244
	struct config_value *cv;
245
245
246
	if (!dev_cache_init()) {
246
	if (!dev_cache_init()) {
247
		stack;
247
		STACK;
248
		return 0;
248
		return 0;
249
	}
249
	}
250
250
Lines 381-387 Link Here
381
	const char *format;
381
	const char *format;
382
382
383
	struct format_type *fmt;
383
	struct format_type *fmt;
384
	struct list *fmth;
384
	struct lvm_list *fmth;
385
385
386
#ifdef HAVE_LIBDL
386
#ifdef HAVE_LIBDL
387
	struct config_node *cn;
387
	struct config_node *cn;
Lines 393-399 Link Here
393
	if (!(fmt = init_lvm1_format(cmd)))
393
	if (!(fmt = init_lvm1_format(cmd)))
394
		return 0;
394
		return 0;
395
	fmt->library = NULL;
395
	fmt->library = NULL;
396
	list_add(&cmd->formats, &fmt->list);
396
	lvm_list_add(&cmd->formats, &fmt->list);
397
#endif
397
#endif
398
398
399
#ifdef HAVE_LIBDL
399
#ifdef HAVE_LIBDL
Lines 412-418 Link Here
412
			}
412
			}
413
			if (!(lib = load_shared_library(cmd->cft, cv->v.str,
413
			if (!(lib = load_shared_library(cmd->cft, cv->v.str,
414
							"format"))) {
414
							"format"))) {
415
				stack;
415
				STACK;
416
				return 0;
416
				return 0;
417
			}
417
			}
418
418
Lines 426-432 Link Here
426
			if (!(fmt = init_format_fn(cmd)))
426
			if (!(fmt = init_format_fn(cmd)))
427
				return 0;
427
				return 0;
428
			fmt->library = lib;
428
			fmt->library = lib;
429
			list_add(&cmd->formats, &fmt->list);
429
			lvm_list_add(&cmd->formats, &fmt->list);
430
		}
430
		}
431
	}
431
	}
432
#endif
432
#endif
Lines 434-448 Link Here
434
	if (!(fmt = create_text_format(cmd)))
434
	if (!(fmt = create_text_format(cmd)))
435
		return 0;
435
		return 0;
436
	fmt->library = NULL;
436
	fmt->library = NULL;
437
	list_add(&cmd->formats, &fmt->list);
437
	lvm_list_add(&cmd->formats, &fmt->list);
438
438
439
	cmd->fmt_backup = fmt;
439
	cmd->fmt_backup = fmt;
440
440
441
	format = find_config_str(cmd->cft->root, "global/format",
441
	format = find_config_str(cmd->cft->root, "global/format",
442
				 DEFAULT_FORMAT);
442
				 DEFAULT_FORMAT);
443
443
444
	list_iterate(fmth, &cmd->formats) {
444
	lvm_list_iterate(fmth, &cmd->formats) {
445
		fmt = list_item(fmth, struct format_type);
445
		fmt = lvm_list_item(fmth, struct format_type);
446
		if (!strcasecmp(fmt->name, format) ||
446
		if (!strcasecmp(fmt->name, format) ||
447
		    (fmt->alias && !strcasecmp(fmt->alias, format))) {
447
		    (fmt->alias && !strcasecmp(fmt->alias, format))) {
448
			cmd->default_settings.fmt = fmt;
448
			cmd->default_settings.fmt = fmt;
Lines 530-536 Link Here
530
	const char *tag;
530
	const char *tag;
531
	int passes;
531
	int passes;
532
532
533
	list_init(&cmd->tags);
533
	lvm_list_init(&cmd->tags);
534
534
535
	if (!(tn = find_config_node(cmd->cft->root, "tags")) ||
535
	if (!(tn = find_config_node(cmd->cft->root, "tags")) ||
536
	    !tn->child) {
536
	    !tn->child) {
Lines 542-548 Link Here
542
			    DEFAULT_HOSTTAGS)) {
542
			    DEFAULT_HOSTTAGS)) {
543
		/* FIXME Strip out invalid chars: only A-Za-z0-9_+.- */
543
		/* FIXME Strip out invalid chars: only A-Za-z0-9_+.- */
544
		if (!_set_tag(cmd, cmd->hostname)) {
544
		if (!_set_tag(cmd, cmd->hostname)) {
545
			stack;
545
			STACK;
546
			return 0;
546
			return 0;
547
		}
547
		}
548
	}
548
	}
Lines 560-573 Link Here
560
		if (cn->child) {
560
		if (cn->child) {
561
			passes = 0;
561
			passes = 0;
562
			if (!_check_host_filters(cmd, cn->child, &passes)) {
562
			if (!_check_host_filters(cmd, cn->child, &passes)) {
563
				stack;
563
				STACK;
564
				return 0;
564
				return 0;
565
			}
565
			}
566
			if (!passes)
566
			if (!passes)
567
				continue;
567
				continue;
568
		}
568
		}
569
		if (!_set_tag(cmd, tag)) {
569
		if (!_set_tag(cmd, tag)) {
570
			stack;
570
			STACK;
571
			return 0;
571
			return 0;
572
		}
572
		}
573
	}
573
	}
Lines 599-605 Link Here
599
	}
599
	}
600
	memset(cmd, 0, sizeof(*cmd));
600
	memset(cmd, 0, sizeof(*cmd));
601
	cmd->args = the_args;
601
	cmd->args = the_args;
602
	list_init(&cmd->formats);
602
	lvm_list_init(&cmd->formats);
603
603
604
	strcpy(cmd->sys_dir, DEFAULT_SYS_DIR);
604
	strcpy(cmd->sys_dir, DEFAULT_SYS_DIR);
605
605
Lines 664-678 Link Here
664
	return 1;
664
	return 1;
665
}
665
}
666
666
667
static void _destroy_formats(struct list *formats)
667
static void _destroy_formats(struct lvm_list *formats)
668
{
668
{
669
	struct list *fmtl, *tmp;
669
	struct lvm_list *fmtl, *tmp;
670
	struct format_type *fmt;
670
	struct format_type *fmt;
671
	void *lib;
671
	void *lib;
672
672
673
	list_iterate_safe(fmtl, tmp, formats) {
673
	lvm_list_iterate_safe(fmtl, tmp, formats) {
674
		fmt = list_item(fmtl, struct format_type);
674
		fmt = lvm_list_item(fmtl, struct format_type);
675
		list_del(&fmt->list);
675
		lvm_list_del(&fmt->list);
676
		lib = fmt->library;
676
		lib = fmt->library;
677
		fmt->ops->destroy(fmt);
677
		fmt->ops->destroy(fmt);
678
#ifdef HAVE_LIBDL
678
#ifdef HAVE_LIBDL
(-)LVM2.2.00.15.orig/lib/commands/toolcontext.h (-2 / +2 lines)
Lines 56-62 Link Here
56
	const struct format_type *fmt;	/* Current format to use by default */
56
	const struct format_type *fmt;	/* Current format to use by default */
57
	struct format_type *fmt_backup;	/* Format to use for backups */
57
	struct format_type *fmt_backup;	/* Format to use for backups */
58
58
59
	struct list formats;	/* Available formats */
59
	struct lvm_list formats;	/* Available formats */
60
	const char *hostname;
60
	const char *hostname;
61
	const char *kernel_vsn;
61
	const char *kernel_vsn;
62
62
Lines 73-79 Link Here
73
	struct config_info current_settings;
73
	struct config_info current_settings;
74
74
75
	/* List of defined tags */
75
	/* List of defined tags */
76
	struct list tags;
76
	struct lvm_list tags;
77
77
78
	char sys_dir[PATH_MAX];
78
	char sys_dir[PATH_MAX];
79
	char dev_dir[PATH_MAX];
79
	char dev_dir[PATH_MAX];
(-)LVM2.2.00.15.orig/lib/config/config.c (-17 / +17 lines)
Lines 99-110 Link Here
99
	struct pool *mem = pool_create(10 * 1024);
99
	struct pool *mem = pool_create(10 * 1024);
100
100
101
	if (!mem) {
101
	if (!mem) {
102
		stack;
102
		STACK;
103
		return 0;
103
		return 0;
104
	}
104
	}
105
105
106
	if (!(c = pool_alloc(mem, sizeof(*c)))) {
106
	if (!(c = pool_alloc(mem, sizeof(*c)))) {
107
		stack;
107
		STACK;
108
		pool_destroy(mem);
108
		pool_destroy(mem);
109
		return 0;
109
		return 0;
110
	}
110
	}
Lines 132-138 Link Here
132
	off_t mmap_offset = 0;
132
	off_t mmap_offset = 0;
133
133
134
	if (!(p = pool_alloc(c->mem, sizeof(*p)))) {
134
	if (!(p = pool_alloc(c->mem, sizeof(*p)))) {
135
		stack;
135
		STACK;
136
		return 0;
136
		return 0;
137
	}
137
	}
138
	p->mem = c->mem;
138
	p->mem = c->mem;
Lines 153-159 Link Here
153
		p->fb = p->fb + mmap_offset;
153
		p->fb = p->fb + mmap_offset;
154
	} else {
154
	} else {
155
		if (!(p->fb = dbg_malloc(size + size2))) {
155
		if (!(p->fb = dbg_malloc(size + size2))) {
156
			stack;
156
			STACK;
157
			return 0;
157
			return 0;
158
		}
158
		}
159
		if (!dev_read(dev, (uint64_t) offset, size, p->fb)) {
159
		if (!dev_read(dev, (uint64_t) offset, size, p->fb)) {
Lines 184-190 Link Here
184
	p->line = 1;
184
	p->line = 1;
185
	_get_token(p, TOK_SECTION_E);
185
	_get_token(p, TOK_SECTION_E);
186
	if (!(cft->root = _file(p))) {
186
	if (!(cft->root = _file(p))) {
187
		stack;
187
		STACK;
188
		goto out;
188
		goto out;
189
	}
189
	}
190
190
Lines 227-238 Link Here
227
	}
227
	}
228
228
229
	if (!(dev = dev_create_file(file, NULL, NULL))) {
229
	if (!(dev = dev_create_file(file, NULL, NULL))) {
230
		stack;
230
		STACK;
231
		return 0;
231
		return 0;
232
	}
232
	}
233
233
234
	if (!dev_open_flags(dev, O_RDONLY, 0, 0)) {
234
	if (!dev_open_flags(dev, O_RDONLY, 0, 0)) {
235
		stack;
235
		STACK;
236
		return 0;
236
		return 0;
237
	}
237
	}
238
238
Lines 300-311 Link Here
300
	}
300
	}
301
301
302
	if (!(dev = dev_create_file(c->filename, NULL, NULL))) {
302
	if (!(dev = dev_create_file(c->filename, NULL, NULL))) {
303
		stack;
303
		STACK;
304
		return 0;
304
		return 0;
305
	}
305
	}
306
306
307
	if (!dev_open_flags(dev, O_RDONLY, 0, 0)) {
307
	if (!dev_open_flags(dev, O_RDONLY, 0, 0)) {
308
		stack;
308
		STACK;
309
		return 0;
309
		return 0;
310
	}
310
	}
311
311
Lines 426-432 Link Here
426
	struct config_node *root = NULL, *n, *l = NULL;
426
	struct config_node *root = NULL, *n, *l = NULL;
427
	while (p->t != TOK_EOF) {
427
	while (p->t != TOK_EOF) {
428
		if (!(n = _section(p))) {
428
		if (!(n = _section(p))) {
429
			stack;
429
			STACK;
430
			return 0;
430
			return 0;
431
		}
431
		}
432
432
Lines 444-455 Link Here
444
	/* IDENTIFIER '{' VALUE* '}' */
444
	/* IDENTIFIER '{' VALUE* '}' */
445
	struct config_node *root, *n, *l = NULL;
445
	struct config_node *root, *n, *l = NULL;
446
	if (!(root = _create_node(p))) {
446
	if (!(root = _create_node(p))) {
447
		stack;
447
		STACK;
448
		return 0;
448
		return 0;
449
	}
449
	}
450
450
451
	if (!(root->key = _dup_tok(p))) {
451
	if (!(root->key = _dup_tok(p))) {
452
		stack;
452
		STACK;
453
		return 0;
453
		return 0;
454
	}
454
	}
455
455
Lines 459-465 Link Here
459
		match(TOK_SECTION_B);
459
		match(TOK_SECTION_B);
460
		while (p->t != TOK_SECTION_E) {
460
		while (p->t != TOK_SECTION_E) {
461
			if (!(n = _section(p))) {
461
			if (!(n = _section(p))) {
462
				stack;
462
				STACK;
463
				return 0;
463
				return 0;
464
			}
464
			}
465
465
Lines 473-479 Link Here
473
	} else {
473
	} else {
474
		match(TOK_EQ);
474
		match(TOK_EQ);
475
		if (!(root->v = _value(p))) {
475
		if (!(root->v = _value(p))) {
476
			stack;
476
			STACK;
477
			return 0;
477
			return 0;
478
		}
478
		}
479
	}
479
	}
Lines 489-495 Link Here
489
		match(TOK_ARRAY_B);
489
		match(TOK_ARRAY_B);
490
		while (p->t != TOK_ARRAY_E) {
490
		while (p->t != TOK_ARRAY_E) {
491
			if (!(l = _type(p))) {
491
			if (!(l = _type(p))) {
492
				stack;
492
				STACK;
493
				return 0;
493
				return 0;
494
			}
494
			}
495
495
Lines 545-551 Link Here
545
545
546
		p->tb++, p->te--;	/* strip "'s */
546
		p->tb++, p->te--;	/* strip "'s */
547
		if (!(v->v.str = _dup_tok(p))) {
547
		if (!(v->v.str = _dup_tok(p))) {
548
			stack;
548
			STACK;
549
			return 0;
549
			return 0;
550
		}
550
		}
551
		p->te++;
551
		p->te++;
Lines 728-734 Link Here
728
	size_t len = p->te - p->tb;
728
	size_t len = p->te - p->tb;
729
	char *str = pool_alloc(p->mem, len + 1);
729
	char *str = pool_alloc(p->mem, len + 1);
730
	if (!str) {
730
	if (!str) {
731
		stack;
731
		STACK;
732
		return 0;
732
		return 0;
733
	}
733
	}
734
	strncpy(str, p->tb, len);
734
	strncpy(str, p->tb, len);
(-)LVM2.2.00.15.orig/lib/datastruct/btree.c (-1 / +1 lines)
Lines 87-93 Link Here
87
87
88
	if (!*c) {
88
	if (!*c) {
89
		if (!(n = pool_alloc(t->mem, sizeof(*n)))) {
89
		if (!(n = pool_alloc(t->mem, sizeof(*n)))) {
90
			stack;
90
			STACK;
91
			return 0;
91
			return 0;
92
		}
92
		}
93
93
(-)LVM2.2.00.15.orig/lib/datastruct/hash.c (-2 / +2 lines)
Lines 90-96 Link Here
90
	struct hash_table *hc = dbg_malloc(sizeof(*hc));
90
	struct hash_table *hc = dbg_malloc(sizeof(*hc));
91
91
92
	if (!hc) {
92
	if (!hc) {
93
		stack;
93
		STACK;
94
		return 0;
94
		return 0;
95
	}
95
	}
96
96
Lines 103-109 Link Here
103
	hc->num_slots = new_size;
103
	hc->num_slots = new_size;
104
	len = sizeof(*(hc->slots)) * new_size;
104
	len = sizeof(*(hc->slots)) * new_size;
105
	if (!(hc->slots = dbg_malloc(len))) {
105
	if (!(hc->slots = dbg_malloc(len))) {
106
		stack;
106
		STACK;
107
		goto bad;
107
		goto bad;
108
	}
108
	}
109
	memset(hc->slots, 0, len);
109
	memset(hc->slots, 0, len);
(-)LVM2.2.00.15.orig/lib/datastruct/list.h (-24 / +24 lines)
Lines 18-35 Link Here
18
18
19
#include <assert.h>
19
#include <assert.h>
20
20
21
struct list {
21
struct lvm_list {
22
	struct list *n, *p;
22
	struct lvm_list *n, *p;
23
};
23
};
24
24
25
#define LIST_INIT(name)	struct list name = { &(name), &(name) }
25
#define LIST_INIT(name)	struct lvm_list name = { &(name), &(name) }
26
26
27
static inline void list_init(struct list *head)
27
static inline void lvm_list_init(struct lvm_list *head)
28
{
28
{
29
	head->n = head->p = head;
29
	head->n = head->p = head;
30
}
30
}
31
31
32
static inline void list_add(struct list *head, struct list *elem)
32
static inline void lvm_list_add(struct lvm_list *head, struct lvm_list *elem)
33
{
33
{
34
	assert(head->n);
34
	assert(head->n);
35
35
Lines 40-46 Link Here
40
	head->p = elem;
40
	head->p = elem;
41
}
41
}
42
42
43
static inline void list_add_h(struct list *head, struct list *elem)
43
static inline void lvm_list_add_h(struct lvm_list *head, struct lvm_list *elem)
44
{
44
{
45
	assert(head->n);
45
	assert(head->n);
46
46
Lines 51-109 Link Here
51
	head->n = elem;
51
	head->n = elem;
52
}
52
}
53
53
54
static inline void list_del(struct list *elem)
54
static inline void lvm_list_del(struct lvm_list *elem)
55
{
55
{
56
	elem->n->p = elem->p;
56
	elem->n->p = elem->p;
57
	elem->p->n = elem->n;
57
	elem->p->n = elem->n;
58
}
58
}
59
59
60
static inline int list_empty(struct list *head)
60
static inline int lvm_list_empty(struct lvm_list *head)
61
{
61
{
62
	return head->n == head;
62
	return head->n == head;
63
}
63
}
64
64
65
static inline int list_end(struct list *head, struct list *elem)
65
static inline int lvm_list_end(struct lvm_list *head, struct lvm_list *elem)
66
{
66
{
67
	return elem->n == head;
67
	return elem->n == head;
68
}
68
}
69
69
70
static inline struct list *list_next(struct list *head, struct list *elem)
70
static inline struct lvm_list *lvm_list_next(struct lvm_list *head, struct lvm_list *elem)
71
{
71
{
72
	return (list_end(head, elem) ? NULL : elem->n);
72
	return (lvm_list_end(head, elem) ? NULL : elem->n);
73
}
73
}
74
74
75
#define list_item(v, t) \
75
#define lvm_list_item(v, t) \
76
    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
76
    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
77
77
78
#define list_struct_base(v, t, h) \
78
#define lvm_list_struct_base(v, t, h) \
79
    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
79
    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
80
80
81
/* Given a known element in a known structure, locate another */
81
/* Given a known element in a known structure, locate another */
82
#define struct_field(v, t, e, f) \
82
#define struct_field(v, t, e, f) \
83
    (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
83
    (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
84
84
85
/* Given a known element in a known structure, locate the list head */
85
/* Given a known element in a known structure, locate the lvm_list head */
86
#define list_head(v, t, e) struct_field(v, t, e, list)
86
#define lvm_list_head(v, t, e) struct_field(v, t, e, lvm_list)
87
87
88
#define list_iterate(v, head) \
88
#define lvm_list_iterate(v, head) \
89
	for (v = (head)->n; v != head; v = v->n)
89
	for (v = (head)->n; v != head; v = v->n)
90
90
91
#define list_uniterate(v, head, start) \
91
#define lvm_list_uniterate(v, head, start) \
92
	for (v = (start)->p; v != head; v = v->p)
92
	for (v = (start)->p; v != head; v = v->p)
93
93
94
#define list_iterate_safe(v, t, head) \
94
#define lvm_list_iterate_safe(v, t, head) \
95
	for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
95
	for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
96
96
97
#define list_iterate_items(v, head) \
97
#define lvm_list_iterate_items(v, head) \
98
	for (v = list_item((head)->n, typeof(*v)); &v->list != (head); \
98
	for (v = lvm_list_item((head)->n, typeof(*v)); &v->list != (head); \
99
	     v = list_item(v->list.n, typeof(*v)))
99
	     v = lvm_list_item(v->list.n, typeof(*v)))
100
100
101
static inline unsigned int list_size(const struct list *head)
101
static inline unsigned int lvm_list_size(const struct lvm_list *head)
102
{
102
{
103
	unsigned int s = 0;
103
	unsigned int s = 0;
104
	const struct list *v;
104
	const struct lvm_list *v;
105
105
106
	list_iterate(v, head)
106
	lvm_list_iterate(v, head)
107
	    s++;
107
	    s++;
108
108
109
	return s;
109
	return s;
(-)LVM2.2.00.15.orig/lib/datastruct/lvm-types.h (-1 / +1 lines)
Lines 25-31 Link Here
25
#define PRIsize_t "Zu"
25
#define PRIsize_t "Zu"
26
26
27
struct str_list {
27
struct str_list {
28
	struct list list;
28
	struct lvm_list list;
29
	const char *str;
29
	const char *str;
30
};
30
};
31
31
(-)LVM2.2.00.15.orig/lib/datastruct/str_list.c (-25 / +25 lines)
Lines 16-41 Link Here
16
#include "lib.h"
16
#include "lib.h"
17
#include "str_list.h"
17
#include "str_list.h"
18
18
19
struct list *str_list_create(struct pool *mem)
19
struct lvm_list *str_list_create(struct pool *mem)
20
{
20
{
21
	struct list *sl;
21
	struct lvm_list *sl;
22
22
23
	if (!(sl = pool_alloc(mem, sizeof(struct list)))) {
23
	if (!(sl = pool_alloc(mem, sizeof(struct lvm_list)))) {
24
		stack;
24
		STACK;
25
		return NULL;
25
		return NULL;
26
	}
26
	}
27
27
28
	list_init(sl);
28
	lvm_list_init(sl);
29
29
30
	return sl;
30
	return sl;
31
}
31
}
32
32
33
int str_list_add(struct pool *mem, struct list *sll, const char *str)
33
int str_list_add(struct pool *mem, struct lvm_list *sll, const char *str)
34
{
34
{
35
	struct str_list *sln;
35
	struct str_list *sln;
36
36
37
	if (!str) {
37
	if (!str) {
38
		stack;
38
		STACK;
39
		return 0;
39
		return 0;
40
	}
40
	}
41
41
Lines 44-80 Link Here
44
		return 1;
44
		return 1;
45
45
46
	if (!(sln = pool_alloc(mem, sizeof(*sln)))) {
46
	if (!(sln = pool_alloc(mem, sizeof(*sln)))) {
47
		stack;
47
		STACK;
48
		return 0;
48
		return 0;
49
	}
49
	}
50
50
51
	sln->str = str;
51
	sln->str = str;
52
	list_add(sll, &sln->list);
52
	lvm_list_add(sll, &sln->list);
53
53
54
	return 1;
54
	return 1;
55
}
55
}
56
56
57
int str_list_del(struct list *sll, const char *str)
57
int str_list_del(struct lvm_list *sll, const char *str)
58
{
58
{
59
	struct list *slh, *slht;
59
	struct lvm_list *slh, *slht;
60
60
61
	list_iterate_safe(slh, slht, sll) {
61
	lvm_list_iterate_safe(slh, slht, sll) {
62
		if (!strcmp(str, list_item(slh, struct str_list)->str))
62
		if (!strcmp(str, lvm_list_item(slh, struct str_list)->str))
63
			 list_del(slh);
63
			 lvm_list_del(slh);
64
	}
64
	}
65
65
66
	return 1;
66
	return 1;
67
}
67
}
68
68
69
int str_list_dup(struct pool *mem, struct list *sllnew, struct list *sllold)
69
int str_list_dup(struct pool *mem, struct lvm_list *sllnew, struct lvm_list *sllold)
70
{
70
{
71
	struct str_list *sl;
71
	struct str_list *sl;
72
72
73
	list_init(sllnew);
73
	lvm_list_init(sllnew);
74
74
75
	list_iterate_items(sl, sllold) {
75
	lvm_list_iterate_items(sl, sllold) {
76
		if (!str_list_add(mem, sllnew, strdup(sl->str))) {
76
		if (!str_list_add(mem, sllnew, strdup(sl->str))) {
77
			stack;
77
			STACK;
78
			return 0;
78
			return 0;
79
		}
79
		}
80
	}
80
	}
Lines 85-95 Link Here
85
/*
85
/*
86
 * Is item on list?
86
 * Is item on list?
87
 */
87
 */
88
int str_list_match_item(struct list *sll, const char *str)
88
int str_list_match_item(struct lvm_list *sll, const char *str)
89
{
89
{
90
	struct str_list *sl;
90
	struct str_list *sl;
91
91
92
	list_iterate_items(sl, sll)
92
	lvm_list_iterate_items(sl, sll)
93
	    if (!strcmp(str, sl->str))
93
	    if (!strcmp(str, sl->str))
94
		return 1;
94
		return 1;
95
95
Lines 99-109 Link Here
99
/*
99
/*
100
 * Is at least one item on both lists?
100
 * Is at least one item on both lists?
101
 */
101
 */
102
int str_list_match_list(struct list *sll, struct list *sll2)
102
int str_list_match_list(struct lvm_list *sll, struct lvm_list *sll2)
103
{
103
{
104
	struct str_list *sl;
104
	struct str_list *sl;
105
105
106
	list_iterate_items(sl, sll)
106
	lvm_list_iterate_items(sl, sll)
107
	    if (str_list_match_item(sll2, sl->str))
107
	    if (str_list_match_item(sll2, sl->str))
108
		return 1;
108
		return 1;
109
109
Lines 113-126 Link Here
113
/*
113
/*
114
 * Do both lists contain the same set of items?
114
 * Do both lists contain the same set of items?
115
 */
115
 */
116
int str_list_lists_equal(struct list *sll, struct list *sll2)
116
int str_list_lists_equal(struct lvm_list *sll, struct lvm_list *sll2)
117
{
117
{
118
	struct str_list *sl;
118
	struct str_list *sl;
119
119
120
	if (list_size(sll) != list_size(sll2))
120
	if (lvm_list_size(sll) != lvm_list_size(sll2))
121
		return 0;
121
		return 0;
122
122
123
	list_iterate_items(sl, sll)
123
	lvm_list_iterate_items(sl, sll)
124
	    if (!str_list_match_item(sll2, sl->str))
124
	    if (!str_list_match_item(sll2, sl->str))
125
		return 0;
125
		return 0;
126
126
(-)LVM2.2.00.15.orig/lib/datastruct/str_list.h (-7 / +7 lines)
Lines 18-29 Link Here
18
18
19
#include "pool.h"
19
#include "pool.h"
20
20
21
struct list *str_list_create(struct pool *mem);
21
struct lvm_list *str_list_create(struct pool *mem);
22
int str_list_add(struct pool *mem, struct list *sll, const char *str);
22
int str_list_add(struct pool *mem, struct lvm_list *sll, const char *str);
23
int str_list_del(struct list *sll, const char *str);
23
int str_list_del(struct lvm_list *sll, const char *str);
24
int str_list_match_item(struct list *sll, const char *str);
24
int str_list_match_item(struct lvm_list *sll, const char *str);
25
int str_list_match_list(struct list *sll, struct list *sll2);
25
int str_list_match_list(struct lvm_list *sll, struct lvm_list *sll2);
26
int str_list_lists_equal(struct list *sll, struct list *sll2);
26
int str_list_lists_equal(struct lvm_list *sll, struct lvm_list *sll2);
27
int str_list_dup(struct pool *mem, struct list *sllnew, struct list *sllold);
27
int str_list_dup(struct pool *mem, struct lvm_list *sllnew, struct lvm_list *sllold);
28
28
29
#endif
29
#endif
(-)LVM2.2.00.15.orig/lib/device/dev-cache.c (-31 / +31 lines)
Lines 32-38 Link Here
32
};
32
};
33
33
34
struct dir_list {
34
struct dir_list {
35
	struct list list;
35
	struct lvm_list list;
36
	char dir[0];
36
	char dir[0];
37
};
37
};
38
38
Lines 42-48 Link Here
42
	struct btree *devices;
42
	struct btree *devices;
43
43
44
	int has_scanned;
44
	int has_scanned;
45
	struct list dirs;
45
	struct lvm_list dirs;
46
46
47
} _cache;
47
} _cache;
48
48
Lines 76-89 Link Here
76
	dev->flags = DEV_REGULAR;
76
	dev->flags = DEV_REGULAR;
77
	if (allocate)
77
	if (allocate)
78
		dev->flags |= DEV_ALLOCED;
78
		dev->flags |= DEV_ALLOCED;
79
	list_init(&dev->aliases);
79
	lvm_list_init(&dev->aliases);
80
	list_add(&dev->aliases, &alias->list);
80
	lvm_list_add(&dev->aliases, &alias->list);
81
	dev->end = UINT64_C(0);
81
	dev->end = UINT64_C(0);
82
	dev->dev = 0;
82
	dev->dev = 0;
83
	dev->fd = -1;
83
	dev->fd = -1;
84
	dev->open_count = 0;
84
	dev->open_count = 0;
85
	memset(dev->pvid, 0, sizeof(dev->pvid));
85
	memset(dev->pvid, 0, sizeof(dev->pvid));
86
	list_init(&dev->open_list);
86
	lvm_list_init(&dev->open_list);
87
87
88
	return dev;
88
	return dev;
89
}
89
}
Lines 97-109 Link Here
97
		return NULL;
97
		return NULL;
98
	}
98
	}
99
	dev->flags = 0;
99
	dev->flags = 0;
100
	list_init(&dev->aliases);
100
	lvm_list_init(&dev->aliases);
101
	dev->dev = d;
101
	dev->dev = d;
102
	dev->fd = -1;
102
	dev->fd = -1;
103
	dev->open_count = 0;
103
	dev->open_count = 0;
104
	dev->end = UINT64_C(0);
104
	dev->end = UINT64_C(0);
105
	memset(dev->pvid, 0, sizeof(dev->pvid));
105
	memset(dev->pvid, 0, sizeof(dev->pvid));
106
	list_init(&dev->open_list);
106
	lvm_list_init(&dev->open_list);
107
107
108
	return dev;
108
	return dev;
109
}
109
}
Lines 172-201 Link Here
172
static int _add_alias(struct device *dev, const char *path)
172
static int _add_alias(struct device *dev, const char *path)
173
{
173
{
174
	struct str_list *sl = _alloc(sizeof(*sl));
174
	struct str_list *sl = _alloc(sizeof(*sl));
175
	struct list *ah;
175
	struct lvm_list *ah;
176
	const char *oldpath;
176
	const char *oldpath;
177
	int prefer_old = 1;
177
	int prefer_old = 1;
178
178
179
	if (!sl) {
179
	if (!sl) {
180
		stack;
180
		STACK;
181
		return 0;
181
		return 0;
182
	}
182
	}
183
183
184
	/* Is name already there? */
184
	/* Is name already there? */
185
	list_iterate(ah, &dev->aliases) {
185
	lvm_list_iterate(ah, &dev->aliases) {
186
		if (!strcmp(list_item(ah, struct str_list)->str, path)) {
186
		if (!strcmp(lvm_list_item(ah, struct str_list)->str, path)) {
187
			stack;
187
			STACK;
188
			return 1;
188
			return 1;
189
		}
189
		}
190
	}
190
	}
191
191
192
	if (!(sl->str = pool_strdup(_cache.mem, path))) {
192
	if (!(sl->str = pool_strdup(_cache.mem, path))) {
193
		stack;
193
		STACK;
194
		return 0;
194
		return 0;
195
	}
195
	}
196
196
197
	if (!list_empty(&dev->aliases)) {
197
	if (!lvm_list_empty(&dev->aliases)) {
198
		oldpath = list_item(dev->aliases.n, struct str_list)->str;
198
		oldpath = lvm_list_item(dev->aliases.n, struct str_list)->str;
199
		prefer_old = _compare_paths(path, oldpath);
199
		prefer_old = _compare_paths(path, oldpath);
200
		log_debug("%s: Aliased to %s in device cache%s",
200
		log_debug("%s: Aliased to %s in device cache%s",
201
			  path, oldpath, prefer_old ? "" : " (preferred name)");
201
			  path, oldpath, prefer_old ? "" : " (preferred name)");
Lines 204-212 Link Here
204
		log_debug("%s: Added to device cache", path);
204
		log_debug("%s: Added to device cache", path);
205
205
206
	if (prefer_old)
206
	if (prefer_old)
207
		list_add(&dev->aliases, &sl->list);
207
		lvm_list_add(&dev->aliases, &sl->list);
208
	else
208
	else
209
		list_add_h(&dev->aliases, &sl->list);
209
		lvm_list_add_h(&dev->aliases, &sl->list);
210
210
211
	return 1;
211
	return 1;
212
}
212
}
Lines 224-230 Link Here
224
						   (uint32_t) d))) {
224
						   (uint32_t) d))) {
225
		/* create new device */
225
		/* create new device */
226
		if (!(dev = _dev_create(d))) {
226
		if (!(dev = _dev_create(d))) {
227
			stack;
227
			STACK;
228
			return 0;
228
			return 0;
229
		}
229
		}
230
230
Lines 295-301 Link Here
295
			}
295
			}
296
296
297
			if (!(path = _join(dir, dirent[n]->d_name))) {
297
			if (!(path = _join(dir, dirent[n]->d_name))) {
298
				stack;
298
				STACK;
299
				return 0;
299
				return 0;
300
			}
300
			}
301
301
Lines 343-349 Link Here
343
		}
343
		}
344
344
345
		if (!_insert_dev(path, info.st_rdev)) {
345
		if (!_insert_dev(path, info.st_rdev)) {
346
			stack;
346
			STACK;
347
			return 0;
347
			return 0;
348
		}
348
		}
349
349
Lines 355-367 Link Here
355
355
356
static void _full_scan(void)
356
static void _full_scan(void)
357
{
357
{
358
	struct list *dh;
358
	struct lvm_list *dh;
359
359
360
	if (_cache.has_scanned)
360
	if (_cache.has_scanned)
361
		return;
361
		return;
362
362
363
	list_iterate(dh, &_cache.dirs) {
363
	lvm_list_iterate(dh, &_cache.dirs) {
364
		struct dir_list *dl = list_item(dh, struct dir_list);
364
		struct dir_list *dl = lvm_list_item(dh, struct dir_list);
365
		_insert_dir(dl->dir);
365
		_insert_dir(dl->dir);
366
	};
366
	};
367
367
Lines 388-399 Link Here
388
	_cache.names = NULL;
388
	_cache.names = NULL;
389
389
390
	if (!(_cache.mem = pool_create(10 * 1024))) {
390
	if (!(_cache.mem = pool_create(10 * 1024))) {
391
		stack;
391
		STACK;
392
		return 0;
392
		return 0;
393
	}
393
	}
394
394
395
	if (!(_cache.names = hash_create(128))) {
395
	if (!(_cache.names = hash_create(128))) {
396
		stack;
396
		STACK;
397
		pool_destroy(_cache.mem);
397
		pool_destroy(_cache.mem);
398
		_cache.mem = 0;
398
		_cache.mem = 0;
399
		return 0;
399
		return 0;
Lines 404-410 Link Here
404
		goto bad;
404
		goto bad;
405
	}
405
	}
406
406
407
	list_init(&_cache.dirs);
407
	lvm_list_init(&_cache.dirs);
408
408
409
	return 1;
409
	return 1;
410
410
Lines 441-447 Link Here
441
441
442
	_cache.devices = NULL;
442
	_cache.devices = NULL;
443
	_cache.has_scanned = 0;
443
	_cache.has_scanned = 0;
444
	list_init(&_cache.dirs);
444
	lvm_list_init(&_cache.dirs);
445
}
445
}
446
446
447
int dev_cache_add_dir(const char *path)
447
int dev_cache_add_dir(const char *path)
Lines 466-472 Link Here
466
	}
466
	}
467
467
468
	strcpy(dl->dir, path);
468
	strcpy(dl->dir, path);
469
	list_add(&_cache.dirs, &dl->list);
469
	lvm_list_add(&_cache.dirs, &dl->list);
470
	return 1;
470
	return 1;
471
}
471
}
472
472
Lines 480-486 Link Here
480
	const char *name;
480
	const char *name;
481
	int r;
481
	int r;
482
482
483
	while ((r = stat(name = list_item(dev->aliases.n,
483
	while ((r = stat(name = lvm_list_item(dev->aliases.n,
484
					  struct str_list)->str, &buf)) ||
484
					  struct str_list)->str, &buf)) ||
485
	       (buf.st_rdev != dev->dev)) {
485
	       (buf.st_rdev != dev->dev)) {
486
		if (r < 0) {
486
		if (r < 0) {
Lines 504-511 Link Here
504
		/* Leave list alone if there isn't an alternative name */
504
		/* Leave list alone if there isn't an alternative name */
505
		/* so dev_name will always find something to return. */
505
		/* so dev_name will always find something to return. */
506
		/* Otherwise add the name to the correct device. */
506
		/* Otherwise add the name to the correct device. */
507
		if (list_size(&dev->aliases) > 1) {
507
		if (lvm_list_size(&dev->aliases) > 1) {
508
			list_del(dev->aliases.n);
508
			lvm_list_del(dev->aliases.n);
509
			if (!r)
509
			if (!r)
510
				_insert(name, 0);
510
				_insert(name, 0);
511
			continue;
511
			continue;
(-)LVM2.2.00.15.orig/lib/device/dev-io.c (-11 / +11 lines)
Lines 157-163 Link Here
157
157
158
	if (!(where->dev->flags & DEV_REGULAR) &&
158
	if (!(where->dev->flags & DEV_REGULAR) &&
159
	    !_get_block_size(where->dev, &block_size)) {
159
	    !_get_block_size(where->dev, &block_size)) {
160
		stack;
160
		STACK;
161
		return 0;
161
		return 0;
162
	}
162
	}
163
163
Lines 187-193 Link Here
187
	/* channel the io through the bounce buffer */
187
	/* channel the io through the bounce buffer */
188
	if (!_io(&widened, bounce, 0)) {
188
	if (!_io(&widened, bounce, 0)) {
189
		if (!should_write) {
189
		if (!should_write) {
190
			stack;
190
			STACK;
191
			return 0;
191
			return 0;
192
		}
192
		}
193
		/* FIXME pre-extend the file */
193
		/* FIXME pre-extend the file */
Lines 285-291 Link Here
285
	if (dev->flags & DEV_REGULAR)
285
	if (dev->flags & DEV_REGULAR)
286
		name = dev_name(dev);
286
		name = dev_name(dev);
287
	else if (!(name = dev_name_confirmed(dev, quiet))) {
287
	else if (!(name = dev_name_confirmed(dev, quiet))) {
288
		stack;
288
		STACK;
289
		return 0;
289
		return 0;
290
	}
290
	}
291
291
Lines 325-331 Link Here
325
		dev->end = lseek(dev->fd, (off_t) 0, SEEK_END);
325
		dev->end = lseek(dev->fd, (off_t) 0, SEEK_END);
326
	}
326
	}
327
327
328
	list_add(&_open_devices, &dev->open_list);
328
	lvm_list_add(&_open_devices, &dev->open_list);
329
	log_debug("Opened %s", dev_name(dev));
329
	log_debug("Opened %s", dev_name(dev));
330
330
331
	return 1;
331
	return 1;
Lines 354-365 Link Here
354
	if (close(dev->fd))
354
	if (close(dev->fd))
355
		log_sys_error("close", dev_name(dev));
355
		log_sys_error("close", dev_name(dev));
356
	dev->fd = -1;
356
	dev->fd = -1;
357
	list_del(&dev->open_list);
357
	lvm_list_del(&dev->open_list);
358
358
359
	log_debug("Closed %s", dev_name(dev));
359
	log_debug("Closed %s", dev_name(dev));
360
360
361
	if (dev->flags & DEV_ALLOCED) {
361
	if (dev->flags & DEV_ALLOCED) {
362
		dbg_free((void *) list_item(dev->aliases.n, struct str_list)->
362
		dbg_free((void *) lvm_list_item(dev->aliases.n, struct str_list)->
363
			 str);
363
			 str);
364
		dbg_free(dev->aliases.n);
364
		dbg_free(dev->aliases.n);
365
		dbg_free(dev);
365
		dbg_free(dev);
Lines 398-408 Link Here
398
398
399
void dev_close_all(void)
399
void dev_close_all(void)
400
{
400
{
401
	struct list *doh, *doht;
401
	struct lvm_list *doh, *doht;
402
	struct device *dev;
402
	struct device *dev;
403
403
404
	list_iterate_safe(doh, doht, &_open_devices) {
404
	lvm_list_iterate_safe(doh, doht, &_open_devices) {
405
		dev = list_struct_base(doh, struct device, open_list);
405
		dev = lvm_list_struct_base(doh, struct device, open_list);
406
		if (dev->open_count < 1)
406
		if (dev->open_count < 1)
407
			_close(dev);
407
			_close(dev);
408
	}
408
	}
Lines 465-471 Link Here
465
	char buffer[4096];
465
	char buffer[4096];
466
466
467
	if (!dev_open(dev)) {
467
	if (!dev_open(dev)) {
468
		stack;
468
		STACK;
469
		return 0;
469
		return 0;
470
	}
470
	}
471
471
Lines 493-499 Link Here
493
	dev->flags |= DEV_ACCESSED_W;
493
	dev->flags |= DEV_ACCESSED_W;
494
494
495
	if (!dev_close(dev))
495
	if (!dev_close(dev))
496
		stack;
496
		STACK;
497
497
498
	/* FIXME: Always display error */
498
	/* FIXME: Always display error */
499
	return (len == 0);
499
	return (len == 0);
(-)LVM2.2.00.15.orig/lib/device/device.h (-4 / +4 lines)
Lines 28-34 Link Here
28
 * pointer comparisons are valid.
28
 * pointer comparisons are valid.
29
 */
29
 */
30
struct device {
30
struct device {
31
	struct list aliases;	/* struct str_list from lvm-types.h */
31
	struct lvm_list aliases;	/* struct str_list from lvm-types.h */
32
	dev_t dev;
32
	dev_t dev;
33
33
34
	/* private */
34
	/* private */
Lines 36-48 Link Here
36
	int open_count;
36
	int open_count;
37
	uint32_t flags;
37
	uint32_t flags;
38
	uint64_t end;
38
	uint64_t end;
39
	struct list open_list;
39
	struct lvm_list open_list;
40
40
41
	char pvid[ID_LEN + 1];
41
	char pvid[ID_LEN + 1];
42
};
42
};
43
43
44
struct device_list {
44
struct device_list {
45
	struct list list;
45
	struct lvm_list list;
46
	struct device *dev;
46
	struct device *dev;
47
};
47
};
48
48
Lines 82-88 Link Here
82
82
83
static inline const char *dev_name(const struct device *dev)
83
static inline const char *dev_name(const struct device *dev)
84
{
84
{
85
	return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
85
	return (dev) ? lvm_list_item(dev->aliases.n, struct str_list)->str :
86
	    "unknown device";
86
	    "unknown device";
87
}
87
}
88
88
(-)LVM2.2.00.15.orig/lib/display/display.c (-16 / +16 lines)
Lines 224-230 Link Here
224
		return;
224
		return;
225
225
226
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
226
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
227
		stack;
227
		STACK;
228
		return;
228
		return;
229
	}
229
	}
230
230
Lines 255-261 Link Here
255
		return;
255
		return;
256
256
257
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
257
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
258
		stack;
258
		STACK;
259
		return;
259
		return;
260
	}
260
	}
261
261
Lines 313-319 Link Here
313
		return 0;
313
		return 0;
314
314
315
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
315
	if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
316
		stack;
316
		STACK;
317
		return 0;
317
		return 0;
318
	}
318
	}
319
319
Lines 356-366 Link Here
356
	int inkernel, snap_active;
356
	int inkernel, snap_active;
357
	char uuid[64];
357
	char uuid[64];
358
	struct snapshot *snap = NULL;
358
	struct snapshot *snap = NULL;
359
	struct list *slh, *snaplist;
359
	struct lvm_list *slh, *snaplist;
360
	float snap_percent;	/* fused, fsize; */
360
	float snap_percent;	/* fused, fsize; */
361
361
362
	if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
362
	if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
363
		stack;
363
		STACK;
364
		return 0;
364
		return 0;
365
	}
365
	}
366
366
Lines 381-388 Link Here
381
		log_print("LV snapshot status     source of");
381
		log_print("LV snapshot status     source of");
382
382
383
		snaplist = find_snapshots(lv);
383
		snaplist = find_snapshots(lv);
384
		list_iterate(slh, snaplist) {
384
		lvm_list_iterate(slh, snaplist) {
385
			snap = list_item(slh, struct snapshot_list)->snapshot;
385
			snap = lvm_list_item(slh, struct snapshot_list)->snapshot;
386
			snap_active = lv_snapshot_percent(snap->cow,
386
			snap_active = lv_snapshot_percent(snap->cow,
387
							  &snap_percent);
387
							  &snap_percent);
388
			if (!snap_active || snap_percent < 0 ||
388
			if (!snap_active || snap_percent < 0 ||
Lines 429-435 Link Here
429
    log_print("Allocated LE           %u", lv->allocated_le);
429
    log_print("Allocated LE           %u", lv->allocated_le);
430
**********/
430
**********/
431
431
432
	log_print("Segments               %u", list_size(&lv->segments));
432
	log_print("Segments               %u", lvm_list_size(&lv->segments));
433
433
434
/********* FIXME Stripes & stripesize for each segment
434
/********* FIXME Stripes & stripesize for each segment
435
	log_print("Stripe size (KByte)    %u", lv->stripesize / 2);
435
	log_print("Stripe size (KByte)    %u", lv->stripesize / 2);
Lines 507-519 Link Here
507
int lvdisplay_segments(struct logical_volume *lv)
507
int lvdisplay_segments(struct logical_volume *lv)
508
{
508
{
509
	uint32_t s;
509
	uint32_t s;
510
	struct list *segh;
510
	struct lvm_list *segh;
511
	struct lv_segment *seg;
511
	struct lv_segment *seg;
512
512
513
	log_print("--- Segments ---");
513
	log_print("--- Segments ---");
514
514
515
	list_iterate(segh, &lv->segments) {
515
	lvm_list_iterate(segh, &lv->segments) {
516
		seg = list_item(segh, struct lv_segment);
516
		seg = lvm_list_item(segh, struct lv_segment);
517
517
518
		log_print("Logical extent %u to %u:",
518
		log_print("Logical extent %u to %u:",
519
			  seg->le, seg->le + seg->len - 1);
519
			  seg->le, seg->le + seg->len - 1);
Lines 570-576 Link Here
570
	char uuid[64];
570
	char uuid[64];
571
571
572
	if (vg->status & PARTIAL_VG)
572
	if (vg->status & PARTIAL_VG)
573
		active_pvs = list_size(&vg->pvs);
573
		active_pvs = lvm_list_size(&vg->pvs);
574
	else
574
	else
575
		active_pvs = vg->pv_count;
575
		active_pvs = vg->pv_count;
576
576
Lines 580-586 Link Here
580
	log_print("Format                %s", vg->fid->fmt->name);
580
	log_print("Format                %s", vg->fid->fmt->name);
581
	if (vg->fid->fmt->features & FMT_MDAS) {
581
	if (vg->fid->fmt->features & FMT_MDAS) {
582
		log_print("Metadata Areas        %d",
582
		log_print("Metadata Areas        %d",
583
			  list_size(&vg->fid->metadata_areas));
583
			  lvm_list_size(&vg->fid->metadata_areas));
584
		log_print("Metadata Sequence No  %d", vg->seqno);
584
		log_print("Metadata Sequence No  %d", vg->seqno);
585
	}
585
	}
586
	access = vg->status & (LVM_READ | LVM_WRITE);
586
	access = vg->status & (LVM_READ | LVM_WRITE);
Lines 642-648 Link Here
642
							    2), SIZE_SHORT));
642
							    2), SIZE_SHORT));
643
643
644
	if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
644
	if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
645
		stack;
645
		STACK;
646
		return;
646
		return;
647
	}
647
	}
648
648
Lines 659-665 Link Here
659
	char uuid[64];
659
	char uuid[64];
660
660
661
	if (vg->status & PARTIAL_VG)
661
	if (vg->status & PARTIAL_VG)
662
		active_pvs = list_size(&vg->pvs);
662
		active_pvs = lvm_list_size(&vg->pvs);
663
	else
663
	else
664
		active_pvs = vg->pv_count;
664
		active_pvs = vg->pv_count;
665
665
Lines 678-684 Link Here
678
	}
678
	}
679
679
680
	if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
680
	if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
681
		stack;
681
		STACK;
682
		return;
682
		return;
683
	}
683
	}
684
684
(-)LVM2.2.00.15.orig/lib/filters/filter-composite.c (-1 / +1 lines)
Lines 51-57 Link Here
51
	struct dev_filter **filters_copy, *cf;
51
	struct dev_filter **filters_copy, *cf;
52
52
53
	if (!filters) {
53
	if (!filters) {
54
		stack;
54
		STACK;
55
		return NULL;
55
		return NULL;
56
	}
56
	}
57
57
(-)LVM2.2.00.15.orig/lib/filters/filter-md.c (-4 / +4 lines)
Lines 32-38 Link Here
32
	uint32_t md_magic;
32
	uint32_t md_magic;
33
33
34
	if (!dev_get_size(dev, &size)) {
34
	if (!dev_get_size(dev, &size)) {
35
		stack;
35
		STACK;
36
		return 0;
36
		return 0;
37
	}
37
	}
38
38
Lines 44-50 Link Here
44
		return 1;
44
		return 1;
45
45
46
	if (!dev_open(dev)) {
46
	if (!dev_open(dev)) {
47
		stack;
47
		STACK;
48
		return 0;
48
		return 0;
49
	}
49
	}
50
50
Lines 56-68 Link Here
56
			log_debug("%s: Skipping md component device",
56
			log_debug("%s: Skipping md component device",
57
				  dev_name(dev));
57
				  dev_name(dev));
58
			if (!dev_close(dev))
58
			if (!dev_close(dev))
59
				stack;
59
				STACK;
60
			return 0;
60
			return 0;
61
		}
61
		}
62
	}
62
	}
63
63
64
	if (!dev_close(dev))
64
	if (!dev_close(dev))
65
		stack;
65
		STACK;
66
66
67
	return 1;
67
	return 1;
68
}
68
}
(-)LVM2.2.00.15.orig/lib/filters/filter-persistent.c (-9 / +9 lines)
Lines 42-48 Link Here
42
		hash_destroy(pf->devices);
42
		hash_destroy(pf->devices);
43
43
44
	if (!(pf->devices = hash_create(128))) {
44
	if (!(pf->devices = hash_create(128))) {
45
		stack;
45
		STACK;
46
		return 0;
46
		return 0;
47
	}
47
	}
48
48
Lines 100-111 Link Here
100
	struct config_tree *cft;
100
	struct config_tree *cft;
101
101
102
	if (!(cft = create_config_tree())) {
102
	if (!(cft = create_config_tree())) {
103
		stack;
103
		STACK;
104
		return 0;
104
		return 0;
105
	}
105
	}
106
106
107
	if (!read_config_file(cft, pf->file)) {
107
	if (!read_config_file(cft, pf->file)) {
108
		stack;
108
		STACK;
109
		goto out;
109
		goto out;
110
	}
110
	}
111
111
Lines 202-215 Link Here
202
	struct pfilter *pf = (struct pfilter *) f->private;
202
	struct pfilter *pf = (struct pfilter *) f->private;
203
	void *l = hash_lookup(pf->devices, dev_name(dev));
203
	void *l = hash_lookup(pf->devices, dev_name(dev));
204
	struct str_list *sl;
204
	struct str_list *sl;
205
	struct list *ah;
205
	struct lvm_list *ah;
206
206
207
	if (!l) {
207
	if (!l) {
208
		l = pf->real->passes_filter(pf->real, dev) ?
208
		l = pf->real->passes_filter(pf->real, dev) ?
209
		    PF_GOOD_DEVICE : PF_BAD_DEVICE;
209
		    PF_GOOD_DEVICE : PF_BAD_DEVICE;
210
210
211
		list_iterate(ah, &dev->aliases) {
211
		lvm_list_iterate(ah, &dev->aliases) {
212
			sl = list_item(ah, struct str_list);
212
			sl = lvm_list_item(ah, struct str_list);
213
			hash_insert(pf->devices, sl->str, l);
213
			hash_insert(pf->devices, sl->str, l);
214
		}
214
		}
215
	}
215
	}
Lines 239-251 Link Here
239
	struct dev_filter *f = NULL;
239
	struct dev_filter *f = NULL;
240
240
241
	if (!(pf = dbg_malloc(sizeof(*pf)))) {
241
	if (!(pf = dbg_malloc(sizeof(*pf)))) {
242
		stack;
242
		STACK;
243
		return NULL;
243
		return NULL;
244
	}
244
	}
245
	memset(pf, 0, sizeof(*pf));
245
	memset(pf, 0, sizeof(*pf));
246
246
247
	if (!(pf->file = dbg_malloc(strlen(file) + 1))) {
247
	if (!(pf->file = dbg_malloc(strlen(file) + 1))) {
248
		stack;
248
		STACK;
249
		goto bad;
249
		goto bad;
250
	}
250
	}
251
	strcpy(pf->file, file);
251
	strcpy(pf->file, file);
Lines 257-263 Link Here
257
	}
257
	}
258
258
259
	if (!(f = dbg_malloc(sizeof(*f)))) {
259
	if (!(f = dbg_malloc(sizeof(*f)))) {
260
		stack;
260
		STACK;
261
		goto bad;
261
		goto bad;
262
	}
262
	}
263
263
(-)LVM2.2.00.15.orig/lib/filters/filter-regex.c (-13 / +13 lines)
Lines 75-81 Link Here
75
	 * copy the regex
75
	 * copy the regex
76
	 */
76
	 */
77
	if (!(r = pool_strdup(mem, pat))) {
77
	if (!(r = pool_strdup(mem, pat))) {
78
		stack;
78
		STACK;
79
		return 0;
79
		return 0;
80
	}
80
	}
81
81
Lines 102-108 Link Here
102
	int i, r = 0;
102
	int i, r = 0;
103
103
104
	if (!(scratch = pool_create(1024))) {
104
	if (!(scratch = pool_create(1024))) {
105
		stack;
105
		STACK;
106
		return 0;
106
		return 0;
107
	}
107
	}
108
108
Lines 123-129 Link Here
123
	 * allocate space for them
123
	 * allocate space for them
124
	 */
124
	 */
125
	if (!(regex = pool_alloc(scratch, sizeof(*regex) * count))) {
125
	if (!(regex = pool_alloc(scratch, sizeof(*regex) * count))) {
126
		stack;
126
		STACK;
127
		goto out;
127
		goto out;
128
	}
128
	}
129
129
Lines 148-154 Link Here
148
	 */
148
	 */
149
	if (!(rf->engine = matcher_create(rf->mem, (const char **) regex,
149
	if (!(rf->engine = matcher_create(rf->mem, (const char **) regex,
150
					  count)))
150
					  count)))
151
		stack;
151
		STACK;
152
	r = 1;
152
	r = 1;
153
153
154
      out:
154
      out:
Lines 158-170 Link Here
158
158
159
static int _accept_p(struct dev_filter *f, struct device *dev)
159
static int _accept_p(struct dev_filter *f, struct device *dev)
160
{
160
{
161
	struct list *ah;
161
	struct lvm_list *ah;
162
	int m, first = 1, rejected = 0;
162
	int m, first = 1, rejected = 0;
163
	struct rfilter *rf = (struct rfilter *) f->private;
163
	struct rfilter *rf = (struct rfilter *) f->private;
164
	struct str_list *sl;
164
	struct str_list *sl;
165
165
166
	list_iterate(ah, &dev->aliases) {
166
	lvm_list_iterate(ah, &dev->aliases) {
167
		sl = list_item(ah, struct str_list);
167
		sl = lvm_list_item(ah, struct str_list);
168
		m = matcher_run(rf->engine, sl->str);
168
		m = matcher_run(rf->engine, sl->str);
169
169
170
		if (m >= 0) {
170
		if (m >= 0) {
Lines 173-180 Link Here
173
				if (!first) {
173
				if (!first) {
174
					log_debug("%s: New preferred name",
174
					log_debug("%s: New preferred name",
175
						  sl->str);
175
						  sl->str);
176
					list_del(&sl->list);
176
					lvm_list_del(&sl->list);
177
					list_add_h(&dev->aliases, &sl->list);
177
					lvm_list_add_h(&dev->aliases, &sl->list);
178
				}
178
				}
179
179
180
				return 1;
180
				return 1;
Lines 206-229 Link Here
206
	struct dev_filter *f;
206
	struct dev_filter *f;
207
207
208
	if (!mem) {
208
	if (!mem) {
209
		stack;
209
		STACK;
210
		return NULL;
210
		return NULL;
211
	}
211
	}
212
212
213
	if (!(rf = pool_alloc(mem, sizeof(*rf)))) {
213
	if (!(rf = pool_alloc(mem, sizeof(*rf)))) {
214
		stack;
214
		STACK;
215
		goto bad;
215
		goto bad;
216
	}
216
	}
217
217
218
	rf->mem = mem;
218
	rf->mem = mem;
219
219
220
	if (!_build_matcher(rf, patterns)) {
220
	if (!_build_matcher(rf, patterns)) {
221
		stack;
221
		STACK;
222
		goto bad;
222
		goto bad;
223
	}
223
	}
224
224
225
	if (!(f = pool_zalloc(mem, sizeof(*f)))) {
225
	if (!(f = pool_zalloc(mem, sizeof(*f)))) {
226
		stack;
226
		STACK;
227
		goto bad;
227
		goto bad;
228
	}
228
	}
229
229
(-)LVM2.2.00.15.orig/lib/filters/filter-sysfs.c (-1 / +1 lines)
Lines 264-270 Link Here
264
	}
264
	}
265
265
266
	if (!(f = pool_zalloc(mem, sizeof(*f)))) {
266
	if (!(f = pool_zalloc(mem, sizeof(*f)))) {
267
		stack;
267
		STACK;
268
		goto bad;
268
		goto bad;
269
	}
269
	}
270
270
(-)LVM2.2.00.15.orig/lib/filters/filter.c (-1 / +1 lines)
Lines 212-218 Link Here
212
	f->destroy = lvm_type_filter_destroy;
212
	f->destroy = lvm_type_filter_destroy;
213
213
214
	if (!(f->private = _scan_proc_dev(proc, cn))) {
214
	if (!(f->private = _scan_proc_dev(proc, cn))) {
215
		stack;
215
		STACK;
216
		return NULL;
216
		return NULL;
217
	}
217
	}
218
218
(-)LVM2.2.00.15.orig/lib/format1/disk-rep.c (-36 / +36 lines)
Lines 22-28 Link Here
22
22
23
#include <fcntl.h>
23
#include <fcntl.h>
24
24
25
#define fail do {stack; return 0;} while(0)
25
#define fail do {STACK; return 0;} while(0)
26
#define xx16(v) disk->v = xlate16(disk->v)
26
#define xx16(v) disk->v = xlate16(disk->v)
27
#define xx32(v) disk->v = xlate32(disk->v)
27
#define xx32(v) disk->v = xlate32(disk->v)
28
#define xx64(v) disk->v = xlate64(disk->v)
28
#define xx64(v) disk->v = xlate64(disk->v)
Lines 210-216 Link Here
210
		memcpy(ul->uuid, buffer, NAME_LEN);
210
		memcpy(ul->uuid, buffer, NAME_LEN);
211
		ul->uuid[NAME_LEN - 1] = '\0';
211
		ul->uuid[NAME_LEN - 1] = '\0';
212
212
213
		list_add(&data->uuids, &ul->list);
213
		lvm_list_add(&data->uuids, &ul->list);
214
214
215
		pos += NAME_LEN;
215
		pos += NAME_LEN;
216
		num_read++;
216
		num_read++;
Lines 245-251 Link Here
245
			continue;
245
			continue;
246
246
247
		read++;
247
		read++;
248
		list_add(&data->lvds, &ll->list);
248
		lvm_list_add(&data->lvds, &ll->list);
249
	}
249
	}
250
250
251
	return 1;
251
	return 1;
Lines 298-314 Link Here
298
	struct lvmcache_info *info;
298
	struct lvmcache_info *info;
299
299
300
	if (!dl) {
300
	if (!dl) {
301
		stack;
301
		STACK;
302
		return NULL;
302
		return NULL;
303
	}
303
	}
304
304
305
	dl->dev = dev;
305
	dl->dev = dev;
306
	dl->mem = mem;
306
	dl->mem = mem;
307
	list_init(&dl->uuids);
307
	lvm_list_init(&dl->uuids);
308
	list_init(&dl->lvds);
308
	lvm_list_init(&dl->lvds);
309
309
310
	if (!_read_pvd(dev, &dl->pvd)) {
310
	if (!_read_pvd(dev, &dl->pvd)) {
311
		stack;
311
		STACK;
312
		goto bad;
312
		goto bad;
313
	}
313
	}
314
314
Lines 317-326 Link Here
317
317
318
	if (!(info = lvmcache_add(fmt->labeller, dl->pvd.pv_uuid, dev,
318
	if (!(info = lvmcache_add(fmt->labeller, dl->pvd.pv_uuid, dev,
319
				  dl->pvd.vg_name, NULL)))
319
				  dl->pvd.vg_name, NULL)))
320
		stack;
320
		STACK;
321
	else {
321
	else {
322
		info->device_size = xlate32(dl->pvd.pv_size) << SECTOR_SHIFT;
322
		info->device_size = xlate32(dl->pvd.pv_size) << SECTOR_SHIFT;
323
		list_init(&info->mdas);
323
		lvm_list_init(&info->mdas);
324
		info->status &= ~CACHE_INVALID;
324
		info->status &= ~CACHE_INVALID;
325
	}
325
	}
326
326
Lines 382-406 Link Here
382
	struct disk_list *r;
382
	struct disk_list *r;
383
383
384
	if (!dev_open(dev)) {
384
	if (!dev_open(dev)) {
385
		stack;
385
		STACK;
386
		return NULL;
386
		return NULL;
387
	}
387
	}
388
388
389
	r = __read_disk(fmt, dev, mem, vg_name);
389
	r = __read_disk(fmt, dev, mem, vg_name);
390
390
391
	if (!dev_close(dev))
391
	if (!dev_close(dev))
392
		stack;
392
		STACK;
393
393
394
	return r;
394
	return r;
395
}
395
}
396
396
397
static void _add_pv_to_list(struct list *head, struct disk_list *data)
397
static void _add_pv_to_list(struct lvm_list *head, struct disk_list *data)
398
{
398
{
399
	struct list *pvdh;
399
	struct lvm_list *pvdh;
400
	struct pv_disk *pvd;
400
	struct pv_disk *pvd;
401
401
402
	list_iterate(pvdh, head) {
402
	lvm_list_iterate(pvdh, head) {
403
		pvd = &list_item(pvdh, struct disk_list)->pvd;
403
		pvd = &lvm_list_item(pvdh, struct disk_list)->pvd;
404
		if (!strncmp(data->pvd.pv_uuid, pvd->pv_uuid,
404
		if (!strncmp(data->pvd.pv_uuid, pvd->pv_uuid,
405
			     sizeof(pvd->pv_uuid))) {
405
			     sizeof(pvd->pv_uuid))) {
406
			if (MAJOR(data->dev->dev) != md_major()) {
406
			if (MAJOR(data->dev->dev) != md_major()) {
Lines 411-421 Link Here
411
			}
411
			}
412
			log_very_verbose("Duplicate PV %s - using md %s",
412
			log_very_verbose("Duplicate PV %s - using md %s",
413
					 pvd->pv_uuid, dev_name(data->dev));
413
					 pvd->pv_uuid, dev_name(data->dev));
414
			list_del(pvdh);
414
			lvm_list_del(pvdh);
415
			break;
415
			break;
416
		}
416
		}
417
	}
417
	}
418
	list_add(head, &data->list);
418
	lvm_list_add(head, &data->list);
419
}
419
}
420
420
421
/*
421
/*
Lines 425-443 Link Here
425
 */
425
 */
426
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
426
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
427
		   struct dev_filter *filter, struct pool *mem,
427
		   struct dev_filter *filter, struct pool *mem,
428
		   struct list *head)
428
		   struct lvm_list *head)
429
{
429
{
430
	struct dev_iter *iter;
430
	struct dev_iter *iter;
431
	struct device *dev;
431
	struct device *dev;
432
	struct disk_list *data = NULL;
432
	struct disk_list *data = NULL;
433
	struct list *vgih;
433
	struct lvm_list *vgih;
434
	struct lvmcache_vginfo *vginfo;
434
	struct lvmcache_vginfo *vginfo;
435
435
436
	/* Fast path if we already saw this VG and cached the list of PVs */
436
	/* Fast path if we already saw this VG and cached the list of PVs */
437
	if (vg_name && (vginfo = vginfo_from_vgname(vg_name)) &&
437
	if (vg_name && (vginfo = vginfo_from_vgname(vg_name)) &&
438
	    vginfo->infos.n) {
438
	    vginfo->infos.n) {
439
		list_iterate(vgih, &vginfo->infos) {
439
		lvm_list_iterate(vgih, &vginfo->infos) {
440
			dev = list_item(vgih, struct lvmcache_info)->dev;
440
			dev = lvm_list_item(vgih, struct lvmcache_info)->dev;
441
			if (dev && !(data = read_disk(fmt, dev, mem, vg_name)))
441
			if (dev && !(data = read_disk(fmt, dev, mem, vg_name)))
442
				break;
442
				break;
443
			_add_pv_to_list(head, data);
443
			_add_pv_to_list(head, data);
Lines 446-456 Link Here
446
		/* Did we find the whole VG? */
446
		/* Did we find the whole VG? */
447
		if (!vg_name || !*vg_name ||
447
		if (!vg_name || !*vg_name ||
448
		    (data && *data->pvd.vg_name &&
448
		    (data && *data->pvd.vg_name &&
449
		     list_size(head) == data->vgd.pv_cur))
449
		     lvm_list_size(head) == data->vgd.pv_cur))
450
			return 1;
450
			return 1;
451
451
452
		/* Failed */
452
		/* Failed */
453
		list_init(head);
453
		lvm_list_init(head);
454
		/* vgcache_del(vg_name); */
454
		/* vgcache_del(vg_name); */
455
	}
455
	}
456
456
Lines 467-473 Link Here
467
	}
467
	}
468
	dev_iter_destroy(iter);
468
	dev_iter_destroy(iter);
469
469
470
	if (list_empty(head))
470
	if (lvm_list_empty(head))
471
		return 0;
471
		return 0;
472
472
473
	return 1;
473
	return 1;
Lines 490-507 Link Here
490
static int _write_uuids(struct disk_list *data)
490
static int _write_uuids(struct disk_list *data)
491
{
491
{
492
	struct uuid_list *ul;
492
	struct uuid_list *ul;
493
	struct list *uh;
493
	struct lvm_list *uh;
494
	uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
494
	uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
495
	uint64_t end = pos + data->pvd.pv_uuidlist_on_disk.size;
495
	uint64_t end = pos + data->pvd.pv_uuidlist_on_disk.size;
496
496
497
	list_iterate(uh, &data->uuids) {
497
	lvm_list_iterate(uh, &data->uuids) {
498
		if (pos >= end) {
498
		if (pos >= end) {
499
			log_error("Too many uuids to fit on %s",
499
			log_error("Too many uuids to fit on %s",
500
				  dev_name(data->dev));
500
				  dev_name(data->dev));
501
			return 0;
501
			return 0;
502
		}
502
		}
503
503
504
		ul = list_item(uh, struct uuid_list);
504
		ul = lvm_list_item(uh, struct uuid_list);
505
		if (!dev_write(data->dev, pos, NAME_LEN, ul->uuid))
505
		if (!dev_write(data->dev, pos, NAME_LEN, ul->uuid))
506
			fail;
506
			fail;
507
507
Lines 524-530 Link Here
524
524
525
static int _write_lvs(struct disk_list *data)
525
static int _write_lvs(struct disk_list *data)
526
{
526
{
527
	struct list *lvh;
527
	struct lvm_list *lvh;
528
	uint64_t pos, offset;
528
	uint64_t pos, offset;
529
529
530
	pos = data->pvd.lv_on_disk.base;
530
	pos = data->pvd.lv_on_disk.base;
Lines 535-542 Link Here
535
		return 0;
535
		return 0;
536
	}
536
	}
537
537
538
	list_iterate(lvh, &data->lvds) {
538
	lvm_list_iterate(lvh, &data->lvds) {
539
		struct lvd_list *ll = list_item(lvh, struct lvd_list);
539
		struct lvd_list *ll = lvm_list_item(lvh, struct lvd_list);
540
540
541
		offset = sizeof(struct lv_disk) * ll->lvd.lv_number;
541
		offset = sizeof(struct lv_disk) * ll->lvd.lv_number;
542
		if (offset + sizeof(struct lv_disk) > data->pvd.lv_on_disk.size) {
542
		if (offset + sizeof(struct lv_disk) > data->pvd.lv_on_disk.size) {
Lines 657-670 Link Here
657
	int r;
657
	int r;
658
658
659
	if (!dev_open(data->dev)) {
659
	if (!dev_open(data->dev)) {
660
		stack;
660
		STACK;
661
		return 0;
661
		return 0;
662
	}
662
	}
663
663
664
	r = __write_all_pvd(fmt, data);
664
	r = __write_all_pvd(fmt, data);
665
665
666
	if (!dev_close(data->dev))
666
	if (!dev_close(data->dev))
667
		stack;
667
		STACK;
668
668
669
	return r;
669
	return r;
670
}
670
}
Lines 674-686 Link Here
674
 * little sanity checking, so make sure correct
674
 * little sanity checking, so make sure correct
675
 * data is passed to here.
675
 * data is passed to here.
676
 */
676
 */
677
int write_disks(const struct format_type *fmt, struct list *pvs)
677
int write_disks(const struct format_type *fmt, struct lvm_list *pvs)
678
{
678
{
679
	struct list *pvh;
679
	struct lvm_list *pvh;
680
	struct disk_list *dl;
680
	struct disk_list *dl;
681
681
682
	list_iterate(pvh, pvs) {
682
	lvm_list_iterate(pvh, pvs) {
683
		dl = list_item(pvh, struct disk_list);
683
		dl = lvm_list_item(pvh, struct disk_list);
684
		if (!(_write_all_pvd(fmt, dl)))
684
		if (!(_write_all_pvd(fmt, dl)))
685
			fail;
685
			fail;
686
686
(-)LVM2.2.00.15.orig/lib/format1/disk-rep.h (-14 / +14 lines)
Lines 148-171 Link Here
148
} __attribute__ ((packed));
148
} __attribute__ ((packed));
149
149
150
struct uuid_list {
150
struct uuid_list {
151
	struct list list;
151
	struct lvm_list list;
152
	char uuid[NAME_LEN];
152
	char uuid[NAME_LEN];
153
};
153
};
154
154
155
struct lvd_list {
155
struct lvd_list {
156
	struct list list;
156
	struct lvm_list list;
157
	struct lv_disk lvd;
157
	struct lv_disk lvd;
158
};
158
};
159
159
160
struct disk_list {
160
struct disk_list {
161
	struct list list;
161
	struct lvm_list list;
162
	struct pool *mem;
162
	struct pool *mem;
163
	struct device *dev;
163
	struct device *dev;
164
164
165
	struct pv_disk pvd;
165
	struct pv_disk pvd;
166
	struct vg_disk vgd;
166
	struct vg_disk vgd;
167
	struct list uuids;
167
	struct lvm_list uuids;
168
	struct list lvds;
168
	struct lvm_list lvds;
169
	struct pe_disk *extents;
169
	struct pe_disk *extents;
170
};
170
};
171
171
Lines 195-203 Link Here
195
195
196
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
196
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
197
		   struct dev_filter *filter,
197
		   struct dev_filter *filter,
198
		   struct pool *mem, struct list *results);
198
		   struct pool *mem, struct lvm_list *results);
199
199
200
int write_disks(const struct format_type *fmt, struct list *pvds);
200
int write_disks(const struct format_type *fmt, struct lvm_list *pvds);
201
201
202
/*
202
/*
203
 * Functions to translate to between disk and in
203
 * Functions to translate to between disk and in
Lines 217-248 Link Here
217
int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd);
217
int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd);
218
218
219
int import_extents(struct pool *mem, struct volume_group *vg,
219
int import_extents(struct pool *mem, struct volume_group *vg,
220
		   struct list *pvds);
220
		   struct lvm_list *pvds);
221
int export_extents(struct disk_list *dl, uint32_t lv_num,
221
int export_extents(struct disk_list *dl, uint32_t lv_num,
222
		   struct logical_volume *lv, struct physical_volume *pv);
222
		   struct logical_volume *lv, struct physical_volume *pv);
223
223
224
int import_pvs(const struct format_type *fmt, struct pool *mem,
224
int import_pvs(const struct format_type *fmt, struct pool *mem,
225
	       struct volume_group *vg,
225
	       struct volume_group *vg,
226
	       struct list *pvds, struct list *results, int *count);
226
	       struct lvm_list *pvds, struct lvm_list *results, int *count);
227
227
228
int import_lvs(struct pool *mem, struct volume_group *vg, struct list *pvds);
228
int import_lvs(struct pool *mem, struct volume_group *vg, struct lvm_list *pvds);
229
int export_lvs(struct disk_list *dl, struct volume_group *vg,
229
int export_lvs(struct disk_list *dl, struct volume_group *vg,
230
	       struct physical_volume *pv, const char *dev_dir);
230
	       struct physical_volume *pv, const char *dev_dir);
231
231
232
int import_snapshots(struct pool *mem, struct volume_group *vg,
232
int import_snapshots(struct pool *mem, struct volume_group *vg,
233
		     struct list *pvds);
233
		     struct lvm_list *pvds);
234
234
235
int export_uuids(struct disk_list *dl, struct volume_group *vg);
235
int export_uuids(struct disk_list *dl, struct volume_group *vg);
236
236
237
void export_numbers(struct list *pvds, struct volume_group *vg);
237
void export_numbers(struct lvm_list *pvds, struct volume_group *vg);
238
238
239
void export_pv_act(struct list *pvds);
239
void export_pv_act(struct lvm_list *pvds);
240
void munge_exported_vg(struct pv_disk *pvd);
240
void munge_exported_vg(struct pv_disk *pvd);
241
241
242
/* blech */
242
/* blech */
243
int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
243
int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
244
		       const char *candidate_vg, int *result);
244
		       const char *candidate_vg, int *result);
245
int export_vg_number(struct format_instance *fid, struct list *pvds,
245
int export_vg_number(struct format_instance *fid, struct lvm_list *pvds,
246
		     const char *vg_name, struct dev_filter *filter);
246
		     const char *vg_name, struct dev_filter *filter);
247
247
248
#endif
248
#endif
(-)LVM2.2.00.15.orig/lib/format1/format1.c (-59 / +59 lines)
Lines 28-36 Link Here
28
#define FMT_LVM1_NAME "lvm1"
28
#define FMT_LVM1_NAME "lvm1"
29
29
30
/* VG consistency checks */
30
/* VG consistency checks */
31
static int _check_vgs(struct list *pvs, int *partial)
31
static int _check_vgs(struct lvm_list *pvs, int *partial)
32
{
32
{
33
	struct list *pvh, *t;
33
	struct lvm_list *pvh, *t;
34
	struct disk_list *dl = NULL;
34
	struct disk_list *dl = NULL;
35
	struct disk_list *first = NULL;
35
	struct disk_list *first = NULL;
36
36
Lines 45-52 Link Here
45
	 * This means an active VG won't be affected if disks are inserted
45
	 * This means an active VG won't be affected if disks are inserted
46
	 * bearing an exported VG with the same name.
46
	 * bearing an exported VG with the same name.
47
	 */
47
	 */
48
	list_iterate(pvh, pvs) {
48
	lvm_list_iterate(pvh, pvs) {
49
		dl = list_item(pvh, struct disk_list);
49
		dl = lvm_list_item(pvh, struct disk_list);
50
50
51
		if (first_time) {
51
		if (first_time) {
52
			exported = dl->pvd.pv_status & VG_EXPORTED;
52
			exported = dl->pvd.pv_status & VG_EXPORTED;
Lines 56-73 Link Here
56
56
57
		if (exported != (dl->pvd.pv_status & VG_EXPORTED)) {
57
		if (exported != (dl->pvd.pv_status & VG_EXPORTED)) {
58
			/* Remove exported PVs */
58
			/* Remove exported PVs */
59
			list_iterate_safe(pvh, t, pvs) {
59
			lvm_list_iterate_safe(pvh, t, pvs) {
60
				dl = list_item(pvh, struct disk_list);
60
				dl = lvm_list_item(pvh, struct disk_list);
61
				if (dl->pvd.pv_status & VG_EXPORTED)
61
				if (dl->pvd.pv_status & VG_EXPORTED)
62
					list_del(pvh);
62
					lvm_list_del(pvh);
63
			}
63
			}
64
			break;
64
			break;
65
		}
65
		}
66
	}
66
	}
67
67
68
	/* Remove any PVs with VG structs that differ from the first */
68
	/* Remove any PVs with VG structs that differ from the first */
69
	list_iterate_safe(pvh, t, pvs) {
69
	lvm_list_iterate_safe(pvh, t, pvs) {
70
		dl = list_item(pvh, struct disk_list);
70
		dl = lvm_list_item(pvh, struct disk_list);
71
71
72
		if (!first)
72
		if (!first)
73
			first = dl;
73
			first = dl;
Lines 104-110 Link Here
104
				  dl->vgd.vgda, dl->vgd.pe_size,
104
				  dl->vgd.vgda, dl->vgd.pe_size,
105
				  dl->vgd.pe_total, dl->vgd.pe_allocated,
105
				  dl->vgd.pe_total, dl->vgd.pe_allocated,
106
				  dl->vgd.pvg_total);
106
				  dl->vgd.pvg_total);
107
			list_del(pvh);
107
			lvm_list_del(pvh);
108
			if (partial_mode()) {
108
			if (partial_mode()) {
109
				*partial = 1;
109
				*partial = 1;
110
				continue;
110
				continue;
Lines 127-133 Link Here
127
}
127
}
128
128
129
static struct volume_group *_build_vg(struct format_instance *fid,
129
static struct volume_group *_build_vg(struct format_instance *fid,
130
				      struct list *pvs)
130
				      struct lvm_list *pvs)
131
{
131
{
132
	struct pool *mem = fid->fmt->cmd->mem;
132
	struct pool *mem = fid->fmt->cmd->mem;
133
	struct volume_group *vg = pool_alloc(mem, sizeof(*vg));
133
	struct volume_group *vg = pool_alloc(mem, sizeof(*vg));
Lines 137-143 Link Here
137
	if (!vg)
137
	if (!vg)
138
		goto bad;
138
		goto bad;
139
139
140
	if (list_empty(pvs))
140
	if (lvm_list_empty(pvs))
141
		goto bad;
141
		goto bad;
142
142
143
	memset(vg, 0, sizeof(*vg));
143
	memset(vg, 0, sizeof(*vg));
Lines 145-159 Link Here
145
	vg->cmd = fid->fmt->cmd;
145
	vg->cmd = fid->fmt->cmd;
146
	vg->fid = fid;
146
	vg->fid = fid;
147
	vg->seqno = 0;
147
	vg->seqno = 0;
148
	list_init(&vg->pvs);
148
	lvm_list_init(&vg->pvs);
149
	list_init(&vg->lvs);
149
	lvm_list_init(&vg->lvs);
150
	list_init(&vg->snapshots);
150
	lvm_list_init(&vg->snapshots);
151
	list_init(&vg->tags);
151
	lvm_list_init(&vg->tags);
152
152
153
	if (!_check_vgs(pvs, &partial))
153
	if (!_check_vgs(pvs, &partial))
154
		goto bad;
154
		goto bad;
155
155
156
	dl = list_item(pvs->n, struct disk_list);
156
	dl = lvm_list_item(pvs->n, struct disk_list);
157
157
158
	if (!import_vg(mem, vg, dl, partial))
158
	if (!import_vg(mem, vg, dl, partial))
159
		goto bad;
159
		goto bad;
Lines 173-179 Link Here
173
	return vg;
173
	return vg;
174
174
175
      bad:
175
      bad:
176
	stack;
176
	STACK;
177
	pool_free(mem, vg);
177
	pool_free(mem, vg);
178
	return NULL;
178
	return NULL;
179
}
179
}
Lines 183-194 Link Here
183
				     struct metadata_area *mda)
183
				     struct metadata_area *mda)
184
{
184
{
185
	struct pool *mem = pool_create(1024 * 10);
185
	struct pool *mem = pool_create(1024 * 10);
186
	struct list pvs;
186
	struct lvm_list pvs;
187
	struct volume_group *vg = NULL;
187
	struct volume_group *vg = NULL;
188
	list_init(&pvs);
188
	lvm_list_init(&pvs);
189
189
190
	if (!mem) {
190
	if (!mem) {
191
		stack;
191
		STACK;
192
		return NULL;
192
		return NULL;
193
	}
193
	}
194
194
Lines 197-208 Link Here
197
197
198
	if (!read_pvs_in_vg
198
	if (!read_pvs_in_vg
199
	    (fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs)) {
199
	    (fid->fmt, vg_name, fid->fmt->cmd->filter, mem, &pvs)) {
200
		stack;
200
		STACK;
201
		goto bad;
201
		goto bad;
202
	}
202
	}
203
203
204
	if (!(vg = _build_vg(fid, &pvs))) {
204
	if (!(vg = _build_vg(fid, &pvs))) {
205
		stack;
205
		STACK;
206
		goto bad;
206
		goto bad;
207
	}
207
	}
208
208
Lines 219-239 Link Here
219
	struct disk_list *dl = pool_alloc(mem, sizeof(*dl));
219
	struct disk_list *dl = pool_alloc(mem, sizeof(*dl));
220
220
221
	if (!dl) {
221
	if (!dl) {
222
		stack;
222
		STACK;
223
		return NULL;
223
		return NULL;
224
	}
224
	}
225
225
226
	dl->mem = mem;
226
	dl->mem = mem;
227
	dl->dev = pv->dev;
227
	dl->dev = pv->dev;
228
228
229
	list_init(&dl->uuids);
229
	lvm_list_init(&dl->uuids);
230
	list_init(&dl->lvds);
230
	lvm_list_init(&dl->lvds);
231
231
232
	if (!export_pv(fid->fmt->cmd, mem, vg, &dl->pvd, pv) ||
232
	if (!export_pv(fid->fmt->cmd, mem, vg, &dl->pvd, pv) ||
233
	    !export_vg(&dl->vgd, vg) ||
233
	    !export_vg(&dl->vgd, vg) ||
234
	    !export_uuids(dl, vg) ||
234
	    !export_uuids(dl, vg) ||
235
	    !export_lvs(dl, vg, pv, dev_dir) || !calculate_layout(dl)) {
235
	    !export_lvs(dl, vg, pv, dev_dir) || !calculate_layout(dl)) {
236
		stack;
236
		STACK;
237
		pool_free(mem, dl);
237
		pool_free(mem, dl);
238
		return NULL;
238
		return NULL;
239
	}
239
	}
Lines 243-271 Link Here
243
243
244
static int _flatten_vg(struct format_instance *fid, struct pool *mem,
244
static int _flatten_vg(struct format_instance *fid, struct pool *mem,
245
		       struct volume_group *vg,
245
		       struct volume_group *vg,
246
		       struct list *pvds, const char *dev_dir,
246
		       struct lvm_list *pvds, const char *dev_dir,
247
		       struct dev_filter *filter)
247
		       struct dev_filter *filter)
248
{
248
{
249
	struct list *pvh;
249
	struct lvm_list *pvh;
250
	struct pv_list *pvl;
250
	struct pv_list *pvl;
251
	struct disk_list *data;
251
	struct disk_list *data;
252
252
253
	list_iterate(pvh, &vg->pvs) {
253
	lvm_list_iterate(pvh, &vg->pvs) {
254
		pvl = list_item(pvh, struct pv_list);
254
		pvl = lvm_list_item(pvh, struct pv_list);
255
255
256
		if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir))) {
256
		if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir))) {
257
			stack;
257
			STACK;
258
			return 0;
258
			return 0;
259
		}
259
		}
260
260
261
		list_add(pvds, &data->list);
261
		lvm_list_add(pvds, &data->list);
262
	}
262
	}
263
263
264
	export_numbers(pvds, vg);
264
	export_numbers(pvds, vg);
265
	export_pv_act(pvds);
265
	export_pv_act(pvds);
266
266
267
	if (!export_vg_number(fid, pvds, vg->name, filter)) {
267
	if (!export_vg_number(fid, pvds, vg->name, filter)) {
268
		stack;
268
		STACK;
269
		return 0;
269
		return 0;
270
	}
270
	}
271
271
Lines 276-290 Link Here
276
		     struct metadata_area *mda)
276
		     struct metadata_area *mda)
277
{
277
{
278
	struct pool *mem = pool_create(1024 * 10);
278
	struct pool *mem = pool_create(1024 * 10);
279
	struct list pvds;
279
	struct lvm_list pvds;
280
	int r = 0;
280
	int r = 0;
281
281
282
	if (!mem) {
282
	if (!mem) {
283
		stack;
283
		STACK;
284
		return 0;
284
		return 0;
285
	}
285
	}
286
286
287
	list_init(&pvds);
287
	lvm_list_init(&pvds);
288
288
289
	r = (_flatten_vg(fid, mem, vg, &pvds, fid->fmt->cmd->dev_dir,
289
	r = (_flatten_vg(fid, mem, vg, &pvds, fid->fmt->cmd->dev_dir,
290
			 fid->fmt->cmd->filter) &&
290
			 fid->fmt->cmd->filter) &&
Lines 296-302 Link Here
296
}
296
}
297
297
298
static int _pv_read(const struct format_type *fmt, const char *pv_name,
298
static int _pv_read(const struct format_type *fmt, const char *pv_name,
299
		    struct physical_volume *pv, struct list *mdas)
299
		    struct physical_volume *pv, struct lvm_list *mdas)
300
{
300
{
301
	struct pool *mem = pool_create(1024);
301
	struct pool *mem = pool_create(1024);
302
	struct disk_list *dl;
302
	struct disk_list *dl;
Lines 306-327 Link Here
306
	log_very_verbose("Reading physical volume data %s from disk", pv_name);
306
	log_very_verbose("Reading physical volume data %s from disk", pv_name);
307
307
308
	if (!mem) {
308
	if (!mem) {
309
		stack;
309
		STACK;
310
		return 0;
310
		return 0;
311
	}
311
	}
312
312
313
	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
313
	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
314
		stack;
314
		STACK;
315
		goto out;
315
		goto out;
316
	}
316
	}
317
317
318
	if (!(dl = read_disk(fmt, dev, mem, NULL))) {
318
	if (!(dl = read_disk(fmt, dev, mem, NULL))) {
319
		stack;
319
		STACK;
320
		goto out;
320
		goto out;
321
	}
321
	}
322
322
323
	if (!import_pv(fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd)) {
323
	if (!import_pv(fmt->cmd->mem, dl->dev, NULL, pv, &dl->pvd)) {
324
		stack;
324
		STACK;
325
		goto out;
325
		goto out;
326
	}
326
	}
327
327
Lines 338-344 Link Here
338
		     uint64_t pe_start, uint32_t extent_count,
338
		     uint64_t pe_start, uint32_t extent_count,
339
		     uint32_t extent_size,
339
		     uint32_t extent_size,
340
		     int pvmetadatacopies,
340
		     int pvmetadatacopies,
341
		     uint64_t pvmetadatasize, struct list *mdas,
341
		     uint64_t pvmetadatasize, struct lvm_list *mdas,
342
		     struct physical_volume *pv, struct volume_group *vg)
342
		     struct physical_volume *pv, struct volume_group *vg)
343
{
343
{
344
	if (pv->size > MAX_PV_SIZE)
344
	if (pv->size > MAX_PV_SIZE)
Lines 358-364 Link Here
358
	 * This works out pe_start and pe_count.
358
	 * This works out pe_start and pe_count.
359
	 */
359
	 */
360
	if (!calculate_extent_count(pv, extent_size, extent_count, pe_start)) {
360
	if (!calculate_extent_count(pv, extent_size, extent_count, pe_start)) {
361
		stack;
361
		STACK;
362
		return 0;
362
		return 0;
363
	}
363
	}
364
364
Lines 395-439 Link Here
395
}
395
}
396
396
397
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
397
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
398
		     struct list *mdas, int64_t sector)
398
		     struct lvm_list *mdas, int64_t sector)
399
{
399
{
400
	struct pool *mem;
400
	struct pool *mem;
401
	struct disk_list *dl;
401
	struct disk_list *dl;
402
	struct list pvs;
402
	struct lvm_list pvs;
403
	struct label *label;
403
	struct label *label;
404
	struct lvmcache_info *info;
404
	struct lvmcache_info *info;
405
405
406
	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
406
	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
407
				  pv->vg_name, NULL))) {
407
				  pv->vg_name, NULL))) {
408
		stack;
408
		STACK;
409
		return 0;
409
		return 0;
410
	}
410
	}
411
	label = info->label;
411
	label = info->label;
412
	info->device_size = pv->size << SECTOR_SHIFT;
412
	info->device_size = pv->size << SECTOR_SHIFT;
413
	info->fmt = fmt;
413
	info->fmt = fmt;
414
414
415
	list_init(&info->mdas);
415
	lvm_list_init(&info->mdas);
416
416
417
	list_init(&pvs);
417
	lvm_list_init(&pvs);
418
418
419
	/* Ensure any residual PE structure is gone */
419
	/* Ensure any residual PE structure is gone */
420
	pv->pe_size = pv->pe_count = 0;
420
	pv->pe_size = pv->pe_count = 0;
421
	pv->pe_start = PE_ALIGN;
421
	pv->pe_start = PE_ALIGN;
422
422
423
	if (!(mem = pool_create(1024))) {
423
	if (!(mem = pool_create(1024))) {
424
		stack;
424
		STACK;
425
		return 0;
425
		return 0;
426
	}
426
	}
427
427
428
	if (!(dl = pool_alloc(mem, sizeof(*dl)))) {
428
	if (!(dl = pool_alloc(mem, sizeof(*dl)))) {
429
		stack;
429
		STACK;
430
		goto bad;
430
		goto bad;
431
	}
431
	}
432
	dl->mem = mem;
432
	dl->mem = mem;
433
	dl->dev = pv->dev;
433
	dl->dev = pv->dev;
434
434
435
	if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) {
435
	if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) {
436
		stack;
436
		STACK;
437
		goto bad;
437
		goto bad;
438
	}
438
	}
439
439
Lines 443-451 Link Here
443
	dl->pvd.pv_on_disk.size = PV_SIZE;
443
	dl->pvd.pv_on_disk.size = PV_SIZE;
444
	dl->pvd.pe_on_disk.base = PE_ALIGN << SECTOR_SHIFT;
444
	dl->pvd.pe_on_disk.base = PE_ALIGN << SECTOR_SHIFT;
445
445
446
	list_add(&pvs, &dl->list);
446
	lvm_list_add(&pvs, &dl->list);
447
	if (!write_disks(fmt, &pvs)) {
447
	if (!write_disks(fmt, &pvs)) {
448
		stack;
448
		STACK;
449
		goto bad;
449
		goto bad;
450
	}
450
	}
451
451
Lines 508-530 Link Here
508
	struct metadata_area *mda;
508
	struct metadata_area *mda;
509
509
510
	if (!(fid = pool_alloc(fmt->cmd->mem, sizeof(*fid)))) {
510
	if (!(fid = pool_alloc(fmt->cmd->mem, sizeof(*fid)))) {
511
		stack;
511
		STACK;
512
		return NULL;
512
		return NULL;
513
	}
513
	}
514
514
515
	fid->fmt = fmt;
515
	fid->fmt = fmt;
516
	list_init(&fid->metadata_areas);
516
	lvm_list_init(&fid->metadata_areas);
517
517
518
	/* Define a NULL metadata area */
518
	/* Define a NULL metadata area */
519
	if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
519
	if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
520
		stack;
520
		STACK;
521
		pool_free(fmt->cmd->mem, fid);
521
		pool_free(fmt->cmd->mem, fid);
522
		return NULL;
522
		return NULL;
523
	}
523
	}
524
524
525
	mda->ops = &_metadata_format1_ops;
525
	mda->ops = &_metadata_format1_ops;
526
	mda->metadata_locn = NULL;
526
	mda->metadata_locn = NULL;
527
	list_add(&fid->metadata_areas, &mda->list);
527
	lvm_list_add(&fid->metadata_areas, &mda->list);
528
528
529
	return fid;
529
	return fid;
530
}
530
}
Lines 560-566 Link Here
560
	struct format_type *fmt = dbg_malloc(sizeof(*fmt));
560
	struct format_type *fmt = dbg_malloc(sizeof(*fmt));
561
561
562
	if (!fmt) {
562
	if (!fmt) {
563
		stack;
563
		STACK;
564
		return NULL;
564
		return NULL;
565
	}
565
	}
566
566
(-)LVM2.2.00.15.orig/lib/format1/import-export.c (-76 / +76 lines)
Lines 57-63 Link Here
57
57
58
	pv->dev = dev;
58
	pv->dev = dev;
59
	if (!(pv->vg_name = pool_strdup(mem, pvd->vg_name))) {
59
	if (!(pv->vg_name = pool_strdup(mem, pvd->vg_name))) {
60
		stack;
60
		STACK;
61
		return 0;
61
		return 0;
62
	}
62
	}
63
63
Lines 87-93 Link Here
87
	pv->pe_count = pvd->pe_total;
87
	pv->pe_count = pvd->pe_total;
88
	pv->pe_alloc_count = pvd->pe_allocated;
88
	pv->pe_alloc_count = pvd->pe_allocated;
89
89
90
	list_init(&pv->tags);
90
	lvm_list_init(&pv->tags);
91
91
92
	return 1;
92
	return 1;
93
}
93
}
Lines 117-123 Link Here
117
	memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
117
	memcpy(pvd->pv_uuid, pv->id.uuid, ID_LEN);
118
118
119
	if (!_check_vg_name(pv->vg_name)) {
119
	if (!_check_vg_name(pv->vg_name)) {
120
		stack;
120
		STACK;
121
		return 0;
121
		return 0;
122
	}
122
	}
123
123
Lines 137-143 Link Here
137
		    strncmp(vg->system_id, EXPORTED_TAG,
137
		    strncmp(vg->system_id, EXPORTED_TAG,
138
			    sizeof(EXPORTED_TAG) - 1)) {
138
			    sizeof(EXPORTED_TAG) - 1)) {
139
			if (!_system_id(cmd, pvd->system_id, EXPORTED_TAG)) {
139
			if (!_system_id(cmd, pvd->system_id, EXPORTED_TAG)) {
140
				stack;
140
				STACK;
141
				return 0;
141
				return 0;
142
			}
142
			}
143
		}
143
		}
Lines 154-160 Link Here
154
	if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
154
	if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
155
	    !strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
155
	    !strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
156
		if (!_system_id(cmd, pvd->system_id, IMPORTED_TAG)) {
156
		if (!_system_id(cmd, pvd->system_id, IMPORTED_TAG)) {
157
			stack;
157
			STACK;
158
			return 0;
158
			return 0;
159
		}
159
		}
160
	}
160
	}
Lines 162-168 Link Here
162
	/* Generate system_id if PV is in VG */
162
	/* Generate system_id if PV is in VG */
163
	if (!pvd->system_id || !*pvd->system_id)
163
	if (!pvd->system_id || !*pvd->system_id)
164
		if (!_system_id(cmd, pvd->system_id, "")) {
164
		if (!_system_id(cmd, pvd->system_id, "")) {
165
			stack;
165
			STACK;
166
			return 0;
166
			return 0;
167
		}
167
		}
168
168
Lines 197-213 Link Here
197
	memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
197
	memcpy(vg->id.uuid, vgd->vg_uuid, ID_LEN);
198
198
199
	if (!_check_vg_name(dl->pvd.vg_name)) {
199
	if (!_check_vg_name(dl->pvd.vg_name)) {
200
		stack;
200
		STACK;
201
		return 0;
201
		return 0;
202
	}
202
	}
203
203
204
	if (!(vg->name = pool_strdup(mem, dl->pvd.vg_name))) {
204
	if (!(vg->name = pool_strdup(mem, dl->pvd.vg_name))) {
205
		stack;
205
		STACK;
206
		return 0;
206
		return 0;
207
	}
207
	}
208
208
209
	if (!(vg->system_id = pool_alloc(mem, NAME_LEN))) {
209
	if (!(vg->system_id = pool_alloc(mem, NAME_LEN))) {
210
		stack;
210
		STACK;
211
		return 0;
211
		return 0;
212
	}
212
	}
213
213
Lines 284-290 Link Here
284
	lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
284
	lvid_from_lvnum(&lv->lvid, &lv->vg->id, lvd->lv_number);
285
285
286
	if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
286
	if (!(lv->name = _create_lv_name(mem, lvd->lv_name))) {
287
		stack;
287
		STACK;
288
		return 0;
288
		return 0;
289
	}
289
	}
290
290
Lines 321-328 Link Here
321
	lv->size = lvd->lv_size;
321
	lv->size = lvd->lv_size;
322
	lv->le_count = lvd->lv_allocated_le;
322
	lv->le_count = lvd->lv_allocated_le;
323
323
324
	list_init(&lv->segments);
324
	lvm_list_init(&lv->segments);
325
	list_init(&lv->tags);
325
	lvm_list_init(&lv->tags);
326
326
327
	return 1;
327
	return 1;
328
}
328
}
Lines 354-362 Link Here
354
354
355
	lvd->lv_read_ahead = lv->read_ahead;
355
	lvd->lv_read_ahead = lv->read_ahead;
356
	lvd->lv_stripes =
356
	lvd->lv_stripes =
357
	    list_item(lv->segments.n, struct lv_segment)->area_count;
357
	    lvm_list_item(lv->segments.n, struct lv_segment)->area_count;
358
	lvd->lv_stripesize =
358
	lvd->lv_stripesize =
359
	    list_item(lv->segments.n, struct lv_segment)->stripe_size;
359
	    lvm_list_item(lv->segments.n, struct lv_segment)->stripe_size;
360
360
361
	lvd->lv_size = lv->size;
361
	lvd->lv_size = lv->size;
362
	lvd->lv_allocated_le = lv->le_count;
362
	lvd->lv_allocated_le = lv->le_count;
Lines 371-383 Link Here
371
int export_extents(struct disk_list *dl, uint32_t lv_num,
371
int export_extents(struct disk_list *dl, uint32_t lv_num,
372
		   struct logical_volume *lv, struct physical_volume *pv)
372
		   struct logical_volume *lv, struct physical_volume *pv)
373
{
373
{
374
	struct list *segh;
374
	struct lvm_list *segh;
375
	struct pe_disk *ped;
375
	struct pe_disk *ped;
376
	struct lv_segment *seg;
376
	struct lv_segment *seg;
377
	uint32_t pe, s;
377
	uint32_t pe, s;
378
378
379
	list_iterate(segh, &lv->segments) {
379
	lvm_list_iterate(segh, &lv->segments) {
380
		seg = list_item(segh, struct lv_segment);
380
		seg = lvm_list_item(segh, struct lv_segment);
381
381
382
		for (s = 0; s < seg->area_count; s++) {
382
		for (s = 0; s < seg->area_count; s++) {
383
			if (seg->type != SEG_STRIPED) {
383
			if (seg->type != SEG_STRIPED) {
Lines 407-436 Link Here
407
407
408
int import_pvs(const struct format_type *fmt, struct pool *mem,
408
int import_pvs(const struct format_type *fmt, struct pool *mem,
409
	       struct volume_group *vg,
409
	       struct volume_group *vg,
410
	       struct list *pvds, struct list *results, int *count)
410
	       struct lvm_list *pvds, struct lvm_list *results, int *count)
411
{
411
{
412
	struct list *pvdh;
412
	struct lvm_list *pvdh;
413
	struct disk_list *dl;
413
	struct disk_list *dl;
414
	struct pv_list *pvl;
414
	struct pv_list *pvl;
415
415
416
	*count = 0;
416
	*count = 0;
417
	list_iterate(pvdh, pvds) {
417
	lvm_list_iterate(pvdh, pvds) {
418
418
419
		dl = list_item(pvdh, struct disk_list);
419
		dl = lvm_list_item(pvdh, struct disk_list);
420
420
421
		if (!(pvl = pool_zalloc(mem, sizeof(*pvl))) ||
421
		if (!(pvl = pool_zalloc(mem, sizeof(*pvl))) ||
422
		    !(pvl->pv = pool_alloc(mem, sizeof(*pvl->pv)))) {
422
		    !(pvl->pv = pool_alloc(mem, sizeof(*pvl->pv)))) {
423
			stack;
423
			STACK;
424
			return 0;
424
			return 0;
425
		}
425
		}
426
426
427
		if (!import_pv(mem, dl->dev, vg, pvl->pv, &dl->pvd)) {
427
		if (!import_pv(mem, dl->dev, vg, pvl->pv, &dl->pvd)) {
428
			stack;
428
			STACK;
429
			return 0;
429
			return 0;
430
		}
430
		}
431
431
432
		pvl->pv->fmt = fmt;
432
		pvl->pv->fmt = fmt;
433
		list_add(results, &pvl->list);
433
		lvm_list_add(results, &pvl->list);
434
		(*count)++;
434
		(*count)++;
435
	}
435
	}
436
436
Lines 446-484 Link Here
446
446
447
	if (!(ll = pool_zalloc(mem, sizeof(*ll))) ||
447
	if (!(ll = pool_zalloc(mem, sizeof(*ll))) ||
448
	    !(ll->lv = pool_zalloc(mem, sizeof(*ll->lv)))) {
448
	    !(ll->lv = pool_zalloc(mem, sizeof(*ll->lv)))) {
449
		stack;
449
		STACK;
450
		return NULL;
450
		return NULL;
451
	}
451
	}
452
	lv = ll->lv;
452
	lv = ll->lv;
453
	lv->vg = vg;
453
	lv->vg = vg;
454
454
455
	if (!import_lv(mem, lv, lvd)) {
455
	if (!import_lv(mem, lv, lvd)) {
456
		stack;
456
		STACK;
457
		return NULL;
457
		return NULL;
458
	}
458
	}
459
459
460
	list_add(&vg->lvs, &ll->list);
460
	lvm_list_add(&vg->lvs, &ll->list);
461
	vg->lv_count++;
461
	vg->lv_count++;
462
462
463
	return lv;
463
	return lv;
464
}
464
}
465
465
466
int import_lvs(struct pool *mem, struct volume_group *vg, struct list *pvds)
466
int import_lvs(struct pool *mem, struct volume_group *vg, struct lvm_list *pvds)
467
{
467
{
468
	struct disk_list *dl;
468
	struct disk_list *dl;
469
	struct lvd_list *ll;
469
	struct lvd_list *ll;
470
	struct lv_disk *lvd;
470
	struct lv_disk *lvd;
471
	struct list *pvdh, *lvdh;
471
	struct lvm_list *pvdh, *lvdh;
472
472
473
	list_iterate(pvdh, pvds) {
473
	lvm_list_iterate(pvdh, pvds) {
474
		dl = list_item(pvdh, struct disk_list);
474
		dl = lvm_list_item(pvdh, struct disk_list);
475
		list_iterate(lvdh, &dl->lvds) {
475
		lvm_list_iterate(lvdh, &dl->lvds) {
476
			ll = list_item(lvdh, struct lvd_list);
476
			ll = lvm_list_item(lvdh, struct lvd_list);
477
			lvd = &ll->lvd;
477
			lvd = &ll->lvd;
478
478
479
			if (!find_lv(vg, lvd->lv_name) &&
479
			if (!find_lv(vg, lvd->lv_name) &&
480
			    !_add_lv(mem, vg, lvd)) {
480
			    !_add_lv(mem, vg, lvd)) {
481
				stack;
481
				STACK;
482
				return 0;
482
				return 0;
483
			}
483
			}
484
		}
484
		}
Lines 492-498 Link Here
492
	       struct physical_volume *pv, const char *dev_dir)
492
	       struct physical_volume *pv, const char *dev_dir)
493
{
493
{
494
	int r = 0;
494
	int r = 0;
495
	struct list *lvh, *sh;
495
	struct lvm_list *lvh, *sh;
496
	struct lv_list *ll;
496
	struct lv_list *ll;
497
	struct lvd_list *lvdl;
497
	struct lvd_list *lvdl;
498
	size_t len;
498
	size_t len;
Lines 500-511 Link Here
500
	struct hash_table *lvd_hash;
500
	struct hash_table *lvd_hash;
501
501
502
	if (!_check_vg_name(vg->name)) {
502
	if (!_check_vg_name(vg->name)) {
503
		stack;
503
		STACK;
504
		return 0;
504
		return 0;
505
	}
505
	}
506
506
507
	if (!(lvd_hash = hash_create(32))) {
507
	if (!(lvd_hash = hash_create(32))) {
508
		stack;
508
		STACK;
509
		return 0;
509
		return 0;
510
	}
510
	}
511
511
Lines 514-528 Link Here
514
	 */
514
	 */
515
	len = sizeof(struct pe_disk) * dl->pvd.pe_total;
515
	len = sizeof(struct pe_disk) * dl->pvd.pe_total;
516
	if (!(dl->extents = pool_alloc(dl->mem, len))) {
516
	if (!(dl->extents = pool_alloc(dl->mem, len))) {
517
		stack;
517
		STACK;
518
		goto out;
518
		goto out;
519
	}
519
	}
520
	memset(dl->extents, 0, len);
520
	memset(dl->extents, 0, len);
521
521
522
	list_iterate(lvh, &vg->lvs) {
522
	lvm_list_iterate(lvh, &vg->lvs) {
523
		ll = list_item(lvh, struct lv_list);
523
		ll = lvm_list_item(lvh, struct lv_list);
524
		if (!(lvdl = pool_alloc(dl->mem, sizeof(*lvdl)))) {
524
		if (!(lvdl = pool_alloc(dl->mem, sizeof(*lvdl)))) {
525
			stack;
525
			STACK;
526
			goto out;
526
			goto out;
527
		}
527
		}
528
528
Lines 533-548 Link Here
533
		lvdl->lvd.lv_number = lv_num;
533
		lvdl->lvd.lv_number = lv_num;
534
534
535
		if (!hash_insert(lvd_hash, ll->lv->name, &lvdl->lvd)) {
535
		if (!hash_insert(lvd_hash, ll->lv->name, &lvdl->lvd)) {
536
			stack;
536
			STACK;
537
			goto out;
537
			goto out;
538
		}
538
		}
539
539
540
		if (!export_extents(dl, lv_num + 1, ll->lv, pv)) {
540
		if (!export_extents(dl, lv_num + 1, ll->lv, pv)) {
541
			stack;
541
			STACK;
542
			goto out;
542
			goto out;
543
		}
543
		}
544
544
545
		list_add(&dl->lvds, &lvdl->list);
545
		lvm_list_add(&dl->lvds, &lvdl->list);
546
		dl->pvd.lv_cur++;
546
		dl->pvd.lv_cur++;
547
	}
547
	}
548
548
Lines 550-558 Link Here
550
	 * Now we need to run through the snapshots, exporting
550
	 * Now we need to run through the snapshots, exporting
551
	 * the SNAPSHOT_ORG flags etc.
551
	 * the SNAPSHOT_ORG flags etc.
552
	 */
552
	 */
553
	list_iterate(sh, &vg->snapshots) {
553
	lvm_list_iterate(sh, &vg->snapshots) {
554
		struct lv_disk *org, *cow;
554
		struct lv_disk *org, *cow;
555
		struct snapshot *s = list_item(sh,
555
		struct snapshot *s = lvm_list_item(sh,
556
					       struct snapshot_list)->snapshot;
556
					       struct snapshot_list)->snapshot;
557
557
558
		if (!(org = hash_lookup(lvd_hash, s->origin->name))) {
558
		if (!(org = hash_lookup(lvd_hash, s->origin->name))) {
Lines 584-593 Link Here
584
 * FIXME: More inefficient code.
584
 * FIXME: More inefficient code.
585
 */
585
 */
586
int import_snapshots(struct pool *mem, struct volume_group *vg,
586
int import_snapshots(struct pool *mem, struct volume_group *vg,
587
		     struct list *pvds)
587
		     struct lvm_list *pvds)
588
{
588
{
589
	struct logical_volume *lvs[MAX_LV];
589
	struct logical_volume *lvs[MAX_LV];
590
	struct list *pvdh, *lvdh;
590
	struct lvm_list *pvdh, *lvdh;
591
	struct disk_list *dl;
591
	struct disk_list *dl;
592
	struct lv_disk *lvd;
592
	struct lv_disk *lvd;
593
	int lvnum;
593
	int lvnum;
Lines 595-605 Link Here
595
595
596
	/* build an index of lv numbers */
596
	/* build an index of lv numbers */
597
	memset(lvs, 0, sizeof(lvs));
597
	memset(lvs, 0, sizeof(lvs));
598
	list_iterate(pvdh, pvds) {
598
	lvm_list_iterate(pvdh, pvds) {
599
		dl = list_item(pvdh, struct disk_list);
599
		dl = lvm_list_item(pvdh, struct disk_list);
600
600
601
		list_iterate(lvdh, &dl->lvds) {
601
		lvm_list_iterate(lvdh, &dl->lvds) {
602
			lvd = &(list_item(lvdh, struct lvd_list)->lvd);
602
			lvd = &(lvm_list_item(lvdh, struct lvd_list)->lvd);
603
603
604
			lvnum = lvd->lv_number;
604
			lvnum = lvd->lv_number;
605
605
Lines 621-631 Link Here
621
	/*
621
	/*
622
	 * Now iterate through yet again adding the snapshots.
622
	 * Now iterate through yet again adding the snapshots.
623
	 */
623
	 */
624
	list_iterate(pvdh, pvds) {
624
	lvm_list_iterate(pvdh, pvds) {
625
		dl = list_item(pvdh, struct disk_list);
625
		dl = lvm_list_item(pvdh, struct disk_list);
626
626
627
		list_iterate(lvdh, &dl->lvds) {
627
		lvm_list_iterate(lvdh, &dl->lvds) {
628
			lvd = &(list_item(lvdh, struct lvd_list)->lvd);
628
			lvd = &(lvm_list_item(lvdh, struct lvd_list)->lvd);
629
629
630
			if (!(lvd->lv_access & LV_SNAPSHOT))
630
			if (!(lvd->lv_access & LV_SNAPSHOT))
631
				continue;
631
				continue;
Lines 658-676 Link Here
658
{
658
{
659
	struct uuid_list *ul;
659
	struct uuid_list *ul;
660
	struct pv_list *pvl;
660
	struct pv_list *pvl;
661
	struct list *pvh;
661
	struct lvm_list *pvh;
662
662
663
	list_iterate(pvh, &vg->pvs) {
663
	lvm_list_iterate(pvh, &vg->pvs) {
664
		pvl = list_item(pvh, struct pv_list);
664
		pvl = lvm_list_item(pvh, struct pv_list);
665
		if (!(ul = pool_alloc(dl->mem, sizeof(*ul)))) {
665
		if (!(ul = pool_alloc(dl->mem, sizeof(*ul)))) {
666
			stack;
666
			STACK;
667
			return 0;
667
			return 0;
668
		}
668
		}
669
669
670
		memset(ul->uuid, 0, sizeof(ul->uuid));
670
		memset(ul->uuid, 0, sizeof(ul->uuid));
671
		memcpy(ul->uuid, pvl->pv->id.uuid, ID_LEN);
671
		memcpy(ul->uuid, pvl->pv->id.uuid, ID_LEN);
672
672
673
		list_add(&dl->uuids, &ul->list);
673
		lvm_list_add(&dl->uuids, &ul->list);
674
	}
674
	}
675
	return 1;
675
	return 1;
676
}
676
}
Lines 679-692 Link Here
679
 * This calculates the nasty pv_number field
679
 * This calculates the nasty pv_number field
680
 * used by LVM1.
680
 * used by LVM1.
681
 */
681
 */
682
void export_numbers(struct list *pvds, struct volume_group *vg)
682
void export_numbers(struct lvm_list *pvds, struct volume_group *vg)
683
{
683
{
684
	struct list *pvdh;
684
	struct lvm_list *pvdh;
685
	struct disk_list *dl;
685
	struct disk_list *dl;
686
	int pv_num = 1;
686
	int pv_num = 1;
687
687
688
	list_iterate(pvdh, pvds) {
688
	lvm_list_iterate(pvdh, pvds) {
689
		dl = list_item(pvdh, struct disk_list);
689
		dl = lvm_list_item(pvdh, struct disk_list);
690
		dl->pvd.pv_number = pv_num++;
690
		dl->pvd.pv_number = pv_num++;
691
	}
691
	}
692
}
692
}
Lines 694-731 Link Here
694
/*
694
/*
695
 * Calculate vg_disk->pv_act.
695
 * Calculate vg_disk->pv_act.
696
 */
696
 */
697
void export_pv_act(struct list *pvds)
697
void export_pv_act(struct lvm_list *pvds)
698
{
698
{
699
	struct list *pvdh;
699
	struct lvm_list *pvdh;
700
	struct disk_list *dl;
700
	struct disk_list *dl;
701
	int act = 0;
701
	int act = 0;
702
702
703
	list_iterate(pvdh, pvds) {
703
	lvm_list_iterate(pvdh, pvds) {
704
		dl = list_item(pvdh, struct disk_list);
704
		dl = lvm_list_item(pvdh, struct disk_list);
705
		if (dl->pvd.pv_status & PV_ACTIVE)
705
		if (dl->pvd.pv_status & PV_ACTIVE)
706
			act++;
706
			act++;
707
	}
707
	}
708
708
709
	list_iterate(pvdh, pvds) {
709
	lvm_list_iterate(pvdh, pvds) {
710
		dl = list_item(pvdh, struct disk_list);
710
		dl = lvm_list_item(pvdh, struct disk_list);
711
		dl->vgd.pv_act = act;
711
		dl->vgd.pv_act = act;
712
	}
712
	}
713
}
713
}
714
714
715
int export_vg_number(struct format_instance *fid, struct list *pvds,
715
int export_vg_number(struct format_instance *fid, struct lvm_list *pvds,
716
		     const char *vg_name, struct dev_filter *filter)
716
		     const char *vg_name, struct dev_filter *filter)
717
{
717
{
718
	struct list *pvdh;
718
	struct lvm_list *pvdh;
719
	struct disk_list *dl;
719
	struct disk_list *dl;
720
	int vg_num;
720
	int vg_num;
721
721
722
	if (!get_free_vg_number(fid, filter, vg_name, &vg_num)) {
722
	if (!get_free_vg_number(fid, filter, vg_name, &vg_num)) {
723
		stack;
723
		STACK;
724
		return 0;
724
		return 0;
725
	}
725
	}
726
726
727
	list_iterate(pvdh, pvds) {
727
	lvm_list_iterate(pvdh, pvds) {
728
		dl = list_item(pvdh, struct disk_list);
728
		dl = lvm_list_item(pvdh, struct disk_list);
729
		dl->vgd.vg_number = vg_num;
729
		dl->vgd.vg_number = vg_num;
730
	}
730
	}
731
731
(-)LVM2.2.00.15.orig/lib/format1/import-extents.c (-22 / +22 lines)
Lines 46-52 Link Here
46
					  struct volume_group *vg)
46
					  struct volume_group *vg)
47
{
47
{
48
	struct hash_table *maps = hash_create(32);
48
	struct hash_table *maps = hash_create(32);
49
	struct list *llh;
49
	struct lvm_list *llh;
50
	struct lv_list *ll;
50
	struct lv_list *ll;
51
	struct lv_map *lvm;
51
	struct lv_map *lvm;
52
52
Lines 56-78 Link Here
56
		return NULL;
56
		return NULL;
57
	}
57
	}
58
58
59
	list_iterate(llh, &vg->lvs) {
59
	lvm_list_iterate(llh, &vg->lvs) {
60
		ll = list_item(llh, struct lv_list);
60
		ll = lvm_list_item(llh, struct lv_list);
61
61
62
		if (!(lvm = pool_alloc(mem, sizeof(*lvm)))) {
62
		if (!(lvm = pool_alloc(mem, sizeof(*lvm)))) {
63
			stack;
63
			STACK;
64
			goto bad;
64
			goto bad;
65
		}
65
		}
66
66
67
		lvm->lv = ll->lv;
67
		lvm->lv = ll->lv;
68
		if (!(lvm->map = pool_zalloc(mem, sizeof(*lvm->map)
68
		if (!(lvm->map = pool_zalloc(mem, sizeof(*lvm->map)
69
					     * ll->lv->le_count))) {
69
					     * ll->lv->le_count))) {
70
			stack;
70
			STACK;
71
			goto bad;
71
			goto bad;
72
		}
72
		}
73
73
74
		if (!hash_insert(maps, ll->lv->name, lvm)) {
74
		if (!hash_insert(maps, ll->lv->name, lvm)) {
75
			stack;
75
			STACK;
76
			goto bad;
76
			goto bad;
77
		}
77
		}
78
	}
78
	}
Lines 87-98 Link Here
87
static int _fill_lv_array(struct lv_map **lvs,
87
static int _fill_lv_array(struct lv_map **lvs,
88
			  struct hash_table *maps, struct disk_list *dl)
88
			  struct hash_table *maps, struct disk_list *dl)
89
{
89
{
90
	struct list *lvh;
90
	struct lvm_list *lvh;
91
	struct lv_map *lvm;
91
	struct lv_map *lvm;
92
92
93
	memset(lvs, 0, sizeof(*lvs) * MAX_LV);
93
	memset(lvs, 0, sizeof(*lvs) * MAX_LV);
94
	list_iterate(lvh, &dl->lvds) {
94
	lvm_list_iterate(lvh, &dl->lvds) {
95
		struct lvd_list *ll = list_item(lvh, struct lvd_list);
95
		struct lvd_list *ll = lvm_list_item(lvh, struct lvd_list);
96
96
97
		if (!(lvm = hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
97
		if (!(lvm = hash_lookup(maps, strrchr(ll->lvd.lv_name, '/')
98
					+ 1))) {
98
					+ 1))) {
Lines 112-134 Link Here
112
}
112
}
113
113
114
static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
114
static int _fill_maps(struct hash_table *maps, struct volume_group *vg,
115
		      struct list *pvds)
115
		      struct lvm_list *pvds)
116
{
116
{
117
	struct list *pvdh;
117
	struct lvm_list *pvdh;
118
	struct disk_list *dl;
118
	struct disk_list *dl;
119
	struct physical_volume *pv;
119
	struct physical_volume *pv;
120
	struct lv_map *lvms[MAX_LV], *lvm;
120
	struct lv_map *lvms[MAX_LV], *lvm;
121
	struct pe_disk *e;
121
	struct pe_disk *e;
122
	uint32_t i, lv_num, le;
122
	uint32_t i, lv_num, le;
123
123
124
	list_iterate(pvdh, pvds) {
124
	lvm_list_iterate(pvdh, pvds) {
125
		dl = list_item(pvdh, struct disk_list);
125
		dl = lvm_list_item(pvdh, struct disk_list);
126
		pv = find_pv(vg, dl->dev);
126
		pv = find_pv(vg, dl->dev);
127
		e = dl->extents;
127
		e = dl->extents;
128
128
129
		/* build an array of lv's for this pv */
129
		/* build an array of lv's for this pv */
130
		if (!_fill_lv_array(lvms, maps, dl)) {
130
		if (!_fill_lv_array(lvms, maps, dl)) {
131
			stack;
131
			STACK;
132
			return 0;
132
			return 0;
133
		}
133
		}
134
134
Lines 194-200 Link Here
194
		lvm = (struct lv_map *) hash_get_data(maps, n);
194
		lvm = (struct lv_map *) hash_get_data(maps, n);
195
195
196
		if (!_check_single_map(lvm)) {
196
		if (!_check_single_map(lvm)) {
197
			stack;
197
			STACK;
198
			return 0;
198
			return 0;
199
		}
199
		}
200
	}
200
	}
Lines 231-237 Link Here
231
231
232
		le += seg->len;
232
		le += seg->len;
233
233
234
		list_add(&lvm->lv->segments, &seg->list);
234
		lvm_list_add(&lvm->lv->segments, &seg->list);
235
	}
235
	}
236
236
237
	return 1;
237
	return 1;
Lines 274-280 Link Here
274
274
275
	while (le < len) {
275
	while (le < len) {
276
		if (!(seg = alloc_lv_segment(mem, lvm->stripes))) {
276
		if (!(seg = alloc_lv_segment(mem, lvm->stripes))) {
277
			stack;
277
			STACK;
278
			return 0;
278
			return 0;
279
		}
279
		}
280
280
Lines 306-312 Link Here
306
		le += seg->len;
306
		le += seg->len;
307
		seg->len *= seg->area_count;
307
		seg->len *= seg->area_count;
308
308
309
		list_add(&lvm->lv->segments, &seg->list);
309
		lvm_list_add(&lvm->lv->segments, &seg->list);
310
	}
310
	}
311
311
312
	return 1;
312
	return 1;
Lines 326-332 Link Here
326
	for (n = hash_get_first(maps); n; n = hash_get_next(maps, n)) {
326
	for (n = hash_get_first(maps); n; n = hash_get_next(maps, n)) {
327
		lvm = (struct lv_map *) hash_get_data(maps, n);
327
		lvm = (struct lv_map *) hash_get_data(maps, n);
328
		if (!_build_segments(mem, lvm)) {
328
		if (!_build_segments(mem, lvm)) {
329
			stack;
329
			STACK;
330
			return 0;
330
			return 0;
331
		}
331
		}
332
	}
332
	}
Lines 334-347 Link Here
334
	return 1;
334
	return 1;
335
}
335
}
336
336
337
int import_extents(struct pool *mem, struct volume_group *vg, struct list *pvds)
337
int import_extents(struct pool *mem, struct volume_group *vg, struct lvm_list *pvds)
338
{
338
{
339
	int r = 0;
339
	int r = 0;
340
	struct pool *scratch = pool_create(10 * 1024);
340
	struct pool *scratch = pool_create(10 * 1024);
341
	struct hash_table *maps;
341
	struct hash_table *maps;
342
342
343
	if (!scratch) {
343
	if (!scratch) {
344
		stack;
344
		STACK;
345
		return 0;
345
		return 0;
346
	}
346
	}
347
347
Lines 356-362 Link Here
356
	}
356
	}
357
357
358
	if (!_check_maps_are_complete(maps) && !(vg->status & PARTIAL_VG)) {
358
	if (!_check_maps_are_complete(maps) && !(vg->status & PARTIAL_VG)) {
359
		stack;
359
		STACK;
360
		goto out;
360
		goto out;
361
	}
361
	}
362
362
(-)LVM2.2.00.15.orig/lib/format1/layout.c (-1 / +1 lines)
Lines 121-127 Link Here
121
	uint32_t end;
121
	uint32_t end;
122
122
123
	if (!pvd) {
123
	if (!pvd) {
124
		stack;
124
		STACK;
125
		return 0;
125
		return 0;
126
	}
126
	}
127
127
(-)LVM2.2.00.15.orig/lib/format1/lvm1-label.c (-2 / +2 lines)
Lines 62-74 Link Here
62
62
63
	munge_exported_vg(pvd);
63
	munge_exported_vg(pvd);
64
	if (!(info = lvmcache_add(l, pvd->pv_uuid, dev, pvd->vg_name, NULL))) {
64
	if (!(info = lvmcache_add(l, pvd->pv_uuid, dev, pvd->vg_name, NULL))) {
65
		stack;
65
		STACK;
66
		return 0;
66
		return 0;
67
	}
67
	}
68
	*label = info->label;
68
	*label = info->label;
69
69
70
	info->device_size = xlate32(pvd->pv_size) << SECTOR_SHIFT;
70
	info->device_size = xlate32(pvd->pv_size) << SECTOR_SHIFT;
71
	list_init(&info->mdas);
71
	lvm_list_init(&info->mdas);
72
72
73
	info->status &= ~CACHE_INVALID;
73
	info->status &= ~CACHE_INVALID;
74
74
(-)LVM2.2.00.15.orig/lib/format1/vg_number.c (-7 / +7 lines)
Lines 27-54 Link Here
27
int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
27
int get_free_vg_number(struct format_instance *fid, struct dev_filter *filter,
28
		       const char *candidate_vg, int *result)
28
		       const char *candidate_vg, int *result)
29
{
29
{
30
	struct list *pvh;
30
	struct lvm_list *pvh;
31
	struct list all_pvs;
31
	struct lvm_list all_pvs;
32
	struct disk_list *dl;
32
	struct disk_list *dl;
33
	struct pool *mem = pool_create(10 * 1024);
33
	struct pool *mem = pool_create(10 * 1024);
34
	int numbers[MAX_VG], i, r = 0;
34
	int numbers[MAX_VG], i, r = 0;
35
35
36
	list_init(&all_pvs);
36
	lvm_list_init(&all_pvs);
37
37
38
	if (!mem) {
38
	if (!mem) {
39
		stack;
39
		STACK;
40
		return 0;
40
		return 0;
41
	}
41
	}
42
42
43
	if (!read_pvs_in_vg(fid->fmt, NULL, filter, mem, &all_pvs)) {
43
	if (!read_pvs_in_vg(fid->fmt, NULL, filter, mem, &all_pvs)) {
44
		stack;
44
		STACK;
45
		goto out;
45
		goto out;
46
	}
46
	}
47
47
48
	memset(numbers, 0, sizeof(numbers));
48
	memset(numbers, 0, sizeof(numbers));
49
49
50
	list_iterate(pvh, &all_pvs) {
50
	lvm_list_iterate(pvh, &all_pvs) {
51
		dl = list_item(pvh, struct disk_list);
51
		dl = lvm_list_item(pvh, struct disk_list);
52
		if (!*dl->pvd.vg_name || !strcmp(dl->pvd.vg_name, candidate_vg))
52
		if (!*dl->pvd.vg_name || !strcmp(dl->pvd.vg_name, candidate_vg))
53
			continue;
53
			continue;
54
54
(-)LVM2.2.00.15.orig/lib/format_text/archive.c (-29 / +29 lines)
Lines 50-56 Link Here
50
 * with the least recent at the head.
50
 * with the least recent at the head.
51
 */
51
 */
52
struct archive_file {
52
struct archive_file {
53
	struct list list;
53
	struct lvm_list list;
54
54
55
	char *path;
55
	char *path;
56
	int index;
56
	int index;
Lines 89-115 Link Here
89
	return 1;
89
	return 1;
90
}
90
}
91
91
92
static void _insert_file(struct list *head, struct archive_file *b)
92
static void _insert_file(struct lvm_list *head, struct archive_file *b)
93
{
93
{
94
	struct list *bh;
94
	struct lvm_list *bh;
95
	struct archive_file *bf = NULL;
95
	struct archive_file *bf = NULL;
96
96
97
	if (list_empty(head)) {
97
	if (lvm_list_empty(head)) {
98
		list_add(head, &b->list);
98
		lvm_list_add(head, &b->list);
99
		return;
99
		return;
100
	}
100
	}
101
101
102
	/* index increases through list */
102
	/* index increases through list */
103
	list_iterate(bh, head) {
103
	lvm_list_iterate(bh, head) {
104
		bf = list_item(bh, struct archive_file);
104
		bf = lvm_list_item(bh, struct archive_file);
105
105
106
		if (bf->index > b->index) {
106
		if (bf->index > b->index) {
107
			list_add(&bf->list, &b->list);
107
			lvm_list_add(&bf->list, &b->list);
108
			return;
108
			return;
109
		}
109
		}
110
	}
110
	}
111
111
112
	list_add_h(&bf->list, &b->list);
112
	lvm_list_add_h(&bf->list, &b->list);
113
}
113
}
114
114
115
static char *_join(struct pool *mem, const char *dir, const char *name)
115
static char *_join(struct pool *mem, const char *dir, const char *name)
Lines 119-125 Link Here
119
	    !pool_grow_object(mem, "/", 1) ||
119
	    !pool_grow_object(mem, "/", 1) ||
120
	    !pool_grow_object(mem, name, strlen(name)) ||
120
	    !pool_grow_object(mem, name, strlen(name)) ||
121
	    !pool_grow_object(mem, "\0", 1)) {
121
	    !pool_grow_object(mem, "\0", 1)) {
122
		stack;
122
		STACK;
123
		return NULL;
123
		return NULL;
124
	}
124
	}
125
125
Lines 129-149 Link Here
129
/*
129
/*
130
 * Returns a list of archive_files.
130
 * Returns a list of archive_files.
131
 */
131
 */
132
static struct list *_scan_archive(struct pool *mem,
132
static struct lvm_list *_scan_archive(struct pool *mem,
133
				  const char *vgname, const char *dir)
133
				  const char *vgname, const char *dir)
134
{
134
{
135
	int i, count, ix;
135
	int i, count, ix;
136
	char vgname_found[64], *path;
136
	char vgname_found[64], *path;
137
	struct dirent **dirent;
137
	struct dirent **dirent;
138
	struct archive_file *af;
138
	struct archive_file *af;
139
	struct list *results;
139
	struct lvm_list *results;
140
140
141
	if (!(results = pool_alloc(mem, sizeof(*results)))) {
141
	if (!(results = pool_alloc(mem, sizeof(*results)))) {
142
		stack;
142
		STACK;
143
		return NULL;
143
		return NULL;
144
	}
144
	}
145
145
146
	list_init(results);
146
	lvm_list_init(results);
147
147
148
	/* Sort fails beyond 5-digit indexes */
148
	/* Sort fails beyond 5-digit indexes */
149
	if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
149
	if ((count = scandir(dir, &dirent, NULL, alphasort)) < 0) {
Lines 166-172 Link Here
166
			continue;
166
			continue;
167
167
168
		if (!(path = _join(mem, dir, dirent[i]->d_name))) {
168
		if (!(path = _join(mem, dir, dirent[i]->d_name))) {
169
			stack;
169
			STACK;
170
			goto out;
170
			goto out;
171
		}
171
		}
172
172
Lines 196-205 Link Here
196
	return results;
196
	return results;
197
}
197
}
198
198
199
static void _remove_expired(struct list *archives, uint32_t archives_size,
199
static void _remove_expired(struct lvm_list *archives, uint32_t archives_size,
200
			    uint32_t retain_days, uint32_t min_archive)
200
			    uint32_t retain_days, uint32_t min_archive)
201
{
201
{
202
	struct list *bh;
202
	struct lvm_list *bh;
203
	struct archive_file *bf;
203
	struct archive_file *bf;
204
	struct stat sb;
204
	struct stat sb;
205
	time_t retain_time;
205
	time_t retain_time;
Lines 213-220 Link Here
213
	retain_time = time(NULL) - (time_t) retain_days *SECS_PER_DAY;
213
	retain_time = time(NULL) - (time_t) retain_days *SECS_PER_DAY;
214
214
215
	/* Assume list is ordered oldest first (by index) */
215
	/* Assume list is ordered oldest first (by index) */
216
	list_iterate(bh, archives) {
216
	lvm_list_iterate(bh, archives) {
217
		bf = list_item(bh, struct archive_file);
217
		bf = lvm_list_item(bh, struct archive_file);
218
218
219
		/* Get the mtime of the file and unlink if too old */
219
		/* Get the mtime of the file and unlink if too old */
220
		if (stat(bf->path, &sb)) {
220
		if (stat(bf->path, &sb)) {
Lines 244-250 Link Here
244
	struct archive_file *last;
244
	struct archive_file *last;
245
	FILE *fp = NULL;
245
	FILE *fp = NULL;
246
	char temp_file[PATH_MAX], archive_name[PATH_MAX];
246
	char temp_file[PATH_MAX], archive_name[PATH_MAX];
247
	struct list *archives;
247
	struct lvm_list *archives;
248
248
249
	/*
249
	/*
250
	 * Write the vg out to a temporary file.
250
	 * Write the vg out to a temporary file.
Lines 261-267 Link Here
261
	}
261
	}
262
262
263
	if (!text_vg_export_file(vg, desc, fp)) {
263
	if (!text_vg_export_file(vg, desc, fp)) {
264
		stack;
264
		STACK;
265
		fclose(fp);
265
		fclose(fp);
266
		return 0;
266
		return 0;
267
	}
267
	}
Lines 276-285 Link Here
276
		return 0;
276
		return 0;
277
	}
277
	}
278
278
279
	if (list_empty(archives))
279
	if (lvm_list_empty(archives))
280
		ix = 0;
280
		ix = 0;
281
	else {
281
	else {
282
		last = list_item(archives->p, struct archive_file);
282
		last = lvm_list_item(archives->p, struct archive_file);
283
		ix = last->index + 1;
283
		ix = last->index + 1;
284
	}
284
	}
285
285
Lines 299-305 Link Here
299
	if (!renamed)
299
	if (!renamed)
300
		log_error("Archive rename failed for %s", temp_file);
300
		log_error("Archive rename failed for %s", temp_file);
301
301
302
	_remove_expired(archives, list_size(archives) + renamed, retain_days,
302
	_remove_expired(archives, lvm_list_size(archives) + renamed, retain_days,
303
			min_archive);
303
			min_archive);
304
304
305
	return 1;
305
	return 1;
Lines 344-350 Link Here
344
344
345
int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
345
int archive_list(struct cmd_context *cmd, const char *dir, const char *vgname)
346
{
346
{
347
	struct list *archives, *ah;
347
	struct lvm_list *archives, *ah;
348
	struct archive_file *af;
348
	struct archive_file *af;
349
349
350
	if (!(archives = _scan_archive(cmd->mem, vgname, dir))) {
350
	if (!(archives = _scan_archive(cmd->mem, vgname, dir))) {
Lines 352-362 Link Here
352
		return 0;
352
		return 0;
353
	}
353
	}
354
354
355
	if (list_empty(archives))
355
	if (lvm_list_empty(archives))
356
		log_print("No archives found in %s.", dir);
356
		log_print("No archives found in %s.", dir);
357
357
358
	list_iterate(ah, archives) {
358
	lvm_list_iterate(ah, archives) {
359
		af = list_item(ah, struct archive_file);
359
		af = lvm_list_item(ah, struct archive_file);
360
360
361
		_display_archive(cmd, af);
361
		_display_archive(cmd, af);
362
	}
362
	}
Lines 371-377 Link Here
371
	struct archive_file af;
371
	struct archive_file af;
372
372
373
	if (!(af.path = _join(cmd->mem, dir, vgname))) {
373
	if (!(af.path = _join(cmd->mem, dir, vgname))) {
374
		stack;
374
		STACK;
375
		return 0;
375
		return 0;
376
	}
376
	}
377
377
(-)LVM2.2.00.15.orig/lib/format_text/export.c (-54 / +54 lines)
Lines 253-259 Link Here
253
	return r;
253
	return r;
254
}
254
}
255
255
256
#define _outf(args...) do {if (!_out(args)) {stack; return 0;}} while (0)
256
#define _outf(args...) do {if (!_out(args)) {STACK; return 0;}} while (0)
257
257
258
static int _print_header(struct formatter *f,
258
static int _print_header(struct formatter *f,
259
			 struct volume_group *vg, const char *desc)
259
			 struct volume_group *vg, const char *desc)
Lines 282-288 Link Here
282
	char buffer[4096];
282
	char buffer[4096];
283
283
284
	if (!id_write_format(&vg->id, buffer, sizeof(buffer))) {
284
	if (!id_write_format(&vg->id, buffer, sizeof(buffer))) {
285
		stack;
285
		STACK;
286
		return 0;
286
		return 0;
287
	}
287
	}
288
288
Lines 291-304 Link Here
291
	_outf(f, "seqno = %u", vg->seqno);
291
	_outf(f, "seqno = %u", vg->seqno);
292
292
293
	if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer))) {
293
	if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer))) {
294
		stack;
294
		STACK;
295
		return 0;
295
		return 0;
296
	}
296
	}
297
	_outf(f, "status = %s", buffer);
297
	_outf(f, "status = %s", buffer);
298
298
299
	if (!list_empty(&vg->tags)) {
299
	if (!lvm_list_empty(&vg->tags)) {
300
		if (!print_tags(&vg->tags, buffer, sizeof(buffer))) {
300
		if (!print_tags(&vg->tags, buffer, sizeof(buffer))) {
301
			stack;
301
			STACK;
302
			return 0;
302
			return 0;
303
		}
303
		}
304
		_outf(f, "tags = %s", buffer);
304
		_outf(f, "tags = %s", buffer);
Lines 309-315 Link Here
309
309
310
	if (!_out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
310
	if (!_out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
311
		       vg->extent_size)) {
311
		       vg->extent_size)) {
312
		stack;
312
		STACK;
313
		return 0;
313
		return 0;
314
	}
314
	}
315
	_outf(f, "max_lv = %u", vg->max_lv);
315
	_outf(f, "max_lv = %u", vg->max_lv);
Lines 331-337 Link Here
331
331
332
static int _print_pvs(struct formatter *f, struct volume_group *vg)
332
static int _print_pvs(struct formatter *f, struct volume_group *vg)
333
{
333
{
334
	struct list *pvh;
334
	struct lvm_list *pvh;
335
	struct physical_volume *pv;
335
	struct physical_volume *pv;
336
	char buffer[4096];
336
	char buffer[4096];
337
	const char *name;
337
	const char *name;
Lines 339-349 Link Here
339
	_outf(f, "physical_volumes {");
339
	_outf(f, "physical_volumes {");
340
	_inc_indent(f);
340
	_inc_indent(f);
341
341
342
	list_iterate(pvh, &vg->pvs) {
342
	lvm_list_iterate(pvh, &vg->pvs) {
343
		pv = list_item(pvh, struct pv_list)->pv;
343
		pv = lvm_list_item(pvh, struct pv_list)->pv;
344
344
345
		if (!(name = _get_pv_name(f, pv))) {
345
		if (!(name = _get_pv_name(f, pv))) {
346
			stack;
346
			STACK;
347
			return 0;
347
			return 0;
348
		}
348
		}
349
349
Lines 352-377 Link Here
352
		_inc_indent(f);
352
		_inc_indent(f);
353
353
354
		if (!id_write_format(&pv->id, buffer, sizeof(buffer))) {
354
		if (!id_write_format(&pv->id, buffer, sizeof(buffer))) {
355
			stack;
355
			STACK;
356
			return 0;
356
			return 0;
357
		}
357
		}
358
358
359
		_outf(f, "id = \"%s\"", buffer);
359
		_outf(f, "id = \"%s\"", buffer);
360
		if (!_out_hint(f, "device = \"%s\"", dev_name(pv->dev))) {
360
		if (!_out_hint(f, "device = \"%s\"", dev_name(pv->dev))) {
361
			stack;
361
			STACK;
362
			return 0;
362
			return 0;
363
		}
363
		}
364
		f->nl(f);
364
		f->nl(f);
365
365
366
		if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer))) {
366
		if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer))) {
367
			stack;
367
			STACK;
368
			return 0;
368
			return 0;
369
		}
369
		}
370
		_outf(f, "status = %s", buffer);
370
		_outf(f, "status = %s", buffer);
371
371
372
		if (!list_empty(&pv->tags)) {
372
		if (!lvm_list_empty(&pv->tags)) {
373
			if (!print_tags(&pv->tags, buffer, sizeof(buffer))) {
373
			if (!print_tags(&pv->tags, buffer, sizeof(buffer))) {
374
				stack;
374
				STACK;
375
				return 0;
375
				return 0;
376
			}
376
			}
377
			_outf(f, "tags = %s", buffer);
377
			_outf(f, "tags = %s", buffer);
Lines 380-386 Link Here
380
		_outf(f, "pe_start = %" PRIu64, pv->pe_start);
380
		_outf(f, "pe_start = %" PRIu64, pv->pe_start);
381
		if (!_out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
381
		if (!_out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
382
			       "pe_count = %u", pv->pe_count)) {
382
			       "pe_count = %u", pv->pe_count)) {
383
			stack;
383
			STACK;
384
			return 0;
384
			return 0;
385
		}
385
		}
386
386
Lines 407-422 Link Here
407
	_outf(f, "start_extent = %u", seg->le);
407
	_outf(f, "start_extent = %u", seg->le);
408
	if (!_out_size(f, (uint64_t) seg->len * vg->extent_size,
408
	if (!_out_size(f, (uint64_t) seg->len * vg->extent_size,
409
		       "extent_count = %u", seg->len)) {
409
		       "extent_count = %u", seg->len)) {
410
		stack;
410
		STACK;
411
		return 0;
411
		return 0;
412
	}
412
	}
413
413
414
	f->nl(f);
414
	f->nl(f);
415
	_outf(f, "type = \"%s\"", get_segtype_string(seg->type));
415
	_outf(f, "type = \"%s\"", get_segtype_string(seg->type));
416
416
417
	if (!list_empty(&seg->tags)) {
417
	if (!lvm_list_empty(&seg->tags)) {
418
		if (!print_tags(&seg->tags, buffer, sizeof(buffer))) {
418
		if (!print_tags(&seg->tags, buffer, sizeof(buffer))) {
419
			stack;
419
			STACK;
420
			return 0;
420
			return 0;
421
		}
421
		}
422
		_outf(f, "tags = %s", buffer);
422
		_outf(f, "tags = %s", buffer);
Lines 453-459 Link Here
453
			case AREA_PV:
453
			case AREA_PV:
454
				if (!(name = _get_pv_name(f, seg->
454
				if (!(name = _get_pv_name(f, seg->
455
							  area[s].u.pv.pv))) {
455
							  area[s].u.pv.pv))) {
456
					stack;
456
					STACK;
457
					return 0;
457
					return 0;
458
				}
458
				}
459
459
Lines 483-491 Link Here
483
static int _count_segments(struct logical_volume *lv)
483
static int _count_segments(struct logical_volume *lv)
484
{
484
{
485
	int r = 0;
485
	int r = 0;
486
	struct list *segh;
486
	struct lvm_list *segh;
487
487
488
	list_iterate(segh, &lv->segments)
488
	lvm_list_iterate(segh, &lv->segments)
489
	    r++;
489
	    r++;
490
490
491
	return r;
491
	return r;
Lines 503-516 Link Here
503
	_inc_indent(f);
503
	_inc_indent(f);
504
504
505
	if (!id_write_format(&snap->id, buffer, sizeof(buffer))) {
505
	if (!id_write_format(&snap->id, buffer, sizeof(buffer))) {
506
		stack;
506
		STACK;
507
		return 0;
507
		return 0;
508
	}
508
	}
509
509
510
	_outf(f, "id = \"%s\"", buffer);
510
	_outf(f, "id = \"%s\"", buffer);
511
	if (!print_flags(LVM_READ | LVM_WRITE | VISIBLE_LV, LV_FLAGS,
511
	if (!print_flags(LVM_READ | LVM_WRITE | VISIBLE_LV, LV_FLAGS,
512
			 buffer, sizeof(buffer))) {
512
			 buffer, sizeof(buffer))) {
513
		stack;
513
		STACK;
514
		return 0;
514
		return 0;
515
	}
515
	}
516
516
Lines 527-536 Link Here
527
	seg.chunk_size = snap->chunk_size;
527
	seg.chunk_size = snap->chunk_size;
528
528
529
	/* Can't tag a snapshot independently of its origin */
529
	/* Can't tag a snapshot independently of its origin */
530
	list_init(&seg.tags);
530
	lvm_list_init(&seg.tags);
531
531
532
	if (!_print_segment(f, snap->origin->vg, 1, &seg)) {
532
	if (!_print_segment(f, snap->origin->vg, 1, &seg)) {
533
		stack;
533
		STACK;
534
		return 0;
534
		return 0;
535
	}
535
	}
536
536
Lines 542-556 Link Here
542
542
543
static int _print_snapshots(struct formatter *f, struct volume_group *vg)
543
static int _print_snapshots(struct formatter *f, struct volume_group *vg)
544
{
544
{
545
	struct list *sh;
545
	struct lvm_list *sh;
546
	struct snapshot *s;
546
	struct snapshot *s;
547
	unsigned int count = 0;
547
	unsigned int count = 0;
548
548
549
	list_iterate(sh, &vg->snapshots) {
549
	lvm_list_iterate(sh, &vg->snapshots) {
550
		s = list_item(sh, struct snapshot_list)->snapshot;
550
		s = lvm_list_item(sh, struct snapshot_list)->snapshot;
551
551
552
		if (!_print_snapshot(f, s, count++)) {
552
		if (!_print_snapshot(f, s, count++)) {
553
			stack;
553
			STACK;
554
			return 0;
554
			return 0;
555
		}
555
		}
556
	}
556
	}
Lines 560-566 Link Here
560
560
561
static int _print_lvs(struct formatter *f, struct volume_group *vg)
561
static int _print_lvs(struct formatter *f, struct volume_group *vg)
562
{
562
{
563
	struct list *lvh;
563
	struct lvm_list *lvh;
564
	struct logical_volume *lv;
564
	struct logical_volume *lv;
565
	struct lv_segment *seg;
565
	struct lv_segment *seg;
566
	char buffer[4096];
566
	char buffer[4096];
Lines 569-582 Link Here
569
	/*
569
	/*
570
	 * Don't bother with an lv section if there are no lvs.
570
	 * Don't bother with an lv section if there are no lvs.
571
	 */
571
	 */
572
	if (list_empty(&vg->lvs))
572
	if (lvm_list_empty(&vg->lvs))
573
		return 1;
573
		return 1;
574
574
575
	_outf(f, "logical_volumes {");
575
	_outf(f, "logical_volumes {");
576
	_inc_indent(f);
576
	_inc_indent(f);
577
577
578
	list_iterate(lvh, &vg->lvs) {
578
	lvm_list_iterate(lvh, &vg->lvs) {
579
		lv = list_item(lvh, struct lv_list)->lv;
579
		lv = lvm_list_item(lvh, struct lv_list)->lv;
580
580
581
		f->nl(f);
581
		f->nl(f);
582
		_outf(f, "%s {", lv->name);
582
		_outf(f, "%s {", lv->name);
Lines 584-604 Link Here
584
584
585
		/* FIXME: Write full lvid */
585
		/* FIXME: Write full lvid */
586
		if (!id_write_format(&lv->lvid.id[1], buffer, sizeof(buffer))) {
586
		if (!id_write_format(&lv->lvid.id[1], buffer, sizeof(buffer))) {
587
			stack;
587
			STACK;
588
			return 0;
588
			return 0;
589
		}
589
		}
590
590
591
		_outf(f, "id = \"%s\"", buffer);
591
		_outf(f, "id = \"%s\"", buffer);
592
592
593
		if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer))) {
593
		if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer))) {
594
			stack;
594
			STACK;
595
			return 0;
595
			return 0;
596
		}
596
		}
597
		_outf(f, "status = %s", buffer);
597
		_outf(f, "status = %s", buffer);
598
598
599
		if (!list_empty(&lv->tags)) {
599
		if (!lvm_list_empty(&lv->tags)) {
600
			if (!print_tags(&lv->tags, buffer, sizeof(buffer))) {
600
			if (!print_tags(&lv->tags, buffer, sizeof(buffer))) {
601
				stack;
601
				STACK;
602
				return 0;
602
				return 0;
603
			}
603
			}
604
			_outf(f, "tags = %s", buffer);
604
			_outf(f, "tags = %s", buffer);
Lines 617-625 Link Here
617
		f->nl(f);
617
		f->nl(f);
618
618
619
		seg_count = 1;
619
		seg_count = 1;
620
		list_iterate_items(seg, &lv->segments) {
620
		lvm_list_iterate_items(seg, &lv->segments) {
621
			if (!_print_segment(f, vg, seg_count++, seg)) {
621
			if (!_print_segment(f, vg, seg_count++, seg)) {
622
				stack;
622
				STACK;
623
				return 0;
623
				return 0;
624
			}
624
			}
625
		}
625
		}
Lines 629-635 Link Here
629
	}
629
	}
630
630
631
	if (!_print_snapshots(f, vg)) {
631
	if (!_print_snapshots(f, vg)) {
632
		stack;
632
		STACK;
633
		return 0;
633
		return 0;
634
	}
634
	}
635
635
Lines 647-682 Link Here
647
static int _build_pv_names(struct formatter *f, struct volume_group *vg)
647
static int _build_pv_names(struct formatter *f, struct volume_group *vg)
648
{
648
{
649
	int count = 0;
649
	int count = 0;
650
	struct list *pvh;
650
	struct lvm_list *pvh;
651
	struct physical_volume *pv;
651
	struct physical_volume *pv;
652
	char buffer[32], *name;
652
	char buffer[32], *name;
653
653
654
	if (!(f->mem = pool_create(512))) {
654
	if (!(f->mem = pool_create(512))) {
655
		stack;
655
		STACK;
656
		goto bad;
656
		goto bad;
657
	}
657
	}
658
658
659
	if (!(f->pv_names = hash_create(128))) {
659
	if (!(f->pv_names = hash_create(128))) {
660
		stack;
660
		STACK;
661
		goto bad;
661
		goto bad;
662
	}
662
	}
663
663
664
	list_iterate(pvh, &vg->pvs) {
664
	lvm_list_iterate(pvh, &vg->pvs) {
665
		pv = list_item(pvh, struct pv_list)->pv;
665
		pv = lvm_list_item(pvh, struct pv_list)->pv;
666
666
667
		/* FIXME But skip if there's already an LV called pv%d ! */
667
		/* FIXME But skip if there's already an LV called pv%d ! */
668
		if (lvm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0) {
668
		if (lvm_snprintf(buffer, sizeof(buffer), "pv%d", count++) < 0) {
669
			stack;
669
			STACK;
670
			goto bad;
670
			goto bad;
671
		}
671
		}
672
672
673
		if (!(name = pool_strdup(f->mem, buffer))) {
673
		if (!(name = pool_strdup(f->mem, buffer))) {
674
			stack;
674
			STACK;
675
			goto bad;
675
			goto bad;
676
		}
676
		}
677
677
678
		if (!hash_insert(f->pv_names, dev_name(pv->dev), name)) {
678
		if (!hash_insert(f->pv_names, dev_name(pv->dev), name)) {
679
			stack;
679
			STACK;
680
			goto bad;
680
			goto bad;
681
		}
681
		}
682
	}
682
	}
Lines 699-708 Link Here
699
	int r = 0;
699
	int r = 0;
700
700
701
	if (!_build_pv_names(f, vg)) {
701
	if (!_build_pv_names(f, vg)) {
702
		stack;
702
		STACK;
703
		goto out;
703
		goto out;
704
	}
704
	}
705
#define fail do {stack; goto out;} while(0)
705
#define fail do {STACK; goto out;} while(0)
706
706
707
	if (f->header && !_print_header(f, vg, desc))
707
	if (f->header && !_print_header(f, vg, desc))
708
		fail;
708
		fail;
Lines 751-757 Link Here
751
	_init();
751
	_init();
752
752
753
	if (!(f = dbg_malloc(sizeof(*f)))) {
753
	if (!(f = dbg_malloc(sizeof(*f)))) {
754
		stack;
754
		STACK;
755
		return 0;
755
		return 0;
756
	}
756
	}
757
757
Lines 779-785 Link Here
779
	_init();
779
	_init();
780
780
781
	if (!(f = dbg_malloc(sizeof(*f)))) {
781
	if (!(f = dbg_malloc(sizeof(*f)))) {
782
		stack;
782
		STACK;
783
		return 0;
783
		return 0;
784
	}
784
	}
785
785
Lines 792-798 Link Here
792
	f->nl = &_nl_raw;
792
	f->nl = &_nl_raw;
793
793
794
	if (!_text_vg_export(f, vg, desc)) {
794
	if (!_text_vg_export(f, vg, desc)) {
795
		stack;
795
		STACK;
796
		r = 0;
796
		r = 0;
797
		goto out;
797
		goto out;
798
	}
798
	}
(-)LVM2.2.00.15.orig/lib/format_text/flags.c (-2 / +2 lines)
Lines 83-89 Link Here
83
	struct flag *flags;
83
	struct flag *flags;
84
84
85
	if (!(flags = _get_flags(type))) {
85
	if (!(flags = _get_flags(type))) {
86
		stack;
86
		STACK;
87
		return 0;
87
		return 0;
88
	}
88
	}
89
89
Lines 124-130 Link Here
124
	struct flag *flags;
124
	struct flag *flags;
125
125
126
	if (!(flags = _get_flags(type))) {
126
	if (!(flags = _get_flags(type))) {
127
		stack;
127
		STACK;
128
		return 0;
128
		return 0;
129
	}
129
	}
130
130
(-)LVM2.2.00.15.orig/lib/format_text/format-text.c (-133 / +133 lines)
Lines 45-56 Link Here
45
						     void *context);
45
						     void *context);
46
46
47
struct dir_list {
47
struct dir_list {
48
	struct list list;
48
	struct lvm_list list;
49
	char dir[0];
49
	char dir[0];
50
};
50
};
51
51
52
struct raw_list {
52
struct raw_list {
53
	struct list list;
53
	struct lvm_list list;
54
	struct device_area dev_area;
54
	struct device_area dev_area;
55
};
55
};
56
56
Lines 121-127 Link Here
121
	}
121
	}
122
122
123
	if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah)) {
123
	if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah)) {
124
		stack;
124
		STACK;
125
		pool_free(fmt->cmd->mem, mdah);
125
		pool_free(fmt->cmd->mem, mdah);
126
		return NULL;
126
		return NULL;
127
	}
127
	}
Lines 169-175 Link Here
169
					     sizeof(mdah->checksum_xl)));
169
					     sizeof(mdah->checksum_xl)));
170
170
171
	if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
171
	if (!dev_write(dev, start_byte, MDA_HEADER_SIZE, mdah)) {
172
		stack;
172
		STACK;
173
		pool_free(fmt->cmd->mem, mdah);
173
		pool_free(fmt->cmd->mem, mdah);
174
		return 0;
174
		return 0;
175
	}
175
	}
Lines 191-197 Link Here
191
	while (rlocn->offset) {
191
	while (rlocn->offset) {
192
		if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
192
		if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
193
			      sizeof(vgnamebuf), vgnamebuf)) {
193
			      sizeof(vgnamebuf), vgnamebuf)) {
194
			stack;
194
			STACK;
195
			return NULL;
195
			return NULL;
196
		}
196
		}
197
		if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
197
		if (!strncmp(vgnamebuf, vgname, len = strlen(vgname)) &&
Lines 212-218 Link Here
212
	struct mda_header *mdah;
212
	struct mda_header *mdah;
213
213
214
	if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area))) {
214
	if (!(mdah = _raw_read_mda_header(fid->fmt, dev_area))) {
215
		stack;
215
		STACK;
216
		return NULL;
216
		return NULL;
217
	}
217
	}
218
218
Lines 225-231 Link Here
225
	int r = 0;
225
	int r = 0;
226
226
227
	if (!dev_open(dev_area->dev)) {
227
	if (!dev_open(dev_area->dev)) {
228
		stack;
228
		STACK;
229
		return 0;
229
		return 0;
230
	}
230
	}
231
231
Lines 233-239 Link Here
233
		r = 1;
233
		r = 1;
234
234
235
	if (!dev_close(dev_area->dev))
235
	if (!dev_close(dev_area->dev))
236
		stack;
236
		STACK;
237
237
238
	return r;
238
	return r;
239
}
239
}
Lines 250-266 Link Here
250
	uint32_t wrap = 0;
250
	uint32_t wrap = 0;
251
251
252
	if (!dev_open(area->dev)) {
252
	if (!dev_open(area->dev)) {
253
		stack;
253
		STACK;
254
		return NULL;
254
		return NULL;
255
	}
255
	}
256
256
257
	if (!(mdah = _raw_read_mda_header(fid->fmt, area))) {
257
	if (!(mdah = _raw_read_mda_header(fid->fmt, area))) {
258
		stack;
258
		STACK;
259
		goto out;
259
		goto out;
260
	}
260
	}
261
261
262
	if (!(rlocn = _vg_posn(fid, area, vgname))) {
262
	if (!(rlocn = _vg_posn(fid, area, vgname))) {
263
		stack;
263
		STACK;
264
		goto out;
264
		goto out;
265
	}
265
	}
266
266
Lines 280-286 Link Here
280
				     (off_t) (area->start + MDA_HEADER_SIZE),
280
				     (off_t) (area->start + MDA_HEADER_SIZE),
281
				     wrap, calc_crc, rlocn->checksum, &when,
281
				     wrap, calc_crc, rlocn->checksum, &when,
282
				     &desc))) {
282
				     &desc))) {
283
		stack;
283
		STACK;
284
		goto out;
284
		goto out;
285
	}
285
	}
286
	log_debug("Read %s metadata (%u) from %s at %" PRIu64 " size %" PRIu64,
286
	log_debug("Read %s metadata (%u) from %s at %" PRIu64 " size %" PRIu64,
Lines 289-295 Link Here
289
289
290
      out:
290
      out:
291
	if (!dev_close(area->dev))
291
	if (!dev_close(area->dev))
292
		stack;
292
		STACK;
293
293
294
	return vg;
294
	return vg;
295
}
295
}
Lines 310-316 Link Here
310
	struct raw_locn *rlocn;
310
	struct raw_locn *rlocn;
311
	struct mda_header *mdah;
311
	struct mda_header *mdah;
312
	struct physical_volume *pv;
312
	struct physical_volume *pv;
313
	struct list *pvh;
313
	struct lvm_list *pvh;
314
	int r = 0;
314
	int r = 0;
315
	uint32_t new_wrap = 0, old_wrap = 0;
315
	uint32_t new_wrap = 0, old_wrap = 0;
316
316
Lines 319-326 Link Here
319
	int found = 0;
319
	int found = 0;
320
320
321
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
321
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
322
	list_iterate(pvh, &vg->pvs) {
322
	lvm_list_iterate(pvh, &vg->pvs) {
323
		pv = list_item(pvh, struct pv_list)->pv;
323
		pv = lvm_list_item(pvh, struct pv_list)->pv;
324
		if (pv->dev == mdac->area.dev) {
324
		if (pv->dev == mdac->area.dev) {
325
			found = 1;
325
			found = 1;
326
			break;
326
			break;
Lines 331-342 Link Here
331
		return 1;
331
		return 1;
332
332
333
	if (!dev_open(mdac->area.dev)) {
333
	if (!dev_open(mdac->area.dev)) {
334
		stack;
334
		STACK;
335
		return 0;
335
		return 0;
336
	}
336
	}
337
337
338
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
338
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
339
		stack;
339
		STACK;
340
		goto out;
340
		goto out;
341
	}
341
	}
342
342
Lines 381-387 Link Here
381
	/* Write text out, circularly */
381
	/* Write text out, circularly */
382
	if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
382
	if (!dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
383
		       (size_t) (mdac->rlocn.size - new_wrap), buf)) {
383
		       (size_t) (mdac->rlocn.size - new_wrap), buf)) {
384
		stack;
384
		STACK;
385
		goto out;
385
		goto out;
386
	}
386
	}
387
387
Lines 394-400 Link Here
394
			       mdac->area.start + MDA_HEADER_SIZE,
394
			       mdac->area.start + MDA_HEADER_SIZE,
395
			       (size_t) new_wrap,
395
			       (size_t) new_wrap,
396
			       buf + mdac->rlocn.size - new_wrap)) {
396
			       buf + mdac->rlocn.size - new_wrap)) {
397
			stack;
397
			STACK;
398
			goto out;
398
			goto out;
399
		}
399
		}
400
	}
400
	}
Lines 411-417 Link Here
411
411
412
      out:
412
      out:
413
	if (!r && !dev_close(mdac->area.dev))
413
	if (!r && !dev_close(mdac->area.dev))
414
		stack;
414
		STACK;
415
415
416
	return r;
416
	return r;
417
}
417
}
Lines 423-435 Link Here
423
	struct mda_header *mdah;
423
	struct mda_header *mdah;
424
	struct raw_locn *rlocn;
424
	struct raw_locn *rlocn;
425
	struct physical_volume *pv;
425
	struct physical_volume *pv;
426
	struct list *pvh;
426
	struct lvm_list *pvh;
427
	int r = 0;
427
	int r = 0;
428
	int found = 0;
428
	int found = 0;
429
429
430
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
430
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
431
	list_iterate(pvh, &vg->pvs) {
431
	lvm_list_iterate(pvh, &vg->pvs) {
432
		pv = list_item(pvh, struct pv_list)->pv;
432
		pv = lvm_list_item(pvh, struct pv_list)->pv;
433
		if (pv->dev == mdac->area.dev) {
433
		if (pv->dev == mdac->area.dev) {
434
			found = 1;
434
			found = 1;
435
			break;
435
			break;
Lines 440-446 Link Here
440
		return 1;
440
		return 1;
441
441
442
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
442
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
443
		stack;
443
		STACK;
444
		goto out;
444
		goto out;
445
	}
445
	}
446
446
Lines 466-472 Link Here
466
466
467
      out:
467
      out:
468
	if (!dev_close(mdac->area.dev))
468
	if (!dev_close(mdac->area.dev))
469
		stack;
469
		STACK;
470
470
471
	return r;
471
	return r;
472
}
472
}
Lines 477-488 Link Here
477
{
477
{
478
	struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
478
	struct mda_context *mdac = (struct mda_context *) mda->metadata_locn;
479
	struct physical_volume *pv;
479
	struct physical_volume *pv;
480
	struct list *pvh;
480
	struct lvm_list *pvh;
481
	int found = 0;
481
	int found = 0;
482
482
483
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
483
	/* Ignore any mda on a PV outside the VG. vgsplit relies on this */
484
	list_iterate(pvh, &vg->pvs) {
484
	lvm_list_iterate(pvh, &vg->pvs) {
485
		pv = list_item(pvh, struct pv_list)->pv;
485
		pv = lvm_list_item(pvh, struct pv_list)->pv;
486
		if (pv->dev == mdac->area.dev) {
486
		if (pv->dev == mdac->area.dev) {
487
			found = 1;
487
			found = 1;
488
			break;
488
			break;
Lines 493-499 Link Here
493
		return 1;
493
		return 1;
494
494
495
	if (!dev_close(mdac->area.dev))
495
	if (!dev_close(mdac->area.dev))
496
		stack;
496
		STACK;
497
497
498
	return 1;
498
	return 1;
499
}
499
}
Lines 507-518 Link Here
507
	int r = 0;
507
	int r = 0;
508
508
509
	if (!dev_open(mdac->area.dev)) {
509
	if (!dev_open(mdac->area.dev)) {
510
		stack;
510
		STACK;
511
		return 0;
511
		return 0;
512
	}
512
	}
513
513
514
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
514
	if (!(mdah = _raw_read_mda_header(fid->fmt, &mdac->area))) {
515
		stack;
515
		STACK;
516
		goto out;
516
		goto out;
517
	}
517
	}
518
518
Lines 535-541 Link Here
535
535
536
      out:
536
      out:
537
	if (!dev_close(mdac->area.dev))
537
	if (!dev_close(mdac->area.dev))
538
		stack;
538
		STACK;
539
539
540
	return r;
540
	return r;
541
}
541
}
Lines 549-555 Link Here
549
	char *desc;
549
	char *desc;
550
550
551
	if (!(vg = text_vg_import_file(fid, path_live, &when, &desc))) {
551
	if (!(vg = text_vg_import_file(fid, path_live, &when, &desc))) {
552
		stack;
552
		STACK;
553
		return NULL;
553
		return NULL;
554
	}
554
	}
555
555
Lines 733-739 Link Here
733
{
733
{
734
	struct dirent *dirent;
734
	struct dirent *dirent;
735
	struct dir_list *dl;
735
	struct dir_list *dl;
736
	struct list *dlh, *dir_list;
736
	struct lvm_list *dlh, *dir_list;
737
	char *tmp;
737
	char *tmp;
738
	DIR *d;
738
	DIR *d;
739
	struct volume_group *vg;
739
	struct volume_group *vg;
Lines 743-750 Link Here
743
743
744
	dir_list = &((struct mda_lists *) fmt->private)->dirs;
744
	dir_list = &((struct mda_lists *) fmt->private)->dirs;
745
745
746
	list_iterate(dlh, dir_list) {
746
	lvm_list_iterate(dlh, dir_list) {
747
		dl = list_item(dlh, struct dir_list);
747
		dl = lvm_list_item(dlh, struct dir_list);
748
		if (!(d = opendir(dl->dir))) {
748
		if (!(d = opendir(dl->dir))) {
749
			log_sys_error("opendir", dl->dir);
749
			log_sys_error("opendir", dl->dir);
750
			continue;
750
			continue;
Lines 786-797 Link Here
786
	int r = 0;
786
	int r = 0;
787
787
788
	if (!dev_open(dev_area->dev)) {
788
	if (!dev_open(dev_area->dev)) {
789
		stack;
789
		STACK;
790
		return 0;
790
		return 0;
791
	}
791
	}
792
792
793
	if (!(mdah = _raw_read_mda_header(fmt, dev_area))) {
793
	if (!(mdah = _raw_read_mda_header(fmt, dev_area))) {
794
		stack;
794
		STACK;
795
		goto out;
795
		goto out;
796
	}
796
	}
797
797
Lines 800-806 Link Here
800
	while (rlocn->offset) {
800
	while (rlocn->offset) {
801
		if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
801
		if (!dev_read(dev_area->dev, dev_area->start + rlocn->offset,
802
			      size, buf)) {
802
			      size, buf)) {
803
			stack;
803
			STACK;
804
			goto out;
804
			goto out;
805
		}
805
		}
806
		len = 0;
806
		len = 0;
Lines 811-817 Link Here
811
811
812
		/* Ignore this entry if the characters aren't permissible */
812
		/* Ignore this entry if the characters aren't permissible */
813
		if (!validate_name(buf)) {
813
		if (!validate_name(buf)) {
814
			stack;
814
			STACK;
815
			goto out;
815
			goto out;
816
		}
816
		}
817
817
Lines 824-830 Link Here
824
824
825
      out:
825
      out:
826
	if (!dev_close(dev_area->dev))
826
	if (!dev_close(dev_area->dev))
827
		stack;
827
		STACK;
828
828
829
	return r;
829
	return r;
830
}
830
}
Lines 832-838 Link Here
832
static int _scan_raw(const struct format_type *fmt)
832
static int _scan_raw(const struct format_type *fmt)
833
{
833
{
834
	struct raw_list *rl;
834
	struct raw_list *rl;
835
	struct list *rlh, *raw_list;
835
	struct lvm_list *rlh, *raw_list;
836
	char vgnamebuf[NAME_LEN + 2];
836
	char vgnamebuf[NAME_LEN + 2];
837
	struct volume_group *vg;
837
	struct volume_group *vg;
838
	struct format_instance fid;
838
	struct format_instance fid;
Lines 840-849 Link Here
840
	raw_list = &((struct mda_lists *) fmt->private)->raws;
840
	raw_list = &((struct mda_lists *) fmt->private)->raws;
841
841
842
	fid.fmt = fmt;
842
	fid.fmt = fmt;
843
	list_init(&fid.metadata_areas);
843
	lvm_list_init(&fid.metadata_areas);
844
844
845
	list_iterate(rlh, raw_list) {
845
	lvm_list_iterate(rlh, raw_list) {
846
		rl = list_item(rlh, struct raw_list);
846
		rl = lvm_list_item(rlh, struct raw_list);
847
847
848
		/* FIXME We're reading mdah twice here... */
848
		/* FIXME We're reading mdah twice here... */
849
		if (vgname_from_mda(fmt, &rl->dev_area, vgnamebuf,
849
		if (vgname_from_mda(fmt, &rl->dev_area, vgnamebuf,
Lines 867-873 Link Here
867
static int _mda_setup(const struct format_type *fmt,
867
static int _mda_setup(const struct format_type *fmt,
868
		      uint64_t pe_start, uint64_t pe_end,
868
		      uint64_t pe_start, uint64_t pe_end,
869
		      int pvmetadatacopies,
869
		      int pvmetadatacopies,
870
		      uint64_t pvmetadatasize, struct list *mdas,
870
		      uint64_t pvmetadatasize, struct lvm_list *mdas,
871
		      struct physical_volume *pv, struct volume_group *vg)
871
		      struct physical_volume *pv, struct volume_group *vg)
872
{
872
{
873
	uint64_t mda_adjustment, disk_size, alignment;
873
	uint64_t mda_adjustment, disk_size, alignment;
Lines 994-1005 Link Here
994
/* Only for orphans */
994
/* Only for orphans */
995
/* Set label_sector to -1 if rewriting existing label into same sector */
995
/* Set label_sector to -1 if rewriting existing label into same sector */
996
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
996
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
997
		     struct list *mdas, int64_t label_sector)
997
		     struct lvm_list *mdas, int64_t label_sector)
998
{
998
{
999
	struct label *label;
999
	struct label *label;
1000
	struct lvmcache_info *info;
1000
	struct lvmcache_info *info;
1001
	struct mda_context *mdac;
1001
	struct mda_context *mdac;
1002
	struct list *mdash;
1002
	struct lvm_list *mdash;
1003
	struct metadata_area *mda;
1003
	struct metadata_area *mda;
1004
	char buf[MDA_HEADER_SIZE];
1004
	char buf[MDA_HEADER_SIZE];
1005
	struct mda_header *mdah = (struct mda_header *) buf;
1005
	struct mda_header *mdah = (struct mda_header *) buf;
Lines 1009-1015 Link Here
1009
1009
1010
	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
1010
	if (!(info = lvmcache_add(fmt->labeller, (char *) &pv->id, pv->dev,
1011
				  ORPHAN, NULL))) {
1011
				  ORPHAN, NULL))) {
1012
		stack;
1012
		STACK;
1013
		return 0;
1013
		return 0;
1014
	}
1014
	}
1015
	label = info->label;
1015
	label = info->label;
Lines 1026-1034 Link Here
1026
		if (info->mdas.n)
1026
		if (info->mdas.n)
1027
			del_mdas(&info->mdas);
1027
			del_mdas(&info->mdas);
1028
		else
1028
		else
1029
			list_init(&info->mdas);
1029
			lvm_list_init(&info->mdas);
1030
		list_iterate(mdash, mdas) {
1030
		lvm_list_iterate(mdash, mdas) {
1031
			mda = list_item(mdash, struct metadata_area);
1031
			mda = lvm_list_item(mdash, struct metadata_area);
1032
			mdac = mda->metadata_locn;
1032
			mdac = mda->metadata_locn;
1033
			log_debug("Creating metadata area on %s at sector %"
1033
			log_debug("Creating metadata area on %s at sector %"
1034
				  PRIu64 " size %" PRIu64 " sectors",
1034
				  PRIu64 " size %" PRIu64 " sectors",
Lines 1040-1058 Link Here
1040
		}
1040
		}
1041
		/* FIXME Temporary until mda creation supported by tools */
1041
		/* FIXME Temporary until mda creation supported by tools */
1042
	} else if (!info->mdas.n) {
1042
	} else if (!info->mdas.n) {
1043
		list_init(&info->mdas);
1043
		lvm_list_init(&info->mdas);
1044
	}
1044
	}
1045
1045
1046
	if (info->das.n)
1046
	if (info->das.n)
1047
		del_das(&info->das);
1047
		del_das(&info->das);
1048
	else
1048
	else
1049
		list_init(&info->das);
1049
		lvm_list_init(&info->das);
1050
1050
1051
	/* Set pe_start to first aligned sector after any metadata 
1051
	/* Set pe_start to first aligned sector after any metadata 
1052
	 * areas that begin before pe_start */
1052
	 * areas that begin before pe_start */
1053
	pv->pe_start = PE_ALIGN;
1053
	pv->pe_start = PE_ALIGN;
1054
	list_iterate(mdash, &info->mdas) {
1054
	lvm_list_iterate(mdash, &info->mdas) {
1055
		mda = list_item(mdash, struct metadata_area);
1055
		mda = lvm_list_item(mdash, struct metadata_area);
1056
		mdac = (struct mda_context *) mda->metadata_locn;
1056
		mdac = (struct mda_context *) mda->metadata_locn;
1057
		if (pv->dev == mdac->area.dev &&
1057
		if (pv->dev == mdac->area.dev &&
1058
		    (mdac->area.start < (pv->pe_start << SECTOR_SHIFT)) &&
1058
		    (mdac->area.start < (pv->pe_start << SECTOR_SHIFT)) &&
Lines 1068-1092 Link Here
1068
	if (!add_da
1068
	if (!add_da
1069
	    (fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT,
1069
	    (fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT,
1070
	     UINT64_C(0))) {
1070
	     UINT64_C(0))) {
1071
		stack;
1071
		STACK;
1072
		return 0;
1072
		return 0;
1073
	}
1073
	}
1074
1074
1075
	if (!dev_open(pv->dev)) {
1075
	if (!dev_open(pv->dev)) {
1076
		stack;
1076
		STACK;
1077
		return 0;
1077
		return 0;
1078
	}
1078
	}
1079
1079
1080
	list_iterate(mdash, &info->mdas) {
1080
	lvm_list_iterate(mdash, &info->mdas) {
1081
		mda = list_item(mdash, struct metadata_area);
1081
		mda = lvm_list_item(mdash, struct metadata_area);
1082
		mdac = mda->metadata_locn;
1082
		mdac = mda->metadata_locn;
1083
		memset(&buf, 0, sizeof(buf));
1083
		memset(&buf, 0, sizeof(buf));
1084
		mdah->size = mdac->area.size;
1084
		mdah->size = mdac->area.size;
1085
		if (!_raw_write_mda_header(fmt, mdac->area.dev,
1085
		if (!_raw_write_mda_header(fmt, mdac->area.dev,
1086
					   mdac->area.start, mdah)) {
1086
					   mdac->area.start, mdah)) {
1087
			stack;
1087
			STACK;
1088
			if (!dev_close(pv->dev))
1088
			if (!dev_close(pv->dev))
1089
				stack;
1089
				STACK;
1090
			return 0;
1090
			return 0;
1091
		}
1091
		}
1092
	}
1092
	}
Lines 1094-1100 Link Here
1094
	label_write(pv->dev, label);
1094
	label_write(pv->dev, label);
1095
1095
1096
	if (!dev_close(pv->dev)) {
1096
	if (!dev_close(pv->dev)) {
1097
		stack;
1097
		STACK;
1098
		return 0;
1098
		return 0;
1099
	}
1099
	}
1100
1100
Lines 1105-1111 Link Here
1105
			   const char *id, struct physical_volume *pv)
1105
			   const char *id, struct physical_volume *pv)
1106
{
1106
{
1107
	struct volume_group *vg;
1107
	struct volume_group *vg;
1108
	struct list *pvh;
1108
	struct lvm_list *pvh;
1109
	struct pv_list *pvl;
1109
	struct pv_list *pvl;
1110
	int consistent = 0;
1110
	int consistent = 0;
1111
1111
Lines 1119-1126 Link Here
1119
		log_error("Warning: Volume group %s is not consistent",
1119
		log_error("Warning: Volume group %s is not consistent",
1120
			  vg_name);
1120
			  vg_name);
1121
1121
1122
	list_iterate(pvh, &vg->pvs) {
1122
	lvm_list_iterate(pvh, &vg->pvs) {
1123
		pvl = list_item(pvh, struct pv_list);
1123
		pvl = lvm_list_item(pvh, struct pv_list);
1124
		if (id_equal(&pvl->pv->id, (const struct id *) id)) {
1124
		if (id_equal(&pvl->pv->id, (const struct id *) id)) {
1125
			memcpy(pv, pvl->pv, sizeof(*pv));
1125
			memcpy(pv, pvl->pv, sizeof(*pv));
1126
			return 1;
1126
			return 1;
Lines 1129-1142 Link Here
1129
	return 0;
1129
	return 0;
1130
}
1130
}
1131
1131
1132
static int _add_raw(struct list *raw_list, struct device_area *dev_area)
1132
static int _add_raw(struct lvm_list *raw_list, struct device_area *dev_area)
1133
{
1133
{
1134
	struct raw_list *rl;
1134
	struct raw_list *rl;
1135
	struct list *rlh;
1135
	struct lvm_list *rlh;
1136
1136
1137
	/* Already present? */
1137
	/* Already present? */
1138
	list_iterate(rlh, raw_list) {
1138
	lvm_list_iterate(rlh, raw_list) {
1139
		rl = list_item(rlh, struct raw_list);
1139
		rl = lvm_list_item(rlh, struct raw_list);
1140
		/* FIXME Check size/overlap consistency too */
1140
		/* FIXME Check size/overlap consistency too */
1141
		if (rl->dev_area.dev == dev_area->dev &&
1141
		if (rl->dev_area.dev == dev_area->dev &&
1142
		    rl->dev_area.start == dev_area->start)
1142
		    rl->dev_area.start == dev_area->start)
Lines 1148-1177 Link Here
1148
		return 0;
1148
		return 0;
1149
	}
1149
	}
1150
	memcpy(&rl->dev_area, dev_area, sizeof(*dev_area));
1150
	memcpy(&rl->dev_area, dev_area, sizeof(*dev_area));
1151
	list_add(raw_list, &rl->list);
1151
	lvm_list_add(raw_list, &rl->list);
1152
1152
1153
	return 1;
1153
	return 1;
1154
}
1154
}
1155
1155
1156
static int _pv_read(const struct format_type *fmt, const char *pv_name,
1156
static int _pv_read(const struct format_type *fmt, const char *pv_name,
1157
		    struct physical_volume *pv, struct list *mdas)
1157
		    struct physical_volume *pv, struct lvm_list *mdas)
1158
{
1158
{
1159
	struct label *label;
1159
	struct label *label;
1160
	struct device *dev;
1160
	struct device *dev;
1161
	struct lvmcache_info *info;
1161
	struct lvmcache_info *info;
1162
	struct metadata_area *mda, *mda_new;
1162
	struct metadata_area *mda, *mda_new;
1163
	struct mda_context *mdac, *mdac_new;
1163
	struct mda_context *mdac, *mdac_new;
1164
	struct list *mdah, *dah;
1164
	struct lvm_list *mdah, *dah;
1165
	struct data_area_list *da;
1165
	struct data_area_list *da;
1166
1166
1167
	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
1167
	if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) {
1168
		stack;
1168
		STACK;
1169
		return 0;
1169
		return 0;
1170
	}
1170
	}
1171
1171
1172
	/* FIXME Optimise out repeated reading when cache lock held */
1172
	/* FIXME Optimise out repeated reading when cache lock held */
1173
	if (!(label_read(dev, &label))) {
1173
	if (!(label_read(dev, &label))) {
1174
		stack;
1174
		STACK;
1175
		return 0;
1175
		return 0;
1176
	}
1176
	}
1177
	info = (struct lvmcache_info *) label->info;
1177
	info = (struct lvmcache_info *) label->info;
Lines 1203-1215 Link Here
1203
	memcpy(&pv->id, &info->dev->pvid, sizeof(pv->id));
1203
	memcpy(&pv->id, &info->dev->pvid, sizeof(pv->id));
1204
1204
1205
	/* Currently only support exactly one data area */
1205
	/* Currently only support exactly one data area */
1206
	if (list_size(&info->das) != 1) {
1206
	if (lvm_list_size(&info->das) != 1) {
1207
		log_error("Must be exactly one data area (found %d) on PV %s",
1207
		log_error("Must be exactly one data area (found %d) on PV %s",
1208
			  list_size(&info->das), dev_name(dev));
1208
			  lvm_list_size(&info->das), dev_name(dev));
1209
		return 0;
1209
		return 0;
1210
	}
1210
	}
1211
	list_iterate(dah, &info->das) {
1211
	lvm_list_iterate(dah, &info->das) {
1212
		da = list_item(dah, struct data_area_list);
1212
		da = lvm_list_item(dah, struct data_area_list);
1213
		pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT;
1213
		pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT;
1214
	}
1214
	}
1215
1215
Lines 1217-1224 Link Here
1217
		return 1;
1217
		return 1;
1218
1218
1219
	/* Add copy of mdas to supplied list */
1219
	/* Add copy of mdas to supplied list */
1220
	list_iterate(mdah, &info->mdas) {
1220
	lvm_list_iterate(mdah, &info->mdas) {
1221
		mda = list_item(mdah, struct metadata_area);
1221
		mda = lvm_list_item(mdah, struct metadata_area);
1222
		mdac = (struct mda_context *) mda->metadata_locn;
1222
		mdac = (struct mda_context *) mda->metadata_locn;
1223
		if (!(mda_new = pool_alloc(fmt->cmd->mem, sizeof(*mda_new)))) {
1223
		if (!(mda_new = pool_alloc(fmt->cmd->mem, sizeof(*mda_new)))) {
1224
			log_error("metadata_area allocation failed");
1224
			log_error("metadata_area allocation failed");
Lines 1231-1237 Link Here
1231
		memcpy(mda_new, mda, sizeof(*mda));
1231
		memcpy(mda_new, mda, sizeof(*mda));
1232
		memcpy(mdac_new, mdac, sizeof(*mdac));
1232
		memcpy(mdac_new, mdac, sizeof(*mdac));
1233
		mda_new->metadata_locn = mdac_new;
1233
		mda_new->metadata_locn = mdac_new;
1234
		list_add(mdas, &mda_new->list);
1234
		lvm_list_add(mdas, &mda_new->list);
1235
	}
1235
	}
1236
1236
1237
	return 1;
1237
	return 1;
Lines 1242-1263 Link Here
1242
	return;
1242
	return;
1243
}
1243
}
1244
1244
1245
static void _free_dirs(struct list *dir_list)
1245
static void _free_dirs(struct lvm_list *dir_list)
1246
{
1246
{
1247
	struct list *dl, *tmp;
1247
	struct lvm_list *dl, *tmp;
1248
1248
1249
	list_iterate_safe(dl, tmp, dir_list) {
1249
	lvm_list_iterate_safe(dl, tmp, dir_list) {
1250
		list_del(dl);
1250
		lvm_list_del(dl);
1251
		dbg_free(dl);
1251
		dbg_free(dl);
1252
	}
1252
	}
1253
}
1253
}
1254
1254
1255
static void _free_raws(struct list *raw_list)
1255
static void _free_raws(struct lvm_list *raw_list)
1256
{
1256
{
1257
	struct list *rl, *tmp;
1257
	struct lvm_list *rl, *tmp;
1258
1258
1259
	list_iterate_safe(rl, tmp, raw_list) {
1259
	lvm_list_iterate_safe(rl, tmp, raw_list) {
1260
		list_del(rl);
1260
		lvm_list_del(rl);
1261
		dbg_free(rl);
1261
		dbg_free(rl);
1262
	}
1262
	}
1263
}
1263
}
Lines 1300-1311 Link Here
1300
		     uint64_t pe_start, uint32_t extent_count,
1300
		     uint64_t pe_start, uint32_t extent_count,
1301
		     uint32_t extent_size,
1301
		     uint32_t extent_size,
1302
		     int pvmetadatacopies,
1302
		     int pvmetadatacopies,
1303
		     uint64_t pvmetadatasize, struct list *mdas,
1303
		     uint64_t pvmetadatasize, struct lvm_list *mdas,
1304
		     struct physical_volume *pv, struct volume_group *vg)
1304
		     struct physical_volume *pv, struct volume_group *vg)
1305
{
1305
{
1306
	struct metadata_area *mda, *mda_new, *mda2;
1306
	struct metadata_area *mda, *mda_new, *mda2;
1307
	struct mda_context *mdac, *mdac_new, *mdac2;
1307
	struct mda_context *mdac, *mdac_new, *mdac2;
1308
	struct list *pvmdas, *pvmdash, *mdash;
1308
	struct lvm_list *pvmdas, *pvmdash, *mdash;
1309
	struct lvmcache_info *info;
1309
	struct lvmcache_info *info;
1310
	int found;
1310
	int found;
1311
	uint64_t pe_end = 0;
1311
	uint64_t pe_end = 0;
Lines 1320-1327 Link Here
1320
		/* Iterate through all mdas on this PV */
1320
		/* Iterate through all mdas on this PV */
1321
		if ((info = info_from_pvid(pv->dev->pvid))) {
1321
		if ((info = info_from_pvid(pv->dev->pvid))) {
1322
			pvmdas = &info->mdas;
1322
			pvmdas = &info->mdas;
1323
			list_iterate(pvmdash, pvmdas) {
1323
			lvm_list_iterate(pvmdash, pvmdas) {
1324
				mda = list_item(pvmdash, struct metadata_area);
1324
				mda = lvm_list_item(pvmdash, struct metadata_area);
1325
				mdac =
1325
				mdac =
1326
				    (struct mda_context *) mda->metadata_locn;
1326
				    (struct mda_context *) mda->metadata_locn;
1327
1327
Lines 1329-1337 Link Here
1329
1329
1330
				/* Ensure it isn't already on list */
1330
				/* Ensure it isn't already on list */
1331
				found = 0;
1331
				found = 0;
1332
				list_iterate(mdash, mdas) {
1332
				lvm_list_iterate(mdash, mdas) {
1333
					mda2 =
1333
					mda2 =
1334
					    list_item(mdash,
1334
					    lvm_list_item(mdash,
1335
						      struct metadata_area);
1335
						      struct metadata_area);
1336
					if (mda2->ops !=
1336
					if (mda2->ops !=
1337
					    &_metadata_text_raw_ops)
1337
					    &_metadata_text_raw_ops)
Lines 1351-1371 Link Here
1351
1351
1352
				if (!(mda_new = pool_alloc(fmt->cmd->mem,
1352
				if (!(mda_new = pool_alloc(fmt->cmd->mem,
1353
							   sizeof(*mda_new)))) {
1353
							   sizeof(*mda_new)))) {
1354
					stack;
1354
					STACK;
1355
					return 0;
1355
					return 0;
1356
				}
1356
				}
1357
1357
1358
				if (!(mdac_new = pool_alloc(fmt->cmd->mem,
1358
				if (!(mdac_new = pool_alloc(fmt->cmd->mem,
1359
							    sizeof(*mdac_new))))
1359
							    sizeof(*mdac_new))))
1360
				{
1360
				{
1361
					stack;
1361
					STACK;
1362
					return 0;
1362
					return 0;
1363
				}
1363
				}
1364
				/* FIXME multiple dev_areas inside area */
1364
				/* FIXME multiple dev_areas inside area */
1365
				memcpy(mda_new, mda, sizeof(*mda));
1365
				memcpy(mda_new, mda, sizeof(*mda));
1366
				memcpy(mdac_new, mdac, sizeof(*mdac));
1366
				memcpy(mdac_new, mdac, sizeof(*mdac));
1367
				mda_new->metadata_locn = mdac_new;
1367
				mda_new->metadata_locn = mdac_new;
1368
				list_add(mdas, &mda_new->list);
1368
				lvm_list_add(mdas, &mda_new->list);
1369
			}
1369
			}
1370
		}
1370
		}
1371
1371
Lines 1377-1383 Link Here
1377
			pe_end = pe_start + extent_count * extent_size - 1;
1377
			pe_end = pe_start + extent_count * extent_size - 1;
1378
		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,
1378
		if (!_mda_setup(fmt, pe_start, pe_end, pvmetadatacopies,
1379
				pvmetadatasize, mdas, pv, vg)) {
1379
				pvmetadatasize, mdas, pv, vg)) {
1380
			stack;
1380
			STACK;
1381
			return 0;
1381
			return 0;
1382
		}
1382
		}
1383
1383
Lines 1396-1402 Link Here
1396
	struct mda_context *mdac, *mdac_new;
1396
	struct mda_context *mdac, *mdac_new;
1397
	struct dir_list *dl;
1397
	struct dir_list *dl;
1398
	struct raw_list *rl;
1398
	struct raw_list *rl;
1399
	struct list *dlh, *dir_list, *rlh, *raw_list, *mdas, *mdash, *infoh;
1399
	struct lvm_list *dlh, *dir_list, *rlh, *raw_list, *mdas, *mdash, *infoh;
1400
	char path[PATH_MAX];
1400
	char path[PATH_MAX];
1401
	struct lvmcache_vginfo *vginfo;
1401
	struct lvmcache_vginfo *vginfo;
1402
1402
Lines 1407-1427 Link Here
1407
1407
1408
	fid->fmt = fmt;
1408
	fid->fmt = fmt;
1409
1409
1410
	list_init(&fid->metadata_areas);
1410
	lvm_list_init(&fid->metadata_areas);
1411
1411
1412
	if (!vgname) {
1412
	if (!vgname) {
1413
		if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1413
		if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1414
			stack;
1414
			STACK;
1415
			return NULL;
1415
			return NULL;
1416
		}
1416
		}
1417
		mda->ops = &_metadata_text_file_backup_ops;
1417
		mda->ops = &_metadata_text_file_backup_ops;
1418
		mda->metadata_locn = context;
1418
		mda->metadata_locn = context;
1419
		list_add(&fid->metadata_areas, &mda->list);
1419
		lvm_list_add(&fid->metadata_areas, &mda->list);
1420
	} else {
1420
	} else {
1421
		dir_list = &((struct mda_lists *) fmt->private)->dirs;
1421
		dir_list = &((struct mda_lists *) fmt->private)->dirs;
1422
1422
1423
		list_iterate(dlh, dir_list) {
1423
		lvm_list_iterate(dlh, dir_list) {
1424
			dl = list_item(dlh, struct dir_list);
1424
			dl = lvm_list_item(dlh, struct dir_list);
1425
			if (lvm_snprintf(path, PATH_MAX, "%s/%s",
1425
			if (lvm_snprintf(path, PATH_MAX, "%s/%s",
1426
					 dl->dir, vgname) < 0) {
1426
					 dl->dir, vgname) < 0) {
1427
				log_error("Name too long %s/%s", dl->dir,
1427
				log_error("Name too long %s/%s", dl->dir,
Lines 1431-1460 Link Here
1431
1431
1432
			context = create_text_context(fmt->cmd, path, NULL);
1432
			context = create_text_context(fmt->cmd, path, NULL);
1433
			if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1433
			if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1434
				stack;
1434
				STACK;
1435
				return NULL;
1435
				return NULL;
1436
			}
1436
			}
1437
			mda->ops = &_metadata_text_file_ops;
1437
			mda->ops = &_metadata_text_file_ops;
1438
			mda->metadata_locn = context;
1438
			mda->metadata_locn = context;
1439
			list_add(&fid->metadata_areas, &mda->list);
1439
			lvm_list_add(&fid->metadata_areas, &mda->list);
1440
		}
1440
		}
1441
1441
1442
		raw_list = &((struct mda_lists *) fmt->private)->raws;
1442
		raw_list = &((struct mda_lists *) fmt->private)->raws;
1443
1443
1444
		list_iterate(rlh, raw_list) {
1444
		lvm_list_iterate(rlh, raw_list) {
1445
			rl = list_item(rlh, struct raw_list);
1445
			rl = lvm_list_item(rlh, struct raw_list);
1446
1446
1447
			/* FIXME Cache this; rescan below if some missing */
1447
			/* FIXME Cache this; rescan below if some missing */
1448
			if (!_raw_holds_vgname(fid, &rl->dev_area, vgname))
1448
			if (!_raw_holds_vgname(fid, &rl->dev_area, vgname))
1449
				continue;
1449
				continue;
1450
1450
1451
			if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1451
			if (!(mda = pool_alloc(fmt->cmd->mem, sizeof(*mda)))) {
1452
				stack;
1452
				STACK;
1453
				return NULL;
1453
				return NULL;
1454
			}
1454
			}
1455
1455
1456
			if (!(mdac = pool_alloc(fmt->cmd->mem, sizeof(*mdac)))) {
1456
			if (!(mdac = pool_alloc(fmt->cmd->mem, sizeof(*mdac)))) {
1457
				stack;
1457
				STACK;
1458
				return NULL;
1458
				return NULL;
1459
			}
1459
			}
1460
			mda->metadata_locn = mdac;
1460
			mda->metadata_locn = mdac;
Lines 1462-1501 Link Here
1462
			memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
1462
			memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
1463
			mda->ops = &_metadata_text_raw_ops;
1463
			mda->ops = &_metadata_text_raw_ops;
1464
			/* FIXME MISTAKE? mda->metadata_locn = context; */
1464
			/* FIXME MISTAKE? mda->metadata_locn = context; */
1465
			list_add(&fid->metadata_areas, &mda->list);
1465
			lvm_list_add(&fid->metadata_areas, &mda->list);
1466
		}
1466
		}
1467
1467
1468
		/* Scan PVs in VG for any further MDAs */
1468
		/* Scan PVs in VG for any further MDAs */
1469
		lvmcache_label_scan(fmt->cmd, 0);
1469
		lvmcache_label_scan(fmt->cmd, 0);
1470
		if (!(vginfo = vginfo_from_vgname(vgname))) {
1470
		if (!(vginfo = vginfo_from_vgname(vgname))) {
1471
			stack;
1471
			STACK;
1472
			goto out;
1472
			goto out;
1473
		}
1473
		}
1474
		list_iterate(infoh, &vginfo->infos) {
1474
		lvm_list_iterate(infoh, &vginfo->infos) {
1475
			mdas = &(list_item(infoh, struct lvmcache_info)->mdas);
1475
			mdas = &(lvm_list_item(infoh, struct lvmcache_info)->mdas);
1476
			list_iterate(mdash, mdas) {
1476
			lvm_list_iterate(mdash, mdas) {
1477
				mda = list_item(mdash, struct metadata_area);
1477
				mda = lvm_list_item(mdash, struct metadata_area);
1478
				mdac =
1478
				mdac =
1479
				    (struct mda_context *) mda->metadata_locn;
1479
				    (struct mda_context *) mda->metadata_locn;
1480
1480
1481
				/* FIXME Check it holds this VG */
1481
				/* FIXME Check it holds this VG */
1482
				if (!(mda_new = pool_alloc(fmt->cmd->mem,
1482
				if (!(mda_new = pool_alloc(fmt->cmd->mem,
1483
							   sizeof(*mda_new)))) {
1483
							   sizeof(*mda_new)))) {
1484
					stack;
1484
					STACK;
1485
					return NULL;
1485
					return NULL;
1486
				}
1486
				}
1487
1487
1488
				if (!(mdac_new = pool_alloc(fmt->cmd->mem,
1488
				if (!(mdac_new = pool_alloc(fmt->cmd->mem,
1489
							    sizeof(*mdac_new))))
1489
							    sizeof(*mdac_new))))
1490
				{
1490
				{
1491
					stack;
1491
					STACK;
1492
					return NULL;
1492
					return NULL;
1493
				}
1493
				}
1494
				/* FIXME multiple dev_areas inside area */
1494
				/* FIXME multiple dev_areas inside area */
1495
				memcpy(mda_new, mda, sizeof(*mda));
1495
				memcpy(mda_new, mda, sizeof(*mda));
1496
				memcpy(mdac_new, mdac, sizeof(*mdac));
1496
				memcpy(mdac_new, mdac, sizeof(*mdac));
1497
				mda_new->metadata_locn = mdac_new;
1497
				mda_new->metadata_locn = mdac_new;
1498
				list_add(&fid->metadata_areas, &mda_new->list);
1498
				lvm_list_add(&fid->metadata_areas, &mda_new->list);
1499
			}
1499
			}
1500
		}
1500
		}
1501
		/* FIXME Check raw metadata area count - rescan if required */
1501
		/* FIXME Check raw metadata area count - rescan if required */
Lines 1519-1535 Link Here
1519
	}
1519
	}
1520
1520
1521
	if (!(tc = pool_alloc(cmd->mem, sizeof(*tc)))) {
1521
	if (!(tc = pool_alloc(cmd->mem, sizeof(*tc)))) {
1522
		stack;
1522
		STACK;
1523
		return NULL;
1523
		return NULL;
1524
	}
1524
	}
1525
1525
1526
	if (!(tc->path_live = pool_strdup(cmd->mem, path))) {
1526
	if (!(tc->path_live = pool_strdup(cmd->mem, path))) {
1527
		stack;
1527
		STACK;
1528
		goto no_mem;
1528
		goto no_mem;
1529
	}
1529
	}
1530
1530
1531
	if (!(tc->path_edit = pool_alloc(cmd->mem, strlen(path) + 5))) {
1531
	if (!(tc->path_edit = pool_alloc(cmd->mem, strlen(path) + 5))) {
1532
		stack;
1532
		STACK;
1533
		goto no_mem;
1533
		goto no_mem;
1534
	}
1534
	}
1535
	sprintf(tc->path_edit, "%s.tmp", path);
1535
	sprintf(tc->path_edit, "%s.tmp", path);
Lines 1538-1544 Link Here
1538
		desc = "";
1538
		desc = "";
1539
1539
1540
	if (!(tc->desc = pool_strdup(cmd->mem, desc))) {
1540
	if (!(tc->desc = pool_strdup(cmd->mem, desc))) {
1541
		stack;
1541
		STACK;
1542
		goto no_mem;
1542
		goto no_mem;
1543
	}
1543
	}
1544
1544
Lines 1563-1580 Link Here
1563
	destroy:_destroy
1563
	destroy:_destroy
1564
};
1564
};
1565
1565
1566
static int _add_dir(const char *dir, struct list *dir_list)
1566
static int _add_dir(const char *dir, struct lvm_list *dir_list)
1567
{
1567
{
1568
	struct dir_list *dl;
1568
	struct dir_list *dl;
1569
1569
1570
	if (create_dir(dir)) {
1570
	if (create_dir(dir)) {
1571
		if (!(dl = dbg_malloc(sizeof(struct list) + strlen(dir) + 1))) {
1571
		if (!(dl = dbg_malloc(sizeof(struct lvm_list) + strlen(dir) + 1))) {
1572
			log_error("_add_dir allocation failed");
1572
			log_error("_add_dir allocation failed");
1573
			return 0;
1573
			return 0;
1574
		}
1574
		}
1575
		log_very_verbose("Adding text format metadata dir: %s", dir);
1575
		log_very_verbose("Adding text format metadata dir: %s", dir);
1576
		strcpy(dl->dir, dir);
1576
		strcpy(dl->dir, dir);
1577
		list_add(dir_list, &dl->list);
1577
		lvm_list_add(dir_list, &dl->list);
1578
		return 1;
1578
		return 1;
1579
	}
1579
	}
1580
1580
Lines 1582-1588 Link Here
1582
}
1582
}
1583
1583
1584
static int _get_config_disk_area(struct cmd_context *cmd,
1584
static int _get_config_disk_area(struct cmd_context *cmd,
1585
				 struct config_node *cn, struct list *raw_list)
1585
				 struct config_node *cn, struct lvm_list *raw_list)
1586
{
1586
{
1587
	struct device_area dev_area;
1587
	struct device_area dev_area;
1588
	char *id_str;
1588
	char *id_str;
Lines 1641-1647 Link Here
1641
	struct mda_lists *mda_lists;
1641
	struct mda_lists *mda_lists;
1642
1642
1643
	if (!(fmt = dbg_malloc(sizeof(*fmt)))) {
1643
	if (!(fmt = dbg_malloc(sizeof(*fmt)))) {
1644
		stack;
1644
		STACK;
1645
		return NULL;
1645
		return NULL;
1646
	}
1646
	}
1647
1647
Lines 1656-1663 Link Here
1656
		return NULL;
1656
		return NULL;
1657
	}
1657
	}
1658
1658
1659
	list_init(&mda_lists->dirs);
1659
	lvm_list_init(&mda_lists->dirs);
1660
	list_init(&mda_lists->raws);
1660
	lvm_list_init(&mda_lists->raws);
1661
	mda_lists->file_ops = &_metadata_text_file_ops;
1661
	mda_lists->file_ops = &_metadata_text_file_ops;
1662
	mda_lists->raw_ops = &_metadata_text_raw_ops;
1662
	mda_lists->raw_ops = &_metadata_text_raw_ops;
1663
	fmt->private = (void *) mda_lists;
1663
	fmt->private = (void *) mda_lists;
(-)LVM2.2.00.15.orig/lib/format_text/format-text.h (-4 / +4 lines)
Lines 47-59 Link Here
47
47
48
int pvhdr_read(struct device *dev, char *buf);
48
int pvhdr_read(struct device *dev, char *buf);
49
49
50
int add_da(const struct format_type *fmt, struct pool *mem, struct list *das,
50
int add_da(const struct format_type *fmt, struct pool *mem, struct lvm_list *das,
51
	   uint64_t start, uint64_t size);
51
	   uint64_t start, uint64_t size);
52
void del_das(struct list *das);
52
void del_das(struct lvm_list *das);
53
53
54
int add_mda(const struct format_type *fmt, struct pool *mem, struct list *mdas,
54
int add_mda(const struct format_type *fmt, struct pool *mem, struct lvm_list *mdas,
55
	    struct device *dev, uint64_t start, uint64_t size);
55
	    struct device *dev, uint64_t start, uint64_t size);
56
void del_mdas(struct list *mdas);
56
void del_mdas(struct lvm_list *mdas);
57
57
58
int vgname_from_mda(const struct format_type *fmt, struct device_area *dev_area,
58
int vgname_from_mda(const struct format_type *fmt, struct device_area *dev_area,
59
		    char *buf, uint32_t size);
59
		    char *buf, uint32_t size);
(-)LVM2.2.00.15.orig/lib/format_text/import-export.h (-2 / +2 lines)
Lines 55-62 Link Here
55
int print_flags(uint32_t status, int type, char *buffer, size_t size);
55
int print_flags(uint32_t status, int type, char *buffer, size_t size);
56
int read_flags(uint32_t *status, int type, struct config_value *cv);
56
int read_flags(uint32_t *status, int type, struct config_value *cv);
57
57
58
int print_tags(struct list *tags, char *buffer, size_t size);
58
int print_tags(struct lvm_list *tags, char *buffer, size_t size);
59
int read_tags(struct pool *mem, struct list *tags, struct config_value *cv);
59
int read_tags(struct pool *mem, struct lvm_list *tags, struct config_value *cv);
60
60
61
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
61
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
62
int text_vg_export_raw(struct volume_group *vg, const char *desc, char *buf,
62
int text_vg_export_raw(struct volume_group *vg, const char *desc, char *buf,
(-)LVM2.2.00.15.orig/lib/format_text/import.c (-2 / +2 lines)
Lines 50-56 Link Here
50
	*when = 0;
50
	*when = 0;
51
51
52
	if (!(cft = create_config_tree())) {
52
	if (!(cft = create_config_tree())) {
53
		stack;
53
		STACK;
54
		goto out;
54
		goto out;
55
	}
55
	}
56
56
Lines 69-75 Link Here
69
			continue;
69
			continue;
70
70
71
		if (!(vg = (*vsn)->read_vg(fid, cft))) {
71
		if (!(vg = (*vsn)->read_vg(fid, cft))) {
72
			stack;
72
			STACK;
73
			goto out;
73
			goto out;
74
		}
74
		}
75
75
(-)LVM2.2.00.15.orig/lib/format_text/import_vsn1.c (-29 / +29 lines)
Lines 118-124 Link Here
118
118
119
	if (!(pvl = pool_zalloc(mem, sizeof(*pvl))) ||
119
	if (!(pvl = pool_zalloc(mem, sizeof(*pvl))) ||
120
	    !(pvl->pv = pool_zalloc(mem, sizeof(*pvl->pv)))) {
120
	    !(pvl->pv = pool_zalloc(mem, sizeof(*pvl->pv)))) {
121
		stack;
121
		STACK;
122
		return 0;
122
		return 0;
123
	}
123
	}
124
124
Lines 129-135 Link Here
129
	 * the lv segments.
129
	 * the lv segments.
130
	 */
130
	 */
131
	if (!hash_insert(pv_hash, pvn->key, pv)) {
131
	if (!hash_insert(pv_hash, pvn->key, pv)) {
132
		stack;
132
		STACK;
133
		return 0;
133
		return 0;
134
	}
134
	}
135
135
Lines 162-168 Link Here
162
	}
162
	}
163
163
164
	if (!(pv->vg_name = pool_strdup(mem, vg->name))) {
164
	if (!(pv->vg_name = pool_strdup(mem, vg->name))) {
165
		stack;
165
		STACK;
166
		return 0;
166
		return 0;
167
	}
167
	}
168
168
Lines 187-193 Link Here
187
		return 0;
187
		return 0;
188
	}
188
	}
189
189
190
	list_init(&pv->tags);
190
	lvm_list_init(&pv->tags);
191
191
192
	/* Optional tags */
192
	/* Optional tags */
193
	if ((cn = find_config_node(pvn, "tags")) &&
193
	if ((cn = find_config_node(pvn, "tags")) &&
Lines 207-233 Link Here
207
	pv->fmt = fid->fmt;
207
	pv->fmt = fid->fmt;
208
208
209
	vg->pv_count++;
209
	vg->pv_count++;
210
	list_add(&vg->pvs, &pvl->list);
210
	lvm_list_add(&vg->pvs, &pvl->list);
211
211
212
	return 1;
212
	return 1;
213
}
213
}
214
214
215
static void _insert_segment(struct logical_volume *lv, struct lv_segment *seg)
215
static void _insert_segment(struct logical_volume *lv, struct lv_segment *seg)
216
{
216
{
217
	struct list *segh;
217
	struct lvm_list *segh;
218
	struct lv_segment *comp;
218
	struct lv_segment *comp;
219
219
220
	list_iterate(segh, &lv->segments) {
220
	lvm_list_iterate(segh, &lv->segments) {
221
		comp = list_item(segh, struct lv_segment);
221
		comp = lvm_list_item(segh, struct lv_segment);
222
222
223
		if (comp->le > seg->le) {
223
		if (comp->le > seg->le) {
224
			list_add(&comp->list, &seg->list);
224
			lvm_list_add(&comp->list, &seg->list);
225
			return;
225
			return;
226
		}
226
		}
227
	}
227
	}
228
228
229
	lv->le_count += seg->len;
229
	lv->le_count += seg->len;
230
	list_add(&lv->segments, &seg->list);
230
	lvm_list_add(&lv->segments, &seg->list);
231
}
231
}
232
232
233
static int _read_segment(struct pool *mem, struct volume_group *vg,
233
static int _read_segment(struct pool *mem, struct volume_group *vg,
Lines 358-364 Link Here
358
		}
358
		}
359
359
360
		if (!vg_add_snapshot(org, cow, 1, &lv->lvid.id[1], chunk_size)) {
360
		if (!vg_add_snapshot(org, cow, 1, &lv->lvid.id[1], chunk_size)) {
361
			stack;
361
			STACK;
362
			return 0;
362
			return 0;
363
		}
363
		}
364
		break;
364
		break;
Lines 476-482 Link Here
476
		 */
476
		 */
477
		if (!sn->v) {
477
		if (!sn->v) {
478
			if (!_read_segment(mem, vg, lv, sn, pv_hash)) {
478
			if (!_read_segment(mem, vg, lv, sn, pv_hash)) {
479
				stack;
479
				STACK;
480
				return 0;
480
				return 0;
481
			}
481
			}
482
482
Lines 504-510 Link Here
504
	 * Check there are no gaps or overlaps in the lv.
504
	 * Check there are no gaps or overlaps in the lv.
505
	 */
505
	 */
506
	if (!lv_check_segments(lv)) {
506
	if (!lv_check_segments(lv)) {
507
		stack;
507
		STACK;
508
		return 0;
508
		return 0;
509
	}
509
	}
510
510
Lines 512-518 Link Here
512
	 * Merge segments in case someones been editing things by hand.
512
	 * Merge segments in case someones been editing things by hand.
513
	 */
513
	 */
514
	if (!lv_merge_segments(lv)) {
514
	if (!lv_merge_segments(lv)) {
515
		stack;
515
		STACK;
516
		return 0;
516
		return 0;
517
	}
517
	}
518
518
Lines 529-542 Link Here
529
529
530
	if (!(lvl = pool_zalloc(mem, sizeof(*lvl))) ||
530
	if (!(lvl = pool_zalloc(mem, sizeof(*lvl))) ||
531
	    !(lvl->lv = pool_zalloc(mem, sizeof(*lvl->lv)))) {
531
	    !(lvl->lv = pool_zalloc(mem, sizeof(*lvl->lv)))) {
532
		stack;
532
		STACK;
533
		return 0;
533
		return 0;
534
	}
534
	}
535
535
536
	lv = lvl->lv;
536
	lv = lvl->lv;
537
537
538
	if (!(lv->name = pool_strdup(mem, lvn->key))) {
538
	if (!(lv->name = pool_strdup(mem, lvn->key))) {
539
		stack;
539
		STACK;
540
		return 0;
540
		return 0;
541
	}
541
	}
542
542
Lines 570-577 Link Here
570
	if (!_read_int32(lvn, "read_ahead", &lv->read_ahead))
570
	if (!_read_int32(lvn, "read_ahead", &lv->read_ahead))
571
		lv->read_ahead = 0;
571
		lv->read_ahead = 0;
572
572
573
	list_init(&lv->segments);
573
	lvm_list_init(&lv->segments);
574
	list_init(&lv->tags);
574
	lvm_list_init(&lv->tags);
575
575
576
	/* Optional tags */
576
	/* Optional tags */
577
	if ((cn = find_config_node(lvn, "tags")) &&
577
	if ((cn = find_config_node(lvn, "tags")) &&
Lines 583-589 Link Here
583
583
584
	lv->vg = vg;
584
	lv->vg = vg;
585
	vg->lv_count++;
585
	vg->lv_count++;
586
	list_add(&vg->lvs, &lvl->list);
586
	lvm_list_add(&vg->lvs, &lvl->list);
587
587
588
	return 1;
588
	return 1;
589
}
589
}
Lines 617-623 Link Here
617
	memcpy(&lv->lvid.id[0], &lv->vg->id, sizeof(lv->lvid.id[0]));
617
	memcpy(&lv->lvid.id[0], &lv->vg->id, sizeof(lv->lvid.id[0]));
618
618
619
	if (!_read_segments(mem, vg, lv, lvn, pv_hash)) {
619
	if (!_read_segments(mem, vg, lv, lvn, pv_hash)) {
620
		stack;
620
		STACK;
621
		return 0;
621
		return 0;
622
	}
622
	}
623
623
Lines 640-646 Link Here
640
		}
640
		}
641
	} else {
641
	} else {
642
		vg->lv_count--;
642
		vg->lv_count--;
643
		list_del(&lvl->list);
643
		lvm_list_del(&lvl->list);
644
	}
644
	}
645
645
646
	return 1;
646
	return 1;
Lines 665-671 Link Here
665
665
666
	for (n = n->child; n; n = n->sib) {
666
	for (n = n->child; n; n = n->sib) {
667
		if (!fn(fid, mem, vg, n, vgn, pv_hash)) {
667
		if (!fn(fid, mem, vg, n, vgn, pv_hash)) {
668
			stack;
668
			STACK;
669
			return 0;
669
			return 0;
670
		}
670
		}
671
	}
671
	}
Lines 690-696 Link Here
690
	}
690
	}
691
691
692
	if (!(vg = pool_zalloc(mem, sizeof(*vg)))) {
692
	if (!(vg = pool_zalloc(mem, sizeof(*vg)))) {
693
		stack;
693
		STACK;
694
		return NULL;
694
		return NULL;
695
	}
695
	}
696
	vg->cmd = fid->fmt->cmd;
696
	vg->cmd = fid->fmt->cmd;
Lines 700-711 Link Here
700
	vg->fid = fid;
700
	vg->fid = fid;
701
701
702
	if (!(vg->name = pool_strdup(mem, vgn->key))) {
702
	if (!(vg->name = pool_strdup(mem, vgn->key))) {
703
		stack;
703
		STACK;
704
		goto bad;
704
		goto bad;
705
	}
705
	}
706
706
707
	if (!(vg->system_id = pool_zalloc(mem, NAME_LEN))) {
707
	if (!(vg->system_id = pool_zalloc(mem, NAME_LEN))) {
708
		stack;
708
		STACK;
709
		goto bad;
709
		goto bad;
710
	}
710
	}
711
711
Lines 774-780 Link Here
774
		goto bad;
774
		goto bad;
775
	}
775
	}
776
776
777
	list_init(&vg->pvs);
777
	lvm_list_init(&vg->pvs);
778
	if (!_read_sections(fid, "physical_volumes", _read_pv, mem, vg,
778
	if (!_read_sections(fid, "physical_volumes", _read_pv, mem, vg,
779
			    vgn, pv_hash, 0)) {
779
			    vgn, pv_hash, 0)) {
780
		log_error("Couldn't find all physical volumes for volume "
780
		log_error("Couldn't find all physical volumes for volume "
Lines 782-790 Link Here
782
		goto bad;
782
		goto bad;
783
	}
783
	}
784
784
785
	list_init(&vg->lvs);
785
	lvm_list_init(&vg->lvs);
786
	list_init(&vg->snapshots);
786
	lvm_list_init(&vg->snapshots);
787
	list_init(&vg->tags);
787
	lvm_list_init(&vg->tags);
788
788
789
	/* Optional tags */
789
	/* Optional tags */
790
	if ((cn = find_config_node(vgn, "tags")) &&
790
	if ((cn = find_config_node(vgn, "tags")) &&
(-)LVM2.2.00.15.orig/lib/format_text/layout.h (-3 / +3 lines)
Lines 29-35 Link Here
29
29
30
/* Data areas (holding PEs) */
30
/* Data areas (holding PEs) */
31
struct data_area_list {
31
struct data_area_list {
32
	struct list list;
32
	struct lvm_list list;
33
	struct disk_locn disk_locn;
33
	struct disk_locn disk_locn;
34
};
34
};
35
35
Lines 65-72 Link Here
65
} __attribute__ ((packed));
65
} __attribute__ ((packed));
66
66
67
struct mda_lists {
67
struct mda_lists {
68
	struct list dirs;
68
	struct lvm_list dirs;
69
	struct list raws;
69
	struct lvm_list raws;
70
	struct metadata_area_ops *file_ops;
70
	struct metadata_area_ops *file_ops;
71
	struct metadata_area_ops *raw_ops;
71
	struct metadata_area_ops *raw_ops;
72
};
72
};
(-)LVM2.2.00.15.orig/lib/format_text/tags.c (-8 / +8 lines)
Lines 20-59 Link Here
20
#include "str_list.h"
20
#include "str_list.h"
21
#include "lvm-string.h"
21
#include "lvm-string.h"
22
22
23
int print_tags(struct list *tags, char *buffer, size_t size)
23
int print_tags(struct lvm_list *tags, char *buffer, size_t size)
24
{
24
{
25
	struct str_list *sl;
25
	struct str_list *sl;
26
	int first = 1;
26
	int first = 1;
27
27
28
	if (!emit_to_buffer(&buffer, &size, "[")) {
28
	if (!emit_to_buffer(&buffer, &size, "[")) {
29
		stack;
29
		STACK;
30
		return 0;
30
		return 0;
31
	}
31
	}
32
32
33
	list_iterate_items(sl, tags) {
33
	lvm_list_iterate_items(sl, tags) {
34
		if (!first) {
34
		if (!first) {
35
			if (!emit_to_buffer(&buffer, &size, ", ")) {
35
			if (!emit_to_buffer(&buffer, &size, ", ")) {
36
				stack;
36
				STACK;
37
				return 0;
37
				return 0;
38
			}
38
			}
39
		} else
39
		} else
40
			first = 0;
40
			first = 0;
41
41
42
		if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str)) {
42
		if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str)) {
43
			stack;
43
			STACK;
44
			return 0;
44
			return 0;
45
		}
45
		}
46
	}
46
	}
47
47
48
	if (!emit_to_buffer(&buffer, &size, "]")) {
48
	if (!emit_to_buffer(&buffer, &size, "]")) {
49
		stack;
49
		STACK;
50
		return 0;
50
		return 0;
51
	}
51
	}
52
52
53
	return 1;
53
	return 1;
54
}
54
}
55
55
56
int read_tags(struct pool *mem, struct list *tags, struct config_value *cv)
56
int read_tags(struct pool *mem, struct lvm_list *tags, struct config_value *cv)
57
{
57
{
58
	if (cv->type == CFG_EMPTY_ARRAY)
58
	if (cv->type == CFG_EMPTY_ARRAY)
59
		return 1;
59
		return 1;
Lines 65-71 Link Here
65
		}
65
		}
66
66
67
		if (!str_list_add(mem, tags, pool_strdup(mem, cv->v.str))) {
67
		if (!str_list_add(mem, tags, pool_strdup(mem, cv->v.str))) {
68
			stack;
68
			STACK;
69
			return 0;
69
			return 0;
70
		}
70
		}
71
71
(-)LVM2.2.00.15.orig/lib/format_text/text_label.c (-24 / +24 lines)
Lines 38-44 Link Here
38
	struct pv_header *pvhdr;
38
	struct pv_header *pvhdr;
39
	struct lvmcache_info *info;
39
	struct lvmcache_info *info;
40
	struct disk_locn *pvh_dlocn_xl;
40
	struct disk_locn *pvh_dlocn_xl;
41
	struct list *mdash, *dash;
41
	struct lvm_list *mdash, *dash;
42
	struct metadata_area *mda;
42
	struct metadata_area *mda;
43
	struct mda_context *mdac;
43
	struct mda_context *mdac;
44
	struct data_area_list *da;
44
	struct data_area_list *da;
Lines 56-63 Link Here
56
	pvh_dlocn_xl = &pvhdr->disk_areas_xl[0];
56
	pvh_dlocn_xl = &pvhdr->disk_areas_xl[0];
57
57
58
	/* List of data areas (holding PEs) */
58
	/* List of data areas (holding PEs) */
59
	list_iterate(dash, &info->das) {
59
	lvm_list_iterate(dash, &info->das) {
60
		da = list_item(dash, struct data_area_list);
60
		da = lvm_list_item(dash, struct data_area_list);
61
61
62
		pvh_dlocn_xl->offset = xlate64(da->disk_locn.offset);
62
		pvh_dlocn_xl->offset = xlate64(da->disk_locn.offset);
63
		pvh_dlocn_xl->size = xlate64(da->disk_locn.size);
63
		pvh_dlocn_xl->size = xlate64(da->disk_locn.size);
Lines 70-77 Link Here
70
	pvh_dlocn_xl++;
70
	pvh_dlocn_xl++;
71
71
72
	/* List of metadata area header locations */
72
	/* List of metadata area header locations */
73
	list_iterate(mdash, &info->mdas) {
73
	lvm_list_iterate(mdash, &info->mdas) {
74
		mda = list_item(mdash, struct metadata_area);
74
		mda = lvm_list_item(mdash, struct metadata_area);
75
		mdac = (struct mda_context *) mda->metadata_locn;
75
		mdac = (struct mda_context *) mda->metadata_locn;
76
76
77
		if (mdac->area.dev != info->dev)
77
		if (mdac->area.dev != info->dev)
Lines 89-95 Link Here
89
	return 1;
89
	return 1;
90
}
90
}
91
91
92
int add_da(const struct format_type *fmt, struct pool *mem, struct list *das,
92
int add_da(const struct format_type *fmt, struct pool *mem, struct lvm_list *das,
93
	   uint64_t start, uint64_t size)
93
	   uint64_t start, uint64_t size)
94
{
94
{
95
	struct data_area_list *dal;
95
	struct data_area_list *dal;
Lines 109-132 Link Here
109
	dal->disk_locn.offset = start;
109
	dal->disk_locn.offset = start;
110
	dal->disk_locn.size = size;
110
	dal->disk_locn.size = size;
111
111
112
	list_add(das, &dal->list);
112
	lvm_list_add(das, &dal->list);
113
113
114
	return 1;
114
	return 1;
115
}
115
}
116
116
117
void del_das(struct list *das)
117
void del_das(struct lvm_list *das)
118
{
118
{
119
	struct list *dah, *tmp;
119
	struct lvm_list *dah, *tmp;
120
	struct data_area_list *da;
120
	struct data_area_list *da;
121
121
122
	list_iterate_safe(dah, tmp, das) {
122
	lvm_list_iterate_safe(dah, tmp, das) {
123
		da = list_item(dah, struct data_area_list);
123
		da = lvm_list_item(dah, struct data_area_list);
124
		list_del(&da->list);
124
		lvm_list_del(&da->list);
125
		dbg_free(da);
125
		dbg_free(da);
126
	}
126
	}
127
}
127
}
128
128
129
int add_mda(const struct format_type *fmt, struct pool *mem, struct list *mdas,
129
int add_mda(const struct format_type *fmt, struct pool *mem, struct lvm_list *mdas,
130
	    struct device *dev, uint64_t start, uint64_t size)
130
	    struct device *dev, uint64_t start, uint64_t size)
131
{
131
{
132
/* FIXME List size restricted by pv_header SECTOR_SIZE */
132
/* FIXME List size restricted by pv_header SECTOR_SIZE */
Lines 165-183 Link Here
165
	mdac->area.size = size;
165
	mdac->area.size = size;
166
	memset(&mdac->rlocn, 0, sizeof(mdac->rlocn));
166
	memset(&mdac->rlocn, 0, sizeof(mdac->rlocn));
167
167
168
	list_add(mdas, &mdal->list);
168
	lvm_list_add(mdas, &mdal->list);
169
	return 1;
169
	return 1;
170
}
170
}
171
171
172
void del_mdas(struct list *mdas)
172
void del_mdas(struct lvm_list *mdas)
173
{
173
{
174
	struct list *mdah, *tmp;
174
	struct lvm_list *mdah, *tmp;
175
	struct metadata_area *mda;
175
	struct metadata_area *mda;
176
176
177
	list_iterate_safe(mdah, tmp, mdas) {
177
	lvm_list_iterate_safe(mdah, tmp, mdas) {
178
		mda = list_item(mdah, struct metadata_area);
178
		mda = lvm_list_item(mdah, struct metadata_area);
179
		dbg_free(mda->metadata_locn);
179
		dbg_free(mda->metadata_locn);
180
		list_del(&mda->list);
180
		lvm_list_del(&mda->list);
181
		dbg_free(mda);
181
		dbg_free(mda);
182
	}
182
	}
183
}
183
}
Lines 197-203 Link Here
197
	struct lvmcache_info *info;
197
	struct lvmcache_info *info;
198
	struct disk_locn *dlocn_xl;
198
	struct disk_locn *dlocn_xl;
199
	uint64_t offset;
199
	uint64_t offset;
200
	struct list *mdah;
200
	struct lvm_list *mdah;
201
	struct metadata_area *mda;
201
	struct metadata_area *mda;
202
	char vgnamebuf[NAME_LEN + 2];
202
	char vgnamebuf[NAME_LEN + 2];
203
	struct mda_context *mdac;
203
	struct mda_context *mdac;
Lines 212-222 Link Here
212
212
213
	if (info->das.n)
213
	if (info->das.n)
214
		del_das(&info->das);
214
		del_das(&info->das);
215
	list_init(&info->das);
215
	lvm_list_init(&info->das);
216
216
217
	if (info->mdas.n)
217
	if (info->mdas.n)
218
		del_mdas(&info->mdas);
218
		del_mdas(&info->mdas);
219
	list_init(&info->mdas);
219
	lvm_list_init(&info->mdas);
220
220
221
	/* Data areas holding the PEs */
221
	/* Data areas holding the PEs */
222
	dlocn_xl = pvhdr->disk_areas_xl;
222
	dlocn_xl = pvhdr->disk_areas_xl;
Lines 234-241 Link Here
234
		dlocn_xl++;
234
		dlocn_xl++;
235
	}
235
	}
236
236
237
	list_iterate(mdah, &info->mdas) {
237
	lvm_list_iterate(mdah, &info->mdas) {
238
		mda = list_item(mdah, struct metadata_area);
238
		mda = lvm_list_item(mdah, struct metadata_area);
239
		mdac = (struct mda_context *) mda->metadata_locn;
239
		mdac = (struct mda_context *) mda->metadata_locn;
240
		if (vgname_from_mda(info->fmt, &mdac->area, vgnamebuf,
240
		if (vgname_from_mda(info->fmt, &mdac->area, vgnamebuf,
241
				    sizeof(vgnamebuf))) {
241
				    sizeof(vgnamebuf))) {
(-)LVM2.2.00.15.orig/lib/label/label.c (-25 / +25 lines)
Lines 30-42 Link Here
30
 * Internal labeller struct.
30
 * Internal labeller struct.
31
 */
31
 */
32
struct labeller_i {
32
struct labeller_i {
33
	struct list list;
33
	struct lvm_list list;
34
34
35
	struct labeller *l;
35
	struct labeller *l;
36
	char name[0];
36
	char name[0];
37
};
37
};
38
38
39
static struct list _labellers;
39
static struct lvm_list _labellers;
40
40
41
static struct labeller_i *_alloc_li(const char *name, struct labeller *l)
41
static struct labeller_i *_alloc_li(const char *name, struct labeller *l)
42
{
42
{
Lines 63-80 Link Here
63
63
64
int label_init(void)
64
int label_init(void)
65
{
65
{
66
	list_init(&_labellers);
66
	lvm_list_init(&_labellers);
67
	return 1;
67
	return 1;
68
}
68
}
69
69
70
void label_exit(void)
70
void label_exit(void)
71
{
71
{
72
	struct list *c, *n;
72
	struct lvm_list *c, *n;
73
	struct labeller_i *li;
73
	struct labeller_i *li;
74
74
75
	for (c = _labellers.n; c != &_labellers; c = n) {
75
	for (c = _labellers.n; c != &_labellers; c = n) {
76
		n = c->n;
76
		n = c->n;
77
		li = list_item(c, struct labeller_i);
77
		li = lvm_list_item(c, struct labeller_i);
78
		li->l->ops->destroy(li->l);
78
		li->l->ops->destroy(li->l);
79
		_free_li(li);
79
		_free_li(li);
80
	}
80
	}
Lines 85-105 Link Here
85
	struct labeller_i *li;
85
	struct labeller_i *li;
86
86
87
	if (!(li = _alloc_li(name, handler))) {
87
	if (!(li = _alloc_li(name, handler))) {
88
		stack;
88
		STACK;
89
		return 0;
89
		return 0;
90
	}
90
	}
91
91
92
	list_add(&_labellers, &li->list);
92
	lvm_list_add(&_labellers, &li->list);
93
	return 1;
93
	return 1;
94
}
94
}
95
95
96
struct labeller *label_get_handler(const char *name)
96
struct labeller *label_get_handler(const char *name)
97
{
97
{
98
	struct list *lih;
98
	struct lvm_list *lih;
99
	struct labeller_i *li;
99
	struct labeller_i *li;
100
100
101
	list_iterate(lih, &_labellers) {
101
	lvm_list_iterate(lih, &_labellers) {
102
		li = list_item(lih, struct labeller_i);
102
		li = lvm_list_item(lih, struct labeller_i);
103
		if (!strcmp(li->name, name))
103
		if (!strcmp(li->name, name))
104
			return li->l;
104
			return li->l;
105
	}
105
	}
Lines 110-116 Link Here
110
static struct labeller *_find_labeller(struct device *dev, char *buf,
110
static struct labeller *_find_labeller(struct device *dev, char *buf,
111
				       uint64_t *label_sector)
111
				       uint64_t *label_sector)
112
{
112
{
113
	struct list *lih;
113
	struct lvm_list *lih;
114
	struct labeller_i *li;
114
	struct labeller_i *li;
115
	struct labeller *r = NULL;
115
	struct labeller *r = NULL;
116
	struct label_header *lh;
116
	struct label_header *lh;
Lines 119-125 Link Here
119
	char readbuf[LABEL_SCAN_SIZE];
119
	char readbuf[LABEL_SCAN_SIZE];
120
120
121
	if (!dev_open(dev)) {
121
	if (!dev_open(dev)) {
122
		stack;
122
		STACK;
123
		return NULL;
123
		return NULL;
124
	}
124
	}
125
125
Lines 158-165 Link Here
158
				continue;
158
				continue;
159
		}
159
		}
160
160
161
		list_iterate(lih, &_labellers) {
161
		lvm_list_iterate(lih, &_labellers) {
162
			li = list_item(lih, struct labeller_i);
162
			li = lvm_list_item(lih, struct labeller_i);
163
			if (li->l->ops->can_handle(li->l, (char *) lh, sector)) {
163
			if (li->l->ops->can_handle(li->l, (char *) lh, sector)) {
164
				log_very_verbose("%s: %s label detected",
164
				log_very_verbose("%s: %s label detected",
165
						 dev_name(dev), li->name);
165
						 dev_name(dev), li->name);
Lines 184-190 Link Here
184
184
185
      out:
185
      out:
186
	if (!dev_close(dev))
186
	if (!dev_close(dev))
187
		stack;
187
		STACK;
188
188
189
	return r;
189
	return r;
190
}
190
}
Lines 197-203 Link Here
197
	int r = 1;
197
	int r = 1;
198
	uint64_t sector;
198
	uint64_t sector;
199
	int wipe;
199
	int wipe;
200
	struct list *lih;
200
	struct lvm_list *lih;
201
	struct labeller_i *li;
201
	struct labeller_i *li;
202
	struct label_header *lh;
202
	struct label_header *lh;
203
203
Lines 206-212 Link Here
206
	log_very_verbose("Scanning for labels to wipe from %s", dev_name(dev));
206
	log_very_verbose("Scanning for labels to wipe from %s", dev_name(dev));
207
207
208
	if (!dev_open(dev)) {
208
	if (!dev_open(dev)) {
209
		stack;
209
		STACK;
210
		return 0;
210
		return 0;
211
	}
211
	}
212
212
Lines 233-240 Link Here
233
			if (xlate64(lh->sector_xl) == sector)
233
			if (xlate64(lh->sector_xl) == sector)
234
				wipe = 1;
234
				wipe = 1;
235
		} else {
235
		} else {
236
			list_iterate(lih, &_labellers) {
236
			lvm_list_iterate(lih, &_labellers) {
237
				li = list_item(lih, struct labeller_i);
237
				li = lvm_list_item(lih, struct labeller_i);
238
				if (li->l->ops->can_handle(li->l, (char *) lh,
238
				if (li->l->ops->can_handle(li->l, (char *) lh,
239
							   sector)) {
239
							   sector)) {
240
					wipe = 1;
240
					wipe = 1;
Lines 258-264 Link Here
258
258
259
      out:
259
      out:
260
	if (!dev_close(dev))
260
	if (!dev_close(dev))
261
		stack;
261
		STACK;
262
262
263
	return r;
263
	return r;
264
}
264
}
Lines 272-278 Link Here
272
	int r;
272
	int r;
273
273
274
	if (!(l = _find_labeller(dev, buf, &sector))) {
274
	if (!(l = _find_labeller(dev, buf, &sector))) {
275
		stack;
275
		STACK;
276
		return 0;
276
		return 0;
277
	}
277
	}
278
278
Lines 307-313 Link Here
307
	lh->offset_xl = xlate32(sizeof(*lh));
307
	lh->offset_xl = xlate32(sizeof(*lh));
308
308
309
	if (!label->labeller->ops->write(label, buf)) {
309
	if (!label->labeller->ops->write(label, buf)) {
310
		stack;
310
		STACK;
311
		return 0;
311
		return 0;
312
	}
312
	}
313
313
Lines 315-321 Link Here
315
				      ((void *) &lh->offset_xl - (void *) lh)));
315
				      ((void *) &lh->offset_xl - (void *) lh)));
316
316
317
	if (!dev_open(dev)) {
317
	if (!dev_open(dev)) {
318
		stack;
318
		STACK;
319
		return 0;
319
		return 0;
320
	}
320
	}
321
321
Lines 327-333 Link Here
327
	}
327
	}
328
328
329
	if (!dev_close(dev))
329
	if (!dev_close(dev))
330
		stack;
330
		STACK;
331
331
332
	return r;
332
	return r;
333
}
333
}
Lines 339-345 Link Here
339
	uint64_t sector;
339
	uint64_t sector;
340
340
341
	if (!(l = _find_labeller(dev, buf, &sector))) {
341
	if (!(l = _find_labeller(dev, buf, &sector))) {
342
		stack;
342
		STACK;
343
		return 0;
343
		return 0;
344
	}
344
	}
345
345
(-)LVM2.2.00.15.orig/lib/locking/external_locking.c (-1 / +1 lines)
Lines 64-70 Link Here
64
				  DEFAULT_LOCKING_LIB);
64
				  DEFAULT_LOCKING_LIB);
65
65
66
	if (!(_locking_lib = load_shared_library(cft, libname, "locking"))) {
66
	if (!(_locking_lib = load_shared_library(cft, libname, "locking"))) {
67
		stack;
67
		STACK;
68
		return 0;
68
		return 0;
69
	}
69
	}
70
70
(-)LVM2.2.00.15.orig/lib/locking/file_locking.c (-8 / +8 lines)
Lines 31-42 Link Here
31
#include <signal.h>
31
#include <signal.h>
32
32
33
struct lock_list {
33
struct lock_list {
34
	struct list list;
34
	struct lvm_list list;
35
	int lf;
35
	int lf;
36
	char *res;
36
	char *res;
37
};
37
};
38
38
39
static struct list _lock_list;
39
static struct lvm_list _lock_list;
40
static char _lock_dir[NAME_LEN];
40
static char _lock_dir[NAME_LEN];
41
41
42
static sig_t _oldhandler;
42
static sig_t _oldhandler;
Lines 46-60 Link Here
46
static int _release_lock(const char *file, int unlock)
46
static int _release_lock(const char *file, int unlock)
47
{
47
{
48
	struct lock_list *ll;
48
	struct lock_list *ll;
49
	struct list *llh, *llt;
49
	struct lvm_list *llh, *llt;
50
50
51
	struct stat buf1, buf2;
51
	struct stat buf1, buf2;
52
52
53
	list_iterate_safe(llh, llt, &_lock_list) {
53
	lvm_list_iterate_safe(llh, llt, &_lock_list) {
54
		ll = list_item(llh, struct lock_list);
54
		ll = lvm_list_item(llh, struct lock_list);
55
55
56
		if (!file || !strcmp(ll->res, file)) {
56
		if (!file || !strcmp(ll->res, file)) {
57
			list_del(llh);
57
			lvm_list_del(llh);
58
			if (unlock) {
58
			if (unlock) {
59
				log_very_verbose("Unlocking %s", ll->res);
59
				log_very_verbose("Unlocking %s", ll->res);
60
				if (flock(ll->lf, LOCK_NB | LOCK_UN))
60
				if (flock(ll->lf, LOCK_NB | LOCK_UN))
Lines 189-195 Link Here
189
			break;
189
			break;
190
	} while (!(flags & LCK_NONBLOCK));
190
	} while (!(flags & LCK_NONBLOCK));
191
191
192
	list_add(&_lock_list, &ll->list);
192
	lvm_list_add(&_lock_list, &ll->list);
193
	return 1;
193
	return 1;
194
194
195
      err:
195
      err:
Lines 279-285 Link Here
279
	if ((access(_lock_dir, R_OK | W_OK | X_OK) == -1) && (errno == EROFS))
279
	if ((access(_lock_dir, R_OK | W_OK | X_OK) == -1) && (errno == EROFS))
280
		return 0;
280
		return 0;
281
281
282
	list_init(&_lock_list);
282
	lvm_list_init(&_lock_list);
283
283
284
	if (sigfillset(&_intsigset) || sigfillset(&_fullsigset)) {
284
	if (sigfillset(&_intsigset) || sigfillset(&_fullsigset)) {
285
		log_sys_error("sigfillset", "init_file_locking");
285
		log_sys_error("sigfillset", "init_file_locking");
(-)LVM2.2.00.15.orig/lib/locking/locking.c (-10 / +10 lines)
Lines 252-264 Link Here
252
}
252
}
253
253
254
/* Unlock list of LVs */
254
/* Unlock list of LVs */
255
int unlock_lvs(struct cmd_context *cmd, struct list *lvs)
255
int unlock_lvs(struct cmd_context *cmd, struct lvm_list *lvs)
256
{
256
{
257
	struct list *lvh;
257
	struct lvm_list *lvh;
258
	struct logical_volume *lv;
258
	struct logical_volume *lv;
259
259
260
	list_iterate(lvh, lvs) {
260
	lvm_list_iterate(lvh, lvs) {
261
		lv = list_item(lvh, struct lv_list)->lv;
261
		lv = lvm_list_item(lvh, struct lv_list)->lv;
262
		unlock_lv(cmd, lv->lvid.s);
262
		unlock_lv(cmd, lv->lvid.s);
263
	}
263
	}
264
264
Lines 266-282 Link Here
266
}
266
}
267
267
268
/* Lock a list of LVs */
268
/* Lock a list of LVs */
269
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags)
269
int lock_lvs(struct cmd_context *cmd, struct lvm_list *lvs, int flags)
270
{
270
{
271
	struct list *lvh;
271
	struct lvm_list *lvh;
272
	struct logical_volume *lv;
272
	struct logical_volume *lv;
273
273
274
	list_iterate(lvh, lvs) {
274
	lvm_list_iterate(lvh, lvs) {
275
		lv = list_item(lvh, struct lv_list)->lv;
275
		lv = lvm_list_item(lvh, struct lv_list)->lv;
276
		if (!lock_vol(cmd, lv->lvid.s, flags)) {
276
		if (!lock_vol(cmd, lv->lvid.s, flags)) {
277
			log_error("Failed to suspend %s", lv->name);
277
			log_error("Failed to suspend %s", lv->name);
278
			list_uniterate(lvh, lvs, lvh) {
278
			lvm_list_uniterate(lvh, lvs, lvh) {
279
				lv = list_item(lvh, struct lv_list)->lv;
279
				lv = lvm_list_item(lvh, struct lv_list)->lv;
280
				unlock_lv(cmd, lv->lvid.s);
280
				unlock_lv(cmd, lv->lvid.s);
281
			}
281
			}
282
282
(-)LVM2.2.00.15.orig/lib/locking/locking.h (-2 / +2 lines)
Lines 82-87 Link Here
82
#define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
82
#define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
83
83
84
/* Process list of LVs */
84
/* Process list of LVs */
85
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags);
85
int lock_lvs(struct cmd_context *cmd, struct lvm_list *lvs, int flags);
86
int unlock_lvs(struct cmd_context *cmd, struct list *lvs);
86
int unlock_lvs(struct cmd_context *cmd, struct lvm_list *lvs);
87
87
(-)LVM2.2.00.15.orig/lib/log/log.h (-2 / +2 lines)
Lines 28-34 Link Here
28
 * In addition, messages will be logged to file or syslog if they
28
 * In addition, messages will be logged to file or syslog if they
29
 * are more serious than the log level specified with the log/debug_level
29
 * are more serious than the log level specified with the log/debug_level
30
 * parameter in the configuration file.  These messages get the file
30
 * parameter in the configuration file.  These messages get the file
31
 * and line number prepended.  'stack' (without arguments) can be used 
31
 * and line number prepended.  'STACK' (without arguments) can be used 
32
 * to log this information at debug level.
32
 * to log this information at debug level.
33
 *
33
 *
34
 * log_sys_error and log_sys_very_verbose are for errors from system calls
34
 * log_sys_error and log_sys_very_verbose are for errors from system calls
Lines 100-106 Link Here
100
#define log_err(x...) plog(_LOG_ERR, x)
100
#define log_err(x...) plog(_LOG_ERR, x)
101
#define log_fatal(x...) plog(_LOG_FATAL, x)
101
#define log_fatal(x...) plog(_LOG_FATAL, x)
102
102
103
#define stack log_debug("<backtrace>")	/* Backtrace on error */
103
#define STACK log_debug("<backtrace>")	/* Backtrace on error */
104
104
105
#define log_error(args...) log_err(args)
105
#define log_error(args...) log_err(args)
106
#define log_print(args...) log_warn(args)
106
#define log_print(args...) log_warn(args)
(-)LVM2.2.00.15.orig/lib/metadata/lv_manip.c (-68 / +68 lines)
Lines 65-75 Link Here
65
	uint32_t len = sizeof(*seg) + (num_areas * sizeof(seg->area[0]));
65
	uint32_t len = sizeof(*seg) + (num_areas * sizeof(seg->area[0]));
66
66
67
	if (!(seg = pool_zalloc(mem, len))) {
67
	if (!(seg = pool_zalloc(mem, len))) {
68
		stack;
68
		STACK;
69
		return NULL;
69
		return NULL;
70
	}
70
	}
71
71
72
	list_init(&seg->tags);
72
	lvm_list_init(&seg->tags);
73
73
74
	return seg;
74
	return seg;
75
}
75
}
Lines 114-120 Link Here
114
		consume_pv_area(pva, area_len);
114
		consume_pv_area(pva, area_len);
115
	}
115
	}
116
116
117
	list_add(&lv->segments, &seg->list);
117
	lvm_list_add(&lv->segments, &seg->list);
118
	*ix += seg->len;
118
	*ix += seg->len;
119
	return 1;
119
	return 1;
120
}
120
}
Lines 134-144 Link Here
134
}
134
}
135
135
136
static int _alloc_parallel(struct logical_volume *lv,
136
static int _alloc_parallel(struct logical_volume *lv,
137
			   struct list *pvms, uint32_t allocated,
137
			   struct lvm_list *pvms, uint32_t allocated,
138
			   uint32_t stripes, uint32_t stripe_size)
138
			   uint32_t stripes, uint32_t stripe_size)
139
{
139
{
140
	int r = 0;
140
	int r = 0;
141
	struct list *pvmh;
141
	struct lvm_list *pvmh;
142
	struct pv_area **areas;
142
	struct pv_area **areas;
143
	unsigned int pv_count = 0, ix;
143
	unsigned int pv_count = 0, ix;
144
	struct pv_map *pvm;
144
	struct pv_map *pvm;
Lines 147-153 Link Here
147
147
148
	area_count = stripes;
148
	area_count = stripes;
149
149
150
	list_iterate(pvmh, pvms)
150
	lvm_list_iterate(pvmh, pvms)
151
	    pv_count++;
151
	    pv_count++;
152
152
153
	/* allocate an array of pv_areas, one candidate per pv */
153
	/* allocate an array of pv_areas, one candidate per pv */
Lines 160-172 Link Here
160
	while (allocated != lv->le_count) {
160
	while (allocated != lv->le_count) {
161
161
162
		ix = 0;
162
		ix = 0;
163
		list_iterate(pvmh, pvms) {
163
		lvm_list_iterate(pvmh, pvms) {
164
			pvm = list_item(pvmh, struct pv_map);
164
			pvm = lvm_list_item(pvmh, struct pv_map);
165
165
166
			if (list_empty(&pvm->areas))
166
			if (lvm_list_empty(&pvm->areas))
167
				continue;
167
				continue;
168
168
169
			areas[ix++] = list_item(pvm->areas.n, struct pv_area);
169
			areas[ix++] = lvm_list_item(pvm->areas.n, struct pv_area);
170
		}
170
		}
171
171
172
		if (ix < area_count) {
172
		if (ix < area_count) {
Lines 181-187 Link Here
181
181
182
		if (!_alloc_parallel_area(lv, area_count, stripe_size, areas,
182
		if (!_alloc_parallel_area(lv, area_count, stripe_size, areas,
183
					  &allocated)) {
183
					  &allocated)) {
184
			stack;
184
			STACK;
185
			goto out;
185
			goto out;
186
		}
186
		}
187
	}
187
	}
Lines 225-231 Link Here
225
	seg->area[0].u.pv.pv = map->pvl->pv;
225
	seg->area[0].u.pv.pv = map->pvl->pv;
226
	seg->area[0].u.pv.pe = pva->start;
226
	seg->area[0].u.pv.pe = pva->start;
227
227
228
	list_add(&lv->segments, &seg->list);
228
	lvm_list_add(&lv->segments, &seg->list);
229
229
230
	consume_pv_area(pva, count);
230
	consume_pv_area(pva, count);
231
	*ix += count;
231
	*ix += count;
Lines 266-272 Link Here
266
	seg->area[1].type = AREA_PV;
266
	seg->area[1].type = AREA_PV;
267
	seg->area[1].u.pv.pv = map->pvl->pv;
267
	seg->area[1].u.pv.pv = map->pvl->pv;
268
	seg->area[1].u.pv.pe = pva->start;
268
	seg->area[1].u.pv.pe = pva->start;
269
	list_add(&lv->segments, &seg->list);
269
	lvm_list_add(&lv->segments, &seg->list);
270
270
271
	consume_pv_area(pva, count);
271
	consume_pv_area(pva, count);
272
	*ix += count;
272
	*ix += count;
Lines 283-307 Link Here
283
 * FIXME: subsequent lvextends may not be contiguous.
283
 * FIXME: subsequent lvextends may not be contiguous.
284
 */
284
 */
285
static int _alloc_contiguous(struct logical_volume *lv,
285
static int _alloc_contiguous(struct logical_volume *lv,
286
			     struct list *pvms, uint32_t allocated)
286
			     struct lvm_list *pvms, uint32_t allocated)
287
{
287
{
288
	struct list *tmp1;
288
	struct lvm_list *tmp1;
289
	struct pv_map *pvm;
289
	struct pv_map *pvm;
290
	struct pv_area *pva;
290
	struct pv_area *pva;
291
291
292
	list_iterate(tmp1, pvms) {
292
	lvm_list_iterate(tmp1, pvms) {
293
		pvm = list_item(tmp1, struct pv_map);
293
		pvm = lvm_list_item(tmp1, struct pv_map);
294
294
295
		if (list_empty(&pvm->areas))
295
		if (lvm_list_empty(&pvm->areas))
296
			continue;
296
			continue;
297
297
298
		/* first item in the list is the biggest */
298
		/* first item in the list is the biggest */
299
		pva = list_item(pvm->areas.n, struct pv_area);
299
		pva = lvm_list_item(pvm->areas.n, struct pv_area);
300
		if (pva->count < lv->le_count)
300
		if (pva->count < lv->le_count)
301
			continue;
301
			continue;
302
302
303
		if (!_alloc_linear_area(lv, &allocated, pvm, pva)) {
303
		if (!_alloc_linear_area(lv, &allocated, pvm, pva)) {
304
			stack;
304
			STACK;
305
			return 0;
305
			return 0;
306
		}
306
		}
307
307
Lines 320-343 Link Here
320
320
321
/* FIXME Contiguous depends on *segment* (i.e. stripe) not LV */
321
/* FIXME Contiguous depends on *segment* (i.e. stripe) not LV */
322
static int _alloc_mirrored(struct logical_volume *lv,
322
static int _alloc_mirrored(struct logical_volume *lv,
323
			   struct list *pvms, uint32_t allocated,
323
			   struct lvm_list *pvms, uint32_t allocated,
324
			   struct physical_volume *mirrored_pv,
324
			   struct physical_volume *mirrored_pv,
325
			   uint32_t mirrored_pe)
325
			   uint32_t mirrored_pe)
326
{
326
{
327
	struct list *tmp1;
327
	struct lvm_list *tmp1;
328
	struct pv_map *pvm;
328
	struct pv_map *pvm;
329
	struct pv_area *pva;
329
	struct pv_area *pva;
330
	uint32_t max_found = 0;
330
	uint32_t max_found = 0;
331
331
332
	/* Try each PV in turn */
332
	/* Try each PV in turn */
333
	list_iterate(tmp1, pvms) {
333
	lvm_list_iterate(tmp1, pvms) {
334
		pvm = list_item(tmp1, struct pv_map);
334
		pvm = lvm_list_item(tmp1, struct pv_map);
335
335
336
		if (list_empty(&pvm->areas))
336
		if (lvm_list_empty(&pvm->areas))
337
			continue;
337
			continue;
338
338
339
		/* first item in the list is the biggest */
339
		/* first item in the list is the biggest */
340
		pva = list_item(pvm->areas.n, struct pv_area);
340
		pva = lvm_list_item(pvm->areas.n, struct pv_area);
341
		if (pva->count < lv->le_count - allocated) {
341
		if (pva->count < lv->le_count - allocated) {
342
			max_found = pva->count;
342
			max_found = pva->count;
343
			continue;
343
			continue;
Lines 345-351 Link Here
345
345
346
		if (!_alloc_mirrored_area(lv, &allocated, pvm, pva,
346
		if (!_alloc_mirrored_area(lv, &allocated, pvm, pva,
347
					  mirrored_pv, mirrored_pe)) {
347
					  mirrored_pv, mirrored_pe)) {
348
			stack;
348
			STACK;
349
			return 0;
349
			return 0;
350
		}
350
		}
351
351
Lines 367-383 Link Here
367
 * is full.
367
 * is full.
368
 */
368
 */
369
static int _alloc_next_free(struct logical_volume *lv,
369
static int _alloc_next_free(struct logical_volume *lv,
370
			    struct list *pvms, uint32_t allocated)
370
			    struct lvm_list *pvms, uint32_t allocated)
371
{
371
{
372
	struct list *tmp1, *tmp2;
372
	struct lvm_list *tmp1, *tmp2;
373
	struct pv_map *pvm;
373
	struct pv_map *pvm;
374
	struct pv_area *pva;
374
	struct pv_area *pva;
375
375
376
	list_iterate(tmp1, pvms) {
376
	lvm_list_iterate(tmp1, pvms) {
377
		pvm = list_item(tmp1, struct pv_map);
377
		pvm = lvm_list_item(tmp1, struct pv_map);
378
378
379
		list_iterate(tmp2, &pvm->areas) {
379
		lvm_list_iterate(tmp2, &pvm->areas) {
380
			pva = list_item(tmp2, struct pv_area);
380
			pva = lvm_list_item(tmp2, struct pv_area);
381
			if (!_alloc_linear_area(lv, &allocated, pvm, pva) ||
381
			if (!_alloc_linear_area(lv, &allocated, pvm, pva) ||
382
			    (allocated == lv->le_count))
382
			    (allocated == lv->le_count))
383
				goto done;
383
				goto done;
Lines 399-416 Link Here
399
 * Chooses a correct allocation policy.
399
 * Chooses a correct allocation policy.
400
 */
400
 */
401
static int _allocate(struct volume_group *vg, struct logical_volume *lv,
401
static int _allocate(struct volume_group *vg, struct logical_volume *lv,
402
		     struct list *allocatable_pvs, uint32_t allocated,
402
		     struct lvm_list *allocatable_pvs, uint32_t allocated,
403
		     uint32_t stripes, uint32_t stripe_size,
403
		     uint32_t stripes, uint32_t stripe_size,
404
		     struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
404
		     struct physical_volume *mirrored_pv, uint32_t mirrored_pe,
405
		     uint32_t status)
405
		     uint32_t status)
406
{
406
{
407
	int r = 0;
407
	int r = 0;
408
	struct pool *scratch;
408
	struct pool *scratch;
409
	struct list *pvms, *old_tail = lv->segments.p, *segh;
409
	struct lvm_list *pvms, *old_tail = lv->segments.p, *segh;
410
	struct lv_segment *seg;
410
	struct lv_segment *seg;
411
411
412
	if (!(scratch = pool_create(1024))) {
412
	if (!(scratch = pool_create(1024))) {
413
		stack;
413
		STACK;
414
		return 0;
414
		return 0;
415
	}
415
	}
416
416
Lines 446-452 Link Here
446
		 * counts in pv's.
446
		 * counts in pv's.
447
		 */
447
		 */
448
		for (segh = lv->segments.p; segh != old_tail; segh = segh->p) {
448
		for (segh = lv->segments.p; segh != old_tail; segh = segh->p) {
449
			seg = list_item(segh, struct lv_segment);
449
			seg = lvm_list_item(segh, struct lv_segment);
450
			_get_extents(seg);
450
			_get_extents(seg);
451
			seg->status = status;
451
			seg->status = status;
452
		}
452
		}
Lines 466-477 Link Here
466
static char *_generate_lv_name(struct volume_group *vg, const char *format,
466
static char *_generate_lv_name(struct volume_group *vg, const char *format,
467
			       char *buffer, size_t len)
467
			       char *buffer, size_t len)
468
{
468
{
469
	struct list *lvh;
469
	struct lvm_list *lvh;
470
	struct logical_volume *lv;
470
	struct logical_volume *lv;
471
	int high = -1, i;
471
	int high = -1, i;
472
472
473
	list_iterate(lvh, &vg->lvs) {
473
	lvm_list_iterate(lvh, &vg->lvs) {
474
		lv = (list_item(lvh, struct lv_list)->lv);
474
		lv = (lvm_list_item(lvh, struct lv_list)->lv);
475
475
476
		if (sscanf(lv->name, format, &i) != 1)
476
		if (sscanf(lv->name, format, &i) != 1)
477
			continue;
477
			continue;
Lines 538-555 Link Here
538
	lv->minor = -1;
538
	lv->minor = -1;
539
	lv->size = UINT64_C(0);
539
	lv->size = UINT64_C(0);
540
	lv->le_count = 0;
540
	lv->le_count = 0;
541
	list_init(&lv->segments);
541
	lvm_list_init(&lv->segments);
542
	list_init(&lv->tags);
542
	lvm_list_init(&lv->tags);
543
543
544
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
544
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
545
		stack;
545
		STACK;
546
		if (ll)
546
		if (ll)
547
			pool_free(cmd->mem, ll);
547
			pool_free(cmd->mem, ll);
548
		return NULL;
548
		return NULL;
549
	}
549
	}
550
550
551
	vg->lv_count++;
551
	vg->lv_count++;
552
	list_add(&vg->lvs, &ll->list);
552
	lvm_list_add(&vg->lvs, &ll->list);
553
553
554
	return lv;
554
	return lv;
555
}
555
}
Lines 562-568 Link Here
562
				 uint32_t stripe_size,
562
				 uint32_t stripe_size,
563
				 uint32_t extents,
563
				 uint32_t extents,
564
				 struct volume_group *vg,
564
				 struct volume_group *vg,
565
				 struct list *allocatable_pvs)
565
				 struct lvm_list *allocatable_pvs)
566
{
566
{
567
	struct logical_volume *lv;
567
	struct logical_volume *lv;
568
568
Lines 578-592 Link Here
578
		return NULL;
578
		return NULL;
579
	}
579
	}
580
580
581
	if (stripes > list_size(allocatable_pvs)) {
581
	if (stripes > lvm_list_size(allocatable_pvs)) {
582
		log_error("Number of stripes (%u) must not exceed "
582
		log_error("Number of stripes (%u) must not exceed "
583
			  "number of physical volumes (%d)", stripes,
583
			  "number of physical volumes (%d)", stripes,
584
			  list_size(allocatable_pvs));
584
			  lvm_list_size(allocatable_pvs));
585
		return NULL;
585
		return NULL;
586
	}
586
	}
587
587
588
	if (!(lv = lv_create_empty(fi, name, "lvol%d", status, alloc, vg))) {
588
	if (!(lv = lv_create_empty(fi, name, "lvol%d", status, alloc, vg))) {
589
		stack;
589
		STACK;
590
		return NULL;
590
		return NULL;
591
	}
591
	}
592
592
Lines 595-606 Link Here
595
595
596
	if (!_allocate(vg, lv, allocatable_pvs, 0u, stripes, stripe_size,
596
	if (!_allocate(vg, lv, allocatable_pvs, 0u, stripes, stripe_size,
597
		       NULL, 0u, 0u)) {
597
		       NULL, 0u, 0u)) {
598
		stack;
598
		STACK;
599
		return NULL;
599
		return NULL;
600
	}
600
	}
601
601
602
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
602
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
603
		stack;
603
		STACK;
604
		return NULL;
604
		return NULL;
605
	}
605
	}
606
606
Lines 610-629 Link Here
610
int lv_reduce(struct format_instance *fi,
610
int lv_reduce(struct format_instance *fi,
611
	      struct logical_volume *lv, uint32_t extents)
611
	      struct logical_volume *lv, uint32_t extents)
612
{
612
{
613
	struct list *segh;
613
	struct lvm_list *segh;
614
	struct lv_segment *seg;
614
	struct lv_segment *seg;
615
	uint32_t count = extents;
615
	uint32_t count = extents;
616
	int striped;
616
	int striped;
617
617
618
	for (segh = lv->segments.p;
618
	for (segh = lv->segments.p;
619
	     (segh != &lv->segments) && count; segh = segh->p) {
619
	     (segh != &lv->segments) && count; segh = segh->p) {
620
		seg = list_item(segh, struct lv_segment);
620
		seg = lvm_list_item(segh, struct lv_segment);
621
621
622
		if (seg->len <= count) {
622
		if (seg->len <= count) {
623
			/* remove this segment completely */
623
			/* remove this segment completely */
624
			count -= seg->len;
624
			count -= seg->len;
625
			_put_extents(seg);
625
			_put_extents(seg);
626
			list_del(segh);
626
			lvm_list_del(segh);
627
		} else {
627
		} else {
628
			/* reduce this segment */
628
			/* reduce this segment */
629
			_put_extents(seg);
629
			_put_extents(seg);
Lines 648-654 Link Here
648
	lv->vg->free_count += extents;
648
	lv->vg->free_count += extents;
649
649
650
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
650
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
651
		stack;
651
		STACK;
652
		return 0;
652
		return 0;
653
	}
653
	}
654
654
Lines 658-664 Link Here
658
int lv_extend(struct format_instance *fi,
658
int lv_extend(struct format_instance *fi,
659
	      struct logical_volume *lv,
659
	      struct logical_volume *lv,
660
	      uint32_t stripes, uint32_t stripe_size,
660
	      uint32_t stripes, uint32_t stripe_size,
661
	      uint32_t extents, struct list *allocatable_pvs)
661
	      uint32_t extents, struct lvm_list *allocatable_pvs)
662
{
662
{
663
	uint32_t old_le_count = lv->le_count;
663
	uint32_t old_le_count = lv->le_count;
664
	uint64_t old_size = lv->size;
664
	uint64_t old_size = lv->size;
Lines 670-676 Link Here
670
		       stripes, stripe_size, NULL, 0u, 0u)) {
670
		       stripes, stripe_size, NULL, 0u, 0u)) {
671
		lv->le_count = old_le_count;
671
		lv->le_count = old_le_count;
672
		lv->size = old_size;
672
		lv->size = old_size;
673
		stack;
673
		STACK;
674
		return 0;
674
		return 0;
675
	}
675
	}
676
676
Lines 681-687 Link Here
681
	}
681
	}
682
682
683
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
683
	if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
684
		stack;
684
		STACK;
685
		return 0;
685
		return 0;
686
	}
686
	}
687
687
Lines 692-698 Link Here
692
		     struct logical_volume *lv,
692
		     struct logical_volume *lv,
693
		     struct physical_volume *mirrored_pv,
693
		     struct physical_volume *mirrored_pv,
694
		     uint32_t mirrored_pe,
694
		     uint32_t mirrored_pe,
695
		     uint32_t extents, struct list *allocatable_pvs,
695
		     uint32_t extents, struct lvm_list *allocatable_pvs,
696
		     uint32_t status)
696
		     uint32_t status)
697
{
697
{
698
	uint32_t old_le_count = lv->le_count;
698
	uint32_t old_le_count = lv->le_count;
Lines 705-716 Link Here
705
		       1, extents, mirrored_pv, mirrored_pe, status)) {
705
		       1, extents, mirrored_pv, mirrored_pe, status)) {
706
		lv->le_count = old_le_count;
706
		lv->le_count = old_le_count;
707
		lv->size = old_size;
707
		lv->size = old_size;
708
		stack;
708
		STACK;
709
		return 0;
709
		return 0;
710
	}
710
	}
711
711
712
	if (fid->fmt->ops->lv_setup && !fid->fmt->ops->lv_setup(fid, lv)) {
712
	if (fid->fmt->ops->lv_setup && !fid->fmt->ops->lv_setup(fid, lv)) {
713
		stack;
713
		STACK;
714
		return 0;
714
		return 0;
715
	}
715
	}
716
716
Lines 719-741 Link Here
719
719
720
int lv_remove(struct volume_group *vg, struct logical_volume *lv)
720
int lv_remove(struct volume_group *vg, struct logical_volume *lv)
721
{
721
{
722
	struct list *segh;
722
	struct lvm_list *segh;
723
	struct lv_list *lvl;
723
	struct lv_list *lvl;
724
724
725
	/* find the lv list */
725
	/* find the lv list */
726
	if (!(lvl = find_lv_in_vg(vg, lv->name))) {
726
	if (!(lvl = find_lv_in_vg(vg, lv->name))) {
727
		stack;
727
		STACK;
728
		return 0;
728
		return 0;
729
	}
729
	}
730
730
731
	/* iterate through the lv's segments freeing off the pe's */
731
	/* iterate through the lv's segments freeing off the pe's */
732
	list_iterate(segh, &lv->segments)
732
	lvm_list_iterate(segh, &lv->segments)
733
	    _put_extents(list_item(segh, struct lv_segment));
733
	    _put_extents(lvm_list_item(segh, struct lv_segment));
734
734
735
	vg->lv_count--;
735
	vg->lv_count--;
736
	vg->free_count += lv->le_count;
736
	vg->free_count += lv->le_count;
737
737
738
	list_del(&lvl->list);
738
	lvm_list_del(&lvl->list);
739
739
740
	return 1;
740
	return 1;
741
}
741
}
Lines 744-757 Link Here
744
{
744
{
745
	int lvnum_used[MAX_RESTRICTED_LVS + 1];
745
	int lvnum_used[MAX_RESTRICTED_LVS + 1];
746
	uint32_t i = 0;
746
	uint32_t i = 0;
747
	struct list *lvh;
747
	struct lvm_list *lvh;
748
	struct lv_list *lvl;
748
	struct lv_list *lvl;
749
	int lvnum;
749
	int lvnum;
750
750
751
	memset(&lvnum_used, 0, sizeof(lvnum_used));
751
	memset(&lvnum_used, 0, sizeof(lvnum_used));
752
752
753
	list_iterate(lvh, &lv->vg->lvs) {
753
	lvm_list_iterate(lvh, &lv->vg->lvs) {
754
		lvl = list_item(lvh, struct lv_list);
754
		lvl = lvm_list_item(lvh, struct lv_list);
755
		lvnum = lvnum_from_lvid(&lvl->lv->lvid);
755
		lvnum = lvnum_from_lvid(&lvl->lv->lvid);
756
		if (lvnum <= MAX_RESTRICTED_LVS)
756
		if (lvnum <= MAX_RESTRICTED_LVS)
757
			lvnum_used[lvnum] = 1;
757
			lvnum_used[lvnum] = 1;
(-)LVM2.2.00.15.orig/lib/metadata/merge.c (-7 / +7 lines)
Lines 76-89 Link Here
76
76
77
int lv_merge_segments(struct logical_volume *lv)
77
int lv_merge_segments(struct logical_volume *lv)
78
{
78
{
79
	struct list *segh, *t;
79
	struct lvm_list *segh, *t;
80
	struct lv_segment *current, *prev = NULL;
80
	struct lv_segment *current, *prev = NULL;
81
81
82
	list_iterate_safe(segh, t, &lv->segments) {
82
	lvm_list_iterate_safe(segh, t, &lv->segments) {
83
		current = list_item(segh, struct lv_segment);
83
		current = lvm_list_item(segh, struct lv_segment);
84
84
85
		if (_merge(prev, current))
85
		if (_merge(prev, current))
86
			list_del(&current->list);
86
			lvm_list_del(&current->list);
87
		else
87
		else
88
			prev = current;
88
			prev = current;
89
	}
89
	}
Lines 100-106 Link Here
100
	uint32_t le = 0;
100
	uint32_t le = 0;
101
	unsigned seg_count = 0;
101
	unsigned seg_count = 0;
102
102
103
	list_iterate_items(seg, &lv->segments) {
103
	lvm_list_iterate_items(seg, &lv->segments) {
104
		seg_count++;
104
		seg_count++;
105
		if (seg->le != le) {
105
		if (seg->le != le) {
106
			log_error("LV %s invalid: segment %u should begin at "
106
			log_error("LV %s invalid: segment %u should begin at "
Lines 176-182 Link Here
176
	seg->area_len = offset;
176
	seg->area_len = offset;
177
177
178
	/* Add split off segment to the list _after_ the original one */
178
	/* Add split off segment to the list _after_ the original one */
179
	list_add_h(&seg->list, &split_seg->list);
179
	lvm_list_add_h(&seg->list, &split_seg->list);
180
180
181
	return 1;
181
	return 1;
182
}
182
}
Lines 199-205 Link Here
199
		return 1;
199
		return 1;
200
200
201
	if (!_lv_split_segment(lv, seg, le)) {
201
	if (!_lv_split_segment(lv, seg, le)) {
202
		stack;
202
		STACK;
203
		return 0;
203
		return 0;
204
	}
204
	}
205
205
(-)LVM2.2.00.15.orig/lib/metadata/metadata.c (-94 / +94 lines)
Lines 28-34 Link Here
28
	struct pv_list *pvl;
28
	struct pv_list *pvl;
29
	struct physical_volume *pv;
29
	struct physical_volume *pv;
30
	struct pool *mem = fid->fmt->cmd->mem;
30
	struct pool *mem = fid->fmt->cmd->mem;
31
	struct list mdas;
31
	struct lvm_list mdas;
32
32
33
	log_verbose("Adding physical volume '%s' to volume group '%s'",
33
	log_verbose("Adding physical volume '%s' to volume group '%s'",
34
		    pv_name, vg->name);
34
		    pv_name, vg->name);
Lines 38-44 Link Here
38
		return 0;
38
		return 0;
39
	}
39
	}
40
40
41
	list_init(&mdas);
41
	lvm_list_init(&mdas);
42
	if (!(pv = pv_read(fid->fmt->cmd, pv_name, &mdas, NULL))) {
42
	if (!(pv = pv_read(fid->fmt->cmd, pv_name, &mdas, NULL))) {
43
		log_error("%s not identified as an existing physical volume",
43
		log_error("%s not identified as an existing physical volume",
44
			  pv_name);
44
			  pv_name);
Lines 101-107 Link Here
101
101
102
	pvl->pv = pv;
102
	pvl->pv = pv;
103
103
104
	list_add(&vg->pvs, &pvl->list);
104
	lvm_list_add(&vg->pvs, &pvl->list);
105
	vg->pv_count++;
105
	vg->pv_count++;
106
	vg->extent_count += pv->pe_count;
106
	vg->extent_count += pv->pe_count;
107
	vg->free_count += pv->pe_count;
107
	vg->free_count += pv->pe_count;
Lines 114-128 Link Here
114
{
114
{
115
	struct pool *mem = cmd->mem;
115
	struct pool *mem = cmd->mem;
116
	struct physical_volume *pv;
116
	struct physical_volume *pv;
117
	struct list *pvh;
117
	struct lvm_list *pvh;
118
118
119
	if (!(vg->name = pool_strdup(mem, new_name))) {
119
	if (!(vg->name = pool_strdup(mem, new_name))) {
120
		log_error("vg->name allocation failed for '%s'", new_name);
120
		log_error("vg->name allocation failed for '%s'", new_name);
121
		return 0;
121
		return 0;
122
	}
122
	}
123
123
124
	list_iterate(pvh, &vg->pvs) {
124
	lvm_list_iterate(pvh, &vg->pvs) {
125
		pv = list_item(pvh, struct pv_list)->pv;
125
		pv = lvm_list_item(pvh, struct pv_list)->pv;
126
		if (!(pv->vg_name = pool_strdup(mem, new_name))) {
126
		if (!(pv->vg_name = pool_strdup(mem, new_name))) {
127
			log_error("pv->vg_name allocation failed for '%s'",
127
			log_error("pv->vg_name allocation failed for '%s'",
128
				  dev_name(pv->dev));
128
				  dev_name(pv->dev));
Lines 170-176 Link Here
170
	int old_partial;
170
	int old_partial;
171
171
172
	if (!(vg = pool_zalloc(mem, sizeof(*vg)))) {
172
	if (!(vg = pool_zalloc(mem, sizeof(*vg)))) {
173
		stack;
173
		STACK;
174
		return NULL;
174
		return NULL;
175
	}
175
	}
176
176
Lines 194-200 Link Here
194
	vg->cmd = cmd;
194
	vg->cmd = cmd;
195
195
196
	if (!(vg->name = pool_strdup(mem, vg_name))) {
196
	if (!(vg->name = pool_strdup(mem, vg_name))) {
197
		stack;
197
		STACK;
198
		goto bad;
198
		goto bad;
199
	}
199
	}
200
200
Lines 212-226 Link Here
212
	vg->max_pv = max_pv;
212
	vg->max_pv = max_pv;
213
213
214
	vg->pv_count = 0;
214
	vg->pv_count = 0;
215
	list_init(&vg->pvs);
215
	lvm_list_init(&vg->pvs);
216
216
217
	vg->lv_count = 0;
217
	vg->lv_count = 0;
218
	list_init(&vg->lvs);
218
	lvm_list_init(&vg->lvs);
219
219
220
	vg->snapshot_count = 0;
220
	vg->snapshot_count = 0;
221
	list_init(&vg->snapshots);
221
	lvm_list_init(&vg->snapshots);
222
222
223
	list_init(&vg->tags);
223
	lvm_list_init(&vg->tags);
224
224
225
	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
225
	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
226
						       NULL))) {
226
						       NULL))) {
Lines 254-266 Link Here
254
				  uint32_t existing_extent_count,
254
				  uint32_t existing_extent_count,
255
				  uint32_t existing_extent_size,
255
				  uint32_t existing_extent_size,
256
				  int pvmetadatacopies,
256
				  int pvmetadatacopies,
257
				  uint64_t pvmetadatasize, struct list *mdas)
257
				  uint64_t pvmetadatasize, struct lvm_list *mdas)
258
{
258
{
259
	struct pool *mem = fmt->cmd->mem;
259
	struct pool *mem = fmt->cmd->mem;
260
	struct physical_volume *pv = pool_alloc(mem, sizeof(*pv));
260
	struct physical_volume *pv = pool_alloc(mem, sizeof(*pv));
261
261
262
	if (!pv) {
262
	if (!pv) {
263
		stack;
263
		STACK;
264
		return NULL;
264
		return NULL;
265
	}
265
	}
266
266
Lines 272-278 Link Here
272
	pv->dev = dev;
272
	pv->dev = dev;
273
273
274
	if (!(pv->vg_name = pool_zalloc(mem, NAME_LEN))) {
274
	if (!(pv->vg_name = pool_zalloc(mem, NAME_LEN))) {
275
		stack;
275
		STACK;
276
		goto bad;
276
		goto bad;
277
	}
277
	}
278
278
Lines 304-310 Link Here
304
	pv->pe_alloc_count = 0;
304
	pv->pe_alloc_count = 0;
305
	pv->fmt = fmt;
305
	pv->fmt = fmt;
306
306
307
	list_init(&pv->tags);
307
	lvm_list_init(&pv->tags);
308
308
309
	if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
309
	if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
310
				existing_extent_size,
310
				existing_extent_size,
Lines 323-333 Link Here
323
323
324
struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
324
struct pv_list *find_pv_in_vg(struct volume_group *vg, const char *pv_name)
325
{
325
{
326
	struct list *pvh;
326
	struct lvm_list *pvh;
327
	struct pv_list *pvl;
327
	struct pv_list *pvl;
328
328
329
	list_iterate(pvh, &vg->pvs) {
329
	lvm_list_iterate(pvh, &vg->pvs) {
330
		pvl = list_item(pvh, struct pv_list);
330
		pvl = lvm_list_item(pvh, struct pv_list);
331
		if (pvl->pv->dev == dev_cache_get(pv_name, vg->cmd->filter))
331
		if (pvl->pv->dev == dev_cache_get(pv_name, vg->cmd->filter))
332
			return pvl;
332
			return pvl;
333
	}
333
	}
Lines 337-346 Link Here
337
337
338
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv)
338
int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv)
339
{
339
{
340
	struct list *pvh;
340
	struct lvm_list *pvh;
341
341
342
	list_iterate(pvh, &vg->pvs) {
342
	lvm_list_iterate(pvh, &vg->pvs) {
343
		if (pv == list_item(pvh, struct pv_list)->pv)
343
		if (pv == lvm_list_item(pvh, struct pv_list)->pv)
344
			 return 1;
344
			 return 1;
345
	}
345
	}
346
346
Lines 350-360 Link Here
350
struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
350
struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
351
					      struct id *id)
351
					      struct id *id)
352
{
352
{
353
	struct list *pvh;
353
	struct lvm_list *pvh;
354
	struct pv_list *pvl;
354
	struct pv_list *pvl;
355
355
356
	list_iterate(pvh, &vg->pvs) {
356
	lvm_list_iterate(pvh, &vg->pvs) {
357
		pvl = list_item(pvh, struct pv_list);
357
		pvl = lvm_list_item(pvh, struct pv_list);
358
		if (id_equal(&pvl->pv->id, id))
358
		if (id_equal(&pvl->pv->id, id))
359
			return pvl->pv;
359
			return pvl->pv;
360
	}
360
	}
Lines 364-370 Link Here
364
364
365
struct lv_list *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
365
struct lv_list *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
366
{
366
{
367
	struct list *lvh;
367
	struct lvm_list *lvh;
368
	struct lv_list *lvl;
368
	struct lv_list *lvl;
369
	const char *ptr;
369
	const char *ptr;
370
370
Lines 374-381 Link Here
374
	else
374
	else
375
		ptr = lv_name;
375
		ptr = lv_name;
376
376
377
	list_iterate(lvh, &vg->lvs) {
377
	lvm_list_iterate(lvh, &vg->lvs) {
378
		lvl = list_item(lvh, struct lv_list);
378
		lvl = lvm_list_item(lvh, struct lv_list);
379
		if (!strcmp(lvl->lv->name, ptr))
379
		if (!strcmp(lvl->lv->name, ptr))
380
			return lvl;
380
			return lvl;
381
	}
381
	}
Lines 386-396 Link Here
386
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
386
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
387
				      const union lvid *lvid)
387
				      const union lvid *lvid)
388
{
388
{
389
	struct list *lvh;
389
	struct lvm_list *lvh;
390
	struct lv_list *lvl;
390
	struct lv_list *lvl;
391
391
392
	list_iterate(lvh, &vg->lvs) {
392
	lvm_list_iterate(lvh, &vg->lvs) {
393
		lvl = list_item(lvh, struct lv_list);
393
		lvl = lvm_list_item(lvh, struct lv_list);
394
		if (!strncmp(lvl->lv->lvid.s, lvid->s, sizeof(*lvid)))
394
		if (!strncmp(lvl->lv->lvid.s, lvid->s, sizeof(*lvid)))
395
			return lvl;
395
			return lvl;
396
	}
396
	}
Lines 406-416 Link Here
406
406
407
struct physical_volume *find_pv(struct volume_group *vg, struct device *dev)
407
struct physical_volume *find_pv(struct volume_group *vg, struct device *dev)
408
{
408
{
409
	struct list *pvh;
409
	struct lvm_list *pvh;
410
	struct physical_volume *pv;
410
	struct physical_volume *pv;
411
411
412
	list_iterate(pvh, &vg->pvs) {
412
	lvm_list_iterate(pvh, &vg->pvs) {
413
		pv = list_item(pvh, struct pv_list)->pv;
413
		pv = lvm_list_item(pvh, struct pv_list)->pv;
414
414
415
		if (dev == pv->dev)
415
		if (dev == pv->dev)
416
			return pv;
416
			return pv;
Lines 421-431 Link Here
421
/* Find segment at a given logical extent in an LV */
421
/* Find segment at a given logical extent in an LV */
422
struct lv_segment *find_seg_by_le(struct logical_volume *lv, uint32_t le)
422
struct lv_segment *find_seg_by_le(struct logical_volume *lv, uint32_t le)
423
{
423
{
424
	struct list *segh;
424
	struct lvm_list *segh;
425
	struct lv_segment *seg;
425
	struct lv_segment *seg;
426
426
427
	list_iterate(segh, &lv->segments) {
427
	lvm_list_iterate(segh, &lv->segments) {
428
		seg = list_item(segh, struct lv_segment);
428
		seg = lvm_list_item(segh, struct lv_segment);
429
		if (le >= seg->le && le < seg->le + seg->len)
429
		if (le >= seg->le && le < seg->le + seg->len)
430
			return seg;
430
			return seg;
431
	}
431
	}
Lines 435-450 Link Here
435
435
436
int vg_remove(struct volume_group *vg)
436
int vg_remove(struct volume_group *vg)
437
{
437
{
438
	struct list *mdah;
438
	struct lvm_list *mdah;
439
	struct metadata_area *mda;
439
	struct metadata_area *mda;
440
440
441
	/* FIXME Improve recovery situation? */
441
	/* FIXME Improve recovery situation? */
442
	/* Remove each copy of the metadata */
442
	/* Remove each copy of the metadata */
443
	list_iterate(mdah, &vg->fid->metadata_areas) {
443
	lvm_list_iterate(mdah, &vg->fid->metadata_areas) {
444
		mda = list_item(mdah, struct metadata_area);
444
		mda = lvm_list_item(mdah, struct metadata_area);
445
		if (mda->ops->vg_remove &&
445
		if (mda->ops->vg_remove &&
446
		    !mda->ops->vg_remove(vg->fid, vg, mda)) {
446
		    !mda->ops->vg_remove(vg->fid, vg, mda)) {
447
			stack;
447
			STACK;
448
			return 0;
448
			return 0;
449
		}
449
		}
450
	}
450
	}
Lines 458-464 Link Here
458
 */
458
 */
459
int vg_write(struct volume_group *vg)
459
int vg_write(struct volume_group *vg)
460
{
460
{
461
	struct list *mdah, *mdah2;
461
	struct lvm_list *mdah, *mdah2;
462
	struct metadata_area *mda;
462
	struct metadata_area *mda;
463
463
464
	if (vg->status & PARTIAL_VG) {
464
	if (vg->status & PARTIAL_VG) {
Lines 467-473 Link Here
467
		return 0;
467
		return 0;
468
	}
468
	}
469
469
470
	if (list_empty(&vg->fid->metadata_areas)) {
470
	if (lvm_list_empty(&vg->fid->metadata_areas)) {
471
		log_error("Aborting vg_write: No metadata areas to write to!");
471
		log_error("Aborting vg_write: No metadata areas to write to!");
472
		return 0;
472
		return 0;
473
	}
473
	}
Lines 475-503 Link Here
475
	vg->seqno++;
475
	vg->seqno++;
476
476
477
	/* Write to each copy of the metadata area */
477
	/* Write to each copy of the metadata area */
478
	list_iterate(mdah, &vg->fid->metadata_areas) {
478
	lvm_list_iterate(mdah, &vg->fid->metadata_areas) {
479
		mda = list_item(mdah, struct metadata_area);
479
		mda = lvm_list_item(mdah, struct metadata_area);
480
		if (!mda->ops->vg_write) {
480
		if (!mda->ops->vg_write) {
481
			log_error("Format does not support writing volume"
481
			log_error("Format does not support writing volume"
482
				  "group metadata areas");
482
				  "group metadata areas");
483
			/* Revert */
483
			/* Revert */
484
			list_uniterate(mdah2, &vg->fid->metadata_areas, mdah) {
484
			lvm_list_uniterate(mdah2, &vg->fid->metadata_areas, mdah) {
485
				mda = list_item(mdah2, struct metadata_area);
485
				mda = lvm_list_item(mdah2, struct metadata_area);
486
				if (mda->ops->vg_revert &&
486
				if (mda->ops->vg_revert &&
487
				    !mda->ops->vg_revert(vg->fid, vg, mda)) {
487
				    !mda->ops->vg_revert(vg->fid, vg, mda)) {
488
					stack;
488
					STACK;
489
				}
489
				}
490
			}
490
			}
491
			return 0;
491
			return 0;
492
		}
492
		}
493
		if (!mda->ops->vg_write(vg->fid, vg, mda)) {
493
		if (!mda->ops->vg_write(vg->fid, vg, mda)) {
494
			stack;
494
			STACK;
495
			/* Revert */
495
			/* Revert */
496
			list_uniterate(mdah2, &vg->fid->metadata_areas, mdah) {
496
			lvm_list_uniterate(mdah2, &vg->fid->metadata_areas, mdah) {
497
				mda = list_item(mdah2, struct metadata_area);
497
				mda = lvm_list_item(mdah2, struct metadata_area);
498
				if (mda->ops->vg_revert &&
498
				if (mda->ops->vg_revert &&
499
				    !mda->ops->vg_revert(vg->fid, vg, mda)) {
499
				    !mda->ops->vg_revert(vg->fid, vg, mda)) {
500
					stack;
500
					STACK;
501
				}
501
				}
502
			}
502
			}
503
			return 0;
503
			return 0;
Lines 510-527 Link Here
510
/* Commit pending changes */
510
/* Commit pending changes */
511
int vg_commit(struct volume_group *vg)
511
int vg_commit(struct volume_group *vg)
512
{
512
{
513
	struct list *mdah;
513
	struct lvm_list *mdah;
514
	struct metadata_area *mda;
514
	struct metadata_area *mda;
515
	int cache_updated = 0;
515
	int cache_updated = 0;
516
	int failed = 0;
516
	int failed = 0;
517
517
518
	/* Commit to each copy of the metadata area */
518
	/* Commit to each copy of the metadata area */
519
	list_iterate(mdah, &vg->fid->metadata_areas) {
519
	lvm_list_iterate(mdah, &vg->fid->metadata_areas) {
520
		mda = list_item(mdah, struct metadata_area);
520
		mda = lvm_list_item(mdah, struct metadata_area);
521
		failed = 0;
521
		failed = 0;
522
		if (mda->ops->vg_commit &&
522
		if (mda->ops->vg_commit &&
523
		    !mda->ops->vg_commit(vg->fid, vg, mda)) {
523
		    !mda->ops->vg_commit(vg->fid, vg, mda)) {
524
			stack;
524
			STACK;
525
			failed = 1;
525
			failed = 1;
526
		}
526
		}
527
		/* Update cache first time we succeed */
527
		/* Update cache first time we succeed */
Lines 539-552 Link Here
539
/* Don't commit any pending changes */
539
/* Don't commit any pending changes */
540
int vg_revert(struct volume_group *vg)
540
int vg_revert(struct volume_group *vg)
541
{
541
{
542
	struct list *mdah;
542
	struct lvm_list *mdah;
543
	struct metadata_area *mda;
543
	struct metadata_area *mda;
544
544
545
	list_iterate(mdah, &vg->fid->metadata_areas) {
545
	lvm_list_iterate(mdah, &vg->fid->metadata_areas) {
546
		mda = list_item(mdah, struct metadata_area);
546
		mda = lvm_list_item(mdah, struct metadata_area);
547
		if (mda->ops->vg_revert &&
547
		if (mda->ops->vg_revert &&
548
		    !mda->ops->vg_revert(vg->fid, vg, mda)) {
548
		    !mda->ops->vg_revert(vg->fid, vg, mda)) {
549
			stack;
549
			STACK;
550
		}
550
		}
551
	}
551
	}
552
552
Lines 557-570 Link Here
557
static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
557
static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
558
{
558
{
559
	struct lvmcache_vginfo *vginfo;
559
	struct lvmcache_vginfo *vginfo;
560
	struct list *ih;
560
	struct lvm_list *ih;
561
	struct device *dev;
561
	struct device *dev;
562
	struct pv_list *pvl;
562
	struct pv_list *pvl;
563
	struct volume_group *vg;
563
	struct volume_group *vg;
564
	struct physical_volume *pv;
564
	struct physical_volume *pv;
565
565
566
	if (!(vginfo = vginfo_from_vgname(ORPHAN))) {
566
	if (!(vginfo = vginfo_from_vgname(ORPHAN))) {
567
		stack;
567
		STACK;
568
		return NULL;
568
		return NULL;
569
	}
569
	}
570
570
Lines 572-589 Link Here
572
		log_error("vg allocation failed");
572
		log_error("vg allocation failed");
573
		return NULL;
573
		return NULL;
574
	}
574
	}
575
	list_init(&vg->pvs);
575
	lvm_list_init(&vg->pvs);
576
	list_init(&vg->lvs);
576
	lvm_list_init(&vg->lvs);
577
	list_init(&vg->snapshots);
577
	lvm_list_init(&vg->snapshots);
578
	list_init(&vg->tags);
578
	lvm_list_init(&vg->tags);
579
	vg->cmd = cmd;
579
	vg->cmd = cmd;
580
	if (!(vg->name = pool_strdup(cmd->mem, ORPHAN))) {
580
	if (!(vg->name = pool_strdup(cmd->mem, ORPHAN))) {
581
		log_error("vg name allocation failed");
581
		log_error("vg name allocation failed");
582
		return NULL;
582
		return NULL;
583
	}
583
	}
584
584
585
	list_iterate(ih, &vginfo->infos) {
585
	lvm_list_iterate(ih, &vginfo->infos) {
586
		dev = list_item(ih, struct lvmcache_info)->dev;
586
		dev = lvm_list_item(ih, struct lvmcache_info)->dev;
587
		if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL))) {
587
		if (!(pv = pv_read(cmd, dev_name(dev), NULL, NULL))) {
588
			continue;
588
			continue;
589
		}
589
		}
Lines 592-598 Link Here
592
			return NULL;
592
			return NULL;
593
		}
593
		}
594
		pvl->pv = pv;
594
		pvl->pv = pv;
595
		list_add(&vg->pvs, &pvl->list);
595
		lvm_list_add(&vg->pvs, &pvl->list);
596
		vg->pv_count++;
596
		vg->pv_count++;
597
	}
597
	}
598
598
Lines 612-618 Link Here
612
	struct format_instance *fid;
612
	struct format_instance *fid;
613
	const struct format_type *fmt;
613
	const struct format_type *fmt;
614
	struct volume_group *vg, *correct_vg = NULL;
614
	struct volume_group *vg, *correct_vg = NULL;
615
	struct list *mdah;
615
	struct lvm_list *mdah;
616
	struct metadata_area *mda;
616
	struct metadata_area *mda;
617
	int inconsistent = 0;
617
	int inconsistent = 0;
618
618
Lines 627-638 Link Here
627
		lvmcache_label_scan(cmd, 0);
627
		lvmcache_label_scan(cmd, 0);
628
		if (!(fmt = fmt_from_vgname(vgname))) {
628
		if (!(fmt = fmt_from_vgname(vgname))) {
629
			if (memlock()) {
629
			if (memlock()) {
630
				stack;
630
				STACK;
631
				return NULL;
631
				return NULL;
632
			}
632
			}
633
			lvmcache_label_scan(cmd, 1);
633
			lvmcache_label_scan(cmd, 1);
634
			if (!(fmt = fmt_from_vgname(vgname))) {
634
			if (!(fmt = fmt_from_vgname(vgname))) {
635
				stack;
635
				STACK;
636
				return NULL;
636
				return NULL;
637
			}
637
			}
638
		}
638
		}
Lines 645-652 Link Here
645
	}
645
	}
646
646
647
	/* Ensure contents of all metadata areas match - else do recovery */
647
	/* Ensure contents of all metadata areas match - else do recovery */
648
	list_iterate(mdah, &fid->metadata_areas) {
648
	lvm_list_iterate(mdah, &fid->metadata_areas) {
649
		mda = list_item(mdah, struct metadata_area);
649
		mda = lvm_list_item(mdah, struct metadata_area);
650
		if (!(vg = mda->ops->vg_read(fid, vgname, mda))) {
650
		if (!(vg = mda->ops->vg_read(fid, vgname, mda))) {
651
			inconsistent = 1;
651
			inconsistent = 1;
652
			continue;
652
			continue;
Lines 665-671 Link Here
665
665
666
	/* Failed to find VG */
666
	/* Failed to find VG */
667
	if (!correct_vg) {
667
	if (!correct_vg) {
668
		stack;
668
		STACK;
669
		return NULL;
669
		return NULL;
670
	}
670
	}
671
671
Lines 711-717 Link Here
711
struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid)
711
struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid)
712
{
712
{
713
	const char *vgname;
713
	const char *vgname;
714
	struct list *vgnames, *slh;
714
	struct lvm_list *vgnames, *slh;
715
	struct volume_group *vg;
715
	struct volume_group *vg;
716
	struct lvmcache_vginfo *vginfo;
716
	struct lvmcache_vginfo *vginfo;
717
	int consistent = 0;
717
	int consistent = 0;
Lines 744-751 Link Here
744
		return NULL;
744
		return NULL;
745
	}
745
	}
746
746
747
	list_iterate(slh, vgnames) {
747
	lvm_list_iterate(slh, vgnames) {
748
		vgname = list_item(slh, struct str_list)->str;
748
		vgname = lvm_list_item(slh, struct str_list)->str;
749
		if (!vgname || !*vgname)
749
		if (!vgname || !*vgname)
750
			continue;	// FIXME Unnecessary? 
750
			continue;	// FIXME Unnecessary? 
751
		consistent = 0;
751
		consistent = 0;
Lines 793-799 Link Here
793
793
794
/* FIXME Use label functions instead of PV functions */
794
/* FIXME Use label functions instead of PV functions */
795
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
795
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
796
				struct list *mdas, uint64_t *label_sector)
796
				struct lvm_list *mdas, uint64_t *label_sector)
797
{
797
{
798
	struct physical_volume *pv;
798
	struct physical_volume *pv;
799
	struct label *label;
799
	struct label *label;
Lines 801-807 Link Here
801
	struct device *dev;
801
	struct device *dev;
802
802
803
	if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
803
	if (!(dev = dev_cache_get(pv_name, cmd->filter))) {
804
		stack;
804
		STACK;
805
		return 0;
805
		return 0;
806
	}
806
	}
807
807
Lines 819-825 Link Here
819
		return 0;
819
		return 0;
820
	}
820
	}
821
821
822
	list_init(&pv->tags);
822
	lvm_list_init(&pv->tags);
823
823
824
	/* FIXME Move more common code up here */
824
	/* FIXME Move more common code up here */
825
	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas))) {
825
	if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas))) {
Lines 835-851 Link Here
835
}
835
}
836
836
837
/* May return empty list */
837
/* May return empty list */
838
struct list *get_vgs(struct cmd_context *cmd, int full_scan)
838
struct lvm_list *get_vgs(struct cmd_context *cmd, int full_scan)
839
{
839
{
840
	return lvmcache_get_vgnames(cmd, full_scan);
840
	return lvmcache_get_vgnames(cmd, full_scan);
841
}
841
}
842
842
843
struct list *get_pvs(struct cmd_context *cmd)
843
struct lvm_list *get_pvs(struct cmd_context *cmd)
844
{
844
{
845
	struct list *results;
845
	struct lvm_list *results;
846
	const char *vgname;
846
	const char *vgname;
847
	struct list *pvh, *tmp;
847
	struct lvm_list *pvh, *tmp;
848
	struct list *vgnames, *slh;
848
	struct lvm_list *vgnames, *slh;
849
	struct volume_group *vg;
849
	struct volume_group *vg;
850
	int consistent = 0;
850
	int consistent = 0;
851
	int old_partial;
851
	int old_partial;
Lines 858-864 Link Here
858
		return NULL;
858
		return NULL;
859
	}
859
	}
860
860
861
	list_init(results);
861
	lvm_list_init(results);
862
862
863
	/* Get list of VGs */
863
	/* Get list of VGs */
864
	if (!(vgnames = get_vgs(cmd, 0))) {
864
	if (!(vgnames = get_vgs(cmd, 0))) {
Lines 872-884 Link Here
872
	old_pvmove = pvmove_mode();
872
	old_pvmove = pvmove_mode();
873
	init_partial(1);
873
	init_partial(1);
874
	init_pvmove(1);
874
	init_pvmove(1);
875
	list_iterate(slh, vgnames) {
875
	lvm_list_iterate(slh, vgnames) {
876
		vgname = list_item(slh, struct str_list)->str;
876
		vgname = lvm_list_item(slh, struct str_list)->str;
877
		if (!vgname)
877
		if (!vgname)
878
			continue;	/* FIXME Unnecessary? */
878
			continue;	/* FIXME Unnecessary? */
879
		consistent = 0;
879
		consistent = 0;
880
		if (!(vg = vg_read(cmd, vgname, &consistent))) {
880
		if (!(vg = vg_read(cmd, vgname, &consistent))) {
881
			stack;
881
			STACK;
882
			continue;
882
			continue;
883
		}
883
		}
884
		if (!consistent)
884
		if (!consistent)
Lines 886-893 Link Here
886
				  vgname);
886
				  vgname);
887
887
888
		/* Move PVs onto results list */
888
		/* Move PVs onto results list */
889
		list_iterate_safe(pvh, tmp, &vg->pvs) {
889
		lvm_list_iterate_safe(pvh, tmp, &vg->pvs) {
890
			list_add(results, pvh);
890
			lvm_list_add(results, pvh);
891
		}
891
		}
892
	}
892
	}
893
	init_pvmove(old_pvmove);
893
	init_pvmove(old_pvmove);
Lines 897-903 Link Here
897
}
897
}
898
898
899
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
899
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
900
	     struct list *mdas, int64_t label_sector)
900
	     struct lvm_list *mdas, int64_t label_sector)
901
{
901
{
902
	if (!pv->fmt->ops->pv_write) {
902
	if (!pv->fmt->ops->pv_write) {
903
		log_error("Format does not support writing physical volumes");
903
		log_error("Format does not support writing physical volumes");
Lines 911-917 Link Here
911
	}
911
	}
912
912
913
	if (!pv->fmt->ops->pv_write(pv->fmt, pv, mdas, label_sector)) {
913
	if (!pv->fmt->ops->pv_write(pv->fmt, pv, mdas, label_sector)) {
914
		stack;
914
		STACK;
915
		return 0;
915
		return 0;
916
	}
916
	}
917
917
(-)LVM2.2.00.15.orig/lib/metadata/metadata.h (-35 / +35 lines)
Lines 89-95 Link Here
89
struct labeller;
89
struct labeller;
90
90
91
struct format_type {
91
struct format_type {
92
	struct list list;
92
	struct lvm_list list;
93
	struct cmd_context *cmd;
93
	struct cmd_context *cmd;
94
	struct format_handler *ops;
94
	struct format_handler *ops;
95
	struct labeller *labeller;
95
	struct labeller *labeller;
Lines 115-121 Link Here
115
	uint32_t pe_count;
115
	uint32_t pe_count;
116
	uint32_t pe_alloc_count;
116
	uint32_t pe_alloc_count;
117
117
118
	struct list tags;
118
	struct lvm_list tags;
119
};
119
};
120
120
121
struct metadata_area;
121
struct metadata_area;
Lines 151-164 Link Here
151
};
151
};
152
152
153
struct metadata_area {
153
struct metadata_area {
154
	struct list list;
154
	struct lvm_list list;
155
	struct metadata_area_ops *ops;
155
	struct metadata_area_ops *ops;
156
	void *metadata_locn;
156
	void *metadata_locn;
157
};
157
};
158
158
159
struct format_instance {
159
struct format_instance {
160
	const struct format_type *fmt;
160
	const struct format_type *fmt;
161
	struct list metadata_areas;	/* e.g. metadata locations */
161
	struct lvm_list metadata_areas;	/* e.g. metadata locations */
162
};
162
};
163
163
164
struct volume_group {
164
struct volume_group {
Lines 181-201 Link Here
181
181
182
	/* physical volumes */
182
	/* physical volumes */
183
	uint32_t pv_count;
183
	uint32_t pv_count;
184
	struct list pvs;
184
	struct lvm_list pvs;
185
185
186
	/* logical volumes */
186
	/* logical volumes */
187
	uint32_t lv_count;
187
	uint32_t lv_count;
188
	struct list lvs;
188
	struct lvm_list lvs;
189
189
190
	/* snapshots */
190
	/* snapshots */
191
	uint32_t snapshot_count;
191
	uint32_t snapshot_count;
192
	struct list snapshots;
192
	struct lvm_list snapshots;
193
193
194
	struct list tags;
194
	struct lvm_list tags;
195
};
195
};
196
196
197
struct lv_segment {
197
struct lv_segment {
198
	struct list list;
198
	struct lvm_list list;
199
	struct logical_volume *lv;
199
	struct logical_volume *lv;
200
200
201
	segment_type_t type;
201
	segment_type_t type;
Lines 213-219 Link Here
213
	uint32_t chunk_size;
213
	uint32_t chunk_size;
214
	uint32_t extents_moved;
214
	uint32_t extents_moved;
215
215
216
	struct list tags;
216
	struct lvm_list tags;
217
217
218
	/* There will be one area for each stripe */
218
	/* There will be one area for each stripe */
219
	struct {
219
	struct {
Lines 246-253 Link Here
246
	uint64_t size;
246
	uint64_t size;
247
	uint32_t le_count;
247
	uint32_t le_count;
248
248
249
	struct list segments;
249
	struct lvm_list segments;
250
	struct list tags;
250
	struct lvm_list tags;
251
};
251
};
252
252
253
struct snapshot {
253
struct snapshot {
Lines 261-296 Link Here
261
};
261
};
262
262
263
struct name_list {
263
struct name_list {
264
	struct list list;
264
	struct lvm_list list;
265
	char *name;
265
	char *name;
266
};
266
};
267
267
268
struct alloc_area {
268
struct alloc_area {
269
	struct list list;
269
	struct lvm_list list;
270
	uint32_t start;		/* PEs */
270
	uint32_t start;		/* PEs */
271
	uint32_t count;		/* PEs */
271
	uint32_t count;		/* PEs */
272
};
272
};
273
273
274
struct pv_list {
274
struct pv_list {
275
	struct list list;
275
	struct lvm_list list;
276
	struct physical_volume *pv;
276
	struct physical_volume *pv;
277
	struct list *mdas;	/* Metadata areas */
277
	struct lvm_list *mdas;	/* Metadata areas */
278
	struct list *alloc_areas;	/* Areas we may allocate from */
278
	struct lvm_list *alloc_areas;	/* Areas we may allocate from */
279
};
279
};
280
280
281
struct lv_list {
281
struct lv_list {
282
	struct list list;
282
	struct lvm_list list;
283
	struct logical_volume *lv;
283
	struct logical_volume *lv;
284
};
284
};
285
285
286
struct snapshot_list {
286
struct snapshot_list {
287
	struct list list;
287
	struct lvm_list list;
288
288
289
	struct snapshot *snapshot;
289
	struct snapshot *snapshot;
290
};
290
};
291
291
292
struct mda_list {
292
struct mda_list {
293
	struct list list;
293
	struct lvm_list list;
294
	struct device_area mda;
294
	struct device_area mda;
295
};
295
};
296
296
Lines 307-313 Link Here
307
	 * Return PV with given path.
307
	 * Return PV with given path.
308
	 */
308
	 */
309
	int (*pv_read) (const struct format_type * fmt, const char *pv_name,
309
	int (*pv_read) (const struct format_type * fmt, const char *pv_name,
310
			struct physical_volume * pv, struct list * mdas);
310
			struct physical_volume * pv, struct lvm_list * mdas);
311
311
312
	/*
312
	/*
313
	 * Tweak an already filled out a pv ready for importing into a
313
	 * Tweak an already filled out a pv ready for importing into a
Lines 317-323 Link Here
317
			 uint64_t pe_start, uint32_t extent_count,
317
			 uint64_t pe_start, uint32_t extent_count,
318
			 uint32_t extent_size,
318
			 uint32_t extent_size,
319
			 int pvmetadatacopies,
319
			 int pvmetadatacopies,
320
			 uint64_t pvmetadatasize, struct list * mdas,
320
			 uint64_t pvmetadatasize, struct lvm_list * mdas,
321
			 struct physical_volume * pv, struct volume_group * vg);
321
			 struct physical_volume * pv, struct volume_group * vg);
322
322
323
	/*
323
	/*
Lines 325-331 Link Here
325
	 * pv->vg_name must be null.
325
	 * pv->vg_name must be null.
326
	 */
326
	 */
327
	int (*pv_write) (const struct format_type * fmt,
327
	int (*pv_write) (const struct format_type * fmt,
328
			 struct physical_volume * pv, struct list * mdas,
328
			 struct physical_volume * pv, struct lvm_list * mdas,
329
			 int64_t label_sector);
329
			 int64_t label_sector);
330
330
331
	/*
331
	/*
Lines 369-382 Link Here
369
			     int *consistent);
369
			     int *consistent);
370
struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid);
370
struct volume_group *vg_read_by_vgid(struct cmd_context *cmd, const char *vgid);
371
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
371
struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
372
				struct list *mdas, uint64_t *label_sector);
372
				struct lvm_list *mdas, uint64_t *label_sector);
373
struct list *get_pvs(struct cmd_context *cmd);
373
struct lvm_list *get_pvs(struct cmd_context *cmd);
374
374
375
/* Set full_scan to 1 to re-read every (filtered) device label */
375
/* Set full_scan to 1 to re-read every (filtered) device label */
376
struct list *get_vgs(struct cmd_context *cmd, int full_scan);
376
struct lvm_list *get_vgs(struct cmd_context *cmd, int full_scan);
377
377
378
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
378
int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
379
	     struct list *mdas, int64_t label_sector);
379
	     struct lvm_list *mdas, int64_t label_sector);
380
380
381
/* pe_start and pe_end relate to any existing data so that new metadata
381
/* pe_start and pe_end relate to any existing data so that new metadata
382
 * areas can avoid overlap */
382
 * areas can avoid overlap */
Lines 388-394 Link Here
388
				  uint32_t existing_extent_count,
388
				  uint32_t existing_extent_count,
389
				  uint32_t existing_extent_size,
389
				  uint32_t existing_extent_size,
390
				  int pvmetadatacopies,
390
				  int pvmetadatacopies,
391
				  uint64_t pvmetadatasize, struct list *mdas);
391
				  uint64_t pvmetadatasize, struct lvm_list *mdas);
392
392
393
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
393
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
394
			       uint32_t extent_size, uint32_t max_pv,
394
			       uint32_t extent_size, uint32_t max_pv,
Lines 411-417 Link Here
411
				 uint32_t stripe_size,
411
				 uint32_t stripe_size,
412
				 uint32_t extents,
412
				 uint32_t extents,
413
				 struct volume_group *vg,
413
				 struct volume_group *vg,
414
				 struct list *allocatable_pvs);
414
				 struct lvm_list *allocatable_pvs);
415
415
416
struct logical_volume *lv_create_empty(struct format_instance *fi,
416
struct logical_volume *lv_create_empty(struct format_instance *fi,
417
				       const char *name,
417
				       const char *name,
Lines 428-440 Link Here
428
	      struct logical_volume *lv,
428
	      struct logical_volume *lv,
429
	      uint32_t stripes,
429
	      uint32_t stripes,
430
	      uint32_t stripe_size,
430
	      uint32_t stripe_size,
431
	      uint32_t extents, struct list *allocatable_pvs);
431
	      uint32_t extents, struct lvm_list *allocatable_pvs);
432
432
433
int lv_extend_mirror(struct format_instance *fid,
433
int lv_extend_mirror(struct format_instance *fid,
434
		     struct logical_volume *lv,
434
		     struct logical_volume *lv,
435
		     struct physical_volume *mirrored_pv,
435
		     struct physical_volume *mirrored_pv,
436
		     uint32_t mirrored_pe,
436
		     uint32_t mirrored_pe,
437
		     uint32_t extents, struct list *allocatable_pvs,
437
		     uint32_t extents, struct lvm_list *allocatable_pvs,
438
		     uint32_t status);
438
		     uint32_t status);
439
439
440
/* lv must be part of vg->lvs */
440
/* lv must be part of vg->lvs */
Lines 502-508 Link Here
502
502
503
struct snapshot *find_cow(const struct logical_volume *lv);
503
struct snapshot *find_cow(const struct logical_volume *lv);
504
struct snapshot *find_origin(const struct logical_volume *lv);
504
struct snapshot *find_origin(const struct logical_volume *lv);
505
struct list *find_snapshots(const struct logical_volume *lv);
505
struct lvm_list *find_snapshots(const struct logical_volume *lv);
506
506
507
int vg_add_snapshot(struct logical_volume *origin,
507
int vg_add_snapshot(struct logical_volume *origin,
508
		    struct logical_volume *cow,
508
		    struct logical_volume *cow,
Lines 517-524 Link Here
517
			  struct logical_volume *lv_mirr,
517
			  struct logical_volume *lv_mirr,
518
			  struct physical_volume *pv,
518
			  struct physical_volume *pv,
519
			  struct logical_volume *lv,
519
			  struct logical_volume *lv,
520
			  struct list *allocatable_pvs,
520
			  struct lvm_list *allocatable_pvs,
521
			  struct list *lvs_changed);
521
			  struct lvm_list *lvs_changed);
522
int remove_pvmove_mirrors(struct volume_group *vg,
522
int remove_pvmove_mirrors(struct volume_group *vg,
523
			  struct logical_volume *lv_mirr);
523
			  struct logical_volume *lv_mirr);
524
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
524
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
Lines 527-533 Link Here
527
struct physical_volume *get_pvmove_pv_from_lv_mirr(struct logical_volume
527
struct physical_volume *get_pvmove_pv_from_lv_mirr(struct logical_volume
528
						   *lv_mirr);
528
						   *lv_mirr);
529
float pvmove_percent(struct logical_volume *lv_mirr);
529
float pvmove_percent(struct logical_volume *lv_mirr);
530
struct list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
530
struct lvm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
531
			  struct logical_volume *lv);
531
			  struct logical_volume *lv);
532
532
533
uint32_t find_free_lvnum(struct logical_volume *lv);
533
uint32_t find_free_lvnum(struct logical_volume *lv);
(-)LVM2.2.00.15.orig/lib/metadata/mirror.c (-33 / +33 lines)
Lines 25-41 Link Here
25
			  struct logical_volume *lv_mirr,
25
			  struct logical_volume *lv_mirr,
26
			  struct physical_volume *pv,
26
			  struct physical_volume *pv,
27
			  struct logical_volume *lv,
27
			  struct logical_volume *lv,
28
			  struct list *allocatable_pvs,
28
			  struct lvm_list *allocatable_pvs,
29
			  struct list *lvs_changed)
29
			  struct lvm_list *lvs_changed)
30
{
30
{
31
	struct list *segh;
31
	struct lvm_list *segh;
32
	struct lv_segment *seg;
32
	struct lv_segment *seg;
33
	struct lv_list *lvl;
33
	struct lv_list *lvl;
34
	int lv_used = 0;
34
	int lv_used = 0;
35
	uint32_t s, start_le, extent_count = 0u;
35
	uint32_t s, start_le, extent_count = 0u;
36
36
37
	list_iterate(segh, &lv->segments) {
37
	lvm_list_iterate(segh, &lv->segments) {
38
		seg = list_item(segh, struct lv_segment);
38
		seg = lvm_list_item(segh, struct lv_segment);
39
		for (s = 0; s < seg->area_count; s++) {
39
		for (s = 0; s < seg->area_count; s++) {
40
			if (seg->area[s].type != AREA_PV ||
40
			if (seg->area[s].type != AREA_PV ||
41
			    seg->area[s].u.pv.pv->dev != pv->dev)
41
			    seg->area[s].u.pv.pv->dev != pv->dev)
Lines 47-53 Link Here
47
					return 0;
47
					return 0;
48
				}
48
				}
49
				lvl->lv = lv;
49
				lvl->lv = lv;
50
				list_add(lvs_changed, &lvl->list);
50
				lvm_list_add(lvs_changed, &lvl->list);
51
				lv_used = 1;
51
				lv_used = 1;
52
			}
52
			}
53
53
Lines 80-97 Link Here
80
int remove_pvmove_mirrors(struct volume_group *vg,
80
int remove_pvmove_mirrors(struct volume_group *vg,
81
			  struct logical_volume *lv_mirr)
81
			  struct logical_volume *lv_mirr)
82
{
82
{
83
	struct list *lvh, *segh;
83
	struct lvm_list *lvh, *segh;
84
	struct logical_volume *lv1;
84
	struct logical_volume *lv1;
85
	struct lv_segment *seg, *mir_seg;
85
	struct lv_segment *seg, *mir_seg;
86
	uint32_t s, c;
86
	uint32_t s, c;
87
87
88
	list_iterate(lvh, &vg->lvs) {
88
	lvm_list_iterate(lvh, &vg->lvs) {
89
		lv1 = list_item(lvh, struct lv_list)->lv;
89
		lv1 = lvm_list_item(lvh, struct lv_list)->lv;
90
		if (lv1 == lv_mirr)
90
		if (lv1 == lv_mirr)
91
			continue;
91
			continue;
92
92
93
		list_iterate(segh, &lv1->segments) {
93
		lvm_list_iterate(segh, &lv1->segments) {
94
			seg = list_item(segh, struct lv_segment);
94
			seg = lvm_list_item(segh, struct lv_segment);
95
			for (s = 0; s < seg->area_count; s++) {
95
			for (s = 0; s < seg->area_count; s++) {
96
				if (seg->area[s].type != AREA_LV ||
96
				if (seg->area[s].type != AREA_LV ||
97
				    seg->area[s].u.lv.lv != lv_mirr)
97
				    seg->area[s].u.lv.lv != lv_mirr)
Lines 136-146 Link Here
136
struct physical_volume *get_pvmove_pv_from_lv_mirr(struct logical_volume
136
struct physical_volume *get_pvmove_pv_from_lv_mirr(struct logical_volume
137
						   *lv_mirr)
137
						   *lv_mirr)
138
{
138
{
139
	struct list *segh;
139
	struct lvm_list *segh;
140
	struct lv_segment *seg;
140
	struct lv_segment *seg;
141
141
142
	list_iterate(segh, &lv_mirr->segments) {
142
	lvm_list_iterate(segh, &lv_mirr->segments) {
143
		seg = list_item(segh, struct lv_segment);
143
		seg = lvm_list_item(segh, struct lv_segment);
144
		if (seg->type != SEG_MIRRORED)
144
		if (seg->type != SEG_MIRRORED)
145
			continue;
145
			continue;
146
		if (seg->area[0].type != AREA_PV)
146
		if (seg->area[0].type != AREA_PV)
Lines 153-164 Link Here
153
153
154
struct physical_volume *get_pvmove_pv_from_lv(struct logical_volume *lv)
154
struct physical_volume *get_pvmove_pv_from_lv(struct logical_volume *lv)
155
{
155
{
156
	struct list *segh;
156
	struct lvm_list *segh;
157
	struct lv_segment *seg;
157
	struct lv_segment *seg;
158
	uint32_t s;
158
	uint32_t s;
159
159
160
	list_iterate(segh, &lv->segments) {
160
	lvm_list_iterate(segh, &lv->segments) {
161
		seg = list_item(segh, struct lv_segment);
161
		seg = lvm_list_item(segh, struct lv_segment);
162
		for (s = 0; s < seg->area_count; s++) {
162
		for (s = 0; s < seg->area_count; s++) {
163
			if (seg->area[s].type != AREA_LV)
163
			if (seg->area[s].type != AREA_LV)
164
				continue;
164
				continue;
Lines 172-190 Link Here
172
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
172
struct logical_volume *find_pvmove_lv(struct volume_group *vg,
173
				      struct device *dev)
173
				      struct device *dev)
174
{
174
{
175
	struct list *lvh, *segh;
175
	struct lvm_list *lvh, *segh;
176
	struct logical_volume *lv;
176
	struct logical_volume *lv;
177
	struct lv_segment *seg;
177
	struct lv_segment *seg;
178
178
179
	/* Loop through all LVs */
179
	/* Loop through all LVs */
180
	list_iterate(lvh, &vg->lvs) {
180
	lvm_list_iterate(lvh, &vg->lvs) {
181
		lv = list_item(lvh, struct lv_list)->lv;
181
		lv = lvm_list_item(lvh, struct lv_list)->lv;
182
182
183
		if (!(lv->status & PVMOVE))
183
		if (!(lv->status & PVMOVE))
184
			continue;
184
			continue;
185
185
186
		list_iterate(segh, &lv->segments) {
186
		lvm_list_iterate(segh, &lv->segments) {
187
			seg = list_item(segh, struct lv_segment);
187
			seg = lvm_list_item(segh, struct lv_segment);
188
			if (seg->area[0].type != AREA_PV)
188
			if (seg->area[0].type != AREA_PV)
189
				continue;
189
				continue;
190
			if (seg->area[0].u.pv.pv->dev != dev)
190
			if (seg->area[0].u.pv.pv->dev != dev)
Lines 196-205 Link Here
196
	return NULL;
196
	return NULL;
197
}
197
}
198
198
199
struct list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
199
struct lvm_list *lvs_using_lv(struct cmd_context *cmd, struct volume_group *vg,
200
			  struct logical_volume *lv)
200
			  struct logical_volume *lv)
201
{
201
{
202
	struct list *lvh, *segh, *lvs;
202
	struct lvm_list *lvh, *segh, *lvs;
203
	struct logical_volume *lv1;
203
	struct logical_volume *lv1;
204
	struct lv_list *lvl;
204
	struct lv_list *lvl;
205
	struct lv_segment *seg;
205
	struct lv_segment *seg;
Lines 210-225 Link Here
210
		return NULL;
210
		return NULL;
211
	}
211
	}
212
212
213
	list_init(lvs);
213
	lvm_list_init(lvs);
214
214
215
	/* Loop through all LVs except the one supplied */
215
	/* Loop through all LVs except the one supplied */
216
	list_iterate(lvh, &vg->lvs) {
216
	lvm_list_iterate(lvh, &vg->lvs) {
217
		lv1 = list_item(lvh, struct lv_list)->lv;
217
		lv1 = lvm_list_item(lvh, struct lv_list)->lv;
218
		if (lv1 == lv)
218
		if (lv1 == lv)
219
			continue;
219
			continue;
220
220
221
		list_iterate(segh, &lv1->segments) {
221
		lvm_list_iterate(segh, &lv1->segments) {
222
			seg = list_item(segh, struct lv_segment);
222
			seg = lvm_list_item(segh, struct lv_segment);
223
			for (s = 0; s < seg->area_count; s++) {
223
			for (s = 0; s < seg->area_count; s++) {
224
				if (seg->area[s].type != AREA_LV ||
224
				if (seg->area[s].type != AREA_LV ||
225
				    seg->area[s].u.lv.lv != lv)
225
				    seg->area[s].u.lv.lv != lv)
Lines 229-235 Link Here
229
					return NULL;
229
					return NULL;
230
				}
230
				}
231
				lvl->lv = lv1;
231
				lvl->lv = lv1;
232
				list_add(lvs, &lvl->list);
232
				lvm_list_add(lvs, &lvl->list);
233
				goto next_lv;
233
				goto next_lv;
234
			}
234
			}
235
		}
235
		}
Lines 243-253 Link Here
243
float pvmove_percent(struct logical_volume *lv_mirr)
243
float pvmove_percent(struct logical_volume *lv_mirr)
244
{
244
{
245
	uint32_t numerator = 0u, denominator = 0u;
245
	uint32_t numerator = 0u, denominator = 0u;
246
	struct list *segh;
246
	struct lvm_list *segh;
247
	struct lv_segment *seg;
247
	struct lv_segment *seg;
248
248
249
	list_iterate(segh, &lv_mirr->segments) {
249
	lvm_list_iterate(segh, &lv_mirr->segments) {
250
		seg = list_item(segh, struct lv_segment);
250
		seg = lvm_list_item(segh, struct lv_segment);
251
		if (!(seg->status & PVMOVE))
251
		if (!(seg->status & PVMOVE))
252
			continue;
252
			continue;
253
253
(-)LVM2.2.00.15.orig/lib/metadata/pv_map.c (-44 / +44 lines)
Lines 17-48 Link Here
17
#include "pv_map.h"
17
#include "pv_map.h"
18
#include "hash.h"
18
#include "hash.h"
19
19
20
static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
20
static int _create_maps(struct pool *mem, struct lvm_list *pvs, struct lvm_list *maps)
21
{
21
{
22
	struct list *tmp;
22
	struct lvm_list *tmp;
23
	struct pv_map *pvm;
23
	struct pv_map *pvm;
24
	struct pv_list *pvl;
24
	struct pv_list *pvl;
25
25
26
	list_iterate(tmp, pvs) {
26
	lvm_list_iterate(tmp, pvs) {
27
		pvl = list_item(tmp, struct pv_list);
27
		pvl = lvm_list_item(tmp, struct pv_list);
28
28
29
		if (!(pvl->pv->status & ALLOCATABLE_PV))
29
		if (!(pvl->pv->status & ALLOCATABLE_PV))
30
			continue;
30
			continue;
31
31
32
		if (!(pvm = pool_zalloc(mem, sizeof(*pvm)))) {
32
		if (!(pvm = pool_zalloc(mem, sizeof(*pvm)))) {
33
			stack;
33
			STACK;
34
			return 0;
34
			return 0;
35
		}
35
		}
36
36
37
		pvm->pvl = pvl;
37
		pvm->pvl = pvl;
38
		if (!(pvm->allocated_extents =
38
		if (!(pvm->allocated_extents =
39
		      bitset_create(mem, pvl->pv->pe_count))) {
39
		      bitset_create(mem, pvl->pv->pe_count))) {
40
			stack;
40
			STACK;
41
			return 0;
41
			return 0;
42
		}
42
		}
43
43
44
		list_init(&pvm->areas);
44
		lvm_list_init(&pvm->areas);
45
		list_add(maps, &pvm->list);
45
		lvm_list_add(maps, &pvm->list);
46
	}
46
	}
47
47
48
	return 1;
48
	return 1;
Lines 73-81 Link Here
73
	return 1;
73
	return 1;
74
}
74
}
75
75
76
static int _fill_bitsets(struct volume_group *vg, struct list *maps)
76
static int _fill_bitsets(struct volume_group *vg, struct lvm_list *maps)
77
{
77
{
78
	struct list *lvh, *pvmh, *segh;
78
	struct lvm_list *lvh, *pvmh, *segh;
79
	struct logical_volume *lv;
79
	struct logical_volume *lv;
80
	struct pv_map *pvm;
80
	struct pv_map *pvm;
81
	uint32_t s, pe;
81
	uint32_t s, pe;
Lines 89-108 Link Here
89
	}
89
	}
90
90
91
	/* populate the hash table */
91
	/* populate the hash table */
92
	list_iterate(pvmh, maps) {
92
	lvm_list_iterate(pvmh, maps) {
93
		pvm = list_item(pvmh, struct pv_map);
93
		pvm = lvm_list_item(pvmh, struct pv_map);
94
		if (!hash_insert(hash, dev_name(pvm->pvl->pv->dev), pvm)) {
94
		if (!hash_insert(hash, dev_name(pvm->pvl->pv->dev), pvm)) {
95
			stack;
95
			STACK;
96
			goto out;
96
			goto out;
97
		}
97
		}
98
	}
98
	}
99
99
100
	/* iterate through all the lv's setting bit's for used pe's */
100
	/* iterate through all the lv's setting bit's for used pe's */
101
	list_iterate(lvh, &vg->lvs) {
101
	lvm_list_iterate(lvh, &vg->lvs) {
102
		lv = list_item(lvh, struct lv_list)->lv;
102
		lv = lvm_list_item(lvh, struct lv_list)->lv;
103
103
104
		list_iterate(segh, &lv->segments) {
104
		lvm_list_iterate(segh, &lv->segments) {
105
			seg = list_item(segh, struct lv_segment);
105
			seg = lvm_list_item(segh, struct lv_segment);
106
106
107
			for (s = 0u; s < seg->area_count; s++) {
107
			for (s = 0u; s < seg->area_count; s++) {
108
				for (pe = 0u; pe < seg->area_len; pe++) {
108
				for (pe = 0u; pe < seg->area_len; pe++) {
Lines 112-118 Link Here
112
							 seg->area[s].u.pv.pv,
112
							 seg->area[s].u.pv.pv,
113
							 seg->area[s].u.pv.pe
113
							 seg->area[s].u.pv.pe
114
							 + pe)) {
114
							 + pe)) {
115
						stack;
115
						STACK;
116
						goto out;
116
						goto out;
117
					}
117
					}
118
				}
118
				}
Lines 129-152 Link Here
129
/*
129
/*
130
 * Areas are maintained in size order.
130
 * Areas are maintained in size order.
131
 */
131
 */
132
static void _insert_area(struct list *head, struct pv_area *a)
132
static void _insert_area(struct lvm_list *head, struct pv_area *a)
133
{
133
{
134
	struct list *pvah;
134
	struct lvm_list *pvah;
135
	struct pv_area *pva = NULL;
135
	struct pv_area *pva = NULL;
136
136
137
	if (list_empty(head)) {
137
	if (lvm_list_empty(head)) {
138
		list_add(head, &a->list);
138
		lvm_list_add(head, &a->list);
139
		return;
139
		return;
140
	}
140
	}
141
141
142
	list_iterate(pvah, head) {
142
	lvm_list_iterate(pvah, head) {
143
		pva = list_item(pvah, struct pv_area);
143
		pva = lvm_list_item(pvah, struct pv_area);
144
144
145
		if (pva->count < a->count)
145
		if (pva->count < a->count)
146
			break;
146
			break;
147
	}
147
	}
148
148
149
	list_add_h(&pva->list, &a->list);
149
	lvm_list_add_h(&pva->list, &a->list);
150
}
150
}
151
151
152
static int _create_single_area(struct pool *mem, struct pv_map *pvm,
152
static int _create_single_area(struct pool *mem, struct pv_map *pvm,
Lines 169-175 Link Here
169
		e++;
169
		e++;
170
170
171
	if (!(pva = pool_zalloc(mem, sizeof(*pva)))) {
171
	if (!(pva = pool_zalloc(mem, sizeof(*pva)))) {
172
		stack;
172
		STACK;
173
		return 0;
173
		return 0;
174
	}
174
	}
175
175
Lines 196-202 Link Here
196
	pe = start;
196
	pe = start;
197
	while (pe <= end)
197
	while (pe <= end)
198
		if (!_create_single_area(mem, pvm, end, &pe)) {
198
		if (!_create_single_area(mem, pvm, end, &pe)) {
199
			stack;
199
			STACK;
200
			return 0;
200
			return 0;
201
		}
201
		}
202
202
Lines 205-220 Link Here
205
205
206
static int _create_allocatable_areas(struct pool *mem, struct pv_map *pvm)
206
static int _create_allocatable_areas(struct pool *mem, struct pv_map *pvm)
207
{
207
{
208
	struct list *alloc_areas, *aah;
208
	struct lvm_list *alloc_areas, *aah;
209
	struct alloc_area *aa;
209
	struct alloc_area *aa;
210
210
211
	alloc_areas = pvm->pvl->alloc_areas;
211
	alloc_areas = pvm->pvl->alloc_areas;
212
212
213
	if (alloc_areas) {
213
	if (alloc_areas) {
214
		list_iterate(aah, alloc_areas) {
214
		lvm_list_iterate(aah, alloc_areas) {
215
			aa = list_item(aah, struct alloc_area);
215
			aa = lvm_list_item(aah, struct alloc_area);
216
			if (!_create_areas(mem, pvm, aa->start, aa->count)) {
216
			if (!_create_areas(mem, pvm, aa->start, aa->count)) {
217
				stack;
217
				STACK;
218
				return 0;
218
				return 0;
219
			}
219
			}
220
220
Lines 223-229 Link Here
223
		/* Use whole PV */
223
		/* Use whole PV */
224
		if (!_create_areas(mem, pvm, UINT32_C(0),
224
		if (!_create_areas(mem, pvm, UINT32_C(0),
225
				   pvm->pvl->pv->pe_count)) {
225
				   pvm->pvl->pv->pe_count)) {
226
			stack;
226
			STACK;
227
			return 0;
227
			return 0;
228
		}
228
		}
229
	}
229
	}
Lines 231-247 Link Here
231
	return 1;
231
	return 1;
232
}
232
}
233
233
234
static int _create_all_areas(struct pool *mem, struct list *maps,
234
static int _create_all_areas(struct pool *mem, struct lvm_list *maps,
235
			     struct list *pvs)
235
			     struct lvm_list *pvs)
236
{
236
{
237
	struct list *tmp;
237
	struct lvm_list *tmp;
238
	struct pv_map *pvm;
238
	struct pv_map *pvm;
239
239
240
	list_iterate(tmp, maps) {
240
	lvm_list_iterate(tmp, maps) {
241
		pvm = list_item(tmp, struct pv_map);
241
		pvm = lvm_list_item(tmp, struct pv_map);
242
242
243
		if (!_create_allocatable_areas(mem, pvm)) {
243
		if (!_create_allocatable_areas(mem, pvm)) {
244
			stack;
244
			STACK;
245
			return 0;
245
			return 0;
246
		}
246
		}
247
	}
247
	}
Lines 249-265 Link Here
249
	return 1;
249
	return 1;
250
}
250
}
251
251
252
struct list *create_pv_maps(struct pool *mem, struct volume_group *vg,
252
struct lvm_list *create_pv_maps(struct pool *mem, struct volume_group *vg,
253
			    struct list *pvs)
253
			    struct lvm_list *pvs)
254
{
254
{
255
	struct list *maps = pool_zalloc(mem, sizeof(*maps));
255
	struct lvm_list *maps = pool_zalloc(mem, sizeof(*maps));
256
256
257
	if (!maps) {
257
	if (!maps) {
258
		stack;
258
		STACK;
259
		return NULL;
259
		return NULL;
260
	}
260
	}
261
261
262
	list_init(maps);
262
	lvm_list_init(maps);
263
263
264
	if (!_create_maps(mem, pvs, maps)) {
264
	if (!_create_maps(mem, pvs, maps)) {
265
		log_error("Couldn't create physical volume maps in %s",
265
		log_error("Couldn't create physical volume maps in %s",
Lines 287-293 Link Here
287
287
288
void consume_pv_area(struct pv_area *pva, uint32_t to_go)
288
void consume_pv_area(struct pv_area *pva, uint32_t to_go)
289
{
289
{
290
	list_del(&pva->list);
290
	lvm_list_del(&pva->list);
291
291
292
	assert(to_go <= pva->count);
292
	assert(to_go <= pva->count);
293
293
(-)LVM2.2.00.15.orig/lib/metadata/pv_map.h (-5 / +5 lines)
Lines 33-51 Link Here
33
	uint32_t start;
33
	uint32_t start;
34
	uint32_t count;
34
	uint32_t count;
35
35
36
	struct list list;
36
	struct lvm_list list;
37
};
37
};
38
38
39
struct pv_map {
39
struct pv_map {
40
	struct pv_list *pvl;
40
	struct pv_list *pvl;
41
	bitset_t allocated_extents;
41
	bitset_t allocated_extents;
42
	struct list areas;
42
	struct lvm_list areas;
43
43
44
	struct list list;
44
	struct lvm_list list;
45
};
45
};
46
46
47
struct list *create_pv_maps(struct pool *mem,
47
struct lvm_list *create_pv_maps(struct pool *mem,
48
			    struct volume_group *vg, struct list *pvs);
48
			    struct volume_group *vg, struct lvm_list *pvs);
49
49
50
void consume_pv_area(struct pv_area *area, uint32_t to_go);
50
void consume_pv_area(struct pv_area *area, uint32_t to_go);
51
51
(-)LVM2.2.00.15.orig/lib/metadata/snapshot_manip.c (-26 / +26 lines)
Lines 19-29 Link Here
19
19
20
int lv_is_origin(const struct logical_volume *lv)
20
int lv_is_origin(const struct logical_volume *lv)
21
{
21
{
22
	struct list *slh;
22
	struct lvm_list *slh;
23
	struct snapshot *s;
23
	struct snapshot *s;
24
24
25
	list_iterate(slh, &lv->vg->snapshots) {
25
	lvm_list_iterate(slh, &lv->vg->snapshots) {
26
		s = list_item(slh, struct snapshot_list)->snapshot;
26
		s = lvm_list_item(slh, struct snapshot_list)->snapshot;
27
		if (s->origin == lv)
27
		if (s->origin == lv)
28
			return 1;
28
			return 1;
29
	}
29
	}
Lines 33-43 Link Here
33
33
34
int lv_is_cow(const struct logical_volume *lv)
34
int lv_is_cow(const struct logical_volume *lv)
35
{
35
{
36
	struct list *slh;
36
	struct lvm_list *slh;
37
	struct snapshot *s;
37
	struct snapshot *s;
38
38
39
	list_iterate(slh, &lv->vg->snapshots) {
39
	lvm_list_iterate(slh, &lv->vg->snapshots) {
40
		s = list_item(slh, struct snapshot_list)->snapshot;
40
		s = lvm_list_item(slh, struct snapshot_list)->snapshot;
41
		if (s->cow == lv)
41
		if (s->cow == lv)
42
			return 1;
42
			return 1;
43
	}
43
	}
Lines 47-57 Link Here
47
47
48
struct snapshot *find_origin(const struct logical_volume *lv)
48
struct snapshot *find_origin(const struct logical_volume *lv)
49
{
49
{
50
	struct list *slh;
50
	struct lvm_list *slh;
51
	struct snapshot *s;
51
	struct snapshot *s;
52
52
53
	list_iterate(slh, &lv->vg->snapshots) {
53
	lvm_list_iterate(slh, &lv->vg->snapshots) {
54
		s = list_item(slh, struct snapshot_list)->snapshot;
54
		s = lvm_list_item(slh, struct snapshot_list)->snapshot;
55
		if (s->origin == lv)
55
		if (s->origin == lv)
56
			return s;
56
			return s;
57
	}
57
	}
Lines 61-71 Link Here
61
61
62
struct snapshot *find_cow(const struct logical_volume *lv)
62
struct snapshot *find_cow(const struct logical_volume *lv)
63
{
63
{
64
	struct list *slh;
64
	struct lvm_list *slh;
65
	struct snapshot *s;
65
	struct snapshot *s;
66
66
67
	list_iterate(slh, &lv->vg->snapshots) {
67
	lvm_list_iterate(slh, &lv->vg->snapshots) {
68
		s = list_item(slh, struct snapshot_list)->snapshot;
68
		s = lvm_list_item(slh, struct snapshot_list)->snapshot;
69
		if (s->cow == lv)
69
		if (s->cow == lv)
70
			return s;
70
			return s;
71
	}
71
	}
Lines 73-82 Link Here
73
	return NULL;
73
	return NULL;
74
}
74
}
75
75
76
struct list *find_snapshots(const struct logical_volume *lv)
76
struct lvm_list *find_snapshots(const struct logical_volume *lv)
77
{
77
{
78
	struct list *slh;
78
	struct lvm_list *slh;
79
	struct list *snaplist;
79
	struct lvm_list *snaplist;
80
	struct snapshot *s;
80
	struct snapshot *s;
81
	struct snapshot_list *newsl;
81
	struct snapshot_list *newsl;
82
	struct pool *mem = lv->vg->cmd->mem;
82
	struct pool *mem = lv->vg->cmd->mem;
Lines 86-95 Link Here
86
		return NULL;
86
		return NULL;
87
	}
87
	}
88
88
89
	list_init(snaplist);
89
	lvm_list_init(snaplist);
90
90
91
	list_iterate(slh, &lv->vg->snapshots) {
91
	lvm_list_iterate(slh, &lv->vg->snapshots) {
92
		s = list_item(slh, struct snapshot_list)->snapshot;
92
		s = lvm_list_item(slh, struct snapshot_list)->snapshot;
93
		if (!(s->origin == lv))
93
		if (!(s->origin == lv))
94
			continue;
94
			continue;
95
		if (!(newsl = pool_alloc(mem, sizeof(*newsl)))) {
95
		if (!(newsl = pool_alloc(mem, sizeof(*newsl)))) {
Lines 98-104 Link Here
98
			return NULL;
98
			return NULL;
99
		}
99
		}
100
		newsl->snapshot = s;
100
		newsl->snapshot = s;
101
		list_add(snaplist, &newsl->list);
101
		lvm_list_add(snaplist, &newsl->list);
102
	}
102
	}
103
103
104
	return snaplist;
104
	return snaplist;
Lines 121-127 Link Here
121
	}
121
	}
122
122
123
	if (!(s = pool_alloc(mem, sizeof(*s)))) {
123
	if (!(s = pool_alloc(mem, sizeof(*s)))) {
124
		stack;
124
		STACK;
125
		return 0;
125
		return 0;
126
	}
126
	}
127
127
Lines 138-151 Link Here
138
	}
138
	}
139
139
140
	if (!(sl = pool_alloc(mem, sizeof(*sl)))) {
140
	if (!(sl = pool_alloc(mem, sizeof(*sl)))) {
141
		stack;
141
		STACK;
142
		pool_free(mem, s);
142
		pool_free(mem, s);
143
		return 0;
143
		return 0;
144
	}
144
	}
145
145
146
	cow->status &= ~VISIBLE_LV;
146
	cow->status &= ~VISIBLE_LV;
147
	sl->snapshot = s;
147
	sl->snapshot = s;
148
	list_add(&origin->vg->snapshots, &sl->list);
148
	lvm_list_add(&origin->vg->snapshots, &sl->list);
149
	origin->vg->snapshot_count++;
149
	origin->vg->snapshot_count++;
150
150
151
	return 1;
151
	return 1;
Lines 153-166 Link Here
153
153
154
int vg_remove_snapshot(struct volume_group *vg, struct logical_volume *cow)
154
int vg_remove_snapshot(struct volume_group *vg, struct logical_volume *cow)
155
{
155
{
156
	struct list *slh;
156
	struct lvm_list *slh;
157
	struct snapshot_list *sl;
157
	struct snapshot_list *sl;
158
158
159
	list_iterate(slh, &vg->snapshots) {
159
	lvm_list_iterate(slh, &vg->snapshots) {
160
		sl = list_item(slh, struct snapshot_list);
160
		sl = lvm_list_item(slh, struct snapshot_list);
161
161
162
		if (sl->snapshot->cow == cow) {
162
		if (sl->snapshot->cow == cow) {
163
			list_del(slh);
163
			lvm_list_del(slh);
164
			vg->snapshot_count--;
164
			vg->snapshot_count--;
165
			return 1;
165
			return 1;
166
		}
166
		}
(-)LVM2.2.00.15.orig/lib/regex/matcher.c (-7 / +7 lines)
Lines 179-185 Link Here
179
	struct state_queue *r = pool_alloc(mem, sizeof(*r));
179
	struct state_queue *r = pool_alloc(mem, sizeof(*r));
180
180
181
	if (!r) {
181
	if (!r) {
182
		stack;
182
		STACK;
183
		return NULL;
183
		return NULL;
184
	}
184
	}
185
185
Lines 200-211 Link Here
200
	bitset_t bs = bitset_create(m->scratch, m->num_nodes), dfa_bits;
200
	bitset_t bs = bitset_create(m->scratch, m->num_nodes), dfa_bits;
201
201
202
	if (!tt) {
202
	if (!tt) {
203
		stack;
203
		STACK;
204
		return 0;
204
		return 0;
205
	}
205
	}
206
206
207
	if (!bs) {
207
	if (!bs) {
208
		stack;
208
		STACK;
209
		return 0;
209
		return 0;
210
	}
210
	}
211
211
Lines 279-290 Link Here
279
	struct matcher *m;
279
	struct matcher *m;
280
280
281
	if (!scratch) {
281
	if (!scratch) {
282
		stack;
282
		STACK;
283
		return NULL;
283
		return NULL;
284
	}
284
	}
285
285
286
	if (!(m = pool_alloc(mem, sizeof(*m)))) {
286
	if (!(m = pool_alloc(mem, sizeof(*m)))) {
287
		stack;
287
		STACK;
288
		return NULL;
288
		return NULL;
289
	}
289
	}
290
290
Lines 297-303 Link Here
297
	ptr = all = pool_alloc(scratch, len + 1);
297
	ptr = all = pool_alloc(scratch, len + 1);
298
298
299
	if (!all) {
299
	if (!all) {
300
		stack;
300
		STACK;
301
		goto bad;
301
		goto bad;
302
	}
302
	}
303
303
Lines 319-325 Link Here
319
	m->nodes = pool_alloc(scratch, sizeof(*m->nodes) * m->num_nodes);
319
	m->nodes = pool_alloc(scratch, sizeof(*m->nodes) * m->num_nodes);
320
320
321
	if (!m->nodes) {
321
	if (!m->nodes) {
322
		stack;
322
		STACK;
323
		goto bad;
323
		goto bad;
324
	}
324
	}
325
325
(-)LVM2.2.00.15.orig/lib/regex/parse_rx.c (-5 / +5 lines)
Lines 226-232 Link Here
226
	switch (ps->type) {
226
	switch (ps->type) {
227
	case 0:
227
	case 0:
228
		if (!(n = _node(ps->mem, CHARSET, NULL, NULL))) {
228
		if (!(n = _node(ps->mem, CHARSET, NULL, NULL))) {
229
			stack;
229
			STACK;
230
			return NULL;
230
			return NULL;
231
		}
231
		}
232
232
Lines 277-283 Link Here
277
		}
277
		}
278
278
279
		if (!n) {
279
		if (!n) {
280
			stack;
280
			STACK;
281
			return NULL;
281
			return NULL;
282
		}
282
		}
283
283
Lines 302-308 Link Here
302
		return l;
302
		return l;
303
303
304
	if (!(n = _node(ps->mem, CAT, l, r)))
304
	if (!(n = _node(ps->mem, CAT, l, r)))
305
		stack;
305
		STACK;
306
306
307
	return n;
307
	return n;
308
}
308
}
Lines 325-331 Link Here
325
	}
325
	}
326
326
327
	if (!(n = _node(ps->mem, OR, l, r)))
327
	if (!(n = _node(ps->mem, OR, l, r)))
328
		stack;
328
		STACK;
329
329
330
	return n;
330
	return n;
331
}
331
}
Lines 337-343 Link Here
337
	struct parse_sp *ps = pool_zalloc(mem, sizeof(*ps));
337
	struct parse_sp *ps = pool_zalloc(mem, sizeof(*ps));
338
338
339
	if (!ps) {
339
	if (!ps) {
340
		stack;
340
		STACK;
341
		return NULL;
341
		return NULL;
342
	}
342
	}
343
343
(-)LVM2.2.00.15.orig/lib/regex/ttree.c (-2 / +2 lines)
Lines 88-94 Link Here
88
88
89
		while (count--) {
89
		while (count--) {
90
			if (!(*c = _node(tt->mem, k))) {
90
			if (!(*c = _node(tt->mem, k))) {
91
				stack;
91
				STACK;
92
				return 0;
92
				return 0;
93
			}
93
			}
94
94
Lines 108-114 Link Here
108
	struct ttree *tt;
108
	struct ttree *tt;
109
109
110
	if (!(tt = pool_zalloc(mem, sizeof(*tt)))) {
110
	if (!(tt = pool_zalloc(mem, sizeof(*tt)))) {
111
		stack;
111
		STACK;
112
		return NULL;
112
		return NULL;
113
	}
113
	}
114
114
(-)LVM2.2.00.15.orig/lib/report/report.c (-47 / +47 lines)
Lines 53-62 Link Here
53
	uint32_t keys_count;
53
	uint32_t keys_count;
54
54
55
	/* Ordered list of fields needed for this report */
55
	/* Ordered list of fields needed for this report */
56
	struct list field_props;
56
	struct lvm_list field_props;
57
57
58
	/* Rows of report data */
58
	/* Rows of report data */
59
	struct list rows;
59
	struct lvm_list rows;
60
};
60
};
61
61
62
/* 
62
/* 
Lines 72-78 Link Here
72
#define FLD_DESCENDING	0x00000080
72
#define FLD_DESCENDING	0x00000080
73
73
74
struct field_properties {
74
struct field_properties {
75
	struct list list;
75
	struct lvm_list list;
76
	uint32_t field_num;
76
	uint32_t field_num;
77
	uint32_t sort_posn;
77
	uint32_t sort_posn;
78
	int width;
78
	int width;
Lines 83-89 Link Here
83
 * Report data
83
 * Report data
84
 */
84
 */
85
struct field {
85
struct field {
86
	struct list list;
86
	struct lvm_list list;
87
	struct field_properties *props;
87
	struct field_properties *props;
88
88
89
	const char *report_string;	/* Formatted ready for display */
89
	const char *report_string;	/* Formatted ready for display */
Lines 91-99 Link Here
91
};
91
};
92
92
93
struct row {
93
struct row {
94
	struct list list;
94
	struct lvm_list list;
95
	struct report_handle *rh;
95
	struct report_handle *rh;
96
	struct list fields;	/* Fields in display order */
96
	struct lvm_list fields;	/* Fields in display order */
97
	struct field *(*sort_fields)[];	/* Fields in sort order */
97
	struct field *(*sort_fields)[];	/* Fields in sort order */
98
};
98
};
99
99
Lines 126-132 Link Here
126
static int _tags_disp(struct report_handle *rh, struct field *field,
126
static int _tags_disp(struct report_handle *rh, struct field *field,
127
		      const void *data)
127
		      const void *data)
128
{
128
{
129
	const struct list *tags = (const struct list *) data;
129
	const struct lvm_list *tags = (const struct lvm_list *) data;
130
	struct str_list *sl;
130
	struct str_list *sl;
131
131
132
	if (!pool_begin_object(rh->mem, 256)) {
132
	if (!pool_begin_object(rh->mem, 256)) {
Lines 134-140 Link Here
134
		return 0;
134
		return 0;
135
	}
135
	}
136
136
137
	list_iterate_items(sl, tags) {
137
	lvm_list_iterate_items(sl, tags) {
138
		if (!pool_grow_object(rh->mem, sl->str, strlen(sl->str)) ||
138
		if (!pool_grow_object(rh->mem, sl->str, strlen(sl->str)) ||
139
		    (sl->list.n != tags && !pool_grow_object(rh->mem, ",", 1))) {
139
		    (sl->list.n != tags && !pool_grow_object(rh->mem, ",", 1))) {
140
			log_error("pool_grow_object failed");
140
			log_error("pool_grow_object failed");
Lines 355-365 Link Here
355
{
355
{
356
	const struct logical_volume *lv = (const struct logical_volume *) data;
356
	const struct logical_volume *lv = (const struct logical_volume *) data;
357
	const char *name;
357
	const char *name;
358
	struct list *segh;
358
	struct lvm_list *segh;
359
	struct lv_segment *seg;
359
	struct lv_segment *seg;
360
360
361
	list_iterate(segh, &lv->segments) {
361
	lvm_list_iterate(segh, &lv->segments) {
362
		seg = list_item(segh, struct lv_segment);
362
		seg = lvm_list_item(segh, struct lv_segment);
363
		if (!(seg->status & PVMOVE))
363
		if (!(seg->status & PVMOVE))
364
			continue;
364
			continue;
365
		name = dev_name(seg->area[0].u.pv.pv->dev);
365
		name = dev_name(seg->area[0].u.pv.pv->dev);
Lines 380-386 Link Here
380
	uint64_t *sortval;
380
	uint64_t *sortval;
381
381
382
	if (!*(disp = display_size(rh->cmd, (uint64_t) size / 2, SIZE_UNIT))) {
382
	if (!*(disp = display_size(rh->cmd, (uint64_t) size / 2, SIZE_UNIT))) {
383
		stack;
383
		STACK;
384
		return 0;
384
		return 0;
385
	}
385
	}
386
386
Lines 408-414 Link Here
408
	uint64_t *sortval;
408
	uint64_t *sortval;
409
409
410
	if (!*(disp = display_size(rh->cmd, size / 2, SIZE_UNIT))) {
410
	if (!*(disp = display_size(rh->cmd, size / 2, SIZE_UNIT))) {
411
		stack;
411
		STACK;
412
		return 0;
412
		return 0;
413
	}
413
	}
414
414
Lines 528-534 Link Here
528
	}
528
	}
529
529
530
	if (!id_write_format((const struct id *) data, repstr, 40)) {
530
	if (!id_write_format((const struct id *) data, repstr, 40)) {
531
		stack;
531
		STACK;
532
		return 0;
532
		return 0;
533
	}
533
	}
534
534
Lines 602-608 Link Here
602
	const struct logical_volume *lv = (const struct logical_volume *) data;
602
	const struct logical_volume *lv = (const struct logical_volume *) data;
603
	uint32_t count;
603
	uint32_t count;
604
604
605
	count = list_size(&lv->segments);
605
	count = lvm_list_size(&lv->segments);
606
606
607
	return _uint32_disp(rh, field, &count);
607
	return _uint32_disp(rh, field, &count);
608
}
608
}
Lines 753-759 Link Here
753
			    && !strncmp(field, "snap_percent", len))
753
			    && !strncmp(field, "snap_percent", len))
754
				fp->flags |= FLD_HIDDEN;
754
				fp->flags |= FLD_HIDDEN;
755
755
756
			list_add(&rh->field_props, &fp->list);
756
			lvm_list_add(&rh->field_props, &fp->list);
757
			return 1;
757
			return 1;
758
		}
758
		}
759
	}
759
	}
Lines 764-774 Link Here
764
static int _add_sort_key(struct report_handle *rh, uint32_t field_num,
764
static int _add_sort_key(struct report_handle *rh, uint32_t field_num,
765
			 uint32_t flags)
765
			 uint32_t flags)
766
{
766
{
767
	struct list *fh;
767
	struct lvm_list *fh;
768
	struct field_properties *fp, *found = NULL;
768
	struct field_properties *fp, *found = NULL;
769
769
770
	list_iterate(fh, &rh->field_props) {
770
	lvm_list_iterate(fh, &rh->field_props) {
771
		fp = list_item(fh, struct field_properties);
771
		fp = lvm_list_item(fh, struct field_properties);
772
772
773
		if (fp->field_num == field_num) {
773
		if (fp->field_num == field_num) {
774
			found = fp;
774
			found = fp;
Lines 788-794 Link Here
788
		found->width = _fields[field_num].width;
788
		found->width = _fields[field_num].width;
789
		found->flags = _fields[field_num].flags | FLD_HIDDEN;
789
		found->flags = _fields[field_num].flags | FLD_HIDDEN;
790
790
791
		list_add(&rh->field_props, &found->list);
791
		lvm_list_add(&rh->field_props, &found->list);
792
	}
792
	}
793
793
794
	if (found->flags & FLD_SORT_KEY) {
794
	if (found->flags & FLD_SORT_KEY) {
Lines 910-917 Link Here
910
	if (headings)
910
	if (headings)
911
		rh->flags |= RH_HEADINGS;
911
		rh->flags |= RH_HEADINGS;
912
912
913
	list_init(&rh->field_props);
913
	lvm_list_init(&rh->field_props);
914
	list_init(&rh->rows);
914
	lvm_list_init(&rh->rows);
915
915
916
	switch (rh->type) {
916
	switch (rh->type) {
917
	case PVS:
917
	case PVS:
Lines 978-984 Link Here
978
		  struct lv_segment *seg)
978
		  struct lv_segment *seg)
979
{
979
{
980
	struct report_handle *rh = handle;
980
	struct report_handle *rh = handle;
981
	struct list *fh;
981
	struct lvm_list *fh;
982
	struct field_properties *fp;
982
	struct field_properties *fp;
983
	struct row *row;
983
	struct row *row;
984
	struct field *field;
984
	struct field *field;
Lines 1003-1014 Link Here
1003
		return 0;
1003
		return 0;
1004
	}
1004
	}
1005
1005
1006
	list_init(&row->fields);
1006
	lvm_list_init(&row->fields);
1007
	list_add(&rh->rows, &row->list);
1007
	lvm_list_add(&rh->rows, &row->list);
1008
1008
1009
	/* For each field to be displayed, call its report_fn */
1009
	/* For each field to be displayed, call its report_fn */
1010
	list_iterate(fh, &rh->field_props) {
1010
	lvm_list_iterate(fh, &rh->field_props) {
1011
		fp = list_item(fh, struct field_properties);
1011
		fp = lvm_list_item(fh, struct field_properties);
1012
1012
1013
		if (!(field = pool_zalloc(rh->mem, sizeof(*field)))) {
1013
		if (!(field = pool_zalloc(rh->mem, sizeof(*field)))) {
1014
			log_error("struct field allocation failed");
1014
			log_error("struct field allocation failed");
Lines 1043-1049 Link Here
1043
		    (field->props->flags & FLD_SORT_KEY)) {
1043
		    (field->props->flags & FLD_SORT_KEY)) {
1044
			(*row->sort_fields)[field->props->sort_posn] = field;
1044
			(*row->sort_fields)[field->props->sort_posn] = field;
1045
		}
1045
		}
1046
		list_add(&row->fields, &field->list);
1046
		lvm_list_add(&row->fields, &field->list);
1047
	}
1047
	}
1048
1048
1049
	if (!(rh->flags & RH_BUFFERED))
1049
	if (!(rh->flags & RH_BUFFERED))
Lines 1058-1064 Link Here
1058
static int _report_headings(void *handle)
1058
static int _report_headings(void *handle)
1059
{
1059
{
1060
	struct report_handle *rh = handle;
1060
	struct report_handle *rh = handle;
1061
	struct list *fh;
1061
	struct lvm_list *fh;
1062
	struct field_properties *fp;
1062
	struct field_properties *fp;
1063
1063
1064
	if (rh->flags & RH_HEADINGS_PRINTED)
1064
	if (rh->flags & RH_HEADINGS_PRINTED)
Lines 1068-1075 Link Here
1068
		goto out;
1068
		goto out;
1069
1069
1070
	/* First heading line */
1070
	/* First heading line */
1071
	list_iterate(fh, &rh->field_props) {
1071
	lvm_list_iterate(fh, &rh->field_props) {
1072
		fp = list_item(fh, struct field_properties);
1072
		fp = lvm_list_item(fh, struct field_properties);
1073
		if (fp->flags & FLD_HIDDEN)
1073
		if (fp->flags & FLD_HIDDEN)
1074
			continue;
1074
			continue;
1075
		if (rh->flags & RH_ALIGNED)
1075
		if (rh->flags & RH_ALIGNED)
Lines 1077-1083 Link Here
1077
			       _fields[fp->field_num].heading);
1077
			       _fields[fp->field_num].heading);
1078
		else
1078
		else
1079
			printf("%s", _fields[fp->field_num].heading);
1079
			printf("%s", _fields[fp->field_num].heading);
1080
		if (!list_end(&rh->field_props, fh))
1080
		if (!lvm_list_end(&rh->field_props, fh))
1081
			printf("%s", rh->separator);
1081
			printf("%s", rh->separator);
1082
	}
1082
	}
1083
	printf("\n");
1083
	printf("\n");
Lines 1137-1162 Link Here
1137
static int _sort_rows(struct report_handle *rh)
1137
static int _sort_rows(struct report_handle *rh)
1138
{
1138
{
1139
	struct row *(*rows)[];
1139
	struct row *(*rows)[];
1140
	struct list *rowh;
1140
	struct lvm_list *rowh;
1141
	uint32_t count = 0;
1141
	uint32_t count = 0;
1142
	struct row *row;
1142
	struct row *row;
1143
1143
1144
	if (!(rows = pool_alloc(rh->mem, sizeof(**rows) *
1144
	if (!(rows = pool_alloc(rh->mem, sizeof(**rows) *
1145
				list_size(&rh->rows)))) {
1145
				lvm_list_size(&rh->rows)))) {
1146
		log_error("sort array allocation failed");
1146
		log_error("sort array allocation failed");
1147
		return 0;
1147
		return 0;
1148
	}
1148
	}
1149
1149
1150
	list_iterate(rowh, &rh->rows) {
1150
	lvm_list_iterate(rowh, &rh->rows) {
1151
		row = list_item(rowh, struct row);
1151
		row = lvm_list_item(rowh, struct row);
1152
		(*rows)[count++] = row;
1152
		(*rows)[count++] = row;
1153
	}
1153
	}
1154
1154
1155
	qsort(rows, count, sizeof(**rows), _row_compare);
1155
	qsort(rows, count, sizeof(**rows), _row_compare);
1156
1156
1157
	list_init(&rh->rows);
1157
	lvm_list_init(&rh->rows);
1158
	while (count--)
1158
	while (count--)
1159
		list_add_h(&rh->rows, &(*rows)[count]->list);
1159
		lvm_list_add_h(&rh->rows, &(*rows)[count]->list);
1160
1160
1161
	return 1;
1161
	return 1;
1162
}
1162
}
Lines 1167-1177 Link Here
1167
int report_output(void *handle)
1167
int report_output(void *handle)
1168
{
1168
{
1169
	struct report_handle *rh = handle;
1169
	struct report_handle *rh = handle;
1170
	struct list *fh, *rowh, *ftmp, *rtmp;
1170
	struct lvm_list *fh, *rowh, *ftmp, *rtmp;
1171
	struct row *row = NULL;
1171
	struct row *row = NULL;
1172
	struct field *field;
1172
	struct field *field;
1173
1173
1174
	if (list_empty(&rh->rows))
1174
	if (lvm_list_empty(&rh->rows))
1175
		return 1;
1175
		return 1;
1176
1176
1177
	/* Sort rows */
1177
	/* Sort rows */
Lines 1183-1192 Link Here
1183
		_report_headings(rh);
1183
		_report_headings(rh);
1184
1184
1185
	/* Print and clear buffer */
1185
	/* Print and clear buffer */
1186
	list_iterate_safe(rowh, rtmp, &rh->rows) {
1186
	lvm_list_iterate_safe(rowh, rtmp, &rh->rows) {
1187
		row = list_item(rowh, struct row);
1187
		row = lvm_list_item(rowh, struct row);
1188
		list_iterate_safe(fh, ftmp, &row->fields) {
1188
		lvm_list_iterate_safe(fh, ftmp, &row->fields) {
1189
			field = list_item(fh, struct field);
1189
			field = lvm_list_item(fh, struct field);
1190
			if (field->props->flags & FLD_HIDDEN)
1190
			if (field->props->flags & FLD_HIDDEN)
1191
				continue;
1191
				continue;
1192
			if (!(rh->flags & RH_ALIGNED))
1192
			if (!(rh->flags & RH_ALIGNED))
Lines 1199-1210 Link Here
1199
				printf("%*.*s", field->props->width,
1199
				printf("%*.*s", field->props->width,
1200
				       field->props->width,
1200
				       field->props->width,
1201
				       field->report_string);
1201
				       field->report_string);
1202
			if (!list_end(&row->fields, fh))
1202
			if (!lvm_list_end(&row->fields, fh))
1203
				printf("%s", rh->separator);
1203
				printf("%s", rh->separator);
1204
			list_del(&field->list);
1204
			lvm_list_del(&field->list);
1205
		}
1205
		}
1206
		printf("\n");
1206
		printf("\n");
1207
		list_del(&row->list);
1207
		lvm_list_del(&row->list);
1208
	}
1208
	}
1209
1209
1210
	if (row)
1210
	if (row)
(-)LVM2.2.00.15.orig/test/device/dev_cache_t.c (-3 / +3 lines)
Lines 24-30 Link Here
24
	int i;
24
	int i;
25
	struct device *dev;
25
	struct device *dev;
26
	struct dev_iter *iter;
26
	struct dev_iter *iter;
27
	struct list_head *tmp;
27
	struct lvm_list_head *tmp;
28
	struct str_list *sl;
28
	struct str_list *sl;
29
29
30
	if (argc < 2) {
30
	if (argc < 2) {
Lines 55-62 Link Here
55
	while ((dev = dev_iter_get(iter))) {
55
	while ((dev = dev_iter_get(iter))) {
56
		printf("%s", dev->name);
56
		printf("%s", dev->name);
57
57
58
		list_for_each(tmp, &dev->aliases) {
58
		lvm_list_for_each(tmp, &dev->aliases) {
59
			sl = list_entry(tmp, struct str_list, list);
59
			sl = lvm_list_entry(tmp, struct str_list, list);
60
			printf(", %s", sl->str);
60
			printf(", %s", sl->str);
61
		}
61
		}
62
		printf("\n");
62
		printf("\n");
(-)LVM2.2.00.15.orig/test/format1/get_pvs_t.c (-3 / +3 lines)
Lines 25-31 Link Here
25
int main(int argc, char **argv)
25
int main(int argc, char **argv)
26
{
26
{
27
	struct io_space *ios;
27
	struct io_space *ios;
28
	struct list_head *pvs, *tmp;
28
	struct lvm_list_head *pvs, *tmp;
29
	struct pool *mem;
29
	struct pool *mem;
30
30
31
	init_log(stderr);
31
	init_log(stderr);
Lines 60-67 Link Here
60
		exit(1);
60
		exit(1);
61
	}
61
	}
62
62
63
	list_for_each(tmp, pvs) {
63
	lvm_list_for_each(tmp, pvs) {
64
		struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
64
		struct pv_list *pvl = lvm_list_entry(tmp, struct pv_list, list);
65
		dump_pv(&pvl->pv, stdout);
65
		dump_pv(&pvl->pv, stdout);
66
	}
66
	}
67
67
(-)LVM2.2.00.15.orig/test/format1/get_vgs_t.c (-1 / +1 lines)
Lines 25-31 Link Here
25
int main(int argc, char **argv)
25
int main(int argc, char **argv)
26
{
26
{
27
	struct io_space *ios;
27
	struct io_space *ios;
28
	struct list_head *vgs;
28
	struct lvm_list_head *vgs;
29
	struct pool *mem;
29
	struct pool *mem;
30
30
31
	init_log(stderr);
31
	init_log(stderr);
(-)LVM2.2.00.15.orig/test/format1/pretty_print.c (-9 / +9 lines)
Lines 50-56 Link Here
50
50
51
void dump_vg(struct volume_group *vg, FILE *fp)
51
void dump_vg(struct volume_group *vg, FILE *fp)
52
{
52
{
53
	struct list_head *tmp;
53
	struct lvm_list_head *tmp;
54
54
55
	fprintf(fp, "volume_group {\n");
55
	fprintf(fp, "volume_group {\n");
56
	fprintf(fp, "\tname = '%s'\n", vg->name);
56
	fprintf(fp, "\tname = '%s'\n", vg->name);
Lines 63-86 Link Here
63
	fprintf(fp, "\tlv_count = %d\n", vg->lv_count);
63
	fprintf(fp, "\tlv_count = %d\n", vg->lv_count);
64
	fprintf(fp, "}\n\n");
64
	fprintf(fp, "}\n\n");
65
65
66
	list_for_each(tmp, &vg->pvs) {
66
	lvm_list_for_each(tmp, &vg->pvs) {
67
		struct pv_list *pvl = list_entry(tmp, struct pv_list, list);
67
		struct pv_list *pvl = lvm_list_entry(tmp, struct pv_list, list);
68
		dump_pv(&pvl->pv, fp);
68
		dump_pv(&pvl->pv, fp);
69
	}
69
	}
70
70
71
	list_for_each(tmp, &vg->lvs) {
71
	lvm_list_for_each(tmp, &vg->lvs) {
72
		struct lv_list *lvl = list_entry(tmp, struct lv_list, list);
72
		struct lv_list *lvl = lvm_list_entry(tmp, struct lv_list, list);
73
		dump_lv(&lvl->lv, fp);
73
		dump_lv(&lvl->lv, fp);
74
	}
74
	}
75
}
75
}
76
76
77
void dump_vg_names(struct list_head *vg_names, FILE *fp)
77
void dump_vg_names(struct lvm_list_head *vg_names, FILE *fp)
78
{
78
{
79
	struct list_head *tmp;
79
	struct lvm_list_head *tmp;
80
	struct name_list *nl;
80
	struct name_list *nl;
81
81
82
	list_for_each(tmp, vg_names) {
82
	lvm_list_for_each(tmp, vg_names) {
83
		nl = list_entry(tmp, struct name_list, list);
83
		nl = lvm_list_entry(tmp, struct name_list, list);
84
		fprintf(fp, "%s\n", nl->name);
84
		fprintf(fp, "%s\n", nl->name);
85
	}
85
	}
86
}
86
}
(-)LVM2.2.00.15.orig/tools/archiver.c (-12 / +12 lines)
Lines 68-81 Link Here
68
	char *buffer;
68
	char *buffer;
69
69
70
	if (!(buffer = pool_zalloc(mem, strlen(line) + 32))) {
70
	if (!(buffer = pool_zalloc(mem, strlen(line) + 32))) {
71
		stack;
71
		STACK;
72
		return NULL;
72
		return NULL;
73
	}
73
	}
74
74
75
	if (snprintf(buffer, len,
75
	if (snprintf(buffer, len,
76
		     "Created %s executing '%s'",
76
		     "Created %s executing '%s'",
77
		     before ? "*before*" : "*after*", line) < 0) {
77
		     before ? "*before*" : "*after*", line) < 0) {
78
		stack;
78
		STACK;
79
		return NULL;
79
		return NULL;
80
	}
80
	}
81
81
Lines 87-93 Link Here
87
	char *desc;
87
	char *desc;
88
88
89
	if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1))) {
89
	if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 1))) {
90
		stack;
90
		STACK;
91
		return 0;
91
		return 0;
92
	}
92
	}
93
93
Lines 163-169 Link Here
163
	char *desc;
163
	char *desc;
164
164
165
	if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0))) {
165
	if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0))) {
166
		stack;
166
		STACK;
167
		return 0;
167
		return 0;
168
	}
168
	}
169
169
Lines 233-241 Link Here
233
		return NULL;
233
		return NULL;
234
	}
234
	}
235
235
236
	list_iterate_items(mda, &tf->metadata_areas) {
236
	lvm_list_iterate_items(mda, &tf->metadata_areas) {
237
		if (!(vg = mda->ops->vg_read(tf, vg_name, mda)))
237
		if (!(vg = mda->ops->vg_read(tf, vg_name, mda)))
238
			stack;
238
			STACK;
239
		break;
239
		break;
240
	}
240
	}
241
241
Lines 263-269 Link Here
263
	}
263
	}
264
264
265
	/* Add any metadata areas on the PVs */
265
	/* Add any metadata areas on the PVs */
266
	list_iterate_items(pvl, &vg->pvs) {
266
	lvm_list_iterate_items(pvl, &vg->pvs) {
267
		pv = pvl->pv;
267
		pv = pvl->pv;
268
		if (!(info = info_from_pvid(pv->dev->pvid))) {
268
		if (!(info = info_from_pvid(pv->dev->pvid))) {
269
			log_error("PV %s missing from cache",
269
			log_error("PV %s missing from cache",
Lines 285-291 Link Here
285
	}
285
	}
286
286
287
	if (!vg_write(vg) || !vg_commit(vg)) {
287
	if (!vg_write(vg) || !vg_commit(vg)) {
288
		stack;
288
		STACK;
289
		return 0;
289
		return 0;
290
	}
290
	}
291
291
Lines 302-308 Link Here
302
	 * Read in the volume group from the text file.
302
	 * Read in the volume group from the text file.
303
	 */
303
	 */
304
	if (!(vg = backup_read_vg(cmd, vg_name, file))) {
304
	if (!(vg = backup_read_vg(cmd, vg_name, file))) {
305
		stack;
305
		STACK;
306
		return 0;
306
		return 0;
307
	}
307
	}
308
308
Lines 340-353 Link Here
340
	}
340
	}
341
341
342
	/* Write and commit the metadata area */
342
	/* Write and commit the metadata area */
343
	list_iterate_items(mda, &tf->metadata_areas) {
343
	lvm_list_iterate_items(mda, &tf->metadata_areas) {
344
		if (!(r = mda->ops->vg_write(tf, vg, mda))) {
344
		if (!(r = mda->ops->vg_write(tf, vg, mda))) {
345
			stack;
345
			STACK;
346
			continue;
346
			continue;
347
		}
347
		}
348
		if (mda->ops->vg_commit &&
348
		if (mda->ops->vg_commit &&
349
		    !(r = mda->ops->vg_commit(tf, vg, mda))) {
349
		    !(r = mda->ops->vg_commit(tf, vg, mda))) {
350
			stack;
350
			STACK;
351
		}
351
		}
352
	}
352
	}
353
353
(-)LVM2.2.00.15.orig/tools/lvchange.c (-7 / +7 lines)
Lines 46-52 Link Here
46
46
47
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
47
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
48
	if (!vg_write(lv->vg)) {
48
	if (!vg_write(lv->vg)) {
49
		stack;
49
		STACK;
50
		return 0;
50
		return 0;
51
	}
51
	}
52
52
Lines 150-156 Link Here
150
150
151
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
151
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
152
	if (!vg_write(lv->vg)) {
152
	if (!vg_write(lv->vg)) {
153
		stack;
153
		STACK;
154
		return 0;
154
		return 0;
155
	}
155
	}
156
156
Lines 158-164 Link Here
158
158
159
	/* No need to suspend LV for this change */
159
	/* No need to suspend LV for this change */
160
	if (!vg_commit(lv->vg)) {
160
	if (!vg_commit(lv->vg)) {
161
		stack;
161
		STACK;
162
		return 0;
162
		return 0;
163
	}
163
	}
164
164
Lines 193-199 Link Here
193
193
194
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
194
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
195
	if (!vg_write(lv->vg)) {
195
	if (!vg_write(lv->vg)) {
196
		stack;
196
		STACK;
197
		return 0;
197
		return 0;
198
	}
198
	}
199
199
Lines 270-276 Link Here
270
270
271
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
271
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
272
	if (!vg_write(lv->vg)) {
272
	if (!vg_write(lv->vg)) {
273
		stack;
273
		STACK;
274
		return 0;
274
		return 0;
275
	}
275
	}
276
276
Lines 328-334 Link Here
328
328
329
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
329
	log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name);
330
	if (!vg_write(lv->vg)) {
330
	if (!vg_write(lv->vg)) {
331
		stack;
331
		STACK;
332
		return 0;
332
		return 0;
333
	}
333
	}
334
334
Lines 336-342 Link Here
336
336
337
	/* No need to suspend LV for this change */
337
	/* No need to suspend LV for this change */
338
	if (!vg_commit(lv->vg)) {
338
	if (!vg_commit(lv->vg)) {
339
		stack;
339
		STACK;
340
		return 0;
340
		return 0;
341
	}
341
	}
342
342
(-)LVM2.2.00.15.orig/tools/lvcreate.c (-5 / +5 lines)
Lines 368-374 Link Here
368
	alloc_policy_t alloc = ALLOC_DEFAULT;
368
	alloc_policy_t alloc = ALLOC_DEFAULT;
369
	struct volume_group *vg;
369
	struct volume_group *vg;
370
	struct logical_volume *lv, *org = NULL;
370
	struct logical_volume *lv, *org = NULL;
371
	struct list *pvh;
371
	struct lvm_list *pvh;
372
	const char *tag;
372
	const char *tag;
373
	int consistent = 1;
373
	int consistent = 1;
374
374
Lines 407-413 Link Here
407
	if (lp->pv_count) {
407
	if (lp->pv_count) {
408
		if (!(pvh = create_pv_list(cmd->mem, vg,
408
		if (!(pvh = create_pv_list(cmd->mem, vg,
409
					   lp->pv_count, lp->pvs))) {
409
					   lp->pv_count, lp->pvs))) {
410
			stack;
410
			STACK;
411
			return 0;
411
			return 0;
412
		}
412
		}
413
	} else
413
	} else
Lines 507-520 Link Here
507
507
508
	/* store vg on disk(s) */
508
	/* store vg on disk(s) */
509
	if (!vg_write(vg)) {
509
	if (!vg_write(vg)) {
510
		stack;
510
		STACK;
511
		return 0;
511
		return 0;
512
	}
512
	}
513
513
514
	backup(vg);
514
	backup(vg);
515
515
516
	if (!vg_commit(vg)) {
516
	if (!vg_commit(vg)) {
517
		stack;
517
		STACK;
518
		return 0;
518
		return 0;
519
	}
519
	}
520
520
Lines 598-604 Link Here
598
	}
598
	}
599
599
600
	if (!_lvcreate(cmd, &lp)) {
600
	if (!_lvcreate(cmd, &lp)) {
601
		stack;
601
		STACK;
602
		goto out;
602
		goto out;
603
	}
603
	}
604
604
(-)LVM2.2.00.15.orig/tools/lvmcmdline.c (-2 / +2 lines)
Lines 91-97 Link Here
91
91
92
	format = a->value;
92
	format = a->value;
93
93
94
	list_iterate_items(fmt, &cmd->formats) {
94
	lvm_list_iterate_items(fmt, &cmd->formats) {
95
		if (!strcasecmp(fmt->name, format) ||
95
		if (!strcasecmp(fmt->name, format) ||
96
		    !strcasecmp(fmt->name + 3, format) ||
96
		    !strcasecmp(fmt->name + 3, format) ||
97
		    (fmt->alias && !strcasecmp(fmt->alias, format))) {
97
		    (fmt->alias && !strcasecmp(fmt->alias, format))) {
Lines 911-917 Link Here
911
	struct cmd_context *cmd;
911
	struct cmd_context *cmd;
912
912
913
	if (!(cmd = create_toolcontext(&the_args[0]))) {
913
	if (!(cmd = create_toolcontext(&the_args[0]))) {
914
		stack;
914
		STACK;
915
		return NULL;
915
		return NULL;
916
	}
916
	}
917
917
(-)LVM2.2.00.15.orig/tools/lvremove.c (-1 / +1 lines)
Lines 71-77 Link Here
71
	if (lv_is_cow(lv)) {
71
	if (lv_is_cow(lv)) {
72
		log_verbose("Removing snapshot %s", lv->name);
72
		log_verbose("Removing snapshot %s", lv->name);
73
		if (!vg_remove_snapshot(lv->vg, lv)) {
73
		if (!vg_remove_snapshot(lv->vg, lv)) {
74
			stack;
74
			STACK;
75
			return ECMD_FAILED;
75
			return ECMD_FAILED;
76
		}
76
		}
77
	}
77
	}
(-)LVM2.2.00.15.orig/tools/lvrename.c (-4 / +4 lines)
Lines 143-149 Link Here
143
	}
143
	}
144
144
145
	if (!archive(lv->vg)) {
145
	if (!archive(lv->vg)) {
146
		stack;
146
		STACK;
147
		goto error;
147
		goto error;
148
	}
148
	}
149
149
Lines 154-160 Link Here
154
154
155
	log_verbose("Writing out updated volume group");
155
	log_verbose("Writing out updated volume group");
156
	if (!vg_write(vg)) {
156
	if (!vg_write(vg)) {
157
		stack;
157
		STACK;
158
		goto error;
158
		goto error;
159
	}
159
	}
160
160
Lines 162-173 Link Here
162
162
163
	if (!lock_vol(cmd, lv->lvid.s, LCK_LV_SUSPEND | LCK_HOLD |
163
	if (!lock_vol(cmd, lv->lvid.s, LCK_LV_SUSPEND | LCK_HOLD |
164
		      LCK_NONBLOCK)) {
164
		      LCK_NONBLOCK)) {
165
		stack;
165
		STACK;
166
		goto error;
166
		goto error;
167
	}
167
	}
168
168
169
	if (!vg_commit(vg)) {
169
	if (!vg_commit(vg)) {
170
		stack;
170
		STACK;
171
		unlock_lv(cmd, lv->lvid.s);
171
		unlock_lv(cmd, lv->lvid.s);
172
		goto error;
172
		goto error;
173
	}
173
	}
(-)LVM2.2.00.15.orig/tools/lvresize.c (-6 / +6 lines)
Lines 32-38 Link Here
32
	const char *vg_name;
32
	const char *vg_name;
33
	char *st, *lock_lvid;
33
	char *st, *lock_lvid;
34
	const char *cmd_name;
34
	const char *cmd_name;
35
	struct list *pvh;
35
	struct lvm_list *pvh;
36
	struct lv_list *lvl;
36
	struct lv_list *lvl;
37
	int opt = 0;
37
	int opt = 0;
38
	int consistent = 1;
38
	int consistent = 1;
Lines 195-201 Link Here
195
195
196
	/* If extending, find stripes, stripesize & size of last segment */
196
	/* If extending, find stripes, stripesize & size of last segment */
197
	if (extents > lv->le_count && !(stripes == 1 || (stripes > 1 && ssize))) {
197
	if (extents > lv->le_count && !(stripes == 1 || (stripes > 1 && ssize))) {
198
		list_iterate_items(seg, &lv->segments) {
198
		lvm_list_iterate_items(seg, &lv->segments) {
199
			if (seg->type != SEG_STRIPED)
199
			if (seg->type != SEG_STRIPED)
200
				continue;
200
				continue;
201
201
Lines 240-246 Link Here
240
			log_error("Ignoring stripes and stripesize arguments "
240
			log_error("Ignoring stripes and stripesize arguments "
241
				  "when reducing");
241
				  "when reducing");
242
242
243
		list_iterate_items(seg, &lv->segments) {
243
		lvm_list_iterate_items(seg, &lv->segments) {
244
			seg_extents = seg->len;
244
			seg_extents = seg->len;
245
245
246
			if (seg->type == SEG_STRIPED) {
246
			if (seg->type == SEG_STRIPED) {
Lines 343-349 Link Here
343
	if (resize == LV_EXTEND) {
343
	if (resize == LV_EXTEND) {
344
		if (!(pvh = argc ? create_pv_list(cmd->mem, vg, argc - opt,
344
		if (!(pvh = argc ? create_pv_list(cmd->mem, vg, argc - opt,
345
						  argv + opt) : &vg->pvs)) {
345
						  argv + opt) : &vg->pvs)) {
346
			stack;
346
			STACK;
347
			goto error;
347
			goto error;
348
		}
348
		}
349
349
Lines 362-368 Link Here
362
362
363
	/* store vg on disk(s) */
363
	/* store vg on disk(s) */
364
	if (!vg_write(vg)) {
364
	if (!vg_write(vg)) {
365
		stack;
365
		STACK;
366
		goto error;
366
		goto error;
367
	}
367
	}
368
368
Lines 381-387 Link Here
381
	}
381
	}
382
382
383
	if (!vg_commit(vg)) {
383
	if (!vg_commit(vg)) {
384
		stack;
384
		STACK;
385
		unlock_lv(cmd, lock_lvid);
385
		unlock_lv(cmd, lock_lvid);
386
		goto error;
386
		goto error;
387
	}
387
	}
(-)LVM2.2.00.15.orig/tools/pvchange.c (-5 / +5 lines)
Lines 22-28 Link Here
22
{
22
{
23
	struct volume_group *vg = NULL;
23
	struct volume_group *vg = NULL;
24
	struct pv_list *pvl;
24
	struct pv_list *pvl;
25
	struct list mdas;
25
	struct lvm_list mdas;
26
	uint64_t sector;
26
	uint64_t sector;
27
27
28
	const char *pv_name = dev_name(pv->dev);
28
	const char *pv_name = dev_name(pv->dev);
Lines 209-218 Link Here
209
	char *pv_name;
209
	char *pv_name;
210
210
211
	struct pv_list *pvl;
211
	struct pv_list *pvl;
212
	struct list *pvslist;
212
	struct lvm_list *pvslist;
213
	struct list mdas;
213
	struct lvm_list mdas;
214
214
215
	list_init(&mdas);
215
	lvm_list_init(&mdas);
216
216
217
	if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) +
217
	if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) +
218
	    arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) {
218
	    arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) {
Lines 251-257 Link Here
251
			return ECMD_FAILED;
251
			return ECMD_FAILED;
252
		}
252
		}
253
253
254
		list_iterate_items(pvl, pvslist) {
254
		lvm_list_iterate_items(pvl, pvslist) {
255
			total++;
255
			total++;
256
			done += _pvchange_single(cmd, pvl->pv, NULL);
256
			done += _pvchange_single(cmd, pvl->pv, NULL);
257
		}
257
		}
(-)LVM2.2.00.15.orig/tools/pvcreate.c (-2 / +2 lines)
Lines 76-82 Link Here
76
	const char *uuid = NULL;
76
	const char *uuid = NULL;
77
	uint64_t size = 0;
77
	uint64_t size = 0;
78
	struct device *dev;
78
	struct device *dev;
79
	struct list mdas;
79
	struct lvm_list mdas;
80
	int pvmetadatacopies;
80
	int pvmetadatacopies;
81
	uint64_t pvmetadatasize;
81
	uint64_t pvmetadatasize;
82
	struct volume_group *vg;
82
	struct volume_group *vg;
Lines 153-159 Link Here
153
		goto error;
153
		goto error;
154
	}
154
	}
155
155
156
	list_init(&mdas);
156
	lvm_list_init(&mdas);
157
	if (!(pv = pv_create(cmd->fmt, dev, idp, size, pe_start,
157
	if (!(pv = pv_create(cmd->fmt, dev, idp, size, pe_start,
158
			     extent_count, extent_size,
158
			     extent_count, extent_size,
159
			     pvmetadatacopies, pvmetadatasize, &mdas))) {
159
			     pvmetadatacopies, pvmetadatasize, &mdas))) {
(-)LVM2.2.00.15.orig/tools/pvmove.c (-30 / +30 lines)
Lines 154-189 Link Here
154
}
154
}
155
155
156
/* Create list of PVs for allocation of replacement extents */
156
/* Create list of PVs for allocation of replacement extents */
157
static struct list *_get_allocatable_pvs(struct cmd_context *cmd, int argc,
157
static struct lvm_list *_get_allocatable_pvs(struct cmd_context *cmd, int argc,
158
					 char **argv, struct volume_group *vg,
158
					 char **argv, struct volume_group *vg,
159
					 struct physical_volume *pv)
159
					 struct physical_volume *pv)
160
{
160
{
161
	struct list *allocatable_pvs, *pvht, *pvh;
161
	struct lvm_list *allocatable_pvs, *pvht, *pvh;
162
	struct pv_list *pvl;
162
	struct pv_list *pvl;
163
163
164
	if (argc) {
164
	if (argc) {
165
		if (!(allocatable_pvs = create_pv_list(cmd->mem, vg, argc,
165
		if (!(allocatable_pvs = create_pv_list(cmd->mem, vg, argc,
166
						       argv))) {
166
						       argv))) {
167
			stack;
167
			STACK;
168
			return NULL;
168
			return NULL;
169
		}
169
		}
170
	} else {
170
	} else {
171
		if (!(allocatable_pvs = clone_pv_list(cmd->mem, &vg->pvs))) {
171
		if (!(allocatable_pvs = clone_pv_list(cmd->mem, &vg->pvs))) {
172
			stack;
172
			STACK;
173
			return NULL;
173
			return NULL;
174
		}
174
		}
175
	}
175
	}
176
176
177
	/* Don't allocate onto the PV we're clearing! */
177
	/* Don't allocate onto the PV we're clearing! */
178
	/* Remove PV if full */
178
	/* Remove PV if full */
179
	list_iterate_safe(pvh, pvht, allocatable_pvs) {
179
	lvm_list_iterate_safe(pvh, pvht, allocatable_pvs) {
180
		pvl = list_item(pvh, struct pv_list);
180
		pvl = lvm_list_item(pvh, struct pv_list);
181
		if ((pvl->pv->dev == pv->dev) ||
181
		if ((pvl->pv->dev == pv->dev) ||
182
		    (pvl->pv->pe_count == pvl->pv->pe_alloc_count))
182
		    (pvl->pv->pe_count == pvl->pv->pe_alloc_count))
183
			    list_del(&pvl->list);
183
			    lvm_list_del(&pvl->list);
184
	}
184
	}
185
185
186
	if (list_empty(allocatable_pvs)) {
186
	if (lvm_list_empty(allocatable_pvs)) {
187
		log_error("No extents available for allocation");
187
		log_error("No extents available for allocation");
188
		return NULL;
188
		return NULL;
189
	}
189
	}
Lines 196-203 Link Here
196
						struct volume_group *vg,
196
						struct volume_group *vg,
197
						struct physical_volume *pv,
197
						struct physical_volume *pv,
198
						const char *lv_name,
198
						const char *lv_name,
199
						struct list *allocatable_pvs,
199
						struct lvm_list *allocatable_pvs,
200
						struct list **lvs_changed)
200
						struct lvm_list **lvs_changed)
201
{
201
{
202
	struct logical_volume *lv_mirr, *lv;
202
	struct logical_volume *lv_mirr, *lv;
203
	struct lv_list *lvl;
203
	struct lv_list *lvl;
Lines 217-226 Link Here
217
		return NULL;
217
		return NULL;
218
	}
218
	}
219
219
220
	list_init(*lvs_changed);
220
	lvm_list_init(*lvs_changed);
221
221
222
	/* Find segments to be moved and set up mirrors */
222
	/* Find segments to be moved and set up mirrors */
223
	list_iterate_items(lvl, &vg->lvs) {
223
	lvm_list_iterate_items(lvl, &vg->lvs) {
224
		lv = lvl->lv;
224
		lv = lvl->lv;
225
		if ((lv == lv_mirr) || (lv_name && strcmp(lv->name, lv_name)))
225
		if ((lv == lv_mirr) || (lv_name && strcmp(lv->name, lv_name)))
226
			continue;
226
			continue;
Lines 234-240 Link Here
234
		}
234
		}
235
		if (!insert_pvmove_mirrors(cmd, lv_mirr, pv, lv,
235
		if (!insert_pvmove_mirrors(cmd, lv_mirr, pv, lv,
236
					   allocatable_pvs, *lvs_changed)) {
236
					   allocatable_pvs, *lvs_changed)) {
237
			stack;
237
			STACK;
238
			return NULL;
238
			return NULL;
239
		}
239
		}
240
	}
240
	}
Lines 249-255 Link Here
249
249
250
static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
250
static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg,
251
			    struct logical_volume *lv_mirr,
251
			    struct logical_volume *lv_mirr,
252
			    struct list *lvs_changed, int first_time)
252
			    struct lvm_list *lvs_changed, int first_time)
253
{
253
{
254
	log_verbose("Updating volume group metadata");
254
	log_verbose("Updating volume group metadata");
255
	if (!vg_write(vg)) {
255
	if (!vg_write(vg)) {
Lines 260-272 Link Here
260
	backup(vg);
260
	backup(vg);
261
261
262
	if (!lock_lvs(cmd, lvs_changed, LCK_LV_SUSPEND | LCK_HOLD)) {
262
	if (!lock_lvs(cmd, lvs_changed, LCK_LV_SUSPEND | LCK_HOLD)) {
263
		stack;
263
		STACK;
264
		return 0;
264
		return 0;
265
	}
265
	}
266
266
267
	if (!first_time) {
267
	if (!first_time) {
268
		if (!lock_vol(cmd, lv_mirr->lvid.s, LCK_LV_SUSPEND | LCK_HOLD)) {
268
		if (!lock_vol(cmd, lv_mirr->lvid.s, LCK_LV_SUSPEND | LCK_HOLD)) {
269
			stack;
269
			STACK;
270
			unlock_lvs(cmd, lvs_changed);
270
			unlock_lvs(cmd, lvs_changed);
271
			vg_revert(vg);
271
			vg_revert(vg);
272
			return 0;
272
			return 0;
Lines 308-329 Link Here
308
{
308
{
309
	const char *lv_name = NULL;
309
	const char *lv_name = NULL;
310
	struct volume_group *vg;
310
	struct volume_group *vg;
311
	struct list *allocatable_pvs;
311
	struct lvm_list *allocatable_pvs;
312
	struct list *lvs_changed;
312
	struct lvm_list *lvs_changed;
313
	struct physical_volume *pv;
313
	struct physical_volume *pv;
314
	struct logical_volume *lv_mirr;
314
	struct logical_volume *lv_mirr;
315
	int first_time = 1;
315
	int first_time = 1;
316
316
317
	/* Find PV (in VG) */
317
	/* Find PV (in VG) */
318
	if (!(pv = _find_pv_by_name(cmd, pv_name))) {
318
	if (!(pv = _find_pv_by_name(cmd, pv_name))) {
319
		stack;
319
		STACK;
320
		return EINVALID_CMD_LINE;
320
		return EINVALID_CMD_LINE;
321
	}
321
	}
322
322
323
	if (arg_count(cmd, name_ARG)) {
323
	if (arg_count(cmd, name_ARG)) {
324
		if (!(lv_name = _extract_lvname(cmd, pv->vg_name,
324
		if (!(lv_name = _extract_lvname(cmd, pv->vg_name,
325
						arg_value(cmd, name_ARG)))) {
325
						arg_value(cmd, name_ARG)))) {
326
			stack;
326
			STACK;
327
			return EINVALID_CMD_LINE;
327
			return EINVALID_CMD_LINE;
328
		}
328
		}
329
	}
329
	}
Lines 332-338 Link Here
332
	log_verbose("Finding volume group \"%s\"", pv->vg_name);
332
	log_verbose("Finding volume group \"%s\"", pv->vg_name);
333
333
334
	if (!(vg = _get_vg(cmd, pv->vg_name))) {
334
	if (!(vg = _get_vg(cmd, pv->vg_name))) {
335
		stack;
335
		STACK;
336
		return ECMD_FAILED;
336
		return ECMD_FAILED;
337
	}
337
	}
338
338
Lines 361-388 Link Here
361
361
362
		if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
362
		if (!(allocatable_pvs = _get_allocatable_pvs(cmd, argc, argv,
363
							     vg, pv))) {
363
							     vg, pv))) {
364
			stack;
364
			STACK;
365
			unlock_vg(cmd, pv->vg_name);
365
			unlock_vg(cmd, pv->vg_name);
366
			return ECMD_FAILED;
366
			return ECMD_FAILED;
367
		}
367
		}
368
368
369
		if (!archive(vg)) {
369
		if (!archive(vg)) {
370
			unlock_vg(cmd, pv->vg_name);
370
			unlock_vg(cmd, pv->vg_name);
371
			stack;
371
			STACK;
372
			return ECMD_FAILED;
372
			return ECMD_FAILED;
373
		}
373
		}
374
374
375
		if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, pv, lv_name,
375
		if (!(lv_mirr = _set_up_pvmove_lv(cmd, vg, pv, lv_name,
376
						  allocatable_pvs,
376
						  allocatable_pvs,
377
						  &lvs_changed))) {
377
						  &lvs_changed))) {
378
			stack;
378
			STACK;
379
			unlock_vg(cmd, pv->vg_name);
379
			unlock_vg(cmd, pv->vg_name);
380
			return ECMD_FAILED;
380
			return ECMD_FAILED;
381
		}
381
		}
382
	}
382
	}
383
383
384
	if (!lock_lvs(cmd, lvs_changed, LCK_LV_ACTIVATE)) {
384
	if (!lock_lvs(cmd, lvs_changed, LCK_LV_ACTIVATE)) {
385
		stack;
385
		STACK;
386
		unlock_vg(cmd, pv->vg_name);
386
		unlock_vg(cmd, pv->vg_name);
387
		return ECMD_FAILED;
387
		return ECMD_FAILED;
388
	}
388
	}
Lines 390-396 Link Here
390
	if (first_time) {
390
	if (first_time) {
391
		if (!_update_metadata
391
		if (!_update_metadata
392
		    (cmd, vg, lv_mirr, lvs_changed, first_time)) {
392
		    (cmd, vg, lv_mirr, lvs_changed, first_time)) {
393
			stack;
393
			STACK;
394
			unlock_vg(cmd, pv->vg_name);
394
			unlock_vg(cmd, pv->vg_name);
395
			return ECMD_FAILED;
395
			return ECMD_FAILED;
396
		}
396
		}
Lines 403-409 Link Here
403
403
404
static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
404
static int _finish_pvmove(struct cmd_context *cmd, struct volume_group *vg,
405
			  struct logical_volume *lv_mirr,
405
			  struct logical_volume *lv_mirr,
406
			  struct list *lvs_changed)
406
			  struct lvm_list *lvs_changed)
407
{
407
{
408
	int r = 1;
408
	int r = 1;
409
409
Lines 476-482 Link Here
476
				const char *pv_name, struct pvmove_parms *parms,
476
				const char *pv_name, struct pvmove_parms *parms,
477
				int *finished)
477
				int *finished)
478
{
478
{
479
	struct list *lvs_changed;
479
	struct lvm_list *lvs_changed;
480
	float segment_percent = 0.0, overall_percent = 0.0;
480
	float segment_percent = 0.0, overall_percent = 0.0;
481
	uint32_t event_nr = 0;
481
	uint32_t event_nr = 0;
482
482
Lines 596-602 Link Here
596
		return ECMD_FAILED;
596
		return ECMD_FAILED;
597
	}
597
	}
598
598
599
	list_iterate_items(lvl, &vg->lvs) {
599
	lvm_list_iterate_items(lvl, &vg->lvs) {
600
		lv_mirr = lvl->lv;
600
		lv_mirr = lvl->lv;
601
		if (!(lv_mirr->status & PVMOVE))
601
		if (!(lv_mirr->status & PVMOVE))
602
			continue;
602
			continue;
Lines 673-679 Link Here
673
		if (!arg_count(cmd, abort_ARG) &&
673
		if (!arg_count(cmd, abort_ARG) &&
674
		    (ret = _set_up_pvmove(cmd, pv_name, argc, argv)) !=
674
		    (ret = _set_up_pvmove(cmd, pv_name, argc, argv)) !=
675
		     ECMD_PROCESSED) {
675
		     ECMD_PROCESSED) {
676
			stack;
676
			STACK;
677
			return ret;
677
			return ret;
678
		}
678
		}
679
	}
679
	}
(-)LVM2.2.00.15.orig/tools/pvscan.c (-6 / +6 lines)
Lines 51-57 Link Here
51
51
52
	if (arg_count(cmd, uuid_ARG)) {
52
	if (arg_count(cmd, uuid_ARG)) {
53
		if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
53
		if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
54
			stack;
54
			STACK;
55
			return;
55
			return;
56
		}
56
		}
57
57
Lines 103-109 Link Here
103
	int new_pvs_found = 0;
103
	int new_pvs_found = 0;
104
	int pvs_found = 0;
104
	int pvs_found = 0;
105
105
106
	struct list *pvslist;
106
	struct lvm_list *pvslist;
107
	struct pv_list *pvl;
107
	struct pv_list *pvl;
108
	struct physical_volume *pv;
108
	struct physical_volume *pv;
109
109
Lines 135-147 Link Here
135
		return ECMD_FAILED;
135
		return ECMD_FAILED;
136
136
137
	/* eliminate exported/new if required */
137
	/* eliminate exported/new if required */
138
	list_iterate_items(pvl, pvslist) {
138
	lvm_list_iterate_items(pvl, pvslist) {
139
		pv = pvl->pv;
139
		pv = pvl->pv;
140
140
141
		if ((arg_count(cmd, exported_ARG)
141
		if ((arg_count(cmd, exported_ARG)
142
		     && !(pv->status & EXPORTED_VG))
142
		     && !(pv->status & EXPORTED_VG))
143
		    || (arg_count(cmd, novolumegroup_ARG) && (*pv->vg_name))) {
143
		    || (arg_count(cmd, novolumegroup_ARG) && (*pv->vg_name))) {
144
			list_del(&pvl->list);
144
			lvm_list_del(&pvl->list);
145
			continue;
145
			continue;
146
		}
146
		}
147
147
Lines 167-173 Link Here
167
167
168
	/* find maximum pv name length */
168
	/* find maximum pv name length */
169
	pv_max_name_len = vg_max_name_len = 0;
169
	pv_max_name_len = vg_max_name_len = 0;
170
	list_iterate_items(pvl, pvslist) {
170
	lvm_list_iterate_items(pvl, pvslist) {
171
		pv = pvl->pv;
171
		pv = pvl->pv;
172
		len = strlen(dev_name(pv->dev));
172
		len = strlen(dev_name(pv->dev));
173
		if (pv_max_name_len < len)
173
		if (pv_max_name_len < len)
Lines 179-185 Link Here
179
	pv_max_name_len += 2;
179
	pv_max_name_len += 2;
180
	vg_max_name_len += 2;
180
	vg_max_name_len += 2;
181
181
182
	list_iterate_items(pvl, pvslist)
182
	lvm_list_iterate_items(pvl, pvslist)
183
	    _pvscan_display_single(cmd, pvl->pv, NULL);
183
	    _pvscan_display_single(cmd, pvl->pv, NULL);
184
184
185
	if (!pvs_found) {
185
	if (!pvs_found) {
(-)LVM2.2.00.15.orig/tools/toollib.c (-64 / +64 lines)
Lines 18-24 Link Here
18
#include <sys/stat.h>
18
#include <sys/stat.h>
19
19
20
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
20
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
21
			  struct list *arg_lvnames, struct list *tags,
21
			  struct lvm_list *arg_lvnames, struct lvm_list *tags,
22
			  void *handle,
22
			  void *handle,
23
			  int (*process_single) (struct cmd_context * cmd,
23
			  int (*process_single) (struct cmd_context * cmd,
24
						 struct logical_volume * lv,
24
						 struct logical_volume * lv,
Lines 38-47 Link Here
38
		return ECMD_FAILED;
38
		return ECMD_FAILED;
39
	}
39
	}
40
40
41
	if (tags && !list_empty(tags))
41
	if (tags && !lvm_list_empty(tags))
42
		tags_supplied = 1;
42
		tags_supplied = 1;
43
43
44
	if (arg_lvnames && !list_empty(arg_lvnames))
44
	if (arg_lvnames && !lvm_list_empty(arg_lvnames))
45
		lvargs_supplied = 1;
45
		lvargs_supplied = 1;
46
46
47
	/* Process all LVs in this VG if no restrictions given */
47
	/* Process all LVs in this VG if no restrictions given */
Lines 53-59 Link Here
53
	    str_list_match_list(tags, &vg->tags))
53
	    str_list_match_list(tags, &vg->tags))
54
		process_all = 1;
54
		process_all = 1;
55
55
56
	list_iterate_items(lvl, &vg->lvs) {
56
	lvm_list_iterate_items(lvl, &vg->lvs) {
57
		/* Should we process this LV? */
57
		/* Should we process this LV? */
58
		if (process_all)
58
		if (process_all)
59
			process_lv = 1;
59
			process_lv = 1;
Lines 109-133 Link Here
109
	int ret = 0;
109
	int ret = 0;
110
	int consistent;
110
	int consistent;
111
111
112
	struct list *slh, *tags_arg;
112
	struct lvm_list *slh, *tags_arg;
113
	struct list *vgnames;		/* VGs to process */
113
	struct lvm_list *vgnames;		/* VGs to process */
114
	struct str_list *sll;
114
	struct str_list *sll;
115
	struct volume_group *vg;
115
	struct volume_group *vg;
116
	struct list tags, lvnames;
116
	struct lvm_list tags, lvnames;
117
	struct list arg_lvnames;	/* Cmdline vgname or vgname/lvname */
117
	struct lvm_list arg_lvnames;	/* Cmdline vgname or vgname/lvname */
118
	char *vglv;
118
	char *vglv;
119
	size_t vglv_sz;
119
	size_t vglv_sz;
120
120
121
	const char *vgname;
121
	const char *vgname;
122
122
123
	list_init(&tags);
123
	lvm_list_init(&tags);
124
	list_init(&arg_lvnames);
124
	lvm_list_init(&arg_lvnames);
125
125
126
	if (argc) {
126
	if (argc) {
127
		struct list arg_vgnames;
127
		struct lvm_list arg_vgnames;
128
128
129
		log_verbose("Using logical volume(s) on command line");
129
		log_verbose("Using logical volume(s) on command line");
130
		list_init(&arg_vgnames);
130
		lvm_list_init(&arg_vgnames);
131
131
132
		for (; opt < argc; opt++) {
132
		for (; opt < argc; opt++) {
133
			const char *lv_name = argv[opt];
133
			const char *lv_name = argv[opt];
Lines 219-234 Link Here
219
		vgnames = &arg_vgnames;
219
		vgnames = &arg_vgnames;
220
	} 
220
	} 
221
221
222
	if (!argc || !list_empty(&tags)) {
222
	if (!argc || !lvm_list_empty(&tags)) {
223
		log_verbose("Finding all logical volumes");
223
		log_verbose("Finding all logical volumes");
224
		if (!(vgnames = get_vgs(cmd, 0)) || list_empty(vgnames)) {
224
		if (!(vgnames = get_vgs(cmd, 0)) || lvm_list_empty(vgnames)) {
225
			log_error("No volume groups found");
225
			log_error("No volume groups found");
226
			return ECMD_FAILED;
226
			return ECMD_FAILED;
227
		}
227
		}
228
	}
228
	}
229
229
230
	list_iterate(slh, vgnames) {
230
	lvm_list_iterate(slh, vgnames) {
231
		vgname = list_item(slh, struct str_list)->str;
231
		vgname = lvm_list_item(slh, struct str_list)->str;
232
		if (!vgname || !*vgname)
232
		if (!vgname || !*vgname)
233
			continue;	/* FIXME Unnecessary? */
233
			continue;	/* FIXME Unnecessary? */
234
		if (!lock_vol(cmd, vgname, lock_type)) {
234
		if (!lock_vol(cmd, vgname, lock_type)) {
Lines 259-273 Link Here
259
		}
259
		}
260
260
261
		tags_arg = &tags;
261
		tags_arg = &tags;
262
		list_init(&lvnames);	/* LVs to be processed in this VG */
262
		lvm_list_init(&lvnames);	/* LVs to be processed in this VG */
263
		list_iterate_items(sll, &arg_lvnames) {
263
		lvm_list_iterate_items(sll, &arg_lvnames) {
264
			const char *vg_name = sll->str;
264
			const char *vg_name = sll->str;
265
			const char *lv_name = strchr(vg_name, '/');
265
			const char *lv_name = strchr(vg_name, '/');
266
266
267
			if ((!lv_name && !strcmp(vg_name, vgname))) {
267
			if ((!lv_name && !strcmp(vg_name, vgname))) {
268
				/* Process all LVs in this VG */
268
				/* Process all LVs in this VG */
269
				tags_arg = NULL;
269
				tags_arg = NULL;
270
				list_init(&lvnames);
270
				lvm_list_init(&lvnames);
271
				break;
271
				break;
272
			} else if (!strncmp(vg_name, vgname, strlen(vgname)) &&
272
			} else if (!strncmp(vg_name, vgname, strlen(vgname)) &&
273
				   strlen(vgname) == lv_name - vg_name) {
273
				   strlen(vgname) == lv_name - vg_name) {
Lines 301-307 Link Here
301
	int ret_max = 0;
301
	int ret_max = 0;
302
	int ret;
302
	int ret;
303
303
304
	list_iterate_items(seg, &lv->segments) {
304
	lvm_list_iterate_items(seg, &lv->segments) {
305
		ret = process_single(cmd, seg, handle);
305
		ret = process_single(cmd, seg, handle);
306
		if (ret > ret_max)
306
		if (ret > ret_max)
307
			ret_max = ret;
307
			ret_max = ret;
Lines 311-317 Link Here
311
}
311
}
312
312
313
static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
313
static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
314
			   struct list *tags, struct list *arg_vgnames,
314
			   struct lvm_list *tags, struct lvm_list *arg_vgnames,
315
			   int lock_type, int consistent, void *handle,
315
			   int lock_type, int consistent, void *handle,
316
			   int ret_max,
316
			   int ret_max,
317
			   int (*process_single) (struct cmd_context * cmd,
317
			   int (*process_single) (struct cmd_context * cmd,
Lines 330-336 Link Here
330
	log_verbose("Finding volume group \"%s\"", vg_name);
330
	log_verbose("Finding volume group \"%s\"", vg_name);
331
	vg = vg_read(cmd, vg_name, &consistent);
331
	vg = vg_read(cmd, vg_name, &consistent);
332
332
333
	if (!list_empty(tags)) {
333
	if (!lvm_list_empty(tags)) {
334
		/* Only process if a tag matches or it's on arg_vgnames */
334
		/* Only process if a tag matches or it's on arg_vgnames */
335
		if (!str_list_match_item(arg_vgnames, vg_name) &&
335
		if (!str_list_match_item(arg_vgnames, vg_name) &&
336
		    !str_list_match_list(tags, &vg->tags)) {
336
		    !str_list_match_list(tags, &vg->tags)) {
Lines 359-372 Link Here
359
	int ret_max = 0;
359
	int ret_max = 0;
360
360
361
	struct str_list *sl;
361
	struct str_list *sl;
362
	struct list *vgnames;
362
	struct lvm_list *vgnames;
363
	struct list arg_vgnames, tags;
363
	struct lvm_list arg_vgnames, tags;
364
364
365
	const char *vg_name;
365
	const char *vg_name;
366
	char *dev_dir = cmd->dev_dir;
366
	char *dev_dir = cmd->dev_dir;
367
367
368
	list_init(&tags);
368
	lvm_list_init(&tags);
369
	list_init(&arg_vgnames);
369
	lvm_list_init(&arg_vgnames);
370
370
371
	if (argc) {
371
	if (argc) {
372
		log_verbose("Using volume group(s) on command line");
372
		log_verbose("Using volume group(s) on command line");
Lines 410-424 Link Here
410
		vgnames = &arg_vgnames;
410
		vgnames = &arg_vgnames;
411
	}
411
	}
412
412
413
	if (!argc || !list_empty(&tags)) {
413
	if (!argc || !lvm_list_empty(&tags)) {
414
		log_verbose("Finding all volume groups");
414
		log_verbose("Finding all volume groups");
415
		if (!(vgnames = get_vgs(cmd, 0)) || list_empty(vgnames)) {
415
		if (!(vgnames = get_vgs(cmd, 0)) || lvm_list_empty(vgnames)) {
416
			log_error("No volume groups found");
416
			log_error("No volume groups found");
417
			return ECMD_FAILED;
417
			return ECMD_FAILED;
418
		}
418
		}
419
	}
419
	}
420
420
421
	list_iterate_items(sl, vgnames) {
421
	lvm_list_iterate_items(sl, vgnames) {
422
		vg_name = sl->str;
422
		vg_name = sl->str;
423
		if (!vg_name || !*vg_name)
423
		if (!vg_name || !*vg_name)
424
			continue;	/* FIXME Unnecessary? */
424
			continue;	/* FIXME Unnecessary? */
Lines 431-437 Link Here
431
}
431
}
432
432
433
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
433
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
434
			  struct list *tags, void *handle,
434
			  struct lvm_list *tags, void *handle,
435
			  int (*process_single) (struct cmd_context * cmd,
435
			  int (*process_single) (struct cmd_context * cmd,
436
						 struct volume_group * vg,
436
						 struct volume_group * vg,
437
						 struct physical_volume * pv,
437
						 struct physical_volume * pv,
Lines 441-448 Link Here
441
	int ret = 0;
441
	int ret = 0;
442
	struct pv_list *pvl;
442
	struct pv_list *pvl;
443
443
444
	list_iterate_items(pvl, &vg->pvs) {
444
	lvm_list_iterate_items(pvl, &vg->pvs) {
445
		if (tags && !list_empty(tags) &&
445
		if (tags && !lvm_list_empty(tags) &&
446
		    !str_list_match_list(tags, &pvl->pv->tags))
446
		    !str_list_match_list(tags, &pvl->pv->tags))
447
			continue;
447
			continue;
448
		if ((ret = process_single(cmd, vg, pvl->pv, handle)) > ret_max)
448
		if ((ret = process_single(cmd, vg, pvl->pv, handle)) > ret_max)
Lines 465-477 Link Here
465
465
466
	struct pv_list *pvl;
466
	struct pv_list *pvl;
467
	struct physical_volume *pv;
467
	struct physical_volume *pv;
468
	struct list *pvslist, *vgnames;
468
	struct lvm_list *pvslist, *vgnames;
469
	struct list tags;
469
	struct lvm_list tags;
470
	struct str_list *sll;
470
	struct str_list *sll;
471
	char *tagname;
471
	char *tagname;
472
	int consistent = 1;
472
	int consistent = 1;
473
473
474
	list_init(&tags);
474
	lvm_list_init(&tags);
475
475
476
	if (argc) {
476
	if (argc) {
477
		log_verbose("Using physical volume(s) on command line");
477
		log_verbose("Using physical volume(s) on command line");
Lines 515-523 Link Here
515
			if (ret > ret_max)
515
			if (ret > ret_max)
516
				ret_max = ret;
516
				ret_max = ret;
517
		}
517
		}
518
		if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) &&
518
		if (!lvm_list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) &&
519
		    !list_empty(vgnames)) {
519
		    !lvm_list_empty(vgnames)) {
520
			list_iterate_items(sll, vgnames) {
520
			lvm_list_iterate_items(sll, vgnames) {
521
				vg = vg_read(cmd, sll->str, &consistent);
521
				vg = vg_read(cmd, sll->str, &consistent);
522
				if (!consistent)
522
				if (!consistent)
523
					continue;
523
					continue;
Lines 541-547 Link Here
541
			if (!(pvslist = get_pvs(cmd)))
541
			if (!(pvslist = get_pvs(cmd)))
542
				return ECMD_FAILED;
542
				return ECMD_FAILED;
543
543
544
			list_iterate_items(pvl, pvslist) {
544
			lvm_list_iterate_items(pvl, pvslist) {
545
				ret = process_single(cmd, NULL, pvl->pv,
545
				ret = process_single(cmd, NULL, pvl->pv,
546
						     handle);
546
						     handle);
547
				if (ret > ret_max)
547
				if (ret > ret_max)
Lines 639-645 Link Here
639
	return pool_strdup(cmd->mem, vg_path);
639
	return pool_strdup(cmd->mem, vg_path);
640
}
640
}
641
641
642
static int _add_alloc_area(struct pool *mem, struct list *alloc_areas,
642
static int _add_alloc_area(struct pool *mem, struct lvm_list *alloc_areas,
643
			   uint32_t start, uint32_t count)
643
			   uint32_t start, uint32_t count)
644
{
644
{
645
	struct alloc_area *aa;
645
	struct alloc_area *aa;
Lines 648-654 Link Here
648
		  start, count);
648
		  start, count);
649
649
650
	/* Ensure no overlap with existing areas */
650
	/* Ensure no overlap with existing areas */
651
	list_iterate_items(aa, alloc_areas) {
651
	lvm_list_iterate_items(aa, alloc_areas) {
652
		if (((start < aa->start) && (start + count - 1 >= aa->start)) ||
652
		if (((start < aa->start) && (start + count - 1 >= aa->start)) ||
653
		    ((start >= aa->start) &&
653
		    ((start >= aa->start) &&
654
		     (aa->start + aa->count - 1) >= start)) {
654
		     (aa->start + aa->count - 1) >= start)) {
Lines 667-678 Link Here
667
667
668
	aa->start = start;
668
	aa->start = start;
669
	aa->count = count;
669
	aa->count = count;
670
	list_add(alloc_areas, &aa->list);
670
	lvm_list_add(alloc_areas, &aa->list);
671
671
672
	return 1;
672
	return 1;
673
}
673
}
674
674
675
static int _parse_pes(struct pool *mem, char *c, struct list *alloc_areas,
675
static int _parse_pes(struct pool *mem, char *c, struct lvm_list *alloc_areas,
676
		      uint32_t size)
676
		      uint32_t size)
677
{
677
{
678
	char *endptr;
678
	char *endptr;
Lines 681-687 Link Here
681
	/* Default to whole PV */
681
	/* Default to whole PV */
682
	if (!c) {
682
	if (!c) {
683
		if (!_add_alloc_area(mem, alloc_areas, UINT32_C(0), size)) {
683
		if (!_add_alloc_area(mem, alloc_areas, UINT32_C(0), size)) {
684
			stack;
684
			STACK;
685
			return 0;
685
			return 0;
686
		}
686
		}
687
		return 1;
687
		return 1;
Lines 731-737 Link Here
731
		}
731
		}
732
732
733
		if (!_add_alloc_area(mem, alloc_areas, start, end - start + 1)) {
733
		if (!_add_alloc_area(mem, alloc_areas, start, end - start + 1)) {
734
			stack;
734
			STACK;
735
			return 0;
735
			return 0;
736
		}
736
		}
737
737
Lines 745-755 Link Here
745
}
745
}
746
746
747
static void _create_pv_entry(struct pool *mem, struct pv_list *pvl,
747
static void _create_pv_entry(struct pool *mem, struct pv_list *pvl,
748
			     char *colon, struct list *r)
748
			     char *colon, struct lvm_list *r)
749
{
749
{
750
	const char *pvname;
750
	const char *pvname;
751
	struct pv_list *new_pvl;
751
	struct pv_list *new_pvl;
752
	struct list *alloc_areas;
752
	struct lvm_list *alloc_areas;
753
753
754
	pvname = dev_name(pvl->pv->dev);
754
	pvname = dev_name(pvl->pv->dev);
755
	if (!(pvl->pv->status & ALLOCATABLE_PV)) {
755
	if (!(pvl->pv->status & ALLOCATABLE_PV)) {
Lines 774-797 Link Here
774
		log_error("Allocation of alloc_areas list failed");
774
		log_error("Allocation of alloc_areas list failed");
775
		return;
775
		return;
776
	}
776
	}
777
	list_init(alloc_areas);
777
	lvm_list_init(alloc_areas);
778
778
779
	/* Specify which physical extents may be used for allocation */
779
	/* Specify which physical extents may be used for allocation */
780
	if (!_parse_pes(mem, colon, alloc_areas, pvl->pv->pe_count)) {
780
	if (!_parse_pes(mem, colon, alloc_areas, pvl->pv->pe_count)) {
781
		stack;
781
		STACK;
782
		return;
782
		return;
783
	}
783
	}
784
	new_pvl->alloc_areas = alloc_areas;
784
	new_pvl->alloc_areas = alloc_areas;
785
785
786
	list_add(r, &new_pvl->list);
786
	lvm_list_add(r, &new_pvl->list);
787
}
787
}
788
788
789
struct list *create_pv_list(struct pool *mem,
789
struct lvm_list *create_pv_list(struct pool *mem,
790
			    struct volume_group *vg, int argc, char **argv)
790
			    struct volume_group *vg, int argc, char **argv)
791
{
791
{
792
	struct list *r;
792
	struct lvm_list *r;
793
	struct pv_list *pvl;
793
	struct pv_list *pvl;
794
	struct list tags, arg_pvnames;
794
	struct lvm_list tags, arg_pvnames;
795
	const char *pvname = NULL; 
795
	const char *pvname = NULL; 
796
	char *colon, *tagname;
796
	char *colon, *tagname;
797
	int i;
797
	int i;
Lines 801-810 Link Here
801
		log_error("Allocation of list failed");
801
		log_error("Allocation of list failed");
802
		return NULL;
802
		return NULL;
803
	}
803
	}
804
	list_init(r);
804
	lvm_list_init(r);
805
805
806
	list_init(&tags);
806
	lvm_list_init(&tags);
807
	list_init(&arg_pvnames);
807
	lvm_list_init(&arg_pvnames);
808
808
809
	for (i = 0; i < argc; i++) {
809
	for (i = 0; i < argc; i++) {
810
		if (*argv[i] == '@') {
810
		if (*argv[i] == '@') {
Lines 813-819 Link Here
813
				log_error("Skipping invalid tag %s", tagname);
813
				log_error("Skipping invalid tag %s", tagname);
814
				continue;
814
				continue;
815
			}
815
			}
816
			list_iterate_items(pvl, &vg->pvs) {
816
			lvm_list_iterate_items(pvl, &vg->pvs) {
817
				if (str_list_match_item(&pvl->pv->tags,
817
				if (str_list_match_item(&pvl->pv->tags,
818
				    tagname)) {
818
				    tagname)) {
819
					_create_pv_entry(mem, pvl, NULL, r);
819
					_create_pv_entry(mem, pvl, NULL, r);
Lines 841-858 Link Here
841
		_create_pv_entry(mem, pvl, colon, r);
841
		_create_pv_entry(mem, pvl, colon, r);
842
	}
842
	}
843
843
844
	if (list_empty(r))
844
	if (lvm_list_empty(r))
845
		log_error("No specified PVs have space available");
845
		log_error("No specified PVs have space available");
846
846
847
	return list_empty(r) ? NULL : r;
847
	return lvm_list_empty(r) ? NULL : r;
848
}
848
}
849
849
850
850
851
851
852
852
853
struct list *clone_pv_list(struct pool *mem, struct list *pvsl)
853
struct lvm_list *clone_pv_list(struct pool *mem, struct lvm_list *pvsl)
854
{
854
{
855
	struct list *r;
855
	struct lvm_list *r;
856
	struct pv_list *pvl, *new_pvl;
856
	struct pv_list *pvl, *new_pvl;
857
857
858
	/* Build up list of PVs */
858
	/* Build up list of PVs */
Lines 860-875 Link Here
860
		log_error("Allocation of list failed");
860
		log_error("Allocation of list failed");
861
		return NULL;
861
		return NULL;
862
	}
862
	}
863
	list_init(r);
863
	lvm_list_init(r);
864
864
865
	list_iterate_items(pvl, pvsl) {
865
	lvm_list_iterate_items(pvl, pvsl) {
866
		if (!(new_pvl = pool_zalloc(mem, sizeof(*new_pvl)))) {
866
		if (!(new_pvl = pool_zalloc(mem, sizeof(*new_pvl)))) {
867
			log_error("Unable to allocate physical volume list.");
867
			log_error("Unable to allocate physical volume list.");
868
			return NULL;
868
			return NULL;
869
		}
869
		}
870
870
871
		memcpy(new_pvl, pvl, sizeof(*new_pvl));
871
		memcpy(new_pvl, pvl, sizeof(*new_pvl));
872
		list_add(r, &new_pvl->list);
872
		lvm_list_add(r, &new_pvl->list);
873
	}
873
	}
874
874
875
	return r;
875
	return r;
(-)LVM2.2.00.15.orig/tools/toollib.h (-4 / +4 lines)
Lines 54-67 Link Here
54
						      void *handle));
54
						      void *handle));
55
55
56
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
56
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
57
			  struct list *tags, void *handle,
57
			  struct lvm_list *tags, void *handle,
58
			  int (*process_single) (struct cmd_context * cmd,
58
			  int (*process_single) (struct cmd_context * cmd,
59
						 struct volume_group * vg,
59
						 struct volume_group * vg,
60
						 struct physical_volume * pv,
60
						 struct physical_volume * pv,
61
						 void *handle));
61
						 void *handle));
62
62
63
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
63
int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
64
			  struct list *arg_lvnames, struct list *tags,
64
			  struct lvm_list *arg_lvnames, struct lvm_list *tags,
65
			  void *handle,
65
			  void *handle,
66
			  int (*process_single) (struct cmd_context * cmd,
66
			  int (*process_single) (struct cmd_context * cmd,
67
						 struct logical_volume * lv,
67
						 struct logical_volume * lv,
Lines 74-82 Link Here
74
 * Builds a list of pv's from the names in argv.  Used in
74
 * Builds a list of pv's from the names in argv.  Used in
75
 * lvcreate/extend.
75
 * lvcreate/extend.
76
 */
76
 */
77
struct list *create_pv_list(struct pool *mem,
77
struct lvm_list *create_pv_list(struct pool *mem,
78
			    struct volume_group *vg, int argc, char **argv);
78
			    struct volume_group *vg, int argc, char **argv);
79
79
80
struct list *clone_pv_list(struct pool *mem, struct list *pvs);
80
struct lvm_list *clone_pv_list(struct pool *mem, struct lvm_list *pvs);
81
81
82
#endif
82
#endif
(-)LVM2.2.00.15.orig/tools/vgcfgbackup.c (-2 / +2 lines)
Lines 34-47 Link Here
34
		if (!consistent) {
34
		if (!consistent) {
35
			log_error("No backup taken: specify filename with -f "
35
			log_error("No backup taken: specify filename with -f "
36
				  "to backup an inconsistent VG");
36
				  "to backup an inconsistent VG");
37
			stack;
37
			STACK;
38
			return ECMD_FAILED;
38
			return ECMD_FAILED;
39
		}
39
		}
40
40
41
		/* just use the normal backup code */
41
		/* just use the normal backup code */
42
		backup_enable(1);	/* force a backup */
42
		backup_enable(1);	/* force a backup */
43
		if (!backup(vg)) {
43
		if (!backup(vg)) {
44
			stack;
44
			STACK;
45
			return ECMD_FAILED;
45
			return ECMD_FAILED;
46
		}
46
		}
47
	}
47
	}
(-)LVM2.2.00.15.orig/tools/vgchange.c (-2 / +2 lines)
Lines 23-29 Link Here
23
	struct physical_volume *pv;
23
	struct physical_volume *pv;
24
	int count = 0;
24
	int count = 0;
25
25
26
	list_iterate_items(lvl, &vg->lvs) {
26
	lvm_list_iterate_items(lvl, &vg->lvs) {
27
		lv = lvl->lv;
27
		lv = lvl->lv;
28
28
29
		/* Only request activation of snapshot origin devices */
29
		/* Only request activation of snapshot origin devices */
Lines 214-220 Link Here
214
214
215
	id_create(&vg->id);
215
	id_create(&vg->id);
216
216
217
	list_iterate_items(lvl, &vg->lvs) {
217
	lvm_list_iterate_items(lvl, &vg->lvs) {
218
		memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id));
218
		memcpy(&lvl->lv->lvid, &vg->id, sizeof(vg->id));
219
	}
219
	}
220
220
(-)LVM2.2.00.15.orig/tools/vgconvert.c (-4 / +4 lines)
Lines 23-29 Link Here
23
	struct logical_volume *lv;
23
	struct logical_volume *lv;
24
	struct lv_list *lvl;
24
	struct lv_list *lvl;
25
	uint64_t size = 0;
25
	uint64_t size = 0;
26
	struct list mdas;
26
	struct lvm_list mdas;
27
	int pvmetadatacopies = 0;
27
	int pvmetadatacopies = 0;
28
	uint64_t pvmetadatasize = 0;
28
	uint64_t pvmetadatasize = 0;
29
	uint64_t pe_end = 0, pe_start = 0;
29
	uint64_t pe_end = 0, pe_start = 0;
Lines 90-96 Link Here
90
90
91
	/* Attempt to change any LVIDs that are too big */
91
	/* Attempt to change any LVIDs that are too big */
92
	if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
92
	if (cmd->fmt->features & FMT_RESTRICTED_LVIDS) {
93
		list_iterate_items(lvl, &vg->lvs) {
93
		lvm_list_iterate_items(lvl, &vg->lvs) {
94
			lv = lvl->lv;
94
			lv = lvl->lv;
95
			if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
95
			if (lvnum_from_lvid(&lv->lvid) < MAX_RESTRICTED_LVS)
96
				continue;
96
				continue;
Lines 109-122 Link Here
109
	if (active)
109
	if (active)
110
		return ECMD_FAILED;
110
		return ECMD_FAILED;
111
111
112
	list_iterate_items(pvl, &vg->pvs) {
112
	lvm_list_iterate_items(pvl, &vg->pvs) {
113
		existing_pv = pvl->pv;
113
		existing_pv = pvl->pv;
114
114
115
		pe_start = existing_pv->pe_start;
115
		pe_start = existing_pv->pe_start;
116
		pe_end = existing_pv->pe_count * existing_pv->pe_size
116
		pe_end = existing_pv->pe_count * existing_pv->pe_size
117
		    + pe_start - 1;
117
		    + pe_start - 1;
118
118
119
		list_init(&mdas);
119
		lvm_list_init(&mdas);
120
		if (!(pv = pv_create(cmd->fmt, existing_pv->dev,
120
		if (!(pv = pv_create(cmd->fmt, existing_pv->dev,
121
				     &existing_pv->id, size,
121
				     &existing_pv->id, size,
122
				     pe_start, existing_pv->pe_count,
122
				     pe_start, existing_pv->pe_count,
(-)LVM2.2.00.15.orig/tools/vgmerge.c (-15 / +15 lines)
Lines 106-115 Link Here
106
	}
106
	}
107
107
108
	/* Check no conflicts with LV names */
108
	/* Check no conflicts with LV names */
109
	list_iterate_items(lvl1, &vg_to->lvs) {
109
	lvm_list_iterate_items(lvl1, &vg_to->lvs) {
110
		char *name1 = lvl1->lv->name;
110
		char *name1 = lvl1->lv->name;
111
111
112
		list_iterate_items(lvl2, &vg_from->lvs) {
112
		lvm_list_iterate_items(lvl2, &vg_from->lvs) {
113
			char *name2 = lvl2->lv->name;
113
			char *name2 = lvl2->lv->name;
114
114
115
			if (!strcmp(name1, name2)) {
115
			if (!strcmp(name1, name2)) {
Lines 128-157 Link Here
128
		goto error;
128
		goto error;
129
129
130
	/* Merge volume groups */
130
	/* Merge volume groups */
131
	while (!list_empty(&vg_from->pvs)) {
131
	while (!lvm_list_empty(&vg_from->pvs)) {
132
		struct list *pvh = vg_from->pvs.n;
132
		struct lvm_list *pvh = vg_from->pvs.n;
133
		struct physical_volume *pv;
133
		struct physical_volume *pv;
134
134
135
		list_del(pvh);
135
		lvm_list_del(pvh);
136
		list_add(&vg_to->pvs, pvh);
136
		lvm_list_add(&vg_to->pvs, pvh);
137
137
138
		pv = list_item(pvh, struct pv_list)->pv;
138
		pv = lvm_list_item(pvh, struct pv_list)->pv;
139
		pv->vg_name = pool_strdup(cmd->mem, vg_to->name);
139
		pv->vg_name = pool_strdup(cmd->mem, vg_to->name);
140
	}
140
	}
141
	vg_to->pv_count += vg_from->pv_count;
141
	vg_to->pv_count += vg_from->pv_count;
142
142
143
	while (!list_empty(&vg_from->lvs)) {
143
	while (!lvm_list_empty(&vg_from->lvs)) {
144
		struct list *lvh = vg_from->lvs.n;
144
		struct lvm_list *lvh = vg_from->lvs.n;
145
145
146
		list_del(lvh);
146
		lvm_list_del(lvh);
147
		list_add(&vg_to->lvs, lvh);
147
		lvm_list_add(&vg_to->lvs, lvh);
148
	}
148
	}
149
149
150
	while (!list_empty(&vg_from->fid->metadata_areas)) {
150
	while (!lvm_list_empty(&vg_from->fid->metadata_areas)) {
151
		struct list *mdah = vg_from->fid->metadata_areas.n;
151
		struct lvm_list *mdah = vg_from->fid->metadata_areas.n;
152
152
153
		list_del(mdah);
153
		lvm_list_del(mdah);
154
		list_add(&vg_to->fid->metadata_areas, mdah);
154
		lvm_list_add(&vg_to->fid->metadata_areas, mdah);
155
	}
155
	}
156
156
157
	vg_to->lv_count += vg_from->lv_count;
157
	vg_to->lv_count += vg_from->lv_count;
(-)LVM2.2.00.15.orig/tools/vgreduce.c (-18 / +18 lines)
Lines 25-31 Link Here
25
	}
25
	}
26
26
27
	if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
27
	if (!id_write_format(&pvl->pv->id, uuid, sizeof(uuid))) {
28
		stack;
28
		STACK;
29
		return 0;
29
		return 0;
30
	}
30
	}
31
31
Lines 41-47 Link Here
41
	vg->extent_count -= pvl->pv->pe_count;
41
	vg->extent_count -= pvl->pv->pe_count;
42
	vg->pv_count--;
42
	vg->pv_count--;
43
43
44
	list_del(&pvl->list);
44
	lvm_list_del(&pvl->list);
45
45
46
	return 1;
46
	return 1;
47
}
47
}
Lines 51-57 Link Here
51
{
51
{
52
	struct snapshot *snap;
52
	struct snapshot *snap;
53
	struct snapshot_list *snl;
53
	struct snapshot_list *snl;
54
	struct list *snaplist;
54
	struct lvm_list *snaplist;
55
55
56
	log_verbose("%s/%s has missing extents: removing (including "
56
	log_verbose("%s/%s has missing extents: removing (including "
57
		    "dependencies)", lv->vg->name, lv->name);
57
		    "dependencies)", lv->vg->name, lv->name);
Lines 83-103 Link Here
83
83
84
	/* Remove snapshot dependencies */
84
	/* Remove snapshot dependencies */
85
	if (!(snaplist = find_snapshots(lv))) {
85
	if (!(snaplist = find_snapshots(lv))) {
86
		stack;
86
		STACK;
87
		return 0;
87
		return 0;
88
	}
88
	}
89
	/* List may be empty */
89
	/* List may be empty */
90
	list_iterate_items(snl, snaplist) {
90
	lvm_list_iterate_items(snl, snaplist) {
91
		*list_unsafe = 1;	/* May remove caller's lvht! */
91
		*list_unsafe = 1;	/* May remove caller's lvht! */
92
		snap = snl->snapshot;
92
		snap = snl->snapshot;
93
		if (!vg_remove_snapshot(lv->vg, snap->cow)) {
93
		if (!vg_remove_snapshot(lv->vg, snap->cow)) {
94
			stack;
94
			STACK;
95
			return 0;
95
			return 0;
96
		}
96
		}
97
		log_verbose("Removing LV %s from VG %s", snap->cow->name,
97
		log_verbose("Removing LV %s from VG %s", snap->cow->name,
98
			    lv->vg->name);
98
			    lv->vg->name);
99
		if (!lv_remove(lv->vg, snap->cow)) {
99
		if (!lv_remove(lv->vg, snap->cow)) {
100
			stack;
100
			STACK;
101
			return 0;
101
			return 0;
102
		}
102
		}
103
	}
103
	}
Lines 105-111 Link Here
105
	/* Remove the LV itself */
105
	/* Remove the LV itself */
106
	log_verbose("Removing LV %s from VG %s", lv->name, lv->vg->name);
106
	log_verbose("Removing LV %s from VG %s", lv->name, lv->vg->name);
107
	if (!lv_remove(lv->vg, lv)) {
107
	if (!lv_remove(lv->vg, lv)) {
108
		stack;
108
		STACK;
109
		return 0;
109
		return 0;
110
	}
110
	}
111
111
Lines 114-121 Link Here
114
114
115
static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
115
static int _make_vg_consistent(struct cmd_context *cmd, struct volume_group *vg)
116
{
116
{
117
	struct list *pvh, *pvht;
117
	struct lvm_list *pvh, *pvht;
118
	struct list *lvh, *lvht;
118
	struct lvm_list *lvh, *lvht;
119
	struct pv_list *pvl;
119
	struct pv_list *pvl;
120
	struct logical_volume *lv;
120
	struct logical_volume *lv;
121
	struct physical_volume *pv;
121
	struct physical_volume *pv;
Lines 127-137 Link Here
127
      restart_loop:
127
      restart_loop:
128
	list_unsafe = 0;	/* Set if we delete a different list-member */
128
	list_unsafe = 0;	/* Set if we delete a different list-member */
129
129
130
	list_iterate_safe(lvh, lvht, &vg->lvs) {
130
	lvm_list_iterate_safe(lvh, lvht, &vg->lvs) {
131
		lv = list_item(lvh, struct lv_list)->lv;
131
		lv = lvm_list_item(lvh, struct lv_list)->lv;
132
132
133
		/* Are any segments of this LV on missing PVs? */
133
		/* Are any segments of this LV on missing PVs? */
134
		list_iterate_items(seg, &lv->segments) {
134
		lvm_list_iterate_items(seg, &lv->segments) {
135
			for (s = 0; s < seg->area_count; s++) {
135
			for (s = 0; s < seg->area_count; s++) {
136
				if (seg->area[s].type != AREA_PV)
136
				if (seg->area[s].type != AREA_PV)
137
					continue;
137
					continue;
Lines 141-147 Link Here
141
				pv = seg->area[s].u.pv.pv;
141
				pv = seg->area[s].u.pv.pv;
142
				if (!pv || !pv->dev) {
142
				if (!pv || !pv->dev) {
143
					if (!_remove_lv(cmd, lv, &list_unsafe)) {
143
					if (!_remove_lv(cmd, lv, &list_unsafe)) {
144
						stack;
144
						STACK;
145
						return 0;
145
						return 0;
146
					}
146
					}
147
					if (list_unsafe)
147
					if (list_unsafe)
Lines 152-163 Link Here
152
	}
152
	}
153
153
154
	/* Remove missing PVs */
154
	/* Remove missing PVs */
155
	list_iterate_safe(pvh, pvht, &vg->pvs) {
155
	lvm_list_iterate_safe(pvh, pvht, &vg->pvs) {
156
		pvl = list_item(pvh, struct pv_list);
156
		pvl = lvm_list_item(pvh, struct pv_list);
157
		if (pvl->pv->dev)
157
		if (pvl->pv->dev)
158
			continue;
158
			continue;
159
		if (!_remove_pv(vg, pvl)) {
159
		if (!_remove_pv(vg, pvl)) {
160
			stack;
160
			STACK;
161
			return 0;
161
			return 0;
162
		}
162
		}
163
	}
163
	}
Lines 191-197 Link Here
191
	log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
191
	log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name);
192
192
193
	if (pvl)
193
	if (pvl)
194
		list_del(&pvl->list);
194
		lvm_list_del(&pvl->list);
195
195
196
	pv->vg_name = ORPHAN;
196
	pv->vg_name = ORPHAN;
197
	vg->pv_count--;
197
	vg->pv_count--;
(-)LVM2.2.00.15.orig/tools/vgremove.c (-1 / +1 lines)
Lines 54-60 Link Here
54
	}
54
	}
55
55
56
	/* init physical volumes */
56
	/* init physical volumes */
57
	list_iterate_items(pvl, &vg->pvs) {
57
	lvm_list_iterate_items(pvl, &vg->pvs) {
58
		pv = pvl->pv;
58
		pv = pvl->pv;
59
		log_verbose("Removing physical volume \"%s\" from "
59
		log_verbose("Removing physical volume \"%s\" from "
60
			    "volume group \"%s\"", dev_name(pv->dev), vg_name);
60
			    "volume group \"%s\"", dev_name(pv->dev), vg_name);
(-)LVM2.2.00.15.orig/tools/vgsplit.c (-15 / +15 lines)
Lines 27-39 Link Here
27
		return 0;
27
		return 0;
28
	}
28
	}
29
29
30
	list_del(&pvl->list);
30
	lvm_list_del(&pvl->list);
31
	list_add(&vg_to->pvs, &pvl->list);
31
	lvm_list_add(&vg_to->pvs, &pvl->list);
32
32
33
	vg_from->pv_count--;
33
	vg_from->pv_count--;
34
	vg_to->pv_count++;
34
	vg_to->pv_count++;
35
35
36
	pv = list_item(pvl, struct pv_list)->pv;
36
	pv = lvm_list_item(pvl, struct pv_list)->pv;
37
37
38
	vg_from->extent_count -= pv->pe_count;
38
	vg_from->extent_count -= pv->pe_count;
39
	vg_to->extent_count += pv->pe_count;
39
	vg_to->extent_count += pv->pe_count;
Lines 46-65 Link Here
46
46
47
static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
47
static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
48
{
48
{
49
	struct list *lvh, *lvht;
49
	struct lvm_list *lvh, *lvht;
50
	struct logical_volume *lv;
50
	struct logical_volume *lv;
51
	struct lv_segment *seg;
51
	struct lv_segment *seg;
52
	struct physical_volume *pv;
52
	struct physical_volume *pv;
53
	struct volume_group *vg_with;
53
	struct volume_group *vg_with;
54
	unsigned int s;
54
	unsigned int s;
55
55
56
	list_iterate_safe(lvh, lvht, &vg_from->lvs) {
56
	lvm_list_iterate_safe(lvh, lvht, &vg_from->lvs) {
57
		lv = list_item(lvh, struct lv_list)->lv;
57
		lv = lvm_list_item(lvh, struct lv_list)->lv;
58
58
59
		/* Ensure all the PVs used by this LV remain in the same */
59
		/* Ensure all the PVs used by this LV remain in the same */
60
		/* VG as each other */
60
		/* VG as each other */
61
		vg_with = NULL;
61
		vg_with = NULL;
62
		list_iterate_items(seg, &lv->segments) {
62
		lvm_list_iterate_items(seg, &lv->segments) {
63
			for (s = 0; s < seg->area_count; s++) {
63
			for (s = 0; s < seg->area_count; s++) {
64
				/* FIXME Check AREA_LV too */
64
				/* FIXME Check AREA_LV too */
65
				if (seg->area[s].type != AREA_PV)
65
				if (seg->area[s].type != AREA_PV)
Lines 95-102 Link Here
95
			continue;
95
			continue;
96
96
97
		/* Move this LV */
97
		/* Move this LV */
98
		list_del(lvh);
98
		lvm_list_del(lvh);
99
		list_add(&vg_to->lvs, lvh);
99
		lvm_list_add(&vg_to->lvs, lvh);
100
100
101
		vg_from->lv_count--;
101
		vg_from->lv_count--;
102
		vg_to->lv_count++;
102
		vg_to->lv_count++;
Lines 111-117 Link Here
111
{
111
{
112
	struct lv_list *lvl;
112
	struct lv_list *lvl;
113
113
114
	list_iterate_items(lvl, &vg->lvs)
114
	lvm_list_iterate_items(lvl, &vg->lvs)
115
		if (lv == lvl->lv)
115
		if (lv == lvl->lv)
116
			 return 1;
116
			 return 1;
117
117
Lines 121-132 Link Here
121
static int _move_snapshots(struct volume_group *vg_from,
121
static int _move_snapshots(struct volume_group *vg_from,
122
			   struct volume_group *vg_to)
122
			   struct volume_group *vg_to)
123
{
123
{
124
	struct list *slh, *slth;
124
	struct lvm_list *slh, *slth;
125
	struct snapshot *snap;
125
	struct snapshot *snap;
126
	int cow_from, origin_from;
126
	int cow_from, origin_from;
127
127
128
	list_iterate_safe(slh, slth, &vg_from->snapshots) {
128
	lvm_list_iterate_safe(slh, slth, &vg_from->snapshots) {
129
		snap = list_item(slh, struct snapshot_list)->snapshot;
129
		snap = lvm_list_item(slh, struct snapshot_list)->snapshot;
130
		cow_from = _lv_is_in_vg(vg_from, snap->cow);
130
		cow_from = _lv_is_in_vg(vg_from, snap->cow);
131
		origin_from = _lv_is_in_vg(vg_from, snap->origin);
131
		origin_from = _lv_is_in_vg(vg_from, snap->origin);
132
		if (cow_from && origin_from)
132
		if (cow_from && origin_from)
Lines 138-145 Link Here
138
		vg_from->snapshot_count--;
138
		vg_from->snapshot_count--;
139
		vg_to->snapshot_count++;
139
		vg_to->snapshot_count++;
140
140
141
		list_del(slh);
141
		lvm_list_del(slh);
142
		list_add(&vg_to->snapshots, slh);
142
		lvm_list_add(&vg_to->snapshots, slh);
143
	}
143
	}
144
144
145
	return 1;
145
	return 1;

Return to bug 56873