Skip to content

Commit 7d41b36

Browse files
amotinrkojedzinszky
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 485dd75 commit 7d41b36

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
@@ -285,8 +285,12 @@ zfs_ioctl(vnode_t *vp, ulong_t com, intptr_t data, int flag, cred_t *cred,
285285
case F_SEEK_HOLE:
286286
{
287287
off = *(offset_t *)data;
288+
error = vn_lock(vp, LK_SHARED);
289+
if (error)
290+
return (error);
288291
/* offset parameter is in/out */
289292
error = zfs_holey(VTOZ(vp), com, &off);
293+
VOP_UNLOCK(vp);
290294
if (error)
291295
return (error);
292296
*(offset_t *)data = off;

0 commit comments

Comments
 (0)