-
Notifications
You must be signed in to change notification settings - Fork 1.9k
FreeBSD: Intialize zlog in zvol_first_open, this prevents a NULL reference later. #11152
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
Conversation
The zil is opened on first write. It looks like the correct fix here is to check that the zvol has been written to before calling --- a/module/os/freebsd/zfs/zvol_os.c
+++ b/module/os/freebsd/zfs/zvol_os.c
@@ -891,7 +891,8 @@ zvol_cdev_open(struct cdev *dev, int flags, int fmt, struct thread *td)
if (flags & (FSYNC | FDSYNC)) {
zsd = &zv->zv_zso->zso_dev;
zsd->zsd_sync_cnt++;
- if (zsd->zsd_sync_cnt == 1)
+ if (zsd->zsd_sync_cnt == 1 &&
+ (zv->zv_flags & ZVOL_WRITTEN_TO) != 0)
zil_async_to_sync(zv->zv_zilog, ZVOL_OBJ);
}
|
That's right, for additional context see 1eacf2b which added the |
Thank you for pointing out that to me. |
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.
Thanks for the PR!
@oshogbo can you rebase this on the latest commits from the master branch and force update the PR. This will resolve the Fedora and FreeBSD build failures and let is get a proper test run with the change. |
Done. |
Check if the ZVOL has been written before calling zil_async_to_sync. The ZIL will be opened on the first write, not earlier. Signed-off-by: Mariusz Zaborski <[email protected]>
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934 git-svn-id: svn+ssh://svn.freebsd.org/base/head@367487 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
Check if the ZVOL has been written before calling zil_async_to_sync. The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Closes #11152
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934 git-svn-id: https://svn.freebsd.org/base/head@367487 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934 git-svn-id: svn+ssh://svn.freebsd.org/base/head@367487 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
Check if the ZVOL has been written before calling zil_async_to_sync. The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Closes openzfs#11152
The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> OpenZFS Pull Request: openzfs/zfs#11152 PR: 250934
Check if the ZVOL has been written before calling zil_async_to_sync. The ZIL will be opened on the first write, not earlier. Reviewed-by: Ryan Moeller <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Mariusz Zaborski <[email protected]> Closes openzfs#11152
Motivation and Context
In the past the zilog was initialized in the zvol_first_open (https://svnweb.freebsd.org/base/stable/12/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.c?revision=365689&view=markup#l842).
While the openzfs upgrade this was dropped.
This cause an page fault in the zvol_cdev_open function while accessing the ZVOL.
https://drive.google.com/file/d/1-dvj8eoUNqRWL5mcVtH5Px4NbrhLfzML/view?usp=sharing
Description
Initialize zlog in the zvol_first_open like in old version of ZFS.
How Has This Been Tested?
Tested on FreeBSD box.
Types of changes
Checklist:
Signed-off-by
.