zfs disk guid

Internally generated by zfs based on "random", merely needs to be unique to ZFS itself. Done by `spa_generate_guid()` in spa_misc.c
Some archs let you "zpool status -g" to show guids as well.
zpool get guid and zpool status -g. 
blkid

python3 virtualenv on mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
Pip3 is installed with Python3
Installation
To install virtualenv via pip run:
$ pip3 install virtualenv
Usage
Creation of virtualenv:
$ virtualenv -p python3 <desired-path>
Activate the virtualenv:
$ source <desired-path>/bin/activate
Deactivate the virtualenv:
$ deactivate

zfs device removal

using currently zfs-0.6.5.6

according to the oracle docs They must have some good way to copy the data safely back to the remaining vdevs.
Background is that ZFS branched off into the Oracle proprietary ZFS and the various OpenZFS implementations. The Oracle documentation is actually great (at least I think so, it's easy to understand and provides good examples) but sometimes you can run into a feature that is documented there but not actually implemented in the OpenZFS variants. OpenZFS cannot use code from Oracle since it is proprietary, so they have to code new features themselves.
I just checked the status and zfsonlinux will support this in the next upcoming major release 0.8.0 (currently zfsonlinux is on 0.7.x and 0.8.0 is not yet released) as follows: 
    Only single device vdevs can be removed, neither mirrors nor RAID-Z vdevs. That means you can remove all devices from a mirror vdev until it is a single device vdev and then you can remove it. At least this is how I understand it will work. Since the mirror has to be broken up first, this means that there might be a small risk of pool destruction if that single device fails during the removal process. I might be wrong but if I am not, then I don't really see the point of this feature, it would be a last resort kinda thing.

zfs raidz and mirror

https://www.ixsystems.com/community/threads/some-differences-between-raidz-and-mirrors-and-why-we-use-mirrors-for-block-storage.44068/

ZFS is a complicated, powerful system. Unfortunately, it isn't actually magic, and there's a lot of opportunity for disappointment if you don't understand what's going on.

RAIDZ (including Z2, Z3) is good for storing large sequential files. ZFS will allocate long, contiguous stretches of disk for large blocks of data, compressing them, and storing the parity in an efficient manner. RAIDZ makes very good use of the raw disk space available when you are using it in this fashion. However, RAIDZ is not good at storing small blocks of data. To illustrate what I mean, consider the case where you wish to store an 8K block of data on RAIDZ3. In order to store that, you store the 8K data block, then three additional parity blocks... not efficient. Further, from an IOPS perspective, a RAIDZ vdev tends to exhibit the IOPS behaviour of a single component disk (and the slowest one, at that).

So we see a lot of people coming into the forums trying to store VM data on their 12 disk wide RAIDZ2 and wonder why their 12 disk 30 TB array sucks for performance. It's exhibiting the speed of a single disk.

The solution to this is mirrors. Mirrors aren't as good at making good use of the raw disk space (because you only end up with 1/2 or 1/3 the space), but in return for the greater resource commitment, you get much better performance. First, mirrors do not consume a variable amount of space for parity. Second, you're likely to have more vdevs. That 12 drive system we were just talking about will have 4 three-way mirrors or 6 two-way mirrors, which is 4x or 6x the number of vdevs. This translates directly to greatly enhanced performance!

Another substantial performance enhancement with ZFS is to maintain low pool occupancy rates.




For RAIDZ style file storage, it's commonly thought that performance will suffer once you pass the 80% mark, but this isn't quite right. It's a combination of fragmentation and occupancy that causes performance to suffer.

For mirrors, this is also true, but because the data being stored is often VM disk files or database files, it becomes more complicated. Because it is a copy-on-write filesystem, rewriting a block in a VM disk file causes a new block somewhere else to be allocated, and creates a hole where the old block was, when that block is freed (after any snapshots are released, etc). When writing new data, ZFS likes to allocate contiguous regions of disk to write its transaction groups. An interesting side effect of this is that if you are rewriting VM disk blocks 1, 5000, 22222, and 876543, these may actually be written as sequentially allocated blocks when ZFS dumps that transaction group to disk. A normal disk array would have to do four seeks to do those writes, but ZFS *may* be able to write them sequentially. Taken to its logical conclusion, when ZFS has massive amounts of free space available to work with, it can potentially be five or ten times faster at performing writes than a conventional disk array. The downside? ZFS will suffer if it lacks that free space.

If you want really fast VM writes, keep your occupancy rates low. As low as 10-25% if possible. Going past 50% may eventually lead to very poor performance as fragmentation grows with age and rewrites.

None of this helps with reads, of course, which over time become highly fragmented. ZFS typically mitigates this with gobs of ARC and L2ARC, which allow it to serve up the most frequently accessed data from the cache.

zpool txg_sync

Tuning needed for zfs parameters or server vm

How to tune zfs or system itself so that txg_sync is not in uninterrupted sleep state ?  ubuntu server 16.04 (kernel 4.15)installed on ZFS backed(no ext4 or xfs), below is zpool status. the server has [256 GB of memory and 46 core cpu] and HDD is 10K SAS drives(no SSD disk). the pool "root_pool" is created with below options enabledashift=12, atime=off , canmount=off ,compression=lz4,logbias=throughput,sync=disabled and No deduplication is enabled (zfs get all output in end)
zpool status 
  pool: root_pool
 state: ONLINE
  scan: none requested
config:
NAME        STATE     READ WRITE CKSUM
root_pool     ONLINE       0     0     0
  sda2      ONLINE       0     0     0
errors: No known data errors
  pool: PoolB
 state: ONLINE
  scan: none requested
config:
NAME        STATE     READ WRITE CKSUM
PoolB  ONLINE       0     0     0
  sdb       ONLINE       0     0     0
errors: No known data errors
# lsblk
NAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16  0 1T 0 disk 
├─sdb9  8:25  0 8M 0 part 
└─sdb1  8:17  0 1024G 0 part 
zd0 230:0 0 4G 0 disk 
sda 8:0 0 1T 0 disk 
├─sda2  8:2 0 1024G 0 part 
├─sda9  8:9 0 8M 0 part 
└─sda1  8:1 0 1007K 0 part 
below is a snippet of the output of iostat -x  where the %iowait value is constantly 5% to 13%
when i search for the process in interruptible sleep
S   PID CMD
D  5858 [txg_sync]
D  4356 [txg_sync]
above is process name I see 99% of the time and the pid 4356 doesn't change
Below is output of zfs getall root_pool/logs which is more io intensive
NAME     PROPERTY              VALUE                  SOURCE
root_pool  type                  filesystem             -
root_pool  creation              Wed Nov 28  8:06 2018  -
root_pool  used                  621G                   -
root_pool  available             363G                   -
root_pool  referenced            96K                    -
root_pool  compressratio         3.62x                  -
root_pool  mounted               no                     -
root_pool  quota                 none                   defau        
sda is maxed out at %util 100. And it's a single-disk pool, so that doesn't likely mean sda is failing, it just means you're asking it to do more than a single disk can do.
Tuning isn't going to fix this, you just plain need more IOPS. Your options are 1. add more vdevs to the pool or 2. replace sda with an SSD.
In general, the IOPS profile of a pool is additive of all vdevs. So you have a single vdev (whether it's one disk, or a six-disk stripe) you get one disk's worth of IOPS. You add a second vdev (again, whether single disk, or n-wide stripe) and you get another disk's worth of IOPS. This is a general trend, not a hard-and-fast exact measurement, but it's good enough for calculations.
You'll be able to roughly double the performance you're seeing now if you add another vdev to the root pool. Of course, you'll also be roughly doubling the likelihood of a failure than can bring the pool low, since you're rocking single-disk vdevs, and therefore have no parity or redundancy. Whether this is acceptable or not is up to you, but be certain you've thought through the consequences of a catastrophic pool failure.
A single decent SSD will give you three orders of magnitude more IOPS than that 10K SAS disk you're using right now. The kicker is going to be the cost per TB of storage. If you're storing a lot of data, you might need to just add more spindles instead. If you do add more vdevs, you're going to need to balance the data you've already got; this ideally would mean backing data up externally, destroying the pool, then copying the data back on board after adding the new vdevs. You canjust add the vdevs, backup the data, then delete the data (and all snapshots containing it) then copy it back on the expanded pool... but it's cleaner to just destroy it.
If you switch from single disk vdevs to mirrors, you get more options. Each vdev still only gives you a single disk worth of write IOPS, but it gives you two disks' worth of read IOPS - probably not critical for a log server - and it gives you the ability to rebalance data on-the-fly with a small risk window:
  • scrub the pool (do not skip this initial step!)
  • detach one disk from each mirror
  • create a new pool with the detached disks, and any new disks you're adding
  • replicate from old pool to new
  • quiesce any write sources
  • replicate from old to new again (will go extremely rapidly; typically <1 min)
  • destroy old pool
  • export new pool, reimport new pool with old pool's name
  • attach remaining disks from destroyed pool to disks in new pool to upgrade from single-disk vdevs to mirror vdevs again
  • de-quiesce data sources
https://www.reddit.com/r/zfs/comments/7l64mt/what_zol_performance_optimization_settings_do_you/

zfs without slog ?

Sync=disabled will indeed improve write performance, but at the cost of possibly losing data if your server crashes or loses power after a write.
I run my personal servers with sync=disabled because that's an acceptable risk to me. However, it won't be to everyone.
One case where sync=disabled is perfectly fine is when initially copying a large amount of data to the ZFS filesystem. You'll know for sure if the server crashed or shutdown during the copy, so you can leave sync disabled until the copy is complete.
One case where it's not okay is a large file server serving multiple users. If the server crashes right after a user thought he saved his file successfully, then the user finds out it didn't save, you will have an angry user on your hands.


  1. Sync writes go to in-pool ZIL (slow), async writes go to RAM
  2. See 1
  3. sync=disabled will mean that your sync writes are no longer synchronously written to disk; this opens you up to the possibility of data loss on these filesystems if there is a crash. logbias=throughput means the writes would have lower priority in the ZIL.

My sytstem has 2 pools:

1 is a data (non-bootable) 10-disk raidz2 pool that has a SLOG already (2 mirrored partitions from a pair of m.2 intel optane drives)

the other pool is a single nvme drive (970 pro) that holds the system's root filesystem. This is mainly using zfs (vs ext4/xfrs/btrfs) to allow sending/receiving snaphots from the raidz2 pool, so i can have a whole bunch of them that can all be used to restore the system without taking up space on the nvme ssd.

This is ZoL (OS is Fedora 29). so not a whole lot of sync writes by default.

Currently I have sync=standard on both, logbias=throughput on the nvme root pool, and the raiudz2 pool uses logbias=latency

Im fairly sure the raidz2 pool it set right, but with the root drive i really am not sure, and dont eve know if zfs uses the same behavior as with a pool, since any "fake-slog" writesto the drive would seeingly just be writing data to the drive normally, whereas with a pool i believe these will get directly written (not as a raidz striped write) which avoids the extra I/O that using parity adds.

I also could add another partition to the intel drives and use those as a mirrored (or striped) SLOG. nvme drive has higher max throughput, but not necessairy at low queue depths. THe optane drives also have a few other nice properties from a "preventing data loss" viewpoint (can be mirrored, use direct writing not a volatile flash cache, etc)


ChrisOfAllTrades

If sync writes are that light against the RAIDZ2 pool, I'd wonder if you really need the SLOG at all. If it's media storage and stuff where latency really doesn't matter, you could just remove it and see if there's a major impact.

As far as the root pool, the same comment I made above about the "double writes" when using in-pool ZIL apply, but if your sync writes are minimal (just running a regular OS on top of it) then I wouldn't be terribly concerned. It's more of an issue if you're using it to host VM images where lack of sync writes can cause corruption.


Oh i know it doesnt have a very big impact. My reasons for implementing it were more-or-less:
  1. it will help a little with synced writes. Even if there arent many, there are a non-zero number of them occurring.
  2. I saw some reports tat not having a SLOG could lead to pol fragmentation over time (or at least speed up how quick fragmentation occurs by a little bit)
  3. the 2x 32gb optanes set me back something like $110 bucks. Of those 64 gb, 8 gb (4 from each drive)is dedicated to the slog (mirrored, so 4 gb usable), and the other 28 gb on each driveis use is used for dual swap devices (which I neded/wanted anyways). So were talking about a $15 or so investment.
The 10x 8gb toshiba N300 drives and 1tb 970 pro set me back nearly 3 grand. So, basically if it improves things half a percent im getting my money's worth out of it.
that said, i still wasnt to set things up optimally, even if it isnt a huge difference in real-world performance.
the same comment I made above about the "double writes" when using in-pool ZIL apply,
Even with a 1-disk pool? i mean i get why youd have this in a raidz setup - you can setup the on-pool ZIL as striped (for speed) and/or mirrored (for redundancy) and avoid the I/O penalty associated with parity.
... But on a single disk, it seems like (unless im misunderstanding something) there would be literally 0 benefit by doing this over just prioritizing the sync writes, since writing to a ondisk zil wont register the writes as completed any faster than "just writing them first" but will still require re-writing them.
side question: say i partitioned off another few gb from the optane drives and made a slog for the nvme drive. Assuming a relatively small number of sync write (i,e., non-database workload), would this ever hurt the overall speed/throughput/data integrity of the root pool? (assume that there are few enough sync writes that the optane drives never hit 100% I/O capacity within a given 5 second write window).
As long as this wont hurt and might help a little i mine as well, for the same reasons i implemented it on the raidz2 pool.

Lack of SLOG + sync writes will indeed increase fragmentation due to the double writes.
Good use of the spare space on the Optane drives as swap (which you hope to tune your system never to use anyways, I assume)
Even with a 1-disk pool? i mean i get why youd have this in a raidz setup - you can setup the on-pool ZIL as striped (for speed) and/or mirrored (for redundancy) and avoid the I/O penalty associated with parity.
In-pool ZIL can't be configured, it's just "there" - you can configure your SLOG vdev(s) however you like of course, but mirrors are recommended. And yes, even on a single-disk stripe, you have an in-pool ZIL.
... But on a single disk, it seems like (unless im misunderstanding something) there would be literally 0 benefit by doing this over just prioritizing the sync writes, since writing to a ondisk zil wont register the writes as completed any faster than "just writing them first" but will still require re-writing them.
Blame the atomic nature of ZFS for this one. It still needs to order things into transaction groups (txg's) and then commit those as an unit that either succeeds or fails as a whole.
side question: say i partitioned off another few gb from the optane drives and made a slog for the nvme drive. Assuming a relatively small number of sync write (i,e., non-database workload), would this ever hurt the overall speed/throughput/data integrity of the root pool? (assume that there are few enough sync writes that the optane drives never hit 100% I/O capacity within a given 5 second write window).
Should work. Optane by design is direct-to-NAND write so you won't have to worry about competing cache flushes, and as long as you don't exceed the total bandwidth available to the underlying device it shouldn't choke the main 10-drive pool.
If we had better access to NVMe devices that supported multiple namespaces and QoS, you could actually enforce that at the hardware level. But I haven't found anything readily consumer-available with that.

##
Student
Good use of the spare space on the Optane drives as swap (which you hope to tune your system never to use anyways, I assume)
in my case its not really a matter of tuning. The system is intended for (among other things) data processing work. It has an i9-7940x that ie already maxced out with 128 gigs of fairly fast (3264 mhz 14-14-14-34) ddr4, and, well, thats just not enough.
Unfortunately, to get more from intel you have to go xeon which is a major cost hike, and going amd id lose significant performance since i can utalize avx512. plus ddr4 is stupid expensive right now.
Im hoping in the not too distant future optane + some software optimization will allow you to basically use optane drives like you would ram and use ram as effectively a L4 CPU cache. Itll never be as fdast as ram, but it doesnt need to be, it just needs to be fast enough to make sure the ram has the stuff the L3 cache is going to ask for in memory before it asks for it. And it seems like this use case is something intel is actively working on (and which would significantly increase the number of potential buyers who can actually benfit from optane), so i think it has a decent shot of actually happening
Anyways, im getting off topic.
(side note: im also rather fond of zfs since its basically the only thing i use other than MKL that utalizes avx512)
Blame the atomic nature of ZFS for this one. It still needs to order things into transaction groups (txg's) and then commit those as an unit that either succeeds or fails as a whole.
ahh, ok that sort of makes sense. Plus i resize that zfs isnt really designed with single drive pools in mind (if it were i imagine they wouldnt have labeled them as "drive pools" lol).
Should work. Optane by design is direct-to-NAND write so you won't have to worry about competing cache flushes,
this is one of the reasons I specifically got optane (vs a standard nvme) to do double duty as slog and swap. between this, low queue depth performance, and high durability, its almost like optane was designed specifically to excel as an slog / in other slog-like use cases.
Should work. Optane by design is direct-to-NAND write so you won't have to worry about competing cache flushes,
appreciate the confirmation. I cant see this ever happening unless my system, usage drastically changes. The little optane drives dont have the performance of their big brothers (like the 900p), but its performance is more than enough for the sync writes my system currently does. (performance is surprising good considering the price - id probably argue it is literally the best SLOG you can get on the planet for $20 or less, lol)

##
If you don't have an SLOG device, in-pool ZIL is extra-slow because you're writing first to the ZIL for safety, and then having to write again to the pool itself.
If you don't mind the risk of data loss to in-flight data, go ahead and set sync=disabled but do backups to other media if you value anything there.
In above quote, do you mean logbias=throughput will directly write the sync writes to the pool
As I understand it, sync writes will still hit the ZIL, but writes from datasets with logbias=latency will be serviced first, in sort of a "pre-emptive" way.
Since i dont have fast SSD for ZIL i think the disk-ZIL is use less any way
It's still going to provide safe write capacity for sync writes, it's just going to enact a significant toll on your performance while doing it.
Is there any way i can determine if the writes are sync or async or ratio of sync/async writes ?
I'm not sure if Richard Elling's zilstat script is provided with the default Ubuntu ZFS installation, but if not, you can get it from here:
I admit I haven't tried too much with ZoL.





Is there any performance impact due to different sized vdev's in a single pool ?

Is there any performance impact due to different sized vdev's in a single pool ?

I have existing pool eg. MyPool with 1 raidz vdev(3 x 500GB, 15000 rpm) and its almost 80% full. Now i want to add
5 X 1TB (15000rpm) disks on a raidz1 configuration to MyPool. But on doing so i get below warning
mismatched replication level: pool uses 3-way raidz and new vdev uses 5-way raidz
im concerned with
  1. What would be the total usable storage space i get from the newly added vdev with 1 TB disks(i assume it to be 5-1=4TB ) will it be 4TB or 1TB(same as existing raidz vdev 3-1=two 500GB disks=1TB )
  2. Are there any impact if i forcefully add them ignoring above message ?Yes, there's a performance impact. It may or may not be critical for you, and it will usually still mean better performance than having one vdev fewer in your pool.
    Let's say you have a pool with one 1T vdev. This pool, regardless of the type of vdev, will approximate the IOPS of a single disk under heavy load. (Exception: a mirror vdev will follow this rule for writes, but read IOPS will approximate the read IOPS of the total number of disks in the mirror vdev.)
    Now, let's say you have a pool with two 1T vdevs. Being of equal size, the pool will generally allocate writes evenly between the two vdevs. This pool has IOPS approximating the IOPS of two disks when under heavy load.
    Now, let's say you have a pool with one 1T vdev and one 2T vdev. The pool will generally distributes writes such that the vdevs fill up at an even rate, meaning double the writes to the 2T vdev that the 1T vdev experiences. This pool will most frequently approximate the IOPS of 1.5 disks when under heavy load - a full disk's worth of IOPS for the 2T vdev, and half a disk's worth of IOPS for the 1T vdev, which will tend to spend half its time binding on waiting for the 2T vdev to finish its crap.
    Of course, this all assumes that the pool and its vdevs are empty at the start: if you have, instead, a half-full 2T vdev and you add a new, empty 2T vdev, then even though the vdevs are the same size, you'll still approximate 1.5 disks worth of IOPS for the pool, because ZFS will still write twice as many records to the empty 2T vdev as to the already-half-full vdev, so that they'll fill up at the same rate and become full at the same time.
    It's also worth noting that reads of things already written solely to the first vdev will still come solely from that vdev, which will impact the IOPS profile of your system according to how many reads are from distributed data vs from the original data which was only one the original vdevs.
    Whew. Still with me so far?
    At the end of the day, adding the new vdev is unlikely to make your performance worse than it was before adding the new vdev - and if you're starting out with a ton of data already on one vdev with no plans to rebalance it, it probably won't be any worse than it would've been if you added a matching vdev, either.
does adding new raidz vdev with 5x 1TB disks to existing raidz vdev (3x500GB) give me additonal 4TB

Yes, roughly speaking. The size of your existing pool has no impact on how much usable space is on the new vdev; all usable space in the new vdev becomes usable space in the pool itself, no matter what.
"4T" is only roughly accurate, though. A RAIDz vdev approximates the amount of space of n-y disks, where n is the total number of disks in the vdev and y is the parity level. But it's only an approximation; you can consult an online storage calculator for a much closer estimate.