-
Notifications
You must be signed in to change notification settings - Fork 2
/
unit_tests
696 lines (608 loc) · 34.4 KB
/
unit_tests
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
Testing:
Scenario 1)
No moves required here, Pool can be shrunk because last mapped block is less than the reduced size specified.
[root@localhost thin_shrink]# ./thin_shrink.py -L2600m -tthinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..44800 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 41600
Yes, this pool can be shrunk. Last mapped block is 40175 and new size in chunks is 41600
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (2.73 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 2600m
------------------------------------------------------------------------------
Shrink further to 2.4G, moving blocks around is required. Only ranges in this case.
[root@localhost thin_shrink]# ./thin_shrink.py -L2400m -tthinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..41600 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 38400
Changes needed to metadata and blocks will be copied
allocated ranges are..
[[0, 2], [2, 1], [3, 1], [4, 160], [164, 1], [165, 1], [166, 1], [167, 1], [168, 1], [169, 1], [170, 1], [171, 1], [172, 1], [173, 1], [174, 1], [175, 1], [176, 1], [177, 1], [178, 1], [179, 2], [181, 1], [182, 1], [183, 160], [343, 1], [344, 1], [345, 1], [346, 1], [347, 1], [348, 1], [349, 1], [350, 1], [351, 1], [352, 1], [353, 1], [354, 192], [8350, 992], [9342, 1024], [10366, 1024], [11390, 984], [12374, 40], [12414, 1024], [13438, 1024], [14462, 1024], [15486, 864], [24350, 992], [25342, 1024], [26366, 1024], [27390, 984], [28374, 40], [28414, 1024], [29438, 1024], [30462, 1024], [31486, 864], [32351, 2047], [34398, 1249], [35656, 1], [35657, 1], [35658, 1], [35659, 1], [35660, 1], [35661, 1], [35662, 1], [35663, 1], [35664, 3808], [39472, 704]]
sorted free ranges are
[[32350, 1], [35647, 9], [546, 7804], [16350, 8000]]
reverse sorted ranges requiring move are
[[35664, 3808], [39472, 704]]
change list is..
[[35664, 546, 3808], [39472, 4354, 704]]
moving 3808 blocks at 35664 to 546
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35664 seek=546 count=3808 conv=notrunc
3808+0 records in
3808+0 records out
249561088 bytes (250 MB) copied, 3.86304 s, 64.6 MB/s
moving 704 blocks at 39472 to 4354
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=39472 seek=4354 count=704 conv=notrunc
704+0 records in
704+0 records out
46137344 bytes (46 MB) copied, 0.414274 s, 111 MB/s
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<2.54 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 2400m
[root@localhost thin_shrink]# diff /tmp/dump /tmp/changed.xml
1c1
< <superblock uuid="" time="0" transaction="2" flags="0" version="2" data_block_size="128" nr_data_blocks="41600">
---
> <superblock uuid="" time="0" transaction="2" flags="0" version="2" data_block_size="128" nr_data_blocks="38400">
24c24
< <range_mapping origin_begin="19499" data_begin="39472" length="704" time="0"/>
---
> <range_mapping origin_begin="19499" data_begin="4354" length="704" time="0"/>
62c62
< <range_mapping origin_begin="16385" data_begin="35664" length="3808" time="0"/>
---
> <range_mapping origin_begin="16385" data_begin="546" length="3808" time="0"/>
[root@localhost thin_shrink]# vgchange -ay
3 logical volume(s) in volume group "thinvg" now active
2 logical volume(s) in volume group "rhel_vm253-73" now active
[root@localhost thin_shrink]# mount /dev/thinvg/t1 /home/nkshirsa/formt/t1
[root@localhost thin_shrink]# umount /home/nkshirsa/formt/t1
[root@localhost thin_shrink]# vgchange -an thinvg
0 logical volume(s) in volume group "thinvg" now active
-------------------------------------------------------------------------------
Scenario 3)
Another run which required both range and single mappings to be moved:
Shrink further to 2200MB,
[root@localhost thin_shrink]# ./thin_shrink.py -L2200m -tthinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..38400 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 35200
Changes needed to metadata and blocks will be copied
allocated ranges are..
[[0, 2], [2, 1], [3, 1], [4, 160], [164, 1], [165, 1], [166, 1], [167, 1], [168, 1], [169, 1], [170, 1], [171, 1], [172, 1], [173, 1], [174, 1], [175, 1], [176, 1], [177, 1], [178, 1], [179, 2], [181, 1], [182, 1], [183, 160], [343, 1], [344, 1], [345, 1], [346, 1], [347, 1], [348, 1], [349, 1], [350, 1], [351, 1], [352, 1], [353, 1], [354, 192], [546, 3808], [4354, 704], [8350, 992], [9342, 1024], [10366, 1024], [11390, 984], [12374, 40], [12414, 1024], [13438, 1024], [14462, 1024], [15486, 864], [24350, 992], [25342, 1024], [26366, 1024], [27390, 984], [28374, 40], [28414, 1024], [29438, 1024], [30462, 1024], [31486, 864], [32351, 2047], [34398, 1249], [35656, 1], [35657, 1], [35658, 1], [35659, 1], [35660, 1], [35661, 1], [35662, 1], [35663, 1]]
sorted free ranges are
[[32350, 1], [5058, 3292], [16350, 8000]]
reverse sorted ranges requiring move are
[[34398, 1249], [35656, 1], [35657, 1], [35658, 1], [35659, 1], [35660, 1], [35661, 1], [35662, 1], [35663, 1]]
change list is..
[[34398, 5058, 1249], [35656, 6307, 1], [35657, 6308, 1], [35658, 6309, 1], [35659, 6310, 1], [35660, 6311, 1], [35661, 6312, 1], [35662, 6313, 1], [35663, 6314, 1]]
moving 1249 blocks at 34398 to 5058
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=34398 seek=5058 count=1249 conv=notrunc
1249+0 records in
1249+0 records out
81854464 bytes (82 MB) copied, 1.26161 s, 64.9 MB/s
moving 1 blocks at 35656 to 6307
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35656 seek=6307 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000855498 s, 76.6 MB/s
moving 1 blocks at 35657 to 6308
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35657 seek=6308 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00157816 s, 41.5 MB/s
moving 1 blocks at 35658 to 6309
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35658 seek=6309 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000324833 s, 202 MB/s
moving 1 blocks at 35659 to 6310
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35659 seek=6310 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000380861 s, 172 MB/s
moving 1 blocks at 35660 to 6311
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35660 seek=6311 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000324412 s, 202 MB/s
moving 1 blocks at 35661 to 6312
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35661 seek=6312 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000530414 s, 124 MB/s
moving 1 blocks at 35662 to 6313
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35662 seek=6313 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000383886 s, 171 MB/s
moving 1 blocks at 35663 to 6314
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35663 seek=6314 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000435793 s, 150 MB/s
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (2.34 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 2200m
[root@localhost thin_shrink]#
[root@localhost thin_shrink]# diff /tmp/dump /tmp/changed.xml
1c1
< <superblock uuid="" time="0" transaction="2" flags="0" version="2" data_block_size="128" nr_data_blocks="38400">
---
> <superblock uuid="" time="0" transaction="2" flags="0" version="2" data_block_size="128" nr_data_blocks="35200">
5c5
< <single_mapping origin_block="994" data_block="35656" time="0"/>
---
> <single_mapping origin_block="994" data_block="6307" time="0"/>
7c7
< <single_mapping origin_block="2019" data_block="35657" time="0"/>
---
> <single_mapping origin_block="2019" data_block="6308" time="0"/>
9c9
< <single_mapping origin_block="3044" data_block="35658" time="0"/>
---
> <single_mapping origin_block="3044" data_block="6309" time="0"/>
11c11
< <single_mapping origin_block="4029" data_block="35659" time="0"/>
---
> <single_mapping origin_block="4029" data_block="6310" time="0"/>
13c13
< <single_mapping origin_block="4070" data_block="35660" time="0"/>
---
> <single_mapping origin_block="4070" data_block="6311" time="0"/>
15c15
< <single_mapping origin_block="5095" data_block="35661" time="0"/>
---
> <single_mapping origin_block="5095" data_block="6312" time="0"/>
17c17
< <single_mapping origin_block="6120" data_block="35662" time="0"/>
---
> <single_mapping origin_block="6120" data_block="6313" time="0"/>
19c19
< <single_mapping origin_block="7145" data_block="35663" time="0"/>
---
> <single_mapping origin_block="7145" data_block="6314" time="0"/>
23c23
< <range_mapping origin_begin="18250" data_begin="34398" length="1249" time="0"/>
---
> <range_mapping origin_begin="18250" data_begin="5058" length="1249" time="0"/>
[root@localhost thin_shrink]#
[root@localhost thin_shrink]# vgchange -ay thinvg
3 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# mount /dev/thinvg/t1 /home/nkshirsa/formt/t1
[root@localhost thin_shrink]# ls /home/nkshirsa/formt/t1/
folder2/ somefile
[root@localhost thin_shrink]# ls /home/nkshirsa/formt/t1/
folder2 somefile
[root@localhost thin_shrink]#
[root@localhost thin_shrink]# diff /tmp/vgmeta_backup /tmp/changed_vgmeta
59c59
< extent_count = 600 # 2.34375 Gigabytes
---
> extent_count = 550
[root@localhost thin_shrink]#
[root@localhost thin_shrink]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel_vm253-73 -wi-ao---- <13.87g
swap rhel_vm253-73 -wi-ao---- 1.60g
p1 thinvg twi-aotz-- <2.15g 69.21 20.02
t1 thinvg Vwi-aotz-- 10.00g p1 7.44
t2 thinvg Vwi-a-tz-- 4.00g p1 18.58
[root@localhost thin_shrink]#
-----------------------
[root@localhost thin_shrink]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel_vm253-73 -wi-ao---- <13.87g
swap rhel_vm253-73 -wi-ao---- 1.60g
p1 thinvg twi-aotz-- <4.45g 27.96 18.55
t1 thinvg Vwi-a-tz-- 10.00g p1 7.44
t2 thinvg Vwi-a-tz-- 4.00g p1 12.48
[root@localhost thin_shrink]# vgchange -an thinvg
0 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# ./thin_shrink.py -L4000m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..72832 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 64000
Yes, this pool can be shrunk. Last mapped block is 40383 and new size in chunks is 64000
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<4.45 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 4000m
[root@localhost thin_shrink]# ./thin_shrink.py -L3000m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..64000 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 48000
Yes, this pool can be shrunk. Last mapped block is 40383 and new size in chunks is 48000
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<3.91 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 3000m
[root@localhost thin_shrink]# ./thin_shrink.py -L2200m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..48000 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 35200
Changes needed to metadata and blocks will be copied
allocated ranges are..
[[0, 2], [4, 160], [164, 1], [165, 1], [166, 1], [167, 1], [168, 1], [169, 1], [170, 1], [171, 2], [175, 160], [335, 1], [336, 1], [337, 1], [338, 1], [339, 1], [340, 1], [341, 1], [342, 1], [343, 1], [344, 1], [345, 1], [346, 1], [347, 1], [348, 1], [349, 1], [350, 1016], [1366, 1024], [2390, 1024], [3414, 960], [4374, 64], [4438, 1024], [5462, 1024], [6486, 1024], [7510, 840], [16350, 1016], [17366, 1024], [18390, 1024], [19414, 960], [20374, 64], [20438, 1024], [21462, 1024], [22486, 1024], [23510, 840], [35631, 2047], [37678, 1953], [40357, 1], [40358, 1], [40359, 1], [40360, 1], [40361, 1], [40362, 1], [40363, 1], [40364, 1], [40365, 1], [40366, 1], [40375, 1], [40376, 1], [40377, 1], [40378, 1], [40379, 1], [40380, 1], [40381, 1], [40382, 1], [40383, 1]]
sorted free ranges are
[[2, 2], [173, 2], [8350, 8000]]
reverse sorted ranges requiring move are
[[35631, 2047], [37678, 1953], [40357, 1], [40358, 1], [40359, 1], [40360, 1], [40361, 1], [40362, 1], [40363, 1], [40364, 1], [40365, 1], [40366, 1], [40375, 1], [40376, 1], [40377, 1], [40378, 1], [40379, 1], [40380, 1], [40381, 1], [40382, 1], [40383, 1]]
change list is..
[[35631, 8350, 2047], [37678, 10397, 1953], [40357, 2, 1], [40358, 173, 1], [40359, 12350, 1], [40360, 12351, 1], [40361, 12352, 1], [40362, 12353, 1], [40363, 12354, 1], [40364, 12355, 1], [40365, 12356, 1], [40366, 12357, 1], [40375, 12358, 1], [40376, 12359, 1], [40377, 12360, 1], [40378, 12361, 1], [40379, 12362, 1], [40380, 12363, 1], [40381, 12364, 1], [40382, 12365, 1], [40383, 12366, 1]]
moving 2047 blocks at 35631 to 8350
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=35631 seek=8350 count=2047 conv=notrunc
2047+0 records in
2047+0 records out
134152192 bytes (134 MB) copied, 1.66689 s, 80.5 MB/s
moving 1953 blocks at 37678 to 10397
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=37678 seek=10397 count=1953 conv=notrunc
1953+0 records in
1953+0 records out
127991808 bytes (128 MB) copied, 1.42024 s, 90.1 MB/s
moving 1 blocks at 40357 to 2
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40357 seek=2 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.0109875 s, 6.0 MB/s
moving 1 blocks at 40358 to 173
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40358 seek=173 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.0152313 s, 4.3 MB/s
moving 1 blocks at 40359 to 12350
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40359 seek=12350 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00566847 s, 11.6 MB/s
moving 1 blocks at 40360 to 12351
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40360 seek=12351 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.0101351 s, 6.5 MB/s
moving 1 blocks at 40361 to 12352
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40361 seek=12352 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000340887 s, 192 MB/s
moving 1 blocks at 40362 to 12353
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40362 seek=12353 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00041912 s, 156 MB/s
moving 1 blocks at 40363 to 12354
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40363 seek=12354 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000262674 s, 249 MB/s
moving 1 blocks at 40364 to 12355
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40364 seek=12355 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00103939 s, 63.1 MB/s
moving 1 blocks at 40365 to 12356
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40365 seek=12356 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000243146 s, 270 MB/s
moving 1 blocks at 40366 to 12357
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40366 seek=12357 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000411183 s, 159 MB/s
moving 1 blocks at 40375 to 12358
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40375 seek=12358 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.0125392 s, 5.2 MB/s
moving 1 blocks at 40376 to 12359
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40376 seek=12359 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.0257946 s, 2.5 MB/s
moving 1 blocks at 40377 to 12360
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40377 seek=12360 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00115909 s, 56.5 MB/s
moving 1 blocks at 40378 to 12361
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40378 seek=12361 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.00588273 s, 11.1 MB/s
moving 1 blocks at 40379 to 12362
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40379 seek=12362 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000306777 s, 214 MB/s
moving 1 blocks at 40380 to 12363
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40380 seek=12363 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000408732 s, 160 MB/s
moving 1 blocks at 40381 to 12364
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40381 seek=12364 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000367871 s, 178 MB/s
moving 1 blocks at 40382 to 12365
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40382 seek=12365 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000457262 s, 143 MB/s
moving 1 blocks at 40383 to 12366
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=40383 seek=12366 count=1 conv=notrunc
1+0 records in
1+0 records out
65536 bytes (66 kB) copied, 0.000309906 s, 211 MB/s
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<2.93 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 2200m
[root@localhost thin_shrink]# dmsetup info -c
Name Maj Min Stat Open Targ Event UUID
rhel_vm253--73-swap 253 3 L--w 2 1 0 LVM-RdasxZPawsqGgqspLkjPWiVKWoTp8gFwHrvi35ngnFUsF7rwOD0p3GlX74l626n9
rhel_vm253--73-root 253 0 L--w 1 1 0 LVM-RdasxZPawsqGgqspLkjPWiVKWoTp8gFw9ukTcqFwiZgKZkGcY0nsBrMQa4L6b0hB
[root@localhost thin_shrink]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel_vm253-73 -wi-ao---- <13.87g
swap rhel_vm253-73 -wi-ao---- 1.60g
p1 thinvg twi---tz-- <2.15g
t1 thinvg Vwi---tz-- 10.00g p1
t2 thinvg Vwi---tz-- 4.00g p1
[root@localhost thin_shrink]# vgchange -ay thinvg
3 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# mount /dev/thinvg/t2 /home/nkshirsa/formt/t2/
[root@localhost thin_shrink]# mount /dev/thinvg/t1 /home/nkshirsa/formt/t1
[root@localhost thin_shrink]# ls /home/nkshirsa/formt/t1/
folder2 somefile
[root@localhost thin_shrink]# ls /home/nkshirsa/formt/t2/
folder1
--------
[root@localhost thin_shrink]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root rhel_vm253-73 -wi-ao---- <13.87g
swap rhel_vm253-73 -wi-ao---- 1.60g
p1 thinvg twi---tz-- <2.15g
t1 thinvg Vwi---tz-- 10.00g p1
t2 thinvg Vwi---tz-- 4.00g p1
[root@localhost thin_shrink]# ./thin_shrink.py -L2000m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..35200 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 32000
Yes, this pool can be shrunk. Last mapped block is 24349 and new size in chunks is 32000
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<2.15 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 2000m
[root@localhost thin_shrink]# vgchange -ay thinvg
3 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# vgchange -an thinvg
0 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# ./thin_shrink.py -L1800m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..32000 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 28800
Yes, this pool can be shrunk. Last mapped block is 24349 and new size in chunks is 28800
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (1.95 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 1800m
[root@localhost thin_shrink]# ./thin_shrink.py -L1300m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..28800 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 20800
Changes needed to metadata and blocks will be copied
allocated ranges are..
[[0, 2], [2, 1], [4, 160], [164, 1], [165, 1], [166, 1], [167, 1], [168, 1], [169, 1], [170, 1], [171, 2], [173, 1], [175, 160], [335, 1], [336, 1], [337, 1], [338, 1], [339, 1], [340, 1], [341, 1], [342, 1], [343, 1], [344, 1], [345, 1], [346, 1], [347, 1], [348, 1], [349, 1], [350, 1016], [1366, 1024], [2390, 1024], [3414, 960], [4374, 64], [4438, 1024], [5462, 1024], [6486, 1024], [7510, 840], [8350, 2047], [10397, 1953], [12350, 1], [12351, 1], [12352, 1], [12353, 1], [12354, 1], [12355, 1], [12356, 1], [12357, 1], [12358, 1], [12359, 1], [12360, 1], [12361, 1], [12362, 1], [12363, 1], [12364, 1], [12365, 1], [12366, 1], [16350, 1016], [17366, 1024], [18390, 1024], [19414, 960], [20374, 64], [20438, 1024], [21462, 1024], [22486, 1024], [23510, 840]]
sorted free ranges are
[[3, 1], [174, 1], [12367, 3983]]
reverse sorted ranges requiring move are
[[20438, 1024], [21462, 1024], [22486, 1024], [23510, 840]]
change list is..
[[20438, 12367, 1024], [21462, 13391, 1024], [22486, 14415, 1024], [23510, 15439, 840]]
moving 1024 blocks at 20438 to 12367
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=20438 seek=12367 count=1024 conv=notrunc
1024+0 records in
1024+0 records out
67108864 bytes (67 MB) copied, 2.11415 s, 31.7 MB/s
moving 1024 blocks at 21462 to 13391
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=21462 seek=13391 count=1024 conv=notrunc
1024+0 records in
1024+0 records out
67108864 bytes (67 MB) copied, 1.14833 s, 58.4 MB/s
moving 1024 blocks at 22486 to 14415
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=22486 seek=14415 count=1024 conv=notrunc
1024+0 records in
1024+0 records out
67108864 bytes (67 MB) copied, 1.22918 s, 54.6 MB/s
moving 840 blocks at 23510 to 15439
dd if=/dev/mapper/shrink_p1 of=/dev/mapper/shrink_p1 bs=64k skip=23510 seek=15439 count=840 conv=notrunc
840+0 records in
840+0 records out
55050240 bytes (55 MB) copied, 0.43219 s, 127 MB/s
lvs -a | grep " thinvg " | grep "\[p1_tmeta]" > /tmp/metadata_lv
lvcreate -n restore_lv -L8m thinvg
WARNING: Sum of all thin volume sizes (14.00 GiB) exceeds the size of thin pools (<1.76 GiB).
WARNING: You have not turned on protection against thin pools running out of space.
WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
Logical volume "restore_lv" created.
thin_restore -i /tmp/changed.xml -o /dev/thinvg/restore_lv
Restoring: [==================================================] 100%
lvconvert --thinpool thinvg/p1 --poolmetadata /dev/thinvg/restore_lv -y
vgcfgbackup -f /tmp/vgmeta_backup thinvg
Volume group "thinvg" successfully backed up.
WARNING: Forced restore of Volume Group thinvg with thin volumes.
Restored volume group thinvg
Logical volume "restore_lv" successfully removed
0 logical volume(s) in volume group "thinvg" now active
This pool has been shrunk to the specified size of 1300m
[root@localhost thin_shrink]#
-----
[root@localhost thin_shrink]# ./thin_shrink.py -L1200m -t thinvg/p1
dmsetup create shrink_p1 --table '0 10485760 linear 252:48 2048'
lvs -o +chunksize thinvg/p1 | grep -v Chunk > /tmp/chunksize
lvchange -an thinvg/p1
lvchange -ay thinvg/p1_tmeta -y
Allowing activation of component LV.
thin_dump /dev/thinvg/p1_tmeta > /tmp/dump
thin_rmap --region 0..20800 /dev/thinvg/p1_tmeta > /tmp/rmap
lvchange -an thinvg/p1_tmeta
Need to shrink pool to this number of chunks ---- 19200
This thin pool cannot be shrunk. The mapped chunks are more than the lower size provided. Discarding allocated blocks from the pool may help.
Failed to find logical volume "thinvg/restore_lv"
0 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]# vgchange -ay thinvg
3 logical volume(s) in volume group "thinvg" now active
[root@localhost thin_shrink]#