> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/vrele.9.md).

# vrele.9

`vput`, `vrele`, `vunref` — 减少 vnode 的使用计数

## 名称

`vput`, `vrele`, `vunref`

## 概要

```c
#include <sys/param.h>
#include <sys/vnode.h>

void
vput(struct vnode *vp)

void
vrele(struct vnode *vp)

void
vunref(struct vnode *vp)
```

## 描述

减少 vnode 的 `v_usecount` 字段。

**`vp`** 要减少计数的 vnode。

`vrele` 函数接受未锁定的 vnode，返回时 vnode 未锁定。

`vput` 函数应接受锁定的 vnode 作为参数，函数返回后 vnode 被解锁。`vput` 在操作上等同于先调用 [VOP\_UNLOCK(9)](https://github.com/FreeBSD-Ask/freebsd-man-sc/tree/main/man9/vop_lock.9.md) 再调用 `vrele`，但开销更小。

`vunref` 函数接受锁定的 vnode 作为参数，返回时 vnode 保持锁定。

系统中通过使用计数表示使用 vnode 的任何代码都应调用列出的函数之一来减少使用计数。如果非 doomed vnode 的 `v_usecount` 字段达到零，则它将被停用并放入空闲列表。

`vrele` 函数可能会锁定 vnode。所有三个函数都可能睡眠。

vnode 的保持计数始终大于或等于使用计数。非强制卸载在挂载点拥有使用计数非零的 vnode 时失败，参见 [vflush(9)](/man/man9/vflush.9.md)。

## 参见

[vget(9)](/man/man9/vget.9.md), [vnode(9)](/man/man9/vnode.9.md), [vref(9)](/man/man9/vref.9.md), [vrefcnt(9)](/man/man9/vrefcnt.9.md)

## 作者

本手册页由 Doug Rabson 和 Konstantin Belousov 编写。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/vrele.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
