Whamcloud - gitweb
- More changes in the connection handle stuff. We are back to where
[fs/lustre-release.git] / lustre / include / linux / lustre_dlm.h
index 14b4e1b..6ace006 100644 (file)
@@ -30,9 +30,9 @@ typedef enum {
 #define LDLM_FL_BLOCK_GRANTED  (1 << 1)
 #define LDLM_FL_BLOCK_CONV     (1 << 2)
 #define LDLM_FL_BLOCK_WAIT     (1 << 3)
-#define LDLM_FL_DYING          (1 << 4)
+#define LDLM_FL_CBPENDING      (1 << 4)
 #define LDLM_FL_AST_SENT       (1 << 5)
-#define LDLM_FL_BLOCKED_PENDING (1 << 6)
+#define LDLM_FL_DESTROYED      (1 << 6)
 
 #define L2B(c) (1 << c)
 
@@ -100,11 +100,13 @@ struct ldlm_namespace {
 
 struct ldlm_lock;
 
-typedef int (*ldlm_lock_callback)(struct ldlm_lock *lock, struct ldlm_lock *new,
-                                  void *data, __u32 data_len,
-                                  struct ptlrpc_request **req);
+typedef int (*ldlm_lock_callback)(struct lustre_handle *lockh,
+                                  struct ldlm_lock_desc *new, void *data,
+                                  __u32 data_len);
 
 struct ldlm_lock {
+        __u64                  l_random;
+        int                   l_refc;
         struct ldlm_resource *l_resource;
         struct ldlm_lock     *l_parent;
         struct list_head      l_children;
@@ -172,6 +174,15 @@ struct ldlm_resource {
         void                  *lr_tmp;
 };
 
+struct ldlm_ast_work { 
+        struct ldlm_lock *w_lock;
+        int               w_blocking;
+        struct ldlm_lock_desc w_desc;
+        struct list_head   w_list;
+        void *w_data;
+        int w_datalen;
+};
+        
 static inline struct ldlm_extent *ldlm_res2extent(struct ldlm_resource *res)
 {
         return (struct ldlm_extent *)(res->lr_name);
@@ -179,16 +190,21 @@ static inline struct ldlm_extent *ldlm_res2extent(struct ldlm_resource *res)
 
 extern struct obd_ops ldlm_obd_ops;
 
+
+extern char *ldlm_lockname[];
+extern char *ldlm_typename[];
+
 #define LDLM_DEBUG(lock, format, a...)                          \
 do {                                                            \
         CDEBUG(D_DLMTRACE, "### " format                        \
-               " (%s: lock %p mode %d/%d on res %Lu (rc %d) "   \
-               " type %d remote %Lx)\n" , ## a,                 \
+               " (%s: lock %p mode %s/%s on res %Lu (rc %d) "   \
+               " type %s remote %Lx)\n" , ## a,                 \
                lock->l_resource->lr_namespace->ns_name, lock,   \
-               lock->l_granted_mode, lock->l_req_mode,          \
+               ldlm_lockname[lock->l_granted_mode],             \
+               ldlm_lockname[lock->l_req_mode],                 \
                lock->l_resource->lr_name[0],                    \
                atomic_read(&lock->l_resource->lr_refcount),     \
-               lock->l_resource->lr_type,                       \
+               ldlm_typename[lock->l_resource->lr_type],        \
                lock->l_remote_handle.addr);                     \
 } while (0)
 
@@ -200,29 +216,32 @@ int ldlm_extent_compat(struct ldlm_lock *, struct ldlm_lock *);
 int ldlm_extent_policy(struct ldlm_lock *, void *, ldlm_mode_t, void *);
 
 /* ldlm_lock.c */
-void ldlm_lock_free(struct ldlm_lock *lock);
+void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
+struct ldlm_lock *ldlm_handle2lock(struct lustre_handle *handle);
+void ldlm_lock2handle(struct ldlm_lock *lock, struct lustre_handle *lockh);
+void ldlm_lock_put(struct ldlm_lock *lock);
+void ldlm_lock_destroy(struct ldlm_lock *lock);
 void ldlm_lock2desc(struct ldlm_lock *lock, struct ldlm_lock_desc *desc);
-void ldlm_lock_addref(struct ldlm_lock *lock, __u32 mode);
-void ldlm_lock_decref(struct ldlm_lock *lock, __u32 mode);
-void ldlm_grant_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
-int ldlm_local_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type,
-                          void *cookie, int cookielen, ldlm_mode_t mode,
-                          struct lustre_handle *lockh);
-ldlm_error_t ldlm_local_lock_create(struct ldlm_namespace *ns,
-                                    struct lustre_handle *parent_lock_handle,
-                                    __u64 *res_id, __u32 type,
-                                     ldlm_mode_t mode,
-                                    void *data,
-                                    __u32 data_len,
-                                    struct lustre_handle *lockh);
-ldlm_error_t ldlm_local_lock_enqueue(struct lustre_handle *lockh,
-                                     void *cookie, int cookie_len,
-                                     int *flags,
-                                     ldlm_lock_callback completion,
-                                     ldlm_lock_callback blocking);
-struct ldlm_resource *ldlm_local_lock_convert(struct lustre_handle *lockh,
-                                              int new_mode, int *flags);
-struct ldlm_resource *ldlm_local_lock_cancel(struct ldlm_lock *lock);
+void ldlm_lock_addref(struct lustre_handle *lockh, __u32 mode);
+void ldlm_lock_addref_internal(struct ldlm_lock* , __u32 mode);
+void ldlm_lock_decref(struct lustre_handle *lockh, __u32 mode);
+void ldlm_grant_lock(struct ldlm_lock *lock);
+int ldlm_lock_match(struct ldlm_namespace *ns, __u64 *res_id, __u32 type,
+                    void *cookie, int cookielen, ldlm_mode_t mode,
+                    struct lustre_handle *lockh);
+struct ldlm_lock *
+ldlm_lock_create(struct ldlm_namespace *ns,
+                 struct lustre_handle *parent_lock_handle,
+                 __u64 *res_id, __u32 type, ldlm_mode_t mode, void *data,
+                 __u32 data_len);
+ldlm_error_t ldlm_lock_enqueue(struct ldlm_lock *lock, void *cookie,
+                               int cookie_len, int *flags,
+                               ldlm_lock_callback completion,
+                               ldlm_lock_callback blocking);
+struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
+                                        int *flags);
+void ldlm_lock_cancel(struct ldlm_lock *lock);
+void ldlm_run_ast_work(struct list_head *rpc_list);
 void ldlm_reprocess_all(struct ldlm_resource *res);
 void ldlm_lock_dump(struct ldlm_lock *lock);
 
@@ -237,13 +256,14 @@ int ldlm_namespace_free(struct ldlm_namespace *ns);
 struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
                                         struct ldlm_resource *parent,
                                         __u64 *name, __u32 type, int create);
-struct ldlm_resource *ldlm_resource_addref(struct ldlm_resource *res);
+struct ldlm_resource *ldlm_resource_getref(struct ldlm_resource *res);
 int ldlm_resource_put(struct ldlm_resource *res);
 void ldlm_resource_add_lock(struct ldlm_resource *res, struct list_head *head,
                             struct ldlm_lock *lock);
-int ldlm_resource_del_lock(struct ldlm_lock *lock);
+void ldlm_resource_unlink_lock(struct ldlm_lock *lock);
 void ldlm_res2desc(struct ldlm_resource *res, struct ldlm_resource_desc *desc);
 void ldlm_resource_dump(struct ldlm_resource *res);
+int ldlm_lock_change_resource(struct ldlm_lock *lock, __u64 new_resid[3]);
 
 /* ldlm_request.c */
 int ldlm_cli_enqueue(struct ptlrpc_client *cl, 
@@ -260,11 +280,11 @@ int ldlm_cli_enqueue(struct ptlrpc_client *cl,
                      void *data,
                      __u32 data_len,
                      struct lustre_handle *lockh);
-int ldlm_cli_callback(struct ldlm_lock *lock, struct ldlm_lock *new,
-                      void *data, __u32 data_len, struct ptlrpc_request **reqp);
+int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
+                    void *data, __u32 data_len);
 int ldlm_cli_convert(struct ptlrpc_client *, struct lustre_handle *,
                      int new_mode, int *flags);
-int ldlm_cli_cancel(struct ptlrpc_client *, struct ldlm_lock *);
+int ldlm_cli_cancel(struct lustre_handle *);
 
 #endif /* __KERNEL__ */