Skip to content

Commit

Permalink
FreeBSD: Lock vnode in zfs_ioctl()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amotin authored and behlendorf committed Dec 3, 2024
1 parent ecd0b15 commit 9060360
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 0 additions & 4 deletions include/os/freebsd/spl/sys/vnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,16 @@ vn_is_readonly(vnode_t *vp)
((vp)->v_object != NULL && \
(vp)->v_object->resident_page_count > 0)

#ifndef IN_BASE
static __inline void
vn_flush_cached_data(vnode_t *vp, boolean_t sync)
{
if (vm_object_mightbedirty(vp->v_object)) {
int flags = sync ? OBJPC_SYNC : 0;
vn_lock(vp, LK_SHARED | LK_RETRY);
zfs_vmobject_wlock(vp->v_object);
vm_object_page_clean(vp->v_object, 0, 0, flags);
zfs_vmobject_wunlock(vp->v_object);
VOP_UNLOCK(vp);
}
}
#endif

#define vn_exists(vp) do { } while (0)
#define vn_invalid(vp) do { } while (0)
Expand Down
4 changes: 4 additions & 0 deletions module/os/freebsd/zfs/zfs_vnops_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,12 @@ zfs_ioctl(vnode_t *vp, ulong_t com, intptr_t data, int flag, cred_t *cred,
case F_SEEK_HOLE:
{
off = *(offset_t *)data;
error = vn_lock(vp, LK_SHARED);
if (error)
return (error);
/* offset parameter is in/out */
error = zfs_holey(VTOZ(vp), com, &off);
VOP_UNLOCK(vp);
if (error)
return (error);
*(offset_t *)data = off;
Expand Down

0 comments on commit 9060360

Please sign in to comment.