1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
5 #ifndef _LUSTRE_DLM_H__
6 #define _LUSTRE_DLM_H__
8 #include <linux/kp30.h>
9 #include <linux/list.h>
11 #define OBD_LDLM_DEVICENAME "ldlm"
13 typedef int cluster_host;
14 typedef int cluster_pid;
28 /* compatibility matrix */
29 #define LCK_COMPAT_EX L2B(LCK_NL)
30 #define LCK_COMPAT_PW (LCK_COMPAT_EX | L2B(LCK_CR))
31 #define LCK_COMPAT_PR (LCK_COMPAT_PW | L2B(LCK_PR))
32 #define LCK_COMPAT_CW (LCK_COMPAT_PW | L2B(LCK_CW))
33 #define LCK_COMPAT_CR (LCK_COMPAT_CW | L2B(LCK_PR) | L2B(LCK_PW))
34 #define LCK_COMPAT_NL (LCK_COMPAT_CR | L2B(LCK_EX))
36 static ldlm_mode_t lck_compat_array[] = {
45 static inline int lockmode_compat(ldlm_mode_t a, ldlm_mode_t b)
47 if ( 0 <= a && a <= 5 ) {
50 if( 0 <= b && b <= 5 ) {
54 return 1 && (lck_compat_array[a] & L2B(b));
63 #define DLM_OST_NAMESPACE 1
64 #define DLM_MDS_NAMESPACE 2
67 - do we just separate this by security domains and use a prefix for
68 multiple namespaces in the same domain?
72 struct ldlm_namespace {
73 struct list_head ns_link; /* in the list of ns's */
74 __u32 ns_id; /* identifier of ns */
75 struct list_head *ns_hash; /* hash table for ns */
76 struct list_head ns_root_list; /* all root resources in ns */
85 #define RES_HASH_BITS 18
86 #define RES_HASH_SIZE (1UL << RES_HASH_BITS)
87 #define RES_HASH_MASK (RES_HASH_SIZE - 1)
89 #define RES_NAME_SIZE 6
90 #define RES_VERSION_SIZE 4
92 struct ldlm_resource {
93 struct list_head lr_hash;
94 struct list_head lr_rootlink; /* link all root resources in NS */
95 struct ldlm_resource *lr_parent; /* 0 for a root resource */
96 struct list_head lr_children; /* list head for child resources */
97 struct list_head lr_childof; /* part of child list of parent */
99 struct list_head lr_granted;
100 struct list_head lr_converting;
101 struct list_head lr_waiting;
102 ldlm_mode_t lr_most_restr;
103 struct ldlm_resource *lr_root;
104 //XXX cluster_host lr_master;
105 __u32 lr_name[RES_NAME_SIZE];
106 __u32 lr_version[RES_VERSION_SIZE];
110 struct ldlm_resource *lb_resource;
111 struct ldlm_lock *lb_parent;
112 struct list_head lb_children;
113 struct list_head lb_childof;
115 ldlm_mode_t lb_req_mode;
116 ldlm_mode_t lb_granted_mode;
117 void *lb_completion_ast;
118 void *lb_blocking_ast;
120 //XXX cluster_host lb_holder;
121 __u32 lb_version[RES_VERSION_SIZE];
125 struct list_head ldlm_namespaces;
128 extern struct obd_ops ldlm_obd_ops;