Open trentbuck opened 2 months ago
tl;dr I'm pretty sure just adding a caching layer for lookups in recv_fix_encryption_hierarchy
would make this take O(free), since it basically spends forever ioctling on zfs list/get iteration, when the equivalent of just doing an enormous "get" or "list" once and using that data should suffice. (You'd have racing issues, in some sense, perhaps, but since you're not preventing people changing anything in the receive hierarchy or around it under you anyway, that's still true either way, I think...)
(In slightly more words - if I follow the code correctly, that function basically does "for dataset in datasets, if encrypted, go walk up and down each direction trying to find the 'closest' 'parent' for the encryptionroot", and since each of those checks is an ioctl, if you start nesting nontrivial numbers of datasets at each layer, you get sad.)
System information
6.7.12+bpo-cloud-amd64
(also6.7.12+bpo-amd64
)2.2.4-1~bpo12+1
(also2.2.3-2~bpo12+1
)Describe the problem you're observing
When doing a zfs send/recv with encryption and replication, zfs send completes after about 15 minutes, but zfs send then spends another 825 minutes using 100% of 1 CPU core.
In my test recipe, "zfs send" takes 20 seconds and generates an 18MB blob, and "zfs receive" takes 2580 seconds.
The issue appears to be proportional to the number of datasets. On a system with ~100 datasets, it is not noticeable. I asked
#openzfs
(IRC) for help with this, and someone there worked out which function was causing the problem (the issue title is what they suggested).Describe how to reproduce the problem
Here is a minimal recipe that demonstrates the time difference.
The output is: zfs.recv_fix_encryption_hierarchy.txt
Include any warning/errors/backtraces from the system logs
No errors --- the
zfs receive
process does eventually terminate, it's just very very slow.