Whamcloud - gitweb
LUDOC-270 doc: describe more connect flags
[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         ldlm_mode_t l_req_mode;
13         ldlm_mode_t l_granted_mode;
14         ldlm_wire_policy_data_t 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 typedef enum {
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 } ldlm_mode_t;
37 ----
38
39 Despite the fact that the lock modes are not overlapping, these lock
40 modes are exclusive.  In addition the mode value 0 is the MINMODE,
41 i.e. no lock at all.
42
43 In a request 'l_req_mode' is the value actually being requested and
44 'l_granted_mode' is the value that currently is in place on for the
45 requester. In a reply the 'l_req_mode' may be modified if more or
46 fewer privileges were granted than requested, and the
47 'l_granted_mode' is what has, in fact, been granted.
48
49 The 'l_policy_data' field gives the kind of resource being
50 requested/granted. It is a union of these struct definitions:
51 [[ldlm-wire-policy-data-t]]
52
53 ----
54 typedef union {
55         struct ldlm_extent l_extent;
56         struct ldlm_flock_wire l_flock;
57         struct ldlm_inodebits l_inodebits;
58 } ldlm_wire_policy_data_t;
59 ----
60
61 ----
62 struct ldlm_extent {
63         __u64 start;
64         __u64 end;
65         __u64 gid;
66 };
67 struct ldlm_flock_wire {
68         __u64 lfw_start;
69         __u64 lfw_end;
70         __u64 lfw_owner;
71         __u32 lfw_padding;
72         __u32 lfw_pid;
73 };
74 struct ldlm_inodebits {
75         __u64 bits;
76 };
77 ----
78
79 Thus the lock may be on an 'extent', a contiguous sequence of bytes
80 in a regular file; an 'flock wire', whatever to heck that is; or a
81 portion of an inode. For a "plain" lock (or one with no type at all)
82 the 'l_policy_data' field has zero length.
83
84