-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
module: zfs: freebsd: vfsops: use setgen for error case #12905
module: zfs: freebsd: vfsops: use setgen for error case #12905
Conversation
For further context this discrepancy was noticed in #12844 and this PR was opened to get feedback from the FreeBSD developers. Should this code include the same check as the Linux code, or should this unused variable be removed. |
module/os/freebsd/zfs/zfs_vfsops.c
Outdated
@@ -1835,6 +1835,12 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) | |||
return (SET_ERROR(EINVAL)); | |||
} | |||
|
|||
if (fid_gen > 1 || setgen != 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This predictably failed to build since setgen is declared inside the if () scope above. It is indeed not used now and should be always zero, but this check is broken.
Check for fid_gen > 1 looks just wrong to me. I am not sure why it was added here, since it can be 0 for snapshots and must be non-zero for normal dataset files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was added on the Linux side as an additional sanity check as part of 9b77d1c, which was for a Linux specific issue. I see setgen
is similarly unused in the Illumos code. So the question is, is there value in a check along these lines for FreeBSD or would you just rather entirely remove the unused code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think checking setgen would be good. It sound potentially dangerous if the same file can be addressed via different file handles.
1c455ba
to
9edd5f1
Compare
Moved |
@nabijaczleweli It may build now, but what is about my other comment? And I'd personally move the check in closer to zfsctl_lookup_objset(), where it would check for actual dataste generation, would it be filled there. |
This is the first line where both data are available; Linux code fills them in reverse order so it lives closer to |
In zfsctl_snapdir_vget() that condition is inside "if (fidp->fid_len == LONG_FID_LEN)". The way you put it here is plain wrong. |
9edd5f1
to
05745a4
Compare
Sure, anded with == LONG_FID_LEN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no more objections.
module/os/freebsd/zfs/zfs_vfsops.c
Outdated
@@ -1835,6 +1835,12 @@ zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) | |||
return (SET_ERROR(EINVAL)); | |||
} | |||
|
|||
if (fidp->fid_len == LONG_FID_LEN && (fid_gen > 1 || setgen != 0)) { | |||
dprintf("snapdir fid: fid_gen (%llu) and setgen (%llu)\n", | |||
fid_gen, setgen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've been casting these to u_longlong_t
for printing elsewhere in this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed; updated.
Based on http://build.zfsonlinux.org/builders/FreeBSD%20stable%2F13%20amd64%20%28TEST%29/builds/2977/steps/shell_1/logs/make Fix from openzfs#12844 (comment) Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
05745a4
to
35942c3
Compare
Fix from openzfs#12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes openzfs#12905
Fix from openzfs#12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes openzfs#12905
Fix from openzfs#12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes openzfs#12905
Fix from #12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #12905
Fix from openzfs#12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes openzfs#12905
Fix from openzfs#12844 (comment) Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Ryan Moeller <ryan@ixsystems.com> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes openzfs#12905
Motivation and Context
https://github.com/nabijaczleweli/zfs/pull/new/lib-ARGSUSED-spinoff-vfsops
Description
Copied from Linux.
How Has This Been Tested?
Not.
Types of changes
Checklist:
Signed-off-by
.