Skip to content

Commit

Permalink
Fix NULL pointer when O_SYNC read in snapshot
Browse files Browse the repository at this point in the history
When doing read on a file open with O_SYNC, it will trigger zil_commit.
However for snapshot, there's no zil, so we shouldn't be doing that.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Chunwei Chen <david.chen@osnexus.com>
Closes openzfs#6478 
Closes openzfs#6494
  • Loading branch information
tuxoko authored and Fabian-Gruenbichler committed Sep 28, 2017
1 parent 281ff2e commit cfbf6f6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion module/zfs/zfs_vnops.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)

/*
* If we're in FRSYNC mode, sync out this znode before reading it.
* Only do this for non-snapshots.
*/
if (ioflag & FRSYNC || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
if (zfsvfs->z_log &&
(ioflag & FRSYNC || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS))
zil_commit(zfsvfs->z_log, zp->z_id);

/*
Expand Down

0 comments on commit cfbf6f6

Please sign in to comment.