搜索

C.3. Glocks

download PDF
要了解 GFS2,最重要的概念,也是与其他文件系统不同的概念就是 glocks。就源代码而言,glock 是一个数据结构,可将 DLM 和缓存带入一个单一静态机器。每个 glock 都与单一 DLM 锁定有 1:1 对应关系,并为那个锁定状态提供缓存,这样来自文件系统单一节点的竞争操作就不会重复调用 DLM,因此可帮助避免不必要的网络流量。glocks 有两个大类,即缓冲元数据的一类和不缓冲元数据的一类。内节点 glock 和资源组 glock 都可缓冲元数据,其他 glock 类型则不缓冲元数据。内节点 glock 还包括缓冲元数据以外的数据,并拥有所有 glock 中最复杂的逻辑。
表 C.1. Glock 模型和 DLM 锁定模型
Glock 模型DLM 锁定模型备注
UNIV/NL未锁定(没有与 glock 或者 NL 锁定关联的 DLM 锁定,具体要看 I 标签)
SHPR共享(读保护)锁定
EXEX排它锁
DFCW直接 I/O 和文件系统停滞时使用的延迟(同时写入)
Glocks remain in memory until either they are unlocked (at the request of another node or at the request of the VM) and there are no local users. At that point they are removed from the glock hash table and freed. When a glock is created, the DLM lock is not associated with the glock immediately. The DLM lock becomes associated with the glock upon the first request to the DLM, and if this request is successful then the 'I' (initial) flag will be set on the glock. 表 C.4 “Glock 标签” shows the meanings of the different glock flags. Once the DLM has been associated with the glock, the DLM lock will always remain at least at NL (Null) lock mode until the glock is to be freed. A demotion of the DLM lock from NL to unlocked is always the last operation in the life of a glock.

注意

从 Red Hat Enterprise Linux 5 可开始 DLM 锁行为的某些方面有了变化,即有时会将附加到 glock 的 DLM 锁完全解锁,因此Red Hat Enterprise Linux 5 有不同的机制保证在需要时保留 LVM(锁值块)。由于在 GFS2 中合并 lock_dlm 锁模块(不会与 DLM 本身混淆)而使得Red Hat Enterprise Linux 6 使用的新方案成为可能。
Each glock can have a number of "holders" associated with it, each of which represents one lock request from the higher layers. System calls relating to GFS2 queue and dequeue holders from the glock to protect the critical section of code.
使用 glock 的机器是基于工作队列(workqueue)。出于性能考虑,更倾向于使用小任务(tasklet),但在当前部署中需要从禁止其使用的上下文中提交 I/O。

注意

工作队列有其自身的跟踪点,如需要可与 GFS2 跟踪点联合使用。
表 C.2 “Glock 模式和数据类型” 显示每个 glock 模块下可能缓存的状态是什么,以及缓存的状态是否 dirty。这可适用于内节点和资源组锁,虽然资源组锁中没有数据内容,只有元数据。
表 C.2. Glock 模式和数据类型
Glock 模型缓存数据缓存元数据脏数据脏数据
UN
SH
DF
EX
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.