← Documents Documentation/filesystems/dlmfs.rst GitHub 원문 ↗

Linux 6.18.37 · Filesystems

DLMFS

OCFS2 DLM cluster 준비, domain·resource inode, open flag lock mode와 LVB sharing을 다룬 전문 번역입니다.

Source pathDocumentation/filesystems/dlmfs.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

dlmfs.rst:1-140

dlmfs는 OCFS2 DLM을 filesystem call로 노출합니다. directory는 lock domain, regular inode는 resource, `open` flag는 Shared Read·Exclusive·Trylock을 나타내며 fd의 read/write로 최대 64-byte LVB를 공유합니다.

dlmfs object mapping
`mkdir` → domain joinregular inode → lock resource`open` → lock request와 fd 획득`read`·`write` → LVB 접근`close` → lock 해제`rmdir` → domain leave

filesystem object와 DLM 개념의 대응 관계입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2 .. include:: <isonum.txt>
3
4 =====
5 DLMFS
6 =====
7
8 A minimal DLM userspace interface implemented via a virtual file
9 system.
10
11 dlmfs is built with OCFS2 as it requires most of its infrastructure.
12
13 :Project web page: http://ocfs2.wiki.kernel.org
14 :Tools web page: https://github.com/markfasheh/ocfs2-tools
15 :OCFS2 mailing lists: https://subspace.kernel.org/lists.linux.dev.html
16
17 All code copyright 2005 Oracle except when otherwise noted.
18
19 Credits
20 =======
21
22 Some code taken from ramfs which is Copyright |copy| 2000 Linus Torvalds
23 and Transmeta Corp.
24
25 Mark Fasheh <mark.fasheh@oracle.com>
26
27 Caveats
28 =======
29 - Right now it only works with the OCFS2 DLM, though support for other
30 DLM implementations should not be a major issue.
31
32 Mount options
33 =============
34 None
35
36 Usage
37 =====
38
39 If you're just interested in OCFS2, then please see ocfs2.rst. The
40 rest of this document will be geared towards those who want to use
41 dlmfs for easy to setup and easy to use clustered locking in
42 userspace.
43
44 Setup
45 =====
46
47 dlmfs requires that the OCFS2 cluster infrastructure be in
48 place. Please download ocfs2-tools from the above url and configure a
49 cluster.
50
51 You'll want to start heartbeating on a volume which all the nodes in
52 your lockspace can access. The easiest way to do this is via
53 ocfs2_hb_ctl (distributed with ocfs2-tools). Right now it requires
54 that an OCFS2 file system be in place so that it can automatically
55 find its heartbeat area, though it will eventually support heartbeat
56 against raw disks.
57
58 Please see the ocfs2_hb_ctl and mkfs.ocfs2 manual pages distributed
59 with ocfs2-tools.
60
61 Once you're heartbeating, DLM lock 'domains' can be easily created /
62 destroyed and locks within them accessed.
63
64 Locking
65 =======
66
67 Users may access dlmfs via standard file system calls, or they can use
68 'libo2dlm' (distributed with ocfs2-tools) which abstracts the file
69 system calls and presents a more traditional locking api.
70
71 dlmfs handles lock caching automatically for the user, so a lock
72 request for an already acquired lock will not generate another DLM
73 call. Userspace programs are assumed to handle their own local
74 locking.
75
76 Two levels of locks are supported - Shared Read, and Exclusive.
77 Also supported is a Trylock operation.
78
79 For information on the libo2dlm interface, please see o2dlm.h,
80 distributed with ocfs2-tools.
81
82 Lock value blocks can be read and written to a resource via read(2)
83 and write(2) against the fd obtained via your open(2) call. The
84 maximum currently supported LVB length is 64 bytes (though that is an
85 OCFS2 DLM limitation). Through this mechanism, users of dlmfs can share
86 small amounts of data amongst their nodes.
87
88 mkdir(2) signals dlmfs to join a domain (which will have the same name
89 as the resulting directory)
90
91 rmdir(2) signals dlmfs to leave the domain
92
93 Locks for a given domain are represented by regular inodes inside the
94 domain directory. Locking against them is done via the open(2) system
95 call.
96
97 The open(2) call will not return until your lock has been granted or
98 an error has occurred, unless it has been instructed to do a trylock
99 operation. If the lock succeeds, you'll get an fd.
100
101 open(2) with O_CREAT to ensure the resource inode is created - dlmfs does
102 not automatically create inodes for existing lock resources.
103
104 ============ ===========================
105 Open Flag Lock Request Type
106 ============ ===========================
107 O_RDONLY Shared Read
108 O_RDWR Exclusive
109 ============ ===========================
110
111
112 ============ ===========================
113 Open Flag Resulting Locking Behavior
114 ============ ===========================
115 O_NONBLOCK Trylock operation
116 ============ ===========================
117
118 You must provide exactly one of O_RDONLY or O_RDWR.
119
120 If O_NONBLOCK is also provided and the trylock operation was valid but
121 could not lock the resource then open(2) will return ETXTBUSY.
122
123 close(2) drops the lock associated with your fd.
124
125 Modes passed to mkdir(2) or open(2) are adhered to locally. Chown is
126 supported locally as well. This means you can use them to restrict
127 access to the resources via dlmfs on your local node only.
128
129 The resource LVB may be read from the fd in either Shared Read or
130 Exclusive modes via the read(2) system call. It can be written via
131 write(2) only when open in Exclusive mode.
132
133 Once written, an LVB will be visible to other nodes who obtain Read
134 Only or higher level locks on the resource.
135
136 See Also
137 ========
138 http://opendlm.sourceforge.net/cvsmirror/opendlm/docs/dlmbook_final.pdf
139
140 For more information on the VMS distributed locking API.
141

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

