Solved Cannot create ZFS cache in pool

I noticed that the zdata pool didn't contain a cache but does have the ZIL. I wanted to add a cache mirror. I created a GPT partition called cache0 on ada0 and cache1 on ada1.

Code:
root@backup:/ # gpart show -l
=>        34  5860533101  mfisyspd0  GPT  (2.7T)
          34        2014             - free -  (1.0M)
        2048  5860531080          1  data_disk0  (2.7T)
  5860533128           7             - free -  (3.5K)

  <..snip..>

=>        34  5860533101  mfisyspd9  GPT  (2.7T)
          34        2014             - free -  (1.0M)
        2048  5860531080          1  data_disk9  (2.7T)
  5860533128           7             - free -  (3.5K)

=>       34  500118125  ada0  GPT  (238G)
         34         94     1  bootcode0  (47K)
        128    2097152     2  swapada0  (1.0G)
    2097280  165150720     3  disk0  (79G)
  167248000   67108864     4  log0  (32G)
  234356864    2097152     5  cache0  (1.0G)
  236454016  263664143        - free -  (126G)

=>       34  500118125  ada1  GPT  (238G)
         34         94     1  bootcode1  (47K)
        128    2097152     2  swapada1  (1.0G)
    2097280  165150720     3  disk1  (79G)
  167248000   67108864     4  log1  (32G)
  234356864    2097152     5  cache1  (1.0G)
  236454016  263664143        - free -  (126G)

Let's find status of all ZFS pools:

[FONT=Courier New]
Code:
root@backup:/ # zpool status
  pool: zdata
state: ONLINE
  scan: scrub repaired 0 in 15h32m with 0 errors on Wed Jul  6 23:12:39 2016
config:

        NAME                  STATE  READ WRITE CKSUM
        zdata                 ONLINE    0     0     0
          raidz3-0            ONLINE    0     0     0
            gpt/data_disk0    ONLINE    0     0     0
            gpt/data_disk1    ONLINE    0     0     0
            gpt/data_disk2    ONLINE    0     0     0
            gpt/data_disk3    ONLINE    0     0     0
            gpt/data_disk4    ONLINE    0     0     0
            gpt/data_disk5    ONLINE    0     0     0
            gpt/data_disk6    ONLINE    0     0     0
            gpt/data_disk7    ONLINE    0     0     0
            gpt/data_disk8    ONLINE    0     0     0
            gpt/data_disk9    ONLINE    0     0     0
        logs
          mirror-1            ONLINE    0     0     0
            gpt/log0          ONLINE    0     0     0
            gpt/log1          ONLINE    0     0     0
errors: No known data errors

  pool: zroot
state: ONLINE
  scan: scrub repaired 0 in 0h2m with 0 errors on Wed Jul  6 07:12:24 2016
config:

        NAME             STATE   READ WRITE CKSUM
        zroot            ONLINE     0     0     0
          mirror-0       ONLINE     0     0     0
            gpt/disk0    ONLINE     0     0     0
            gpt/disk1    ONLINE     0     0     0
errors: No known data errors
[/FONT]

Let's add cache to the zdata pool:
[FONT=Courier New]
Code:
root@backup:/ # zpool add zdata cache gpt/cache0 gpt/cache1
invalid vdev specification
use '-f' to override the following errors:
/dev/gpt/cache0 is part of potentially active pool 'cache'
/dev/gpt/cache1 is part of potentially active pool 'cache'
[/FONT]
Uh oh, there appears to be an existing zfs pool by the name of cache. See if we can import it:
[FONT=Courier New]
Code:
root@backup:/ # zpool import
  pool: cache
  id: 1461940675727504241
  state: UNAVAIL
status: One or more devices contains corrupted data.
action: The pool cannot be imported due to damaged devices or data.
  see: http://illumos.org/msg/ZFS-8000-5E
config:

       cache                     UNAVAIL  insufficient replicas
         mirror-0                UNAVAIL  insufficient replicas
           11994887483163950582  UNAVAIL  corrupted data
           1506924040515699145   UNAVAIL  corrupted data
[/FONT]

Oh, it looks like someone tried to create cache as a separate ZFS pool and is now corrupt. Let's try to remove it:

