-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Locking does not work on PEFS backed by a ZFS volume #51
Comments
monwarez - can you please try the advlock branch and see if it fixes it? |
I did a quick test and it does not, note that this times it is not a plain 13.1-rc1, I cherry picked a commit related to locking but it did not improve. So I need to test it with a cleaner environment to be sure |
Actually I tested it wrong and it doesn't work, I'll have to debug more. |
Works on: Broken on: |
If I recall correctly, it was working on 13.1-BETA1, just before the merge of openzfs 2.1 |
I found a workaround: if I
Then the test passes |
I just upgraded to |
I don't really have the time to look at it right now sorry. |
So we did some digging. The problem or one of the problems appears to be that ZFS does not properly increase the "gen" attribute for a directory when creating a file. This causes the dircache to malfunction, because based on an older directory version it decides the file does not exist. This patch fixes the issues we ran into:
|
Thanks for the debug work Robin! As a work around I think people could set |
This patch doesn't disable the cache fully, only "negative caches", eg the case where a file does not exist according to the cache. Positive cache hits are still pushed forward. |
Did some more debugging, it seems like ZFS switched the value returned for va_gen from "seq" to "z_gen" and the latter does not seem to be increased for a directory when a file is created in it. I've reported this as a bug at openzfs here: openzfs/zfs#13962 EDIT: For people who build their own FreeBSD or OpenZFS for FreeBSD I can confirm that reverting openzfs/zfs#12851 fixes the issue. |
Thanks, I did some digging on va_gen but then fell down a rabbit hole trying to work out where it was created/updated and not having any luck. I just noticed now that Does changing |
I'll check whether it works for ZFS tomorrow, but I already did a quick check and at least for tmpfs va_filerev is always 0 (hardcoded value), so its at least not a universal solution. Assuming the zfs guys do not see this as a big but intended behaviour we might need to detect what underlying fs we are mounting on to determine which cache invalidation method to use. |
Changing the contents of a directory does not make it a new directory, so the pair The way to check for modification is FWIW, I don't see tmpfs updating |
Ah thank you very much for that explanation. I tried to find some documentation on these values somewhere but really couldn't find anything that explains them. PEFS already implemented that if the va_gen value is 0 it will ignore the dircache, so I guess that will work just as well for filerev. I tested it on ZFS and it seems to work fine when we replace va_gen with va_filerev. I've created a PR with the necessary changes (properly renaming and retyping everything). |
Another possibility would be to use va_gen and va_filerev together. I think that would work for all upper file systems. |
Had a week of holiday which gave me some time to think about it and I agree that might be the best approach, will update the PR. |
Thanks, that would be very helpful! |
Just pushed it, haven't properly tested it yet, will try to do that tomorrow. |
Just build and tested it, seems to work just fine :) |
I just tested and it works, now it correctly lock the file, and also remove the lock file if not needed. |
Excellent news, three cheers for @RobinGeuze |
With PEFS mounted on /testtank/test/pefs locking does not work:
If its not mounted, or if it is backed by UFS it does work:
The text was updated successfully, but these errors were encountered: