Skip to content

Commit eda3968

Browse files
amotinbehlendorf
authored andcommitted
FreeBSD: Lock vnode in zfs_ioctl()
Previously vnode was not locked there, unlike Linux. It required locking it in vn_flush_cached_data(), which recursed on the lock if called from zfs_clone_range(), having the vnode locked. Reviewed-by: Alan Somers <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#16789 Closes openzfs#16796
1 parent 6fb74ca commit eda3968

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

include/os/freebsd/spl/sys/vnode.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,16 @@ vn_is_readonly(vnode_t *vp)
9191
((vp)->v_object != NULL && \
9292
(vp)->v_object->resident_page_count > 0)
9393

94-
#ifndef IN_BASE
9594
static __inline void
9695
vn_flush_cached_data(vnode_t *vp, boolean_t sync)
9796
{
9897
if (vm_object_mightbedirty(vp->v_object)) {
9998
int flags = sync ? OBJPC_SYNC : 0;
100-
vn_lock(vp, LK_SHARED | LK_RETRY);
10199
zfs_vmobject_wlock(vp->v_object);
102100
vm_object_page_clean(vp->v_object, 0, 0, flags);
103101
zfs_vmobject_wunlock(vp->v_object);
104-
VOP_UNLOCK(vp);
105102
}
106103
}
107-
#endif
108104

109105
#define vn_exists(vp) do { } while (0)
110106
#define vn_invalid(vp) do { } while (0)

module/os/freebsd/zfs/zfs_vnops_os.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,12 @@ zfs_ioctl(vnode_t *vp, ulong_t com, intptr_t data, int flag, cred_t *cred,
291291
case F_SEEK_HOLE:
292292
{
293293
off = *(offset_t *)data;
294+
error = vn_lock(vp, LK_SHARED);
295+
if (error)
296+
return (error);
294297
/* offset parameter is in/out */
295298
error = zfs_holey(VTOZ(vp), com, &off);
299+
VOP_UNLOCK(vp);
296300
if (error)
297301
return (error);
298302
*(offset_t *)data = off;

0 commit comments

Comments
 (0)