[FONT=Courier New]
Code:
root@backup:/ # zpool export cache
cannot open 'cache': no such pool
root@backup:/ # zpool destroy -F cache
cannot open 'cache': no such pool
root@backup:/ #zpool clear cache
cannot open 'cache': no such pool
[/FONT]
Let's find out what ZFS thinks is the disk structure:
[FONT=Courier New]
Code:
root@backup:/ # zdb -C
zdata:
    version: 5000
    name: 'zdata'
    state: 0
    txg: 14915347
    pool_guid: 939299116
    hostid: 1679191605
    hostname: 'backup.dawnsign.com'
    vdev_children: 2
    vdev_tree:
        type: 'root'
        id: 0
        guid: 939299116
        create_txg: 4
        children[0]:
            type: 'raidz'
            id: 0
            guid: 647953515
            nparity: 3
            metaslab_array: 33
            metaslab_shift: 38
            ashift: 9
            asize: 30005869936640
            is_log: 0
            create_txg: 4
            children[0]:
                type: 'disk'
                id: 0
                guid: 265152668
                path: '/dev/gpt/data_disk0'
                phys_path: '/dev/gpt/data_disk0'
                whole_disk: 1
                DTL: 356
                create_txg: 4
            children[1]:
                type: 'disk'
                id: 1
                guid: 392323551
                path: '/dev/gpt/data_disk1'
                phys_path: '/dev/gpt/data_disk1'
                whole_disk: 1
                DTL: 355
                create_txg: 4

   <..snip..>

            children[8]:
                type: 'disk'
                id: 8
                guid: 1908467374
                path: '/dev/gpt/data_disk8'
                phys_path: '/dev/gpt/data_disk8'
                whole_disk: 1
                DTL: 348
                create_txg: 4
            children[9]:
                type: 'disk'
                id: 9
                guid: 795403226
                path: '/dev/gpt/data_disk9'
                phys_path: '/dev/gpt/data_disk9'
                whole_disk: 1
                DTL: 347
                create_txg: 4
        children[1]:
            type: 'mirror'
            id: 1
            guid: 15434186492787759721
            metaslab_array: 164
            metaslab_shift: 28
            ashift: 9
            asize: 34355019776
            is_log: 1
            create_txg: 14915345
            children[0]:
                type: 'disk'
                id: 0
                guid: 11399782678873612021
                path: '/dev/gpt/log0'
                phys_path: '/dev/gpt/log0'
                whole_disk: 1
                create_txg: 14915345
            children[1]:
                type: 'disk'
                id: 1
                guid: 3690602554018923392
                path: '/dev/gpt/log1'
                phys_path: '/dev/gpt/log1'
                whole_disk: 1
                create_txg: 14915345
  features_for_read:
      com.delphix:hole_birth
zroot:
    version: 5000
    name: 'zroot'
    state: 0
    txg: 15003274
    pool_guid: 500578219
    hostid: 1679191605
    hostname: ''
    vdev_children: 1
    vdev_tree:
        type: 'root'
        id: 0
        guid: 500578219
        children[0]:
            type: 'mirror'
            id: 0
            guid: 1524681434
            metaslab_array: 33
            metaslab_shift: 29
            ashift: 12
            asize: 84552450048
            is_log: 0
            create_txg: 4
            children[0]:
                type: 'disk'
                id: 0
                guid: 1545985234
                path: '/dev/gpt/disk0'
                phys_path: '/dev/gpt/disk0'
                whole_disk: 1
                DTL: 403
                create_txg: 4
            children[1]:
                type: 'disk'
                id: 1
                guid: 969182785
                path: '/dev/gpt/disk1'
                phys_path: '/dev/gpt/disk1'
                whole_disk: 1
                DTL: 402
                create_txg: 4
    features_for_read:
        com.delphix:hole_birth
root@backup:/ #
[/FONT]
Code:

How does one remove cache? How does one clean up a zfs pool when it doesn't have a corresponding gpart structure? It looks like /dev/ada0p[5-6] and /dev/ada1p[5-6] was destroyed some time ago prior to removing the ZFS pool thus corrupting the ZFS pool cache.

~Doug
 
Use zpool labelclear to remove all traces from the two cache devices (deletes all GPT headers as well). Then repartition the drives. Then add them to the existing pool as cache devices.

NOTE: Be sure to read the man page for zpool(8) to get the syntax for labelclear right!! Or, do it on a box that doesn't have a ZFS pool running, just in case. :)
 
Use zpool labelclear to remove all traces from the two cache devices (deletes all GPT headers as well). Then repartition the drives. Then add them to the existing pool as cache devices.

NOTE: Be sure to read the man page for zpool(8) to get the syntax for labelclear right!! Or, do it on a box that doesn't have a ZFS pool running, just in case. :)

Your suggestions did the trick!

