Documentation/translations/zh_CN/core-api/watch_queue.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/core-api/watch_queue.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/core-api/watch_queue.rst- Extension
.rst- Size
- 10494 bytes
- Lines
- 314
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
struct watch_notificationstruct watchstruct watch_notification_filterstruct watch_notification_type_filterfunction consumer
Annotated Snippet
struct watch_notification {
__u32 type:24;
__u32 subtype:8;
__u32 info;
};
“type”表示通知记录的来源,“subtype”表示该来源的记录类型(见下文观测源章节)。该类
型也可以是“WATCH_TYPE_META”。这是一个由观测队列本身在内部生成的特殊记录类型。有两
个子类型:
* WATCH_META_REMOVAL_NOTIFICATION
* WATCH_META_LOSS_NOTIFICATION
第一个表示安装了观察的对象已被删除或销毁,第二个表示某些消息已丢失。
“info”表示一系列东西,包括:
* 消息的长度,以字节为单位,包括头(带有WATCH_INFO_LENGTH的掩码,并按
WATCH_INFO_LENGTH__SHIFT移位)。这表示记录的大小,可能在8到127字节之间。
* 观测ID(带有WATCH_INFO_ID掩码,并按WATCH_INFO_ID__SHIFT移位)。这表示观测的主
叫ID,可能在0到255之间。多个观测组可以共享一个队列,这提供了一种区分它们的方法。
* 特定类型的字段(WATCH_INFO_TYPE_INFO)。这是由通知生产者设置的,以指示类型和
子类型的某些特定含义。
除长度外,信息中的所有内容都可以用于过滤。
头部后面可以有补充信息。此格式是由类型和子类型决定的。
观测列表(通知源)API
=====================
“观测列表“是订阅通知源的观测者的列表。列表可以附加到对象(比如键或超级块),也可
以是全局的(比如对于设备事件)。从用户空间的角度来看,一个非全局的观测列表通常是
通过引用它所属的对象来引用的(比如使用KEYCTL_NOTIFY并给它一个密钥序列号来观测特定
的密钥)。
为了管理观测列表,提供了以下函数:
* ::
void init_watch_list(struct watch_list *wlist,
void (*release_watch)(struct watch *wlist));
初始化一个观测列表。 如果 ``release_watch`` 不是NULL,那么这表示当watch_list对
象被销毁时,应该调用函数来丢弃观测列表对被观测对象的任何引用。
* ``void remove_watch_list(struct watch_list *wlist);``
这将删除订阅watch_list的所有观测,并释放它们,然后销毁watch_list对象本身。
观测队列(通知输出)API
=======================
“观测队列”是由应用程序分配的用以记录通知的缓冲区,其工作原理完全隐藏在管道设备驱
动中,但必须获得对它的引用才能设置观测。可以通过以下方式进行管理:
* ``struct watch_queue *get_watch_queue(int fd);``
由于观测队列在内核中通过实现缓冲区的管道的文件描述符表示,用户空间必须通过系
统调用传递该文件描述符,这可以用于从系统调用中查找指向观测队列的不透明指针。
* ``void put_watch_queue(struct watch_queue *wqueue);``
该函数用以丢弃从 ``get_watch_queue()`` 获得的引用。
Annotation
- Detected declarations: `struct watch_notification`, `struct watch`, `struct watch_notification_filter`, `struct watch_notification_type_filter`, `function consumer`.
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.