meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
zfs [2015/03/24 08:24] niziaklinux:fs:zfs [2021/03/02 12:59] niziak
Line 1: Line 1:
 ====== ZFS ====== ====== ZFS ======
  
-===== Creating ZFS dataset =====+[[https://lists.debian.org/debian-user/2012/05/msg01026.html]] 
 + 
 +Features: 
 +  * data pools (tanks) are abstraction aggregate block devices (simple, mirror, raidz, spares, etc) 
 +  * data set is created on data pool or another (parent) data set. 
 +  * whole data pool space is shared between dataset (no fixed partition size problem). Size of data set (and its descendants) can be limited using quota 
 +  * compression 
 +  * block level deduplication (not usable for emails with attachment, where attachment are shifted to different offset) 
 + 
 +OpenZFS2.0.0 (Dec 20) [[https://github.com/openzfs/zfs/releases/tag/zfs-2.0.0]]: 
 +  * Sequential resilver (rebuild only used by data portions) 
 +  * Persistent L2ARC cache (survives between reboots) 
 +  * ZSTD 
 +  * Redacted replication (replicate with some data excluded) 
 +  * FreeBSD and Linux unification 
 + 
 +Proposed use case: 
 +POOL created on encrypted LUKS block device.
  
 <code> <code>
 + POOL
 +   |-- /filer (quota)
 +       |- foto 
 +       |- mp3 (dedup)
 +       |- movies
 +       +- backup (copies=2, compression)
 +   |
 +   |-- /home (compression, dedup, quota)
 +   +-- /var (quota)
 +         +- log (compression)
 +</code>
 +
 +===== ZFS implementations =====
 +
 +ZFS-Fuse 0.7 is using old pool version 23, where [[http://zfsonlinux.org|ZFSonLinux]] is using pool version 28.
 +[[http://exitcode.de/?p=106|zfs-fuse vs. zfsonlinux]]
 +
 +
 +
 +===== Creating ZFS dataset =====
 +
 +<code bash>
 zpool create INBOX /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3 zpool create INBOX /dev/loop0 /dev/loop1 /dev/loop2 /dev/loop3
 </code> </code>
  
-<code>+<code bash>
 # zpool list # zpool list
 NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
Line 13: Line 52:
 </code> </code>
  
-<code>+<code bash>
 # zpool status # zpool status
   pool: INBOX   pool: INBOX
Line 32: Line 71:
 Dataset "INBOX" is also automatically created based on zpool name "INBOX". It is mounted as /INBOX Dataset "INBOX" is also automatically created based on zpool name "INBOX". It is mounted as /INBOX
  
-<code>+<code bash>
 # zfs list # zfs list
 NAME    USED  AVAIL  REFER  MOUNTPOINT NAME    USED  AVAIL  REFER  MOUNTPOINT
Line 61: Line 100:
 zfs set dedup=on INBOX zfs set dedup=on INBOX
 </code> </code>
 +New attributed applies only to newly written data.
  
-Tests+Tests
 For test I was using 3 files 16MB each of random data (/dev/urandom): B1, B2 and B3 For test I was using 3 files 16MB each of random data (/dev/urandom): B1, B2 and B3
 +Above 3 files takes 38,6M on disc:
 +<code>
 +# zdb -S INBOX
 +Simulated DDT histogram:
  
-===== Compression =====+bucket              allocated                       referenced 
 +______   ______________________________   ______________________________ 
 +refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE 
 +------   ------   -----   -----   -----   ------   -----   -----   ----- 
 +          309   38.6M   38.6M   38.6M      309   38.6M   38.6M   38.6M 
 + Total      309   38.6M   38.6M   38.6M      309   38.6M   38.6M   38.6M
  
-Enable compression and dedupliaction in parent dataset (will be inherited by childs)+dedup = 1.00, compress = 1.00, copies = 1.00, dedup * compress / copies = 1.00 
 +</code>
  
 +Additionaly one big file with content B1|B2|B3 was added to filesystem:
 <code> <code>
-zfs set dedup=on INBOX +# zdb -S INBOX 
-zfs set compression=on INBOX +Simulated DDT histogram:
-</code>+
  
-But new attributed applies only to newly written data.+bucket              allocated                       referenced 
 +______   ______________________________   ______________________________ 
 +refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE 
 +------   ------   -----   -----   -----   ------   -----   -----   ----- 
 +          384     48M     48M     48M      768     96M     96M     96M 
 + Total      384     48M     48M     48M      768     96M     96M     96M 
 + 
 +dedup = 2.00, compress = 1.00, copies = 1.00, dedup * compress / copies = 2.00
  
-<code> 
-NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT 
-INBOX   975M   724M   251M    74%  1.00x  ONLINE  - 
 </code> </code>
  
-The same data copied again to dataset after compression enabled+Additionaly one big file with content B1|B2|B3|B1|B2|B3 was added to filesystem: 
 +<code> 
 +# zdb -S INBOX 
 +Simulated DDT histogram:
  
 +bucket              allocated                       referenced
 +______   ______________________________   ______________________________
 +refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
 +------   ------   -----   -----   -----   ------   -----   -----   -----
 +          384     48M     48M     48M    1.50K    192M    192M    192M
 + Total      384     48M     48M     48M    1.50K    192M    192M    192M
 +
 +dedup = 4.00, compress = 1.00, copies = 1.00, dedup * compress / copies = 4.00
 +
 +</code>
 +
 +Next, new file with content 0|B1|B2|B3 (one dummy byte plus B1|B2|B3) was added:
 <code> <code>
-NAME    SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT +# zdb -S INBOX 
-INBOX   975M   563M   412M    57%  1.00x  ONLINE  -+Simulated DDT histogram: 
 + 
 +bucket              allocated                       referenced 
 +______   ______________________________   ______________________________ 
 +refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE 
 +------   ------   -----   -----   -----   ------   -----   -----   ----- 
 +          385   48.1M   48.1M   48.1M      385   48.1M   48.1M   48.1M 
 +          384     48M     48M     48M    1.50K    192M    192M    192M 
 + Total      769   96.1M   96.1M   96.1M    1.88K    240M    240M    240M 
 + 
 +dedup = 2.50, compress = 1.00, copies = 1.00, dedup * compress / copies = 2.50
 </code> </code>
  
-zdb -S INBOX+**So ZFS cannot match shifted data and make deduplication!**
  
-zdb -b INBOX+Additional simple test. Two files: 
 +|0|B1|0|B2|0|B3|0| 
 +|0|B1|B2|B3| 
 +Only beginning of both files |0|B1| was deduplicated (16MB saved)
  
-====== Tests: ======+ZFS provides block level deduplication based on block checksums which we got almost for free.
  
-Filesystem was tested with 648MiB of e-mail stored in Maildir format (lots of binary attachment encoded as BASE64). 
  
-SquashFS=365MB vs ZFS=563MB+===== Compression =====
  
-Deduplication:+Enable compression and dedupliaction in parent dataset (will be inherited by childs)
  
-Deduplication on file level works on ZFS and SquashFS (the same folder copied again).+<code> 
 +zfs set compression=on INBOX 
 +</code> 
 +Possible parameters for compression=on | off | lzjb | gzip | gzip-[1-9] | zle 
 +New attributed applies only to newly written data. For test data I was using Maildir with some huge e-mails.
  
-Deduplication of 2 different 32MB blobs, with file concatenated from blob1 blob2 | 0 | blob1 blob2 |0|+^compression ^ logical size  ^ physical size^ ratio  
 +|off           702 MB      703 MB       1.  | 
 +|on = lzjb     702 MB      531 MB       | 1.32  | 
 +|gzip-1      |   702 MB      | 374 MB       | 1.87  | 
 +|gzip=gzip-6 |   702 MB      | 359 MB       | 1.95  | 
 +|gzip-9      |   702 MB      | 353 MB       | 1.96  | 
 +|-- 
 +|squashfs    |               | 365 MB             |
  
-Deduplication on the same attachment inside different email doesn't work in ZFS. 
  
-====== References: ======+zdb -S INBOX 
 +zdb -b INBOX 
 + 
 + 
 + 
 +<code bash> 
 +zfs get compressratio 
 +</code> 
 + 
 +===== References: ===== 
 +[[http://docs.oracle.com/cd/E19253-01/819-5461/6n7ht6qu6/index.html]] 
 +[[https://wiki.freebsd.org/ZFSQuickStartGuide]]
  
 [[http://www.funtoo.org/ZFS_Fun|http://www.funtoo.org/ZFS_Fun]] [[http://www.funtoo.org/ZFS_Fun|http://www.funtoo.org/ZFS_Fun]]