Code:
root@backup:~ # zpool labelclear /dev/ada0p5
labelclear operation failed.
  Vdev /dev/ada0p5 is a member of the pool "cache".
  This pool is unknown to this system, but may be active on
  another system. Use 'zpool labelclear -f /dev/ada0p5' to force the
  removal of label information.
root@backup:~ # zpool labelclear /dev/ada1p5
labelclear operation failed.
  Vdev /dev/ada1p5 is a member of the pool "cache".
  This pool is unknown to this system, but may be active on
  another system. Use 'zpool labelclear -f /dev/ada1p5' to force the
  removal of label information.
root@backup:~ #
Okay, let's force it.
Code:
root@backup:~ # zpool labelclear -f /dev/ada1p5
root@backup:~ # zpool labelclear -f /dev/ada0p5
root@backup:~ # gpart list
Geom name: mfisyspd0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 5860533134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: mfisyspd0p1
  Mediasize: 3000591912960 (2.7T)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 1048576
  Mode: r1w1e2
  rawuuid: 77158a40-cf97-11e3-bd38-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: data_disk0
  length: 3000591912960
  offset: 1048576
  type: freebsd-zfs
  index: 1
  end: 5860533127
  start: 2048
Consumers:
1. Name: mfisyspd0
  Mediasize: 3000592982016 (2.7T)
  Sectorsize: 512
  Mode: r1w1e3

  <...snip...>

Geom name: mfisyspd9
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 5860533134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: mfisyspd9p1
  Mediasize: 3000591912960 (2.7T)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 1048576
  Mode: r1w1e2
  rawuuid: 776ac1be-cf97-11e3-bd38-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: data_disk9
  length: 3000591912960
  offset: 1048576
  type: freebsd-zfs
  index: 1
  end: 5860533127
  start: 2048
Consumers:
1. Name: mfisyspd9
  Mediasize: 3000592982016 (2.7T)
  Sectorsize: 512
  Mode: r1w1e3

Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 976746234
first: 6
entries: 128
scheme: GPT
Providers:
1. Name: da0p1
  Mediasize: 4000752553984 (3.6T)
  Sectorsize: 4096
  Stripesize: 0
  Stripeoffset: 24576
  Mode: r0w0e0
  rawuuid: 1e7958da-1ac0-11e5-bb28-002590e845c4
  rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
  label: master_rsync_2
  length: 4000752553984
  offset: 24576
  type: freebsd-ufs
  index: 1
  end: 976746234
  start: 6
Consumers:
1. Name: da0
  Mediasize: 4000752599040 (3.6T)
  Sectorsize: 4096
  Mode: r0w0e0

Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 500118158
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada0p1
  Mediasize: 48128 (47K)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 17408
  Mode: r0w0e0
  rawuuid: 151b6ba4-cc94-11e3-85a4-002590e845c4
  rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
  label: bootcode0
  length: 48128
  offset: 17408
  type: freebsd-boot
  index: 1
  end: 127
  start: 34
