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

# vn\_deallocate(9)

zero and/or deallocate storage from a file

## NAME

**vn\_deallocate** – zero and/or deallocate storage from a file

## SYNOPSIS

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

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

*int*\

**vn\_deallocate**(*struct vnode \*vp*, *off\_t \*offset*, *off\_t \*length*, *int flags*, *int ioflag*, *struct ucred \*active\_cred*, *struct ucred \*file\_cred*);

## DESCRIPTION

The **vn\_deallocate**() function zeros and/or deallocates backing storage space from a file. This function only works on vnodes with VREG type.

The arguments are:

- *vp*

  The vnode of the file.

- *offset*

  The starting offset of the operation range.

- *length*

  The length of the operation range. This must be greater than 0.

- *flags*

  The control flags of the operation. This should be set to 0 for now.

- *ioflag*

  Directives and hints to be given to the file system.

- *active\_cred*

  The user credentials of the calling thread.

- *file\_cred*

  The credentials installed on the file description pointing to the vnode or NOCRED.

The **ioflag**() argument gives directives and hints to the file system. It may include one or more of the following flags:

- IO\_NODELOCKED

  The vnode was locked before the call.

- IO\_RANGELOCKED

  Rangelock was owned around the call.

- IO\_NOMACCHECK

  Skip MAC checking in the call.

- IO\_SYNC

  Do I/O synchronously.

- IO\_DIRECT

  Attempt to bypass buffer cache.

*\*offset* and *\*length* are updated to reflect the unprocessed operation range of the call. For a successful completion, *\*length* is updated to be the value 0, and *\*offset* is incremented by the number of bytes zeroed before the end-of-file.

## RETURN VALUES

Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned.

## SEE ALSO

[vnode(9)](/vnode/9.md), [VOP\_DEALLOCATE(9)](/VOP_DEALLOCATE/9.md)

## AUTHORS

**vn\_deallocate** and this manual page was written by Ka Ho Ng ⟨*khng@FreeBSD.org*⟩ under sponsorship from the FreeBSD Foundation.
