diff options
author | Mark Johnston <[email protected]> | 2020-09-22 19:05:52 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-22 16:05:52 -0700 |
commit | 0daa0320e99437c72aac946500f445875e476010 (patch) | |
tree | bf4b0fd0395d43cb76074ee8f8701c9f1ce61321 /module/os | |
parent | 5f8a9e6a028e9528567682cb0a92addb23032787 (diff) |
Fix a logic bug in the FreeBSD getpages VOP
In commit cd32b4f5b79c ("Fix a deadlock in the FreeBSD getpages VOP") I
introduced a bug while porting the patch originally committed to
FreeBSD: the rangelock pointer may be NULL if the try operation failed,
so we must avoid calling zfs_rangelock_unlock() in that case.
Reviewed-by: Allan Jude <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Matt Macy <[email protected]>
Reported-by: Steve Wills <[email protected]>
Signed-off-by: Mark Johnston <[email protected]>
Closes #10519
Closes #10960
Diffstat (limited to 'module/os')
-rw-r--r-- | module/os/freebsd/zfs/zfs_vnops.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/module/os/freebsd/zfs/zfs_vnops.c b/module/os/freebsd/zfs/zfs_vnops.c index 2dde5b1f9..79202b60a 100644 --- a/module/os/freebsd/zfs/zfs_vnops.c +++ b/module/os/freebsd/zfs/zfs_vnops.c @@ -4859,7 +4859,8 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, obj_size = object->un_pager.vnp.vnp_size; zfs_vmobject_wunlock(object); if (IDX_TO_OFF(ma[count - 1]->pindex) >= obj_size) { - zfs_rangelock_exit(lr); + if (lr != NULL) + zfs_rangelock_exit(lr); ZFS_EXIT(zfsvfs); return (zfs_vm_pagerret_bad); } @@ -4887,7 +4888,8 @@ zfs_getpages(struct vnode *vp, vm_page_t *ma, int count, int *rbehind, error = dmu_read_pages(os, zp->z_id, ma, count, &pgsin_b, &pgsin_a, MIN(end, obj_size) - (end - PAGE_SIZE)); - zfs_rangelock_exit(lr); + if (lr != NULL) + zfs_rangelock_exit(lr); ZFS_ACCESSTIME_STAMP(zfsvfs, zp); ZFS_EXIT(zfsvfs); |