From: Chunwei Chen Date: Fri, 11 Aug 2017 15:57:54 +0000 (-0700) Subject: Fix NULL pointer when O_SYNC read in snapshot X-Git-Tag: zfs-0.7.2~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aec43188702b16f805aa71234a4dc5c60398af43;p=zfs Fix NULL pointer when O_SYNC read in snapshot 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 Reviewed-by: George Melikov Signed-off-by: Chunwei Chen Closes #6478 Closes #6494 --- diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index d415e8024..7e2413076 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -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); /*