DLMFS 개요, 제약과 mount option

1-34

dlmfs는 virtual filesystem을 통해 구현한 최소 DLM userspace interface입니다. OCFS2 infrastructure 대부분을 필요로 하므로 OCFS2와 함께 빌드됩니다.

프로젝트 정보는 `http://ocfs2.wiki.kernel.org`, 도구는 `https://github.com/markfasheh/ocfs2-tools`, mailing list는 `https://subspace.kernel.org/lists.linux.dev.html`에서 확인합니다. 별도 표기가 없는 코드는 2005 Oracle 저작권이며 일부 ramfs 코드는 Linus Torvalds와 Transmeta Corp.의 2000년 코드에서 가져왔습니다.

현재는 OCFS2 DLM에서만 동작합니다. 다른 DLM 구현 지원이 큰 문제는 아닐 것으로 예상하지만 아직 제공되지 않습니다. dlmfs에는 mount option이 없습니다.

dlmfs 구성 요소
요소역할
dlmfsfilesystem call 기반 최소 DLM interface
OCFS2 DLM현재 지원하는 distributed lock manager
ocfs2-toolscluster·heartbeat·libo2dlm 도구 제공
mount options없음

userspace filesystem interface가 OCFS2 cluster infrastructure에 기대는 관계입니다.

.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

=====
DLMFS
=====

A minimal DLM userspace interface implemented via a virtual file
system.

dlmfs is built with OCFS2 as it requires most of its infrastructure.

:Project web page:    http://ocfs2.wiki.kernel.org
:Tools web page:      https://github.com/markfasheh/ocfs2-tools
:OCFS2 mailing lists: https://subspace.kernel.org/lists.linux.dev.html

All code copyright 2005 Oracle except when otherwise noted.

Credits
=======

Some code taken from ramfs which is Copyright |copy| 2000 Linus Torvalds
and Transmeta Corp.

Mark Fasheh <mark.fasheh@oracle.com>

Caveats
=======
- Right now it only works with the OCFS2 DLM, though support for other
  DLM implementations should not be a major issue.

Mount options
=============
None

Cluster와 heartbeat 설정

35-63

OCFS2 filesystem 자체가 목적이면 `ocfs2.rst`를 참고합니다. 이 문서의 나머지는 userspace에서 쉽게 구성하고 사용할 수 있는 clustered locking을 위해 dlmfs를 쓰는 사용자를 대상으로 합니다.

먼저 OCFS2 cluster infrastructure를 구성해야 합니다. 위 URL에서 `ocfs2-tools`를 내려받아 cluster를 설정합니다.

lockspace의 모든 node가 접근할 수 있는 volume에서 heartbeat를 시작해야 합니다. 가장 간단한 방법은 ocfs2-tools에 포함된 `ocfs2_hb_ctl`입니다. 현재 이 도구는 heartbeat area를 자동으로 찾기 위해 OCFS2 filesystem이 있어야 하지만, 장차 raw disk heartbeat도 지원할 예정입니다.

세부 절차는 ocfs2-tools의 `ocfs2_hb_ctl`과 `mkfs.ocfs2` manual page를 참고합니다. heartbeat가 시작되면 DLM lock domain을 손쉽게 만들고 제거하며 그 안의 lock에 접근할 수 있습니다.

dlmfs 준비 순서
`ocfs2-tools` 설치OCFS2 cluster 구성모든 lockspace node가 접근하는 volume 준비`ocfs2_hb_ctl`로 heartbeat 시작dlmfs에서 lock domain 생성·제거

cluster infrastructure에서 lock domain을 사용할 수 있게 되는 단계입니다.


Usage
=====

If you're just interested in OCFS2, then please see ocfs2.rst. The
rest of this document will be geared towards those who want to use
dlmfs for easy to setup and easy to use clustered locking in
userspace.

Setup
=====

dlmfs requires that the OCFS2 cluster infrastructure be in
place. Please download ocfs2-tools from the above url and configure a
cluster.

You'll want to start heartbeating on a volume which all the nodes in
your lockspace can access. The easiest way to do this is via
ocfs2_hb_ctl (distributed with ocfs2-tools). Right now it requires
that an OCFS2 file system be in place so that it can automatically
find its heartbeat area, though it will eventually support heartbeat
against raw disks.

Please see the ocfs2_hb_ctl and mkfs.ocfs2 manual pages distributed
with ocfs2-tools.

Once you're heartbeating, DLM lock 'domains' can be easily created /
destroyed and locks within them accessed.

Lock caching, mode와 LVB

64-86

사용자는 표준 filesystem call로 dlmfs에 접근하거나 ocfs2-tools의 `libo2dlm`을 사용할 수 있습니다. libo2dlm은 filesystem call을 감추고 전통적인 locking API를 제공합니다.

dlmfs는 lock caching을 자동 처리합니다. 이미 획득한 lock을 다시 요청해도 DLM call을 새로 만들지 않습니다. 다만 같은 node 안의 local locking은 userspace program이 직접 처리한다고 가정합니다.

지원되는 lock level은 Shared Read와 Exclusive 두 가지이며 Trylock operation도 제공합니다. libo2dlm interface는 ocfs2-tools의 `o2dlm.h`를 참고합니다.

`open(2)`으로 얻은 fd에 `read(2)`와 `write(2)`를 수행하면 lock value block(LVB)을 읽고 쓸 수 있습니다. 현재 최대 LVB 길이는 64 bytes이며 이는 OCFS2 DLM의 제한입니다. 이 방식으로 node 사이에 소량의 데이터를 공유할 수 있습니다.

dlmfs lock 기능
기능동작
Shared Read공유 읽기 lock
Exclusive배타 lock과 LVB write 권한
Trylock대기하지 않는 lock 시도
Lock cache이미 획득한 lock의 중복 DLM call 억제
LVB최대 64-byte node 간 공유 data

lock mode와 별도로 LVB가 제공하는 작은 공유 데이터 영역을 구분합니다.

Locking
=======

Users may access dlmfs via standard file system calls, or they can use
'libo2dlm' (distributed with ocfs2-tools) which abstracts the file
system calls and presents a more traditional locking api.

dlmfs handles lock caching automatically for the user, so a lock
request for an already acquired lock will not generate another DLM
call. Userspace programs are assumed to handle their own local
locking.

Two levels of locks are supported - Shared Read, and Exclusive.
Also supported is a Trylock operation.

For information on the libo2dlm interface, please see o2dlm.h,
distributed with ocfs2-tools.

Lock value blocks can be read and written to a resource via read(2)
and write(2) against the fd obtained via your open(2) call. The
maximum currently supported LVB length is 64 bytes (though that is an
OCFS2 DLM limitation). Through this mechanism, users of dlmfs can share
small amounts of data amongst their nodes.

Domain·resource inode와 open flag

87-123

