Thursday 11 Apr 2013

Thursday 11 Apr 2013

zfs survey

sudo zdb -b warship Traversing all blocks to verify nothing leaked ...

No leaks (block sum matches space maps exactly)

bp count: 509 bp logical: 53506560 avg: 105120 bp physical: 52801024 avg: 103734 compression: 1.01 bp allocated: 52938240 avg: 104004 compression: 1.01 bp deduped: 0 ref>1: 0 deduplication: 1.00 SPA allocated: 52938240 used: 0.25%

sudo zdb -S warship Simulated DDT histogram:

bucket allocated referenced ________________ ______________________ refcnt blocks LSIZE PSIZE DSIZE blocks LSIZE PSIZE DSIZE


1 410 50.3M 50.3M 50.3M 410 50.3M 50.3M 50.3M Total 410 50.3M 50.3M 50.3M 410 50.3M 50.3M 50.3M

dedup = 1.00, compress = 1.00, copies = 1.00, dedup * compress / copies = 1.00

sudo zdb -C warship

MOS Configuration: version: 5000 name: 'warship' state: 0 txg: 233 pool_guid: 3578300579301691619 hostname: 'thomas-virtual-machine' vdev_children: 1 vdev_tree: type: 'root' id: 0 guid: 3578300579301691619 children[0]: type: 'disk' id: 0 guid: 8408819898074402039 path: '/dev/sdb1' whole_disk: 1 metaslab_array: 33 metaslab_shift: 27 ashift: 9 asize: 21459632128 is_log: 0 create_txg: 4 features_for_read:

sudo zdb -d warship Dataset mos [META], ID 0, cr_txg 4, 99.0K, 54 objects Dataset warship/p2 [ZPL], ID 47, cr_txg 134, 30.0K, 6 objects Dataset warship/p1@1158 [ZPL], ID 38, cr_txg 1070, 50.3M, 17 objects Dataset warship/p1 [ZPL], ID 54, cr_txg 144, 50.3M, 17 objects Dataset warship@20130307 [ZPL], ID 40, cr_txg 16626, 32K, 8 objects Dataset warship [ZPL], ID 21, cr_txg 1, 32K, 8 objects

sudo zdb -h warship

History: 2013-03-06.10:25:21 zpool create -f warship sdb 2013-03-06.10:25:21 [internal pool create txg:5] pool spa 5000; zfs spa 5000; zpl 5; uts (null) thomas-virtual-machine 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 19:02:34 UTC 2013 2013-03-06.10:28:06 [internal create txg:38] dataset = 40 2013-03-06.10:28:06 [internal property set txg:39] refreservation=4430495744 dataset = 40 2013-03-06.10:28:11 zfs create warship/p1 -V 4G 2013-03-06.10:35:57 [internal create txg:134] dataset = 47 2013-03-06.10:36:02 zfs create warship/p2 2013-03-06.10:36:36 [internal property set txg:142] refreservation=0 dataset = 40 2013-03-06.10:36:36 [internal destroy txg:142] dataset = 40 2013-03-06.10:36:36 [internal property set txg:142] reservation=0 dataset = 40 2013-03-06.10:36:41 zfs destroy warship/p1 2013-03-06.10:36:42 [internal create txg:144] dataset = 54 2013-03-06.10:36:47 zfs create warship/p1 2013-03-06.10:48:46 zpool export warship 2013-03-06.10:49:34 [internal pool import txg:233] pool spa 5000; zfs spa 5000; zpl 5; uts (null) thomas-virtual-machine 3.5.0-25-generic #39-Ubuntu SMP Mon Feb 25 19:02:34 UTC 2013 2013-03-06.10:49:39 zpool import warship 2013-03-06.11:58:35 [internal snapshot txg:1070] dataset = 38 2013-03-06.11:58:40 zfs snapshot warship/p1@1158 2013-03-07.09:34:54 [internal snapshot txg:16626] dataset = 40 2013-03-07.09:34:59 zfs snapshot warship@20130307

sudo zdb -lu /dev/sdb1


LABEL 0


