diff --git a/module/os/freebsd/zfs/zfs_znode_os.c b/module/os/freebsd/zfs/zfs_znode_os.c index 649022ab5..b9f427b39 100644 --- a/module/os/freebsd/zfs/zfs_znode_os.c +++ b/module/os/freebsd/zfs/zfs_znode_os.c @@ -121,11 +121,12 @@ zfs_rangelock_cb(zfs_locked_range_t *new, void *arg) } /* - * If we need to grow the block size then lock the whole file range. + * If we might grow the block size then lock the whole file range. + * NB: this test should match the check in zfs_grow_blocksize */ uint64_t end_size = MAX(zp->z_size, new->lr_offset + new->lr_length); - if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) || - zp->z_blksz < ZTOZSB(zp)->z_max_blksz)) { + if (zp->z_size <= zp->z_blksz && end_size > zp->z_blksz && + (!ISP2(zp->z_blksz) || zp->z_blksz < ZTOZSB(zp)->z_max_blksz)) { new->lr_offset = 0; new->lr_length = UINT64_MAX; } diff --git a/module/os/linux/zfs/zfs_znode_os.c b/module/os/linux/zfs/zfs_znode_os.c index bcaabeb32..03976d01a 100644 --- a/module/os/linux/zfs/zfs_znode_os.c +++ b/module/os/linux/zfs/zfs_znode_os.c @@ -95,11 +95,12 @@ zfs_rangelock_cb(zfs_locked_range_t *new, void *arg) } /* - * If we need to grow the block size then lock the whole file range. + * If we might grow the block size then lock the whole file range. + * NB: this test should match the check in zfs_grow_blocksize */ uint64_t end_size = MAX(zp->z_size, new->lr_offset + new->lr_length); - if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) || - zp->z_blksz < ZTOZSB(zp)->z_max_blksz)) { + if (zp->z_size <= zp->z_blksz && end_size > zp->z_blksz && + (!ISP2(zp->z_blksz) || zp->z_blksz < ZTOZSB(zp)->z_max_blksz)) { new->lr_offset = 0; new->lr_length = UINT64_MAX; }