diff options
author | Mariusz Zaborski <[email protected]> | 2020-11-06 02:02:19 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-11-05 17:02:19 -0800 |
commit | ae37ceadaa2a8cf09fbf1a9baafaa6dc6e24318a (patch) | |
tree | 35942a66be13b8eebfc308e413719f719241d57f /module/os | |
parent | a4246bce5024df202e7c41a682c3f74555777197 (diff) |
FreeBSD: Prevent a NULL reference in zvol_cdev_open
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
Diffstat (limited to 'module/os')
-rw-r--r-- | module/os/freebsd/zfs/zvol_os.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/module/os/freebsd/zfs/zvol_os.c b/module/os/freebsd/zfs/zvol_os.c index 0db21b575..14c43bbff 100644 --- 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); } |