version: 5000 name: 'warship' state: 0 txg: 233 pool_guid: 3578300579301691619 hostname: 'thomas-virtual-machine' top_guid: 8408819898074402039 guid: 8408819898074402039 vdev_children: 1 vdev_tree: type: 'disk' id: 0 guid: 8408819898074402039 path: '/dev/sdb1' whole_disk: 1 metaslab_array: 33 metaslab_shift: 27 ashift: 9 asize: 21459632128 is_log: 0 create_txg: 4 features_for_read: Uberblock[4] magic = 0000000000bab10c version = 5000 txg = 4 guid_sum = 11987120477376093658 timestamp = 1362536716 UTC = Wed Mar 6 10:25:16 2013 Uberblock[5] magic = 0000000000bab10c version = 5000 txg = 5 guid_sum = 11987120477376093658 timestamp = 1362536721 UTC = Wed Mar 6 10:25:21 2013

-L

Disable leak tracing and the loading of space maps. By default, zdb verifies that all non-free blocks are refer‐ enced, which can be very expensive. ... Metaslabs: vdev 0 metaslabs 159 offset spacemap free


metaslab 0 offset 0 spacemap 36 free 77.7M metaslab 1 offset 8000000 spacemap 37 free 128M metaslab 2 offset 10000000 spacemap 0 free 128M metaslab 3 offset 18000000 spacemap 0 free 128M metaslab 4 offset 20000000 spacemap 0 free 128M metaslab 5 offset 28000000 spacemap 0 free 128M metaslab 6 offset 30000000 spacemap 0 free 128M metaslab 7 offset 38000000 spacemap 0 free 128M metaslab 8 offset 40000000 spacemap 0 free 128M metaslab 9 offset 48000000 spacemap 0 free 128M metaslab 10 offset 50000000 spacemap 0 free 128M ...

-m

Display the offset, spacemap, and free space of each metaslab. When specified twice, also display information about the maximum contiguous free space and the percentage of free space in each space map. When specified three times display every spacemap record. ... Metaslabs: vdev 0 metaslabs 159 offset spacemap free


metaslab 0 offset 0 spacemap 36 free 77.7M metaslab 1 offset 8000000 spacemap 37 free 128M metaslab 2 offset 10000000 spacemap 0 free 128M metaslab 3 offset 18000000 spacemap 0 free 128M metaslab 4 offset 20000000 spacemap 0 free 128M metaslab 5 offset 28000000 spacemap 0 free 128M metaslab 6 offset 30000000 spacemap 0 free 128M metaslab 7 offset 38000000 spacemap 0 free 128M metaslab 8 offset 40000000 spacemap 0 free 128M metaslab 9 offset 48000000 spacemap 0 free 128M metaslab 10 offset 50000000 spacemap 0 free 128M ...

sudo zdb -s warship capacity operations bandwidth ---- errors ---- description used avail read write read write read write cksum warship 50.5M 19.8G 241 0 1.14M 0 0 0 0 /dev/sdb1 50.5M 19.8G 241 0 1.14M 0 0 0 0

When ZFS decides to allocate blocks from a particular metaslab, it first reads that metaslab's space map from disk and replays the allocations and frees into an in-memory AVL tree of free space, sorted by offset. This yields a compact in-memory representation of free space that supports efficient allocation of contiguous space. ZFS also takes this opportunity to condense the space map: if there are many allocation-free pairs that cancel out, ZFS replaces the on-disk space map with the smaller in-memory version.

important log: checkout zdb.c:495 dump_spacemap..... thomas@thomas-virtual-machine:\~/source/zfs-linux-0.6.0.97/cmd/zdb\$ sudo ./zdb -v -m warship | more

Metaslabs: scan child 1 scan all child 1 vdev 0 metaslabs 159 offset spacemap free


