{"id":180,"date":"2010-04-04T04:11:31","date_gmt":"2010-04-04T04:11:31","guid":{"rendered":"http:\/\/poojanwagh.opalstacked.com\/techblog\/?p=180"},"modified":"2010-04-04T04:14:28","modified_gmt":"2010-04-04T04:14:28","slug":"adding-cache-device-to-zfs","status":"publish","type":"post","link":"https:\/\/tech.poojanblog.com\/blog\/unix-linux\/adding-cache-device-to-zfs\/","title":{"rendered":"Adding cache device to ZFS"},"content":{"rendered":"<p>I went ahead and bought <a title=\"Amazon Associates link\" href=\"http:\/\/www.amazon.com\/gp\/product\/B0037W5KJY?ie=UTF8&amp;tag=poojanblog-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0037W5KJY\">this USB stick<\/a> to put in the back of my Portwell machine. The idea is to use it as a device cache to speed up my ZFS tank.<br \/>\nBased on <a href=\"http:\/\/www.leidinger.net\/blog\/2010\/02\/10\/making-zfs-faster\/\">this post by Alexander Leidinger<\/a>, it should reduce latency (when data is in the cache), but not otherwise. I was also curious on whether it would reduce power consumption. I have no idea if FreeBSD powers down USB devices when they are not being actively used.<br \/>\nI don&#8217;t write to the disks frequently. At most, there&#8217;ll be a read here and there. (I use Allway Sync which keeps some metadata on the remote storage, that does need to get read. However, like rsync, it won&#8217;t write unless necessary.)<\/p>\n<p>I had the <a title=\"Amazon Associates link\" href=\"http:\/\/www.amazon.com\/gp\/product\/B001U638PM?ie=UTF8&amp;tag=poojanblog-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001U638PM\" target=\"_blank\">Kill-a-Watt<\/a> running continuously (909 hours) before I did this switch, and it measured $29.92\/year (at 0.122 cents\/kWh, 25.95 kWh). When I looked at it, the <a title=\"Amazon Associates link\" href=\"http:\/\/www.amazon.com\/gp\/product\/B001U638PM?ie=UTF8&amp;tag=poojanblog-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B001U638PM\" target=\"_blank\">Kill-a-Watt<\/a> registered 28 watts. (I think that\u2019s instantaneous, not average.)<\/p>\n<p>After doing so, I get the following <code>dmesg<\/code>:<\/p>\n<code>usbus0: 12Mbps Full Speed USB v1.0<br \/>\nusbus1: 12Mbps Full Speed USB v1.0<br \/>\nusbus2: 12Mbps Full Speed USB v1.0<br \/>\nusbus3: 480Mbps High Speed USB v2.0<br \/>\nad0: 152627MB &lt;Hitachi HTE543216L9A300 FB2OC45C&gt; at ata0-master UDMA33<br \/>\nugen0.1: &lt;Intel&gt; at usbus0<br \/>\nuhub0: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus0<br \/>\nugen1.1: &lt;Intel&gt; at usbus1<br \/>\nuhub1: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus1<br \/>\nugen2.1: &lt;Intel&gt; at usbus2<br \/>\nuhub2: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus2<br \/>\nugen3.1: &lt;Intel&gt; at usbus3<br \/>\nuhub3: &lt;Intel EHCI root HUB, class 9\/0, rev 2.00\/1.00, addr 1&gt; on usbus3<br \/>\nRoot mount waiting for: usbus3 usbus2 usbus1 usbus0<br \/>\nuhub0: 2 ports with 2 removable, self powered<br \/>\nuhub1: 2 ports with 2 removable, self powered<br \/>\nuhub2: 2 ports with 2 removable, self powered<br \/>\nRoot mount waiting for: usbus3<br \/>\nRoot mount waiting for: usbus3<br \/>\nRoot mount waiting for: usbus3<br \/>\nuhub3: 8 ports with 8 removable, self powered<br \/>\nugen3.2: &lt;MICRONET&gt; at usbus3<br \/>\numass0: &lt;MICRONET FANTOM DRIVE, class 0\/0, rev 2.00\/2.10, addr 2&gt; on usbus3<br \/>\numass0:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\nRoot mount waiting for: usbus3<br \/>\numass0:0:0:-1: Attached to scbus0<br \/>\nda0 at umass-sim0 bus 0 target 0 lun 0<br \/>\nda0: &lt;MICRONET FANTOM DRIVE 2.10&gt; Fixed Direct Access SCSI-4 device<br \/>\nda0: 40.000MB\/s transfers<br \/>\nda0: 476940MB (976773168 512 byte sectors: 255H 63S\/T 60801C)<br \/>\nugen3.3: &lt;SMI Corporation&gt; at usbus3<br \/>\numass1: &lt;SMI Corporation USB, class 0\/0, rev 2.00\/0.00, addr 3&gt; on usbus3<br \/>\numass1:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\numass1:1:1:-1: Attached to scbus1<br \/>\nda1 at umass-sim1 bus 1 target 0 lun 0<br \/>\nda1: &lt;ST 16GB 0000&gt; Removable Direct Access SCSI-0 device<br \/>\nda1: 40.000MB\/s transfers<br \/>\nda1: 15296MB (31326208 512 byte sectors: 255H 63S\/T 1949C)<br \/>\nusbd_set_config_index:523: could not read device status: USB_ERR_SHORT_XFER<br \/>\nugen3.4: &lt;Simpletech&gt; at usbus3<br \/>\numass2: &lt;MSC Bulk-Only Transfer&gt; on usbus3<br \/>\numass2:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\numass2:2:2:-1: Attached to scbus2<br \/>\nda2 at umass-sim2 bus 2 target 0 lun 0<br \/>\nda2: &lt;Hitachi HDS721010CLA332 &gt; Fixed Direct Access SCSI-2 device<br \/>\nda2: 40.000MB\/s transfers<br \/>\nda2: 953869MB (1953525168 512 byte sectors: 255H 63S\/T 121601C)<br \/>\nGEOM: da1: partition 1 does not start on a track boundary.<br \/>\nGEOM: da1: partition 1 does not end on a track boundary.<br \/>\nRoot mount waiting for: usbus3<br \/>\nugen3.5: &lt;MICRONET&gt; at usbus3<br \/>\numass3: &lt;MICRONET FANTOM DRIVE, class 0\/0, rev 2.00\/2.10, addr 5&gt; on usbus3<br \/>\numass3:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\nRoot mount waiting for: usbus3<br \/>\numass3:3:3:-1: Attached to scbus3<br \/>\nda3 at umass-sim3 bus 3 target 0 lun 0<br \/>\nda3: &lt;MICRONET FANTOM DRIVE 2.10&gt; Fixed Direct Access SCSI-4 device<br \/>\nda3: 40.000MB\/s transfers<br \/>\nda3: 953869MB (1953525168 512 byte sectors: 255H 63S\/T 121601C)<br \/>\nugen3.6: &lt;vendor 0x13d1&gt; at usbus3<br \/>\nugen2.2: &lt;Cesko&gt; at usbus2<\/code>\n<p>You\u2019ll notice from <a title=\"archived syslog post\" href=\"http:\/\/poojanwagh.opalstacked.com\/techblog\/un\/archiving-syslog-dmesg\/\">my previous post<\/a> that the drive that used to be da1 is now da2 and the drive that used to be da2 is now da3. zpool status shows:<\/p>\n<code>&gt; zpool status<br \/>\npool: tank<br \/>\nstate: UNAVAIL<br \/>\nscrub: none requested<br \/>\nconfig:<\/p>\n<p>NAME\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 STATE\u00a0\u00a0\u00a0\u00a0 READ WRITE CKSUM<br \/>\ntank\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UNAVAIL\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0 insufficient replicas<br \/>\nraidz1\u00a0\u00a0\u00a0 UNAVAIL\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0 corrupted data<br \/>\nda0s1\u00a0\u00a0 ONLINE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0<br \/>\nda1s1\u00a0\u00a0 ONLINE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0<br \/>\nda2s1\u00a0\u00a0 ONLINE\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0\u00a0 0<\/code>\n<p>I don\u2019t know for sure, but I think <a href=\"http:\/\/www.freebsd.org\/doc\/handbook\/geom-glabel.html\">glabel<\/a> would have <a href=\"http:\/\/forums.freebsd.org\/showthread.php?t=4439\">solved all this USB port-numbering nonsense<\/a>. The newly inserted USB key is now drive da1, bumping all the other drives up by one number. Anyway, at this point, it\u2019s fairly simple to play musical chairs (USB ports) with the last three drives. After doing so (and a fair amount of memory game with USB ports\/cables), I get the following <code>dmesg<\/code>:<\/p>\n<code>usbus0: 12Mbps Full Speed USB v1.0<br \/>\nusbus1: 12Mbps Full Speed USB v1.0<br \/>\nusbus2: 12Mbps Full Speed USB v1.0<br \/>\nusbus3: 480Mbps High Speed USB v2.0<br \/>\nad0: 152627MB &lt;Hitachi HTE543216L9A300 FB2OC45C&gt; at ata0-master UDMA33<br \/>\nugen0.1: &lt;Intel&gt; at usbus0<br \/>\nuhub0: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus0<br \/>\nugen1.1: &lt;Intel&gt; at usbus1<br \/>\nuhub1: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus1<br \/>\nugen2.1: &lt;Intel&gt; at usbus2<br \/>\nuhub2: &lt;Intel UHCI root HUB, class 9\/0, rev 1.00\/1.00, addr 1&gt; on usbus2<br \/>\nugen3.1: &lt;Intel&gt; at usbus3<br \/>\nuhub3: &lt;Intel EHCI root HUB, class 9\/0, rev 2.00\/1.00, addr 1&gt; on usbus3<br \/>\nRoot mount waiting for: usbus3 usbus2 usbus1 usbus0<br \/>\nuhub0: 2 ports with 2 removable, self powered<br \/>\nuhub1: 2 ports with 2 removable, self powered<br \/>\nuhub2: 2 ports with 2 removable, self powered<br \/>\nRoot mount waiting for: usbus3<br \/>\nRoot mount waiting for: usbus3<br \/>\nRoot mount waiting for: usbus3<br \/>\nuhub3: 8 ports with 8 removable, self powered<br \/>\nugen3.2: &lt;MICRONET&gt; at usbus3<br \/>\numass0: &lt;MICRONET FANTOM DRIVE, class 0\/0, rev 2.00\/2.10, addr 2&gt; on usbus3<br \/>\numass0:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\nRoot mount waiting for: usbus3<br \/>\numass0:0:0:-1: Attached to scbus0<br \/>\nda0 at umass-sim0 bus 0 target 0 lun 0<br \/>\nda0: &lt;MICRONET FANTOM DRIVE 2.10&gt; Fixed Direct Access SCSI-4 device<br \/>\nda0: 40.000MB\/s transfers<br \/>\nda0: 476940MB (976773168 512 byte sectors: 255H 63S\/T 60801C)<br \/>\nusbd_set_config_index:523: could not read device status: USB_ERR_SHORT_XFER<br \/>\nugen3.3: &lt;Simpletech&gt; at usbus3<br \/>\numass1: &lt;MSC Bulk-Only Transfer&gt; on usbus3<br \/>\numass1:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\numass1:1:1:-1: Attached to scbus1<br \/>\nda1 at umass-sim1 bus 1 target 0 lun 0<br \/>\nda1: &lt;Hitachi HDS721010CLA332 &gt; Fixed Direct Access SCSI-2 device<br \/>\nda1: 40.000MB\/s transfers<br \/>\nda1: 953869MB (1953525168 512 byte sectors: 255H 63S\/T 121601C)<br \/>\nugen3.4: &lt;MICRONET&gt; at usbus3<br \/>\numass2: &lt;MICRONET FANTOM DRIVE, class 0\/0, rev 2.00\/2.10, addr 4&gt; on usbus3<br \/>\numass2:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\numass2:2:2:-1: Attached to scbus2<br \/>\nda2 at umass-sim2 bus 2 target 0 lun 0<br \/>\nda2: &lt;MICRONET FANTOM DRIVE 2.10&gt; Fixed Direct Access SCSI-4 device<br \/>\nda2: 40.000MB\/s transfers<br \/>\nda2: 953869MB (1953525168 512 byte sectors: 255H 63S\/T 121601C)<br \/>\nugen3.5: &lt;SMI Corporation&gt; at usbus3<br \/>\numass3: &lt;SMI Corporation USB, class 0\/0, rev 2.00\/0.00, addr 5&gt; on usbus3<br \/>\numass3:\u00a0 SCSI over Bulk-Only; quirks = 0x0000<br \/>\numass3:3:3:-1: Attached to scbus3<br \/>\nda3 at umass-sim3 bus 3 target 0 lun 0<br \/>\nda3: &lt;ST 16GB 0000&gt; Removable Direct Access SCSI-0 device<br \/>\nda3: 40.000MB\/s transfers<br \/>\nda3: 15296MB (31326208 512 byte sectors: 255H 63S\/T 1949C)<br \/>\nugen3.6: &lt;vendor 0x13d1&gt; at usbus3<br \/>\nugen2.2: &lt;Cesko&gt; at usbus2<br \/>\nGEOM: da3: partition 1 does not start on a track boundary.<br \/>\nGEOM: da3: partition 1 does not end on a track boundary.<br \/>\nTrying to mount root from ufs:\/dev\/ad0s1a<br \/>\nWARNING: \/ was not properly dismounted<br \/>\nZFS filesystem version 13<br \/>\nZFS storage pool version 13<\/code>\n<p>Just to be safe, I then did a <code>zpool scrub tank<\/code>. Okay, I got impatient and cancelled it after about 25% completion.<\/p>\n<p>After that, I used glabel to give the USB flash drive a persistent label (might as well start now): <code> sudo glabel label -v pico_usb \/dev\/da3<\/code>. Then, I added the device as a cache:<\/p>\n<code>sudo zpool add tank cache \/dev\/label\/pico_usb<\/code>\n<p>I\u2019m running a scrub now. Next, up, I\u2019ll use glabel on the other drives to have them have persistent labels (irrespective of which port I plug them into).<\/p>\n<div class='wp_likes' id='wp_likes_post-180'><a class='like' href=\"javascript:wp_likes.like(180);\" title='' ><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/tech.poojanblog.com\/blog\/wp-content\/plugins\/wp-likes\/images\/like.png\" alt='' border='0'\/><\/a><span class='text'>Be the first to like.<\/span><\/p>\n<div class='like' ><a href=\"javascript:wp_likes.like(180);\">Like<\/a><\/div>\n<div class='unlike' ><a href=\"javascript:wp_likes.unlike(180);\">Unlike<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I went ahead and bought this USB stick to put in the back of my Portwell machine. The idea is to use it as a device cache to speed up my ZFS tank. Based on this post by Alexander Leidinger, it should reduce latency (when data is in the cache), but not otherwise. I was [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[10],"tags":[78,12,80,79,60,3],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-unix-linux","tag-cache","tag-freebsd","tag-glabel","tag-l2arc","tag-latency","tag-zfs"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":6,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":187,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/posts\/180\/revisions\/187"}],"wp:attachment":[{"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.poojanblog.com\/blog\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}