Whamcloud - gitweb
LUDOC-296 protocol: remove internal details from descriptions
[doc/protocol.git] / ldlm_lock_desc.txt
1 LDLM Lock Descriptor
2 ^^^^^^^^^^^^^^^^^^^^
3 [[struct-ldlm-lock-desc]]
4
5 The lock descriptor conveys the specific details about a particular
6 lock being requested or granted. It appears in
7 <<struct-ldlm-request>>.
8
9 ----
10 struct ldlm_lock_desc {
11         struct ldlm_resource_desc l_resource;
12         enum ldlm_mode l_req_mode;
13         enum ldlm_mode l_granted_mode;
14         union ldlm_wire_policy_data l_policy_data;
15 };
16 ----
17
18 The 'l_resource' field identifies the resource upon which the lock is
19 being requested or granted. See the description of
20 <<struct-ldlm-resource-desc>>.
21
22 The 'l_req_mode' and 'l_granted_mode' fields give the kind of lock
23 being requested and the kind of lock that has been granted. The field
24 values are:
25
26 ----
27 enum ldlm_mode {
28         LCK_EX      = 1, /* exclusive */
29         LCK_PW      = 2, /* privileged write */
30         LCK_PR      = 4, /* privileged read */
31         LCK_CW      = 8, /* concurrent write */
32         LCK_CR      = 16, /* concurrent read */
33         LCK_NL      = 32, /* */
34         LCK_GROUP   = 64, /* */
35         LCK_COS     = 128, /* */
36 };
37 ----
38 [[struct-ldlm-mode]]
39
40 Despite the fact that the lock modes are not overlapping, these lock
41 modes are exclusive.  In addition the mode value 0 is the MINMODE,
42 i.e. no lock at all.
43
44 In a request 'l_req_mode' is the value actually being requested and
45 'l_granted_mode' is the value that currently is in place on for the
46 requester. In a reply the 'l_req_mode' may be modified if more or
47 fewer privileges were granted than requested, and the
48 'l_granted_mode' is what has, in fact, been granted.
49
50 The 'l_policy_data' field gives the kind of resource being
51 requested/granted. It is a union of these struct definitions:
52 [[struct-ldlm-wire-policy-data]]
53
54 ----
55 union ldlm_wire_policy_data {
56         struct ldlm_extent l_extent;
57         struct ldlm_flock_wire l_flock;
58         struct ldlm_inodebits l_inodebits;
59 };
60 ----
61
62 ----
63 struct ldlm_extent {
64         __u64 start;
65         __u64 end;
66         __u64 gid;
67 };
68 ----
69 [[struct-ldlm-extent]]
70 ----
71 struct ldlm_flock_wire {
72         __u64 lfw_start;
73         __u64 lfw_end;
74         __u64 lfw_owner;
75         __u32 lfw_padding;
76         __u32 lfw_pid;
77 };
78 ----
79 [[struct-ldlm-flock-wire]]
80 ----
81 struct ldlm_inodebits {
82         __u64 bits;
83 };
84 ----
85 [[struct-ldlm-inodebits]]
86
87 Thus the lock may be on an 'extent', a contiguous sequence of bytes
88 in a regular file; an 'flock wire', whatever to heck that is; or a
89 portion of an inode. For a "plain" lock (or one with no type at all)
90 the 'l_policy_data' field has zero length.