Skip to content

Commit d8fd810

Browse files
jsai20lundman
authored andcommitted
Fix zfs_open() to skip zil_async_to_sync() for the snapshot
Fix zfs_open() to skip zil_async_to_sync() for the snapshot, as it won't have any transactions. zfsvfs->z_log is NULL for the snapshot. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com> Closes openzfs#18091
1 parent 7dbc3fb commit d8fd810

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@ zfs_open(vnode_t **vpp, int flag, cred_t *cr)
242242
* Keep a count of the synchronous opens in the znode. On first
243243
* synchronous open we must convert all previous async transactions
244244
* into sync to keep correct ordering.
245+
* Skip it for snapshot, as it won't have any transactions.
245246
*/
246-
if (flag & O_SYNC) {
247+
if (!zfsvfs->z_issnap && (flag & O_SYNC)) {
247248
if (atomic_inc_32_nv(&zp->z_sync_cnt) == 1)
248249
zil_async_to_sync(zfsvfs->z_log, zp->z_id);
249250
}
@@ -264,7 +265,7 @@ zfs_close(vnode_t *vp, int flag, int count, offset_t offset, cred_t *cr)
264265
return (error);
265266

266267
/* Decrement the synchronous opens in the znode */
267-
if ((flag & O_SYNC) && (count == 1))
268+
if (!zfsvfs->z_issnap && (flag & O_SYNC) && (count == 1))
268269
atomic_dec_32(&zp->z_sync_cnt);
269270

270271
zfs_exit(zfsvfs, FTAG);

module/os/linux/zfs/zfs_vnops_os.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,9 @@ zfs_open(struct inode *ip, int mode, int flag, cred_t *cr)
200200
* Keep a count of the synchronous opens in the znode. On first
201201
* synchronous open we must convert all previous async transactions
202202
* into sync to keep correct ordering.
203+
* Skip it for snapshot, as it won't have any transactions.
203204
*/
204-
if (flag & O_SYNC) {
205+
if (!zfsvfs->z_issnap && (flag & O_SYNC)) {
205206
if (atomic_inc_32_nv(&zp->z_sync_cnt) == 1)
206207
zil_async_to_sync(zfsvfs->z_log, zp->z_id);
207208
}
@@ -222,7 +223,7 @@ zfs_close(struct inode *ip, int flag, cred_t *cr)
222223
return (error);
223224

224225
/* Decrement the synchronous opens in the znode */
225-
if (flag & O_SYNC)
226+
if (!zfsvfs->z_issnap && (flag & O_SYNC))
226227
atomic_dec_32(&zp->z_sync_cnt);
227228

228229
zfs_exit(zfsvfs, FTAG);

0 commit comments

Comments
 (0)