---
name: "VOP_UNLOCK"
section: "9"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/VOP_ISLOCKED"
---

# VOP\_UNLOCK(9)

serialize access to a vnode

Part of [VOP\_ISLOCKED(9)](/VOP_ISLOCKED/9.md).

## NAME

**VOP\_LOCK**, **VOP\_UNLOCK**, **VOP\_ISLOCKED**, **vn\_lock** – serialize access to a vnode

## SYNOPSIS

**#include \<sys/param.h\>**

**#include \<sys/lock.h\>**

**#include \<sys/vnode.h\>**

*int*\

**VOP\_LOCK**(*struct vnode \*vp*, *int flags*);

*int*\

**VOP\_UNLOCK**(*struct vnode \*vp*);

*int*\

**VOP\_ISLOCKED**(*struct vnode \*vp*);

*int*\

**vn\_lock**(*struct vnode \*vp*, *int flags*);

## DESCRIPTION

These calls are used to serialize access to the file system, such as to prevent two writes to the same file from happening at the same time.

The arguments are:

- *vp*

  The vnode being locked or unlocked.

- *flags*

  One of the lock request types:

  - LK\_SHARED

    Shared lock.

  - LK\_EXCLUSIVE

    Exclusive lock.

  - LK\_UPGRADE

    Shared-to-exclusive upgrade.

  - LK\_DOWNGRADE

    Exclusive-to-shared downgrade.

  - LK\_RELEASE

    Release any type of lock.

  - LK\_DRAIN

    Wait for all lock activity to end.

    The lock type may be *or*'ed with these lock flags:

    - LK\_NOWAIT

      Do not sleep to wait for lock.

    - LK\_SLEEPFAIL

      Sleep, then return failure.

    - LK\_CANRECURSE

      Allow recursive exclusive lock.

    - LK\_NOWITNESS

      Instruct [witness(4)](/witness/4.md) to ignore this instance.

      The lock type may be *or*'ed with these control flags:

      - LK\_INTERLOCK

        Specify when the caller already has a simple lock (**VOP\_LOCK**() will unlock the simple lock after getting the lock).

      - LK\_RETRY

        Retry until locked.

        Kernel code should use **vn\_lock**() to lock a vnode rather than calling **VOP\_LOCK**() directly. **vn\_lock**() also does not want a thread specified as argument but it assumes curthread to be used.

## RETURN VALUES

Zero is returned on success, otherwise an error is returned.

## SEE ALSO

[vnode(9)](/vnode/9.md)

## AUTHORS

This manual page was written by Doug Rabson.