metaslab 0 offset 0 spacemap 36 free 77.7M segments 25 maxsize 77.0M freepct 60% manual print dump_spacemap dump_spacemap [ 0] ALLOC: txg 187, pass 1 [ 1] A range: 0000000000-0000000400 size: 000400 [ 2] A range: 0000003e00-0000004000 size: 000200 [ 3] A range: 0000000600-0000001800 size: 001200 [ 4] A range: 0000006200-0000006400 size: 000200 [ 5] A range: 0000007c00-0000008600 size: 000a00 [ 6] A range: 0000006600-0000007400 size: 000e00 [ 7] A range: 0000004400-0000005a00 size: 001600 [ 8] A range: 000000d600-000000de00 size: 000800 [ 9] A range: 000001f400-000001fc00 size: 000800 [ 10] A range: 000001b600-000001f200 size: 003c00 [ 11] A range: 0000029000-0000029200 size: 000200 [ 12] A range: 000002e000-000002e600 size: 000600 [ 13] A range: 0000029c00-000002a000 size: 000400 [ 14] A range: 0000021c00-0000021e00 size: 000200 [ 15] A range: 0000008e00-000000be00 size: 003000 [ 16] A range: 0000031c00-0000032c00 size: 001000 [ 17] A range: 0000038000-0000039600 size: 001600 [ 18] A range: 0000034800-0000034c00 size: 000400 [ 19] A range: 000003ba00-000003c000 size: 000600 [ 20] A range: 0000186200-0001186200 size: 1000000 [ 21] A range: 0001186200-00020e6200 size: f60000 [ 22] A range: 0000040a00-0000162200 size: 121800 [ 23] A range: 0000039a00-000003b800 size: 001e00 [ 24] A range: 00032f7200-00032f8400 size: 001200 [ 25] A range: 0003233e00-00032f7000 size: 0c3200 [ 26] A range: 000210a600-000310a600 size: 1000000 [ 27] A range: 000310a600-000320bc00 size: 101600 [ 28] A range: 000002e800-000002f800 size: 001000 [ 29] ALLOC: txg 187, pass 2 [ 30] A range: 00032f8400-00032f8a00 size: 000600 [ 31] FREE: txg 187, pass 2 [ 32] F range: 0003233e00-0003234400 size: 000600 [ 33] FREE: txg 188, pass 1 [ 34] F range: 00032f7800-00032f8400 size: 000c00 [ 35] FREE: txg 188, pass 2 [ 36] F range: 0000008400-0000008600 size: 000200 [ 37] F range: 00032f8400-00032f8a00 size: 000600 [ 38] F range: 000000d600-000000de00 size: 000800 [ 39] FREE: txg 216, pass 1 [ 40] F range: 000001ce00-000001f200 size: 002400 [ 41] F range: 00032f7200-00032f7800 size: 000600 [ 42] F range: 00032f4e00-00032f7000 size: 002200 [ 43] FREE: txg 226, pass 2 [ 44] F range: 0000038000-0000039600 size: 001600 [ 45] FREE: txg 229, pass 1 [ 46] F range: 0000029c00-000002a000 size: 000400 [ 47] FREE: txg 235, pass 1 [ 48] F range: 000003ba00-000003c000 size: 000600 [ 49] F range: 0000039a00-000003b800 size: 001e00 [ 50] FREE: txg 266, pass 1 [ 51] F range: 0000034800-0000034a00 size: 000200 [ 52] FREE: txg 799, pass 1 [ 53] F range: 0000000000-0000000200 size: 000200 [ 54] FREE: txg 1070, pass 2 [ 55] F range: 0000032600-0000032a00 size: 000400 [ 56] F range: 0000032200-0000032400 size: 000200 [ 57] FREE: txg 16626, pass 2 [ 58] F range: 0000005600-0000005800 size: 000200 [ 59] FREE: txg 30076, pass 1 [ 60] F range: 000001bc00-000001be00 size: 000200 metaslab 1 offset 8000000 spacemap 37 free 66.0M segments 19 maxsize 65.5M freepct 51% manual print dump_spacemap dump_spacemap [ 0] ALLOC: txg 30076, pass 1 [ 1] A range: 0008001200-0008001400 size: 000200 [ 2] A range: 0008002400-0008002a00 size: 000600 [ 3] A range: 0008003600-0008003a00 size: 000400 [ 4] A range: 0008004600-0008004a00 size: 000400 [ 5] A range: 0008003e00-0008004200 size: 000400 [ 6] A range: 0008002e00-0008003200 size: 000400 [ 7] A range: 0008005e00-0008006000 size: 000200 [ 8] A range: 0008005600-0008005a00 size: 000400 [ 9] A range: 000800be00-000800fc00 size: 003e00 [ 10] A range: 0008007c00-0008009600 size: 001a00 [ 11] A range: 0008006600-0008006c00 size: 000600 [ 12] A range: 0008004e00-0008005200 size: 000400 [ 13] A range: 0008012200-0008012e00 size: 000c00 [ 14] A range: 0008021e00-0008283c00 size: 261e00 [ 15] A range: 0008014400-0008015a00 size: 001600 [ 16] A range: 000ba54a00-000ba54c00 size: 000200 [ 17] A range: 0008299400-0009299400 size: 1000000 [ 18] A range: 0009299400-0009fbac00 size: d21800 [ 19] A range: 000ba58a00-000ba58c00 size: 000200 [ 20] A range: 000ba6ba00-000ba6c000 size: 000600 [ 21] A range: 000ba6b000-000ba6b800 size: 000800 [ 22] A range: 000ba6ec00-000ba6ee00 size: 000200 [ 23] A range: 000ba72c00-000ba74400 size: 001800 [ 24] A range: 000ba71600-000ba71800 size: 000200 [ 25] A range: 000ba6e600-000ba6e800 size: 000200 [ 26] A range: 000ba58600-000ba58800 size: 000200 [ 27] A range: 000800fe00-0008012000 size: 002200 [ 28] ALLOC: txg 30076, pass 2 [ 29] A range: 0008283c00-0008284400 size: 000800 [ 30] FREE: txg 30076, pass 2 [ 31] F range: 000ba71600-000ba71800 size: 000200 [ 32] F range: 000800be00-000800ee00 size: 003000 [ 33] ALLOC: txg 30079, pass 1 [ 34] A range: 0008284400-0008289000 size: 004c00 [ 35] A range: 000ba74400-000be74400 size: 400000 [ 36] A range: 0009fbac00-000afbac00 size: 1000000 [ 37] A range: 000afbac00-000ba3ac00 size: a80000 [ 38] FREE: txg 30079, pass 1 [ 39] F range: 000800f400-000800fc00 size: 000800 [ 40] F range: 0008012800-0008012e00 size: 000600 [ 41] F range: 0008281e00-0008283c00 size: 001e00 [ 42] F range: 0008287200-0008287400 size: 000200 [ 43] F range: 0008014400-0008015a00 size: 001600 [ 44] ALLOC: txg 30079, pass 2 [ 45] A range: 0008289000-0008289600 size: 000600 [ 46] FREE: txg 30079, pass 2 [ 47] F range: 0008283e00-0008284400 size: 000600 [ 48] ALLOC: txg 31306, pass 1 [ 49] A range: 0008289600-000828d200 size: 003c00 [ 50] FREE: txg 31306, pass 1 [ 51] F range: 0008285400-0008287200 size: 001e00 [ 52] F range: 000828b400-000828b600 size: 000200 [ 53] F range: 0008287400-0008289000 size: 001c00 [ 54] ALLOC: txg 31306, pass 2 [ 55] A range: 000828d200-000828d800 size: 000600 [ 56] FREE: txg 31306, pass 2 [ 57] F range: 0008289000-0008289600 size: 000600 [ 58] ALLOC: txg 31306, pass 3 [ 59] A range: 000828d800-000828dc00 size: 000400 [ 60] ALLOC: txg 31306, pass 4 [ 61] A range: 000828dc00-000828ec00 size: 001000 [ 62] ALLOC: txg 31306, pass 5 [ 63] A range: 0008009600-0008009e00 size: 000800 [ 64] A range: 0008012800-0008015800 size: 003000 [ 65] A range: 000ba3ac00-000ba3ec00 size: 004000 [ 66] A range: 000828ec00-0008296c00 size: 008000 [ 67] FREE: txg 31307, pass 1 [ 68] F range: 0008009600-0008009e00 size: 000800 [ 69] F range: 000ba3ac00-000ba3ec00 size: 004000 [ 70] F range: 000828bc00-0008292c00 size: 007000 [ 71] FREE: txg 31307, pass 2 [ 72] F range: 0008001200-0008001400 size: 000200 [ 73] F range: 0008292c00-0008296c00 size: 004000 [ 74] F range: 0008012800-0008015800 size: 003000 [ 75] FREE: txg 31348, pass 1 [ 76] F range: 0008002400-0008002a00 size: 000600 [ 77] F range: 0008003600-0008003a00 size: 000400 [ 78] F range: 0008002e00-0008003200 size: 000400 [ 79] F range: 0008004600-0008004a00 size: 000400 [ 80] F range: 0008005600-0008005a00 size: 000400 [ 81] F range: 0008004e00-0008005200 size: 000400 [ 82] F range: 0008008200-0008009400 size: 001200 [ 83] F range: 0008006600-0008006a00 size: 000400 [ 84] F range: 0008005e00-0008006000 size: 000200 [ 85] F range: 0008003e00-0008004200 size: 000400 [ 86] FREE: txg 31387, pass 1 [ 87] F range: 0008009400-0008009600 size: 000200 [ 88] F range: 000ba58600-000ba58800 size: 000200 metaslab 2 offset 10000000 spacemap 50 free 66.0M segments 12 maxsize 65.8M freepct 51% manual print dump_spacemap dump_spacemap [ 0] ALLOC: txg 31387, pass 1 [ 1] A range: 0010006000-0010008000 size: 002000 [ 2] A range: 0010000e00-0010002000 size: 001200 [ 3] A range: 0010153400-0010153600 size: 000200 [ 4] A range: 0010013000-0010153000 size: 140000 [ 5] A range: 0010158800-0010158c00 size: 000400 [ 6] A range: 001029d800-00103dd800 size: 140000 [ 7] A range: 0010159000-0010299000 size: 140000 [ 8] A range: 0012369200-0013369200 size: 1000000 [ 9] A range: 0013369200-0013e2bc00 size: ac2a00 [ 10] A range: 0013e31a00-0013e34e00 size: 003400 [ 11] A range: 0013e2f600-0013e31800 size: 002200 [ 12] A range: 0013e2be00-0013e2c400 size: 000600 [ 13] A range: 00103e2000-00113e2000 size: 1000000 [ 14] A range: 00113e2000-0012362800 size: f80800 [ 15] A range: 0010156600-0010157800 size: 001200 [ 16] ALLOC: txg 31387, pass 2 [ 17] A range: 0013e34e00-0013e35800 size: 000a00 [ 18] FREE: txg 31387, pass 2 [ 19] F range: 0010001000-0010002000 size: 001000 [ 20] F range: 0010158800-0010158c00 size: 000400 [ 21] F range: 0010006000-0010008000 size: 002000 metaslab 3 offset 18000000 spacemap 0 free 128M segments 1 maxsize 128M freepct 100% manual print dump_spacemap metaslab 4 offset 20000000 spacemap 0 free 128M segments 1 maxsize 128M freepct 100% m