`mkdir(2)`는 생성되는 directory와 같은 이름의 domain에 가입하라는 신호이고, `rmdir(2)`는 그 domain에서 탈퇴하라는 신호입니다.

domain의 lock은 domain directory 안의 regular inode로 표현합니다. 해당 inode에 대한 `open(2)`이 lock request이며, trylock이 아니면 lock을 얻거나 error가 발생할 때까지 반환하지 않습니다. 성공하면 fd를 받습니다.

기존 lock resource가 있다고 해서 dlmfs가 inode를 자동으로 만들지는 않으므로, resource inode 생성을 보장하려면 `open(2)`에 `O_CREAT`를 사용합니다.

정확히 `O_RDONLY` 또는 `O_RDWR` 중 하나를 제공해야 합니다. `O_RDONLY`는 Shared Read, `O_RDWR`는 Exclusive request입니다. `O_NONBLOCK`을 함께 주면 Trylock이 됩니다.

유효한 Trylock이 resource lock을 얻지 못하면 `open(2)`은 `ETXTBUSY`를 반환합니다. `close(2)`는 fd와 연결된 lock을 해제합니다.

open flag와 dlmfs lock
Flag요청·결과
`O_CREAT`resource inode 생성 보장
`O_RDONLY`Shared Read lock
`O_RDWR`Exclusive lock
`O_NONBLOCK`Trylock operation
Trylock 실패`ETXTBUSY`
`close(2)`fd에 연결된 lock 해제

resource inode를 여는 flag가 lock mode와 대기 동작을 결정합니다.


mkdir(2) signals dlmfs to join a domain (which will have the same name
as the resulting directory)

rmdir(2) signals dlmfs to leave the domain

Locks for a given domain are represented by regular inodes inside the
domain directory.  Locking against them is done via the open(2) system
call.

The open(2) call will not return until your lock has been granted or
an error has occurred, unless it has been instructed to do a trylock
operation. If the lock succeeds, you'll get an fd.

open(2) with O_CREAT to ensure the resource inode is created - dlmfs does
not automatically create inodes for existing lock resources.

============  ===========================
Open Flag     Lock Request Type
============  ===========================
O_RDONLY      Shared Read
O_RDWR        Exclusive
============  ===========================


============  ===========================
Open Flag     Resulting Locking Behavior
============  ===========================
O_NONBLOCK    Trylock operation
============  ===========================

You must provide exactly one of O_RDONLY or O_RDWR.

If O_NONBLOCK is also provided and the trylock operation was valid but
could not lock the resource then open(2) will return ETXTBUSY.

close(2) drops the lock associated with your fd.

Local permission과 LVB visibility

124-140

`mkdir(2)`나 `open(2)`에 전달한 mode는 local node에서 지켜지며 `chown`도 local에서 지원됩니다. 따라서 이 권한은 dlmfs resource에 대한 해당 node의 접근만 제한합니다.

resource LVB는 Shared Read 또는 Exclusive mode로 연 fd에서 `read(2)`할 수 있습니다. `write(2)`는 Exclusive mode에서만 허용됩니다.

한 번 기록한 LVB는 그 resource에서 Read Only 이상의 lock을 얻은 다른 node에도 보입니다. VMS distributed locking API에 관한 추가 자료는 원문의 OpenDLM PDF를 참고합니다.

LVB 공유와 local 접근 제어
`mkdir`·`open` mode와 `chown`은 local node에만 적용Shared Read 또는 Exclusive fd에서 LVB 읽기Exclusive fd에서만 LVB 쓰기기록된 LVB는 lock을 얻은 다른 node에 공개

node-local mode와 cluster-visible LVB의 범위를 구분합니다.


Modes passed to mkdir(2) or open(2) are adhered to locally. Chown is
supported locally as well. This means you can use them to restrict
access to the resources via dlmfs on your local node only.

The resource LVB may be read from the fd in either Shared Read or
Exclusive modes via the read(2) system call. It can be written via
write(2) only when open in Exclusive mode.

Once written, an LVB will be visible to other nodes who obtain Read
Only or higher level locks on the resource.

See Also
========
http://opendlm.sourceforge.net/cvsmirror/opendlm/docs/dlmbook_final.pdf

For more information on the VMS distributed locking API.