2. Name: ada0p2
  Mediasize: 1073741824 (1.0G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 65536
  Mode: r1w1e2
  rawuuid: 151ed576-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
  label: swapada0
  length: 1073741824
  offset: 65536
  type: freebsd-swap
  index: 2
  end: 2097279
  start: 128
3. Name: ada0p3
  Mediasize: 84557168640 (79G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 1073807360
  Mode: r1w1e2
  rawuuid: 1521fe67-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: disk0
  length: 84557168640
  offset: 1073807360
  type: freebsd-zfs
  index: 3
  end: 167247999
  start: 2097280
4. Name: ada0p4
  Mediasize: 34359738368 (32G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 4026597376
  Mode: r1w1e2
  rawuuid: 15247e97-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: log0
  length: 34359738368
  offset: 85630976000
  type: freebsd-zfs
  index: 4
  end: 234356863
  start: 167248000
5. Name: ada0p5
  Mediasize: 1073741824 (1.0G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 4026597376
  Mode: r0w0e0
  rawuuid: 52173e19-35a7-11e6-8c8c-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: cache0
  length: 1073741824
  offset: 119990714368
  type: freebsd-zfs
  index: 5
  end: 236454015
  start: 234356864
Consumers:
1. Name: ada0
  Mediasize: 256060514304 (238G)
  Sectorsize: 512
  Mode: r3w3e9

Geom name: ada1
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 500118158
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada1p1
  Mediasize: 48128 (47K)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 17408
  Mode: r0w0e0
  rawuuid: 152fa250-cc94-11e3-85a4-002590e845c4
  rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
  label: bootcode1
  length: 48128
  offset: 17408
  type: freebsd-boot
  index: 1
  end: 127
  start: 34
2. Name: ada1p2
  Mediasize: 1073741824 (1.0G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 65536
  Mode: r1w1e2
  rawuuid: 1532f473-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
  label: swapada1
  length: 1073741824
  offset: 65536
  type: freebsd-swap
  index: 2
  end: 2097279
  start: 128
3. Name: ada1p3
  Mediasize: 84557168640 (79G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 1073807360
  Mode: r1w1e2
  rawuuid: 153700c5-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: disk1
  length: 84557168640
  offset: 1073807360
  type: freebsd-zfs
  index: 3
  end: 167247999
  start: 2097280
4. Name: ada1p4
  Mediasize: 34359738368 (32G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 4026597376
  Mode: r1w1e2
  rawuuid: 15396945-cc94-11e3-85a4-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: log1
  length: 34359738368
  offset: 85630976000
  type: freebsd-zfs
  index: 4
  end: 234356863
  start: 167248000
5. Name: ada1p5
  Mediasize: 1073741824 (1.0G)
  Sectorsize: 512
  Stripesize: 0
  Stripeoffset: 4026597376
  Mode: r0w0e0
  rawuuid: 86517ef3-35a7-11e6-8c8c-002590e845c4
  rawtype: 516e7cba-6ecf-11d6-8ff8-00022d09712b
  label: cache1
  length: 1073741824
  offset: 119990714368
  type: freebsd-zfs
  index: 5
  end: 236454015
  start: 234356864
Consumers:
1. Name: ada1
  Mediasize: 256060514304 (238G)
  Sectorsize: 512
  Mode: r3w3e9

Geom name: da1
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 1220934394
first: 6
entries: 128
scheme: GPT
Providers:
1. Name: da1p1
  Mediasize: 5000945205248 (4.5T)
  Sectorsize: 4096
  Stripesize: 0
  Stripeoffset: 1048576
  Mode: r0w0e0
  rawuuid: b2cc374b-be2c-11e5-b123-002590e845c4
  rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
  label: master_rsync_3
  length: 5000945205248
  offset: 1048576
  type: freebsd-ufs
  index: 1
  end: 1220934143
  start: 256
Consumers:
1. Name: da1
  Mediasize: 5000947302400 (4.5T)
  Sectorsize: 4096
  Mode: r0w0e0

root@backup:~ #

After forcefully removing the ZFS labels from /dev/ada0p5 and /dev/ada1p5, I tried adding cache as follows:

Code:
root@backup:~ # zpool add zdata cache gpt/cache0 gpt/cache1
root@backup:~ # zpool status
  pool: zdata
state: ONLINE
  scan: scrub in progress since Wed Aug  3 07:40:01 2016
  5.31T scanned out of 13.8T at 315M/s, 7h52m to go
  0 repaired, 38.41% done
config:

  NAME  STATE  READ WRITE CKSUM
  zdata  ONLINE  0  0  0
  raidz3-0  ONLINE  0  0  0
  gpt/data_disk0  ONLINE  0  0  0
  gpt/data_disk1  ONLINE  0  0  0
  gpt/data_disk2  ONLINE  0  0  0
  gpt/data_disk3  ONLINE  0  0  0
  gpt/data_disk4  ONLINE  0  0  0
  gpt/data_disk5  ONLINE  0  0  0
  gpt/data_disk6  ONLINE  0  0  0
  gpt/data_disk7  ONLINE  0  0  0
  gpt/data_disk8  ONLINE  0  0  0
  gpt/data_disk9  ONLINE  0  0  0
  logs
  mirror-1  ONLINE  0  0  0
  gpt/log0  ONLINE  0  0  0
  gpt/log1  ONLINE  0  0  0
  cache
  gpt/cache0  ONLINE  0  0  0
  gpt/cache1  ONLINE  0  0  0

errors: No known data errors

  pool: zroot
state: ONLINE
  scan: scrub repaired 0 in 0h2m with 0 errors on Wed Aug  3 07:12:28 2016
config:

  NAME  STATE  READ WRITE CKSUM
  zroot  ONLINE  0  0  0
  mirror-0  ONLINE  0  0  0
  gpt/disk0  ONLINE  0  0  0
  gpt/disk1  ONLINE  0  0  0

errors: No known data errors
root@backup:~ #

Looks good! Thanks!
 
Back
Top