The value stored in offset is the offset in terms of sectors (512 byte blocks). To find the physical block byte offset from the beginning of a slice, the value inside offset must be shifted over (\<\<) by 9 (2\^9 =512) and this value must be added to 0x400000 (size of two vdev_labels and boot block). physical block address = (offset \<\< 9) + 0x400000 (4MB)

(void) printf("\t [%6llu] %c range:" " %010llx-%010llx size: %06llx\n", (u_longlong_t)(offset / sizeof (entry)), SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F', (u_longlong_t)((SM_OFFSET_DECODE(entry) \<\< mapshift) + mapstart), (u_longlong_t)((SM_OFFSET_DECODE(entry) \<\< mapshift) + mapstart + (SM_RUN_DECODE(entry) \<\< mapshift)), (u_longlong_t)(SM_RUN_DECODE(entry) \<\< mapshift));

A range: 0010156600-0010157800 size: 001200 log offset = 0x10156600, size=0x1200 phy offset = 0x10156600/512+0x400000

(gdb) bt #0 dump_spacemap (os=0x807c600, smo=smo@entry=0x80889d4, sm=sm@entry=0x8088edc) at ../../cmd/zdb/zdb.c:499 #1 0x08050226 in dump_metaslab (msp=0x80889b0) at ../../cmd/zdb/zdb.c:592 #2 0x0804c328 in dump_metaslabs (spa=\<optimized out>) at ../../cmd/zdb/zdb.c:655 #3 dump_zpool (spa=0x80608c8) at ../../cmd/zdb/zdb.c:2551 #4 main (argc=0, argv=0xbffff7e0) at ../../cmd/zdb/zdb.c:3229

zpool export \<pool> zpool import -d /dev/

sudo zpool import -d /dev/ pool: ez1 id: 3141013898880858664 state: ONLINE action: The pool can be imported using its name or numeric identifier. config:

ez1 ONLINE loop1 ONLINE

sudo zpool import -d /dev/ ez1

sudo zpool export ez1 thomas@thomas-virtual-machine:\~/source/zfs-fuse-0.7.0/src\$ sudo ./cmd/zdd/zdd /dev/loop1 open /dev/loop1 name = ez1 name = ez1 name = ez1 name = ez1 name = ez1

所以必須先import zpool

Comments