Whamcloud - gitweb
LU-1214 ldlm: splits server specific lock handling from client
authorLiu Xuezhao <xuezhao.liu@emc.com>
Fri, 16 Mar 2012 04:30:07 +0000 (12:30 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 7 May 2012 18:50:41 +0000 (14:50 -0400)
Splits/removes these server-side specific lock handlings:
1. Server-side blocking/completion/glimpse AST
2. ldlm_cancel_service
3. Resource policy functions
4. ldlm_handle_enqueue /ldlm_handle_convert etc.

Uses "HAVE_SERVER_SUPPORT" to comment out those server-side codes.

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Change-Id: Ia5b607715a45737182932bf5ec90bda9199eaf07
Reviewed-on: http://review.whamcloud.com/2361
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_extent.c
lustre/ldlm/ldlm_flock.c
lustre/ldlm/ldlm_inodebits.c
lustre/ldlm/ldlm_internal.h
lustre/ldlm/ldlm_lock.c
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_plain.c

index b1f778d..81c38cf 100644 (file)
@@ -960,28 +960,43 @@ int ldlm_flock_completion_ast(struct ldlm_lock *lock, int flags, void *data);
 /* ldlm_extent.c */
 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms);
 
 /* ldlm_extent.c */
 __u64 ldlm_extent_shift_kms(struct ldlm_lock *lock, __u64 old_kms);
 
+struct ldlm_callback_suite {
+        ldlm_completion_callback lcs_completion;
+        ldlm_blocking_callback   lcs_blocking;
+        ldlm_glimpse_callback    lcs_glimpse;
+        ldlm_weigh_callback      lcs_weigh;
+};
 
 /* ldlm_lockd.c */
 
 /* ldlm_lockd.c */
+#ifdef HAVE_SERVER_SUPPORT
 int ldlm_server_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
                              void *data, int flag);
 int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data);
 int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data);
 int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_completion_callback,
                         ldlm_blocking_callback, ldlm_glimpse_callback);
 int ldlm_server_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *,
                              void *data, int flag);
 int ldlm_server_completion_ast(struct ldlm_lock *lock, int flags, void *data);
 int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data);
 int ldlm_handle_enqueue(struct ptlrpc_request *req, ldlm_completion_callback,
                         ldlm_blocking_callback, ldlm_glimpse_callback);
+int ldlm_handle_enqueue0(struct ldlm_namespace *ns, struct ptlrpc_request *req,
+                         const struct ldlm_request *dlm_req,
+                         const struct ldlm_callback_suite *cbs);
 int ldlm_handle_convert(struct ptlrpc_request *req);
 int ldlm_handle_convert(struct ptlrpc_request *req);
+int ldlm_handle_convert0(struct ptlrpc_request *req,
+                         const struct ldlm_request *dlm_req);
 int ldlm_handle_cancel(struct ptlrpc_request *req);
 int ldlm_request_cancel(struct ptlrpc_request *req,
                         const struct ldlm_request *dlm_req, int first);
 int ldlm_handle_cancel(struct ptlrpc_request *req);
 int ldlm_request_cancel(struct ptlrpc_request *req,
                         const struct ldlm_request *dlm_req, int first);
+void ldlm_revoke_export_locks(struct obd_export *exp);
+#endif
 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
 int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout);
 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
 int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout);
-void ldlm_revoke_export_locks(struct obd_export *exp);
 int ldlm_get_ref(void);
 void ldlm_put_ref(void);
 int ldlm_init_export(struct obd_export *exp);
 void ldlm_destroy_export(struct obd_export *exp);
 
 /* ldlm_lock.c */
 int ldlm_get_ref(void);
 void ldlm_put_ref(void);
 int ldlm_init_export(struct obd_export *exp);
 void ldlm_destroy_export(struct obd_export *exp);
 
 /* ldlm_lock.c */
+#ifdef HAVE_SERVER_SUPPORT
 ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
 ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res);
+#endif
 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
 void ldlm_lock2handle(const struct ldlm_lock *lock,
                       struct lustre_handle *lockh);
 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg);
 void ldlm_lock2handle(const struct ldlm_lock *lock,
                       struct lustre_handle *lockh);
@@ -1143,13 +1158,6 @@ int ldlm_lock_change_resource(struct ldlm_namespace *, struct ldlm_lock *,
         lu_ref_del(&(res)->lr_reference, __FUNCTION__, cfs_current());  \
 } while (0)
 
         lu_ref_del(&(res)->lr_reference, __FUNCTION__, cfs_current());  \
 } while (0)
 
-struct ldlm_callback_suite {
-        ldlm_completion_callback lcs_completion;
-        ldlm_blocking_callback   lcs_blocking;
-        ldlm_glimpse_callback    lcs_glimpse;
-        ldlm_weigh_callback      lcs_weigh;
-};
-
 /* ldlm_request.c */
 int ldlm_expired_completion_wait(void *data);
 int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock);
 /* ldlm_request.c */
 int ldlm_expired_completion_wait(void *data);
 int ldlm_blocking_ast_nocheck(struct ldlm_lock *lock);
@@ -1172,9 +1180,6 @@ int ldlm_prep_elc_req(struct obd_export *exp,
                       struct ptlrpc_request *req,
                       int version, int opc, int canceloff,
                       cfs_list_t *cancels, int count);
                       struct ptlrpc_request *req,
                       int version, int opc, int canceloff,
                       cfs_list_t *cancels, int count);
-int ldlm_handle_enqueue0(struct ldlm_namespace *ns, struct ptlrpc_request *req,
-                         const struct ldlm_request *dlm_req,
-                         const struct ldlm_callback_suite *cbs);
 int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
                           ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode,
                           int *flags, void *lvb, __u32 lvb_len,
 int ldlm_cli_enqueue_fini(struct obd_export *exp, struct ptlrpc_request *req,
                           ldlm_type_t type, __u8 with_policy, ldlm_mode_t mode,
                           int *flags, void *lvb, __u32 lvb_len,
@@ -1193,8 +1198,6 @@ int ldlm_server_ast(struct lustre_handle *lockh, struct ldlm_lock_desc *new,
                     void *data, __u32 data_len);
 int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags);
 int ldlm_cli_update_pool(struct ptlrpc_request *req);
                     void *data, __u32 data_len);
 int ldlm_cli_convert(struct lustre_handle *, int new_mode, __u32 *flags);
 int ldlm_cli_update_pool(struct ptlrpc_request *req);
-int ldlm_handle_convert0(struct ptlrpc_request *req,
-                         const struct ldlm_request *dlm_req);
 int ldlm_cli_cancel(struct lustre_handle *lockh);
 int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *,
                            ldlm_cancel_flags_t flags, void *opaque);
 int ldlm_cli_cancel(struct lustre_handle *lockh);
 int ldlm_cli_cancel_unused(struct ldlm_namespace *, const struct ldlm_res_id *,
                            ldlm_cancel_flags_t flags, void *opaque);
index ffdb127..de28c93 100644 (file)
@@ -56,7 +56,8 @@
 
 #include "ldlm_internal.h"
 
 
 #include "ldlm_internal.h"
 
-#define LDLM_MAX_GROWN_EXTENT (32 * 1024 * 1024 - 1)
+#ifdef HAVE_SERVER_SUPPORT
+# define LDLM_MAX_GROWN_EXTENT (32 * 1024 * 1024 - 1)
 
 /* fixup the ldlm_extent after expanding */
 static void ldlm_extent_internal_policy_fixup(struct ldlm_lock *req,
 
 /* fixup the ldlm_extent after expanding */
 static void ldlm_extent_internal_policy_fixup(struct ldlm_lock *req,
@@ -761,6 +762,7 @@ out:
         }
         RETURN(rc);
 }
         }
         RETURN(rc);
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 /* When a lock is cancelled by a client, the KMS may undergo change if this
  * is the "highest lock".  This function returns the new KMS value.
 
 /* When a lock is cancelled by a client, the KMS may undergo change if this
  * is the "highest lock".  This function returns the new KMS value.
index c988f28..2a06ede 100644 (file)
@@ -469,6 +469,7 @@ reprocess:
         }
 
         if (*flags != LDLM_FL_WAIT_NOREPROC) {
         }
 
         if (*flags != LDLM_FL_WAIT_NOREPROC) {
+#ifdef HAVE_SERVER_SUPPORT
                 if (first_enq) {
                         /* If this is an unlock, reprocess the waitq and
                          * send completions ASTs for locks that can now be
                 if (first_enq) {
                         /* If this is an unlock, reprocess the waitq and
                          * send completions ASTs for locks that can now be
@@ -497,6 +498,13 @@ restart:
                         LASSERT(req->l_completion_ast);
                         ldlm_add_ast_work_item(req, NULL, work_list);
                 }
                         LASSERT(req->l_completion_ast);
                         ldlm_add_ast_work_item(req, NULL, work_list);
                 }
+#else /* !HAVE_SERVER_SUPPORT */
+                /* The only one possible case for client-side calls flock
+                 * policy function is ldlm_flock_completion_ast inside which
+                 * carries LDLM_FL_WAIT_NOREPROC flag. */
+                CERROR("Illegal parameter for client-side-only module.\n");
+                LBUG();
+#endif /* HAVE_SERVER_SUPPORT */
         }
 
         /* In case we're reprocessing the requested lock we can't destroy
         }
 
         /* In case we're reprocessing the requested lock we can't destroy
index 18d5afa..e3efca7 100644 (file)
@@ -52,6 +52,7 @@
 
 #include "ldlm_internal.h"
 
 
 #include "ldlm_internal.h"
 
+#ifdef HAVE_SERVER_SUPPORT
 /* Determine if the lock is compatible with all locks on the queue. */
 static int
 ldlm_inodebits_compat_queue(cfs_list_t *queue, struct ldlm_lock *req,
 /* Determine if the lock is compatible with all locks on the queue. */
 static int
 ldlm_inodebits_compat_queue(cfs_list_t *queue, struct ldlm_lock *req,
@@ -194,6 +195,7 @@ int ldlm_process_inodebits_lock(struct ldlm_lock *lock, int *flags,
         }
         RETURN(0);
 }
         }
         RETURN(0);
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 void ldlm_ibits_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
                                      ldlm_policy_data_t *lpolicy)
 
 void ldlm_ibits_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
                                      ldlm_policy_data_t *lpolicy)
index de95520..5e7e9a9 100644 (file)
@@ -134,8 +134,10 @@ void ldlm_lock_decref_internal(struct ldlm_lock *, __u32 mode);
 void ldlm_lock_decref_internal_nolock(struct ldlm_lock *, __u32 mode);
 void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
                             cfs_list_t *work_list);
 void ldlm_lock_decref_internal_nolock(struct ldlm_lock *, __u32 mode);
 void ldlm_add_ast_work_item(struct ldlm_lock *lock, struct ldlm_lock *new,
                             cfs_list_t *work_list);
+#ifdef HAVE_SERVER_SUPPORT
 int ldlm_reprocess_queue(struct ldlm_resource *res, cfs_list_t *queue,
                          cfs_list_t *work_list);
 int ldlm_reprocess_queue(struct ldlm_resource *res, cfs_list_t *queue,
                          cfs_list_t *work_list);
+#endif
 int ldlm_run_ast_work(struct ldlm_namespace *ns, cfs_list_t *rpc_list,
                       ldlm_desc_ast_t ast_type);
 int ldlm_lock_remove_from_lru(struct ldlm_lock *lock);
 int ldlm_run_ast_work(struct ldlm_namespace *ns, cfs_list_t *rpc_list,
                       ldlm_desc_ast_t ast_type);
 int ldlm_lock_remove_from_lru(struct ldlm_lock *lock);
@@ -156,13 +158,22 @@ int ldlm_bl_to_thread_list(struct ldlm_namespace *ns, struct ldlm_lock_desc *ld,
 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
                              struct ldlm_lock_desc *ld, struct ldlm_lock *lock);
 
 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
                              struct ldlm_lock_desc *ld, struct ldlm_lock *lock);
 
+#ifdef HAVE_SERVER_SUPPORT
 /* ldlm_plain.c */
 int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
                             ldlm_error_t *err, cfs_list_t *work_list);
 
 /* ldlm_plain.c */
 int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
                             ldlm_error_t *err, cfs_list_t *work_list);
 
+/* ldlm_inodebits.c */
+int ldlm_process_inodebits_lock(struct ldlm_lock *lock, int *flags,
+                                int first_enq, ldlm_error_t *err,
+                                cfs_list_t *work_list);
+#endif
+
 /* ldlm_extent.c */
 /* ldlm_extent.c */
+#ifdef HAVE_SERVER_SUPPORT
 int ldlm_process_extent_lock(struct ldlm_lock *lock, int *flags, int first_enq,
                              ldlm_error_t *err, cfs_list_t *work_list);
 int ldlm_process_extent_lock(struct ldlm_lock *lock, int *flags, int first_enq,
                              ldlm_error_t *err, cfs_list_t *work_list);
+#endif
 void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
 void ldlm_extent_unlink_lock(struct ldlm_lock *lock);
 
 void ldlm_extent_add_lock(struct ldlm_resource *res, struct ldlm_lock *lock);
 void ldlm_extent_unlink_lock(struct ldlm_lock *lock);
 
@@ -170,11 +181,6 @@ void ldlm_extent_unlink_lock(struct ldlm_lock *lock);
 int ldlm_process_flock_lock(struct ldlm_lock *req, int *flags, int first_enq,
                             ldlm_error_t *err, cfs_list_t *work_list);
 
 int ldlm_process_flock_lock(struct ldlm_lock *req, int *flags, int first_enq,
                             ldlm_error_t *err, cfs_list_t *work_list);
 
-/* ldlm_inodebits.c */
-int ldlm_process_inodebits_lock(struct ldlm_lock *lock, int *flags,
-                                int first_enq, ldlm_error_t *err,
-                                cfs_list_t *work_list);
-
 /* l_lock.c */
 void l_check_ns_lock(struct ldlm_namespace *ns);
 void l_check_no_ns_lock(struct ldlm_namespace *ns);
 /* l_lock.c */
 void l_check_ns_lock(struct ldlm_namespace *ns);
 void l_check_no_ns_lock(struct ldlm_namespace *ns);
index b0cf30d..c4268a5 100644 (file)
@@ -157,12 +157,13 @@ char *ldlm_it2str(int it)
 
 extern cfs_mem_cache_t *ldlm_lock_slab;
 
 
 extern cfs_mem_cache_t *ldlm_lock_slab;
 
+#ifdef HAVE_SERVER_SUPPORT
 static ldlm_processing_policy ldlm_processing_policy_table[] = {
         [LDLM_PLAIN] ldlm_process_plain_lock,
         [LDLM_EXTENT] ldlm_process_extent_lock,
 static ldlm_processing_policy ldlm_processing_policy_table[] = {
         [LDLM_PLAIN] ldlm_process_plain_lock,
         [LDLM_EXTENT] ldlm_process_extent_lock,
-#ifdef __KERNEL__
+# ifdef __KERNEL__
         [LDLM_FLOCK] ldlm_process_flock_lock,
         [LDLM_FLOCK] ldlm_process_flock_lock,
-#endif
+# endif
         [LDLM_IBITS] ldlm_process_inodebits_lock,
 };
 
         [LDLM_IBITS] ldlm_process_inodebits_lock,
 };
 
@@ -170,6 +171,7 @@ ldlm_processing_policy ldlm_get_processing_policy(struct ldlm_resource *res)
 {
         return ldlm_processing_policy_table[res->lr_type];
 }
 {
         return ldlm_processing_policy_table[res->lr_type];
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg)
 {
 
 void ldlm_register_intent(struct ldlm_namespace *ns, ldlm_res_policy arg)
 {
@@ -1363,7 +1365,9 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
         struct ldlm_lock *lock = *lockp;
         struct ldlm_resource *res = lock->l_resource;
         int local = ns_is_client(ldlm_res_to_ns(res));
         struct ldlm_lock *lock = *lockp;
         struct ldlm_resource *res = lock->l_resource;
         int local = ns_is_client(ldlm_res_to_ns(res));
+#ifdef HAVE_SERVER_SUPPORT
         ldlm_processing_policy policy;
         ldlm_processing_policy policy;
+#endif
         ldlm_error_t rc = ELDLM_OK;
         struct ldlm_interval *node = NULL;
         ENTRY;
         ldlm_error_t rc = ELDLM_OK;
         struct ldlm_interval *node = NULL;
         ENTRY;
@@ -1444,6 +1448,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
                 else
                         ldlm_grant_lock(lock, NULL);
                 GOTO(out, ELDLM_OK);
                 else
                         ldlm_grant_lock(lock, NULL);
                 GOTO(out, ELDLM_OK);
+#ifdef HAVE_SERVER_SUPPORT
         } else if (*flags & LDLM_FL_REPLAY) {
                 if (*flags & LDLM_FL_BLOCK_CONV) {
                         ldlm_resource_add_lock(res, &res->lr_converting, lock);
         } else if (*flags & LDLM_FL_REPLAY) {
                 if (*flags & LDLM_FL_BLOCK_CONV) {
                         ldlm_resource_add_lock(res, &res->lr_converting, lock);
@@ -1461,6 +1466,14 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
         policy = ldlm_processing_policy_table[res->lr_type];
         policy(lock, flags, 1, &rc, NULL);
         GOTO(out, rc);
         policy = ldlm_processing_policy_table[res->lr_type];
         policy(lock, flags, 1, &rc, NULL);
         GOTO(out, rc);
+#else
+        } else {
+                CERROR("This is client-side-only module, cannot handle "
+                       "LDLM_NAMESPACE_SERVER resource type lock.\n");
+                LBUG();
+        }
+#endif
+
 out:
         unlock_res_and_lock(lock);
         if (node)
 out:
         unlock_res_and_lock(lock);
         if (node)
@@ -1468,6 +1481,7 @@ out:
         return rc;
 }
 
         return rc;
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 /* Must be called with namespace taken: queue is waiting or converting. */
 int ldlm_reprocess_queue(struct ldlm_resource *res, cfs_list_t *queue,
                          cfs_list_t *work_list)
 /* Must be called with namespace taken: queue is waiting or converting. */
 int ldlm_reprocess_queue(struct ldlm_resource *res, cfs_list_t *queue,
                          cfs_list_t *work_list)
@@ -1498,6 +1512,7 @@ int ldlm_reprocess_queue(struct ldlm_resource *res, cfs_list_t *queue,
 
         RETURN(rc);
 }
 
         RETURN(rc);
 }
+#endif
 
 static int
 ldlm_work_bl_ast_lock(cfs_list_t *tmp, struct ldlm_cb_set_arg *arg)
 
 static int
 ldlm_work_bl_ast_lock(cfs_list_t *tmp, struct ldlm_cb_set_arg *arg)
@@ -1679,16 +1694,17 @@ void ldlm_reprocess_all_ns(struct ldlm_namespace *ns)
 void ldlm_reprocess_all(struct ldlm_resource *res)
 {
         CFS_LIST_HEAD(rpc_list);
 void ldlm_reprocess_all(struct ldlm_resource *res)
 {
         CFS_LIST_HEAD(rpc_list);
+
+#ifdef HAVE_SERVER_SUPPORT
         int rc;
         ENTRY;
         int rc;
         ENTRY;
-
         /* Local lock trees don't get reprocessed. */
         if (ns_is_client(ldlm_res_to_ns(res))) {
                 EXIT;
                 return;
         }
 
         /* Local lock trees don't get reprocessed. */
         if (ns_is_client(ldlm_res_to_ns(res))) {
                 EXIT;
                 return;
         }
 
- restart:
+restart:
         lock_res(res);
         rc = ldlm_reprocess_queue(res, &res->lr_converting, &rpc_list);
         if (rc == LDLM_ITER_CONTINUE)
         lock_res(res);
         rc = ldlm_reprocess_queue(res, &res->lr_converting, &rpc_list);
         if (rc == LDLM_ITER_CONTINUE)
@@ -1701,6 +1717,14 @@ void ldlm_reprocess_all(struct ldlm_resource *res)
                 LASSERT(cfs_list_empty(&rpc_list));
                 goto restart;
         }
                 LASSERT(cfs_list_empty(&rpc_list));
                 goto restart;
         }
+#else
+        ENTRY;
+        if (!ns_is_client(ldlm_res_to_ns(res))) {
+                CERROR("This is client-side-only module, cannot handle "
+                       "LDLM_NAMESPACE_SERVER resource type lock.\n");
+                LBUG();
+        }
+#endif
         EXIT;
 }
 
         EXIT;
 }
 
@@ -1854,9 +1878,8 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
         struct ldlm_resource *res;
         struct ldlm_namespace *ns;
         int granted = 0;
         struct ldlm_resource *res;
         struct ldlm_namespace *ns;
         int granted = 0;
-        int old_mode, rc;
+        int old_mode;
         struct sl_insert_point prev;
         struct sl_insert_point prev;
-        ldlm_error_t err;
         struct ldlm_interval *node;
         ENTRY;
 
         struct ldlm_interval *node;
         ENTRY;
 
@@ -1924,7 +1947,10 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
                         if (lock->l_completion_ast)
                                 lock->l_completion_ast(lock, 0, NULL);
                 }
                         if (lock->l_completion_ast)
                                 lock->l_completion_ast(lock, 0, NULL);
                 }
+#ifdef HAVE_SERVER_SUPPORT
         } else {
         } else {
+                int rc;
+                ldlm_error_t err;
                 int pflags = 0;
                 ldlm_processing_policy policy;
                 policy = ldlm_processing_policy_table[res->lr_type];
                 int pflags = 0;
                 ldlm_processing_policy policy;
                 policy = ldlm_processing_policy_table[res->lr_type];
@@ -1942,6 +1968,13 @@ struct ldlm_resource *ldlm_lock_convert(struct ldlm_lock *lock, int new_mode,
                         granted = 1;
                 }
         }
                         granted = 1;
                 }
         }
+#else
+        } else {
+                CERROR("This is client-side-only module, cannot handle "
+                       "LDLM_NAMESPACE_SERVER resource type lock.\n");
+                LBUG();
+        }
+#endif
         unlock_res_and_lock(lock);
 
         if (granted)
         unlock_res_and_lock(lock);
 
         if (granted)
index f32054b..3902521 100644 (file)
@@ -562,12 +562,6 @@ int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout)
 }
 #else /* !__KERNEL__ */
 
 }
 #else /* !__KERNEL__ */
 
-static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
-{
-        LASSERT(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK));
-        RETURN(1);
-}
-
 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
 {
         RETURN(0);
 int ldlm_del_waiting_lock(struct ldlm_lock *lock)
 {
         RETURN(0);
@@ -579,6 +573,15 @@ int ldlm_refresh_waiting_lock(struct ldlm_lock *lock, int timeout)
 }
 #endif /* __KERNEL__ */
 
 }
 #endif /* __KERNEL__ */
 
+#ifdef HAVE_SERVER_SUPPORT
+# ifndef __KERNEL__
+static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
+{
+        LASSERT(!(lock->l_flags & LDLM_FL_CANCEL_ON_BLOCK));
+        RETURN(1);
+}
+# endif
+
 static void ldlm_failed_ast(struct ldlm_lock *lock, int rc,
                             const char *ast_type)
 {
 static void ldlm_failed_ast(struct ldlm_lock *lock, int rc,
                             const char *ast_type)
 {
@@ -1012,12 +1015,6 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
         RETURN(rc);
 }
 
         RETURN(rc);
 }
 
-#ifdef __KERNEL__
-extern unsigned long long lu_time_stamp_get(void);
-#else
-#define lu_time_stamp_get() time(NULL)
-#endif
-
 static void ldlm_svc_get_eopc(const struct ldlm_request *dlm_req,
                        struct lprocfs_stats *srv_stats)
 {
 static void ldlm_svc_get_eopc(const struct ldlm_request *dlm_req,
                        struct lprocfs_stats *srv_stats)
 {
@@ -1498,6 +1495,7 @@ int ldlm_handle_cancel(struct ptlrpc_request *req)
 
         RETURN(ptlrpc_reply(req));
 }
 
         RETURN(ptlrpc_reply(req));
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
                              struct ldlm_lock_desc *ld, struct ldlm_lock *lock)
 
 void ldlm_handle_bl_callback(struct ldlm_namespace *ns,
                              struct ldlm_lock_desc *ld, struct ldlm_lock *lock)
@@ -2054,6 +2052,7 @@ static int ldlm_callback_handler(struct ptlrpc_request *req)
         RETURN(0);
 }
 
         RETURN(0);
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 static int ldlm_cancel_handler(struct ptlrpc_request *req)
 {
         int rc;
 static int ldlm_cancel_handler(struct ptlrpc_request *req)
 {
         int rc;
@@ -2257,6 +2256,7 @@ void ldlm_revoke_export_locks(struct obd_export *exp)
 
         EXIT;
 }
 
         EXIT;
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 #ifdef __KERNEL__
 static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
 
 #ifdef __KERNEL__
 static struct ldlm_bl_work_item *ldlm_bl_get_work(struct ldlm_bl_pool *blp)
@@ -2581,6 +2581,7 @@ static int ldlm_setup(void)
                 GOTO(out_proc, rc = -ENOMEM);
         }
 
                 GOTO(out_proc, rc = -ENOMEM);
         }
 
+#ifdef HAVE_SERVER_SUPPORT
         ldlm_state->ldlm_cancel_service =
                 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
                                 LDLM_MAXREPSIZE, LDLM_CANCEL_REQUEST_PORTAL,
         ldlm_state->ldlm_cancel_service =
                 ptlrpc_init_svc(LDLM_NBUFS, LDLM_BUFSIZE, LDLM_MAXREQSIZE,
                                 LDLM_MAXREPSIZE, LDLM_CANCEL_REQUEST_PORTAL,
@@ -2596,6 +2597,7 @@ static int ldlm_setup(void)
                 CERROR("failed to start service\n");
                 GOTO(out_proc, rc = -ENOMEM);
         }
                 CERROR("failed to start service\n");
                 GOTO(out_proc, rc = -ENOMEM);
         }
+#endif
 
         OBD_ALLOC(blp, sizeof(*blp));
         if (blp == NULL)
 
         OBD_ALLOC(blp, sizeof(*blp));
         if (blp == NULL)
@@ -2618,9 +2620,11 @@ static int ldlm_setup(void)
                         GOTO(out_thread, rc);
         }
 
                         GOTO(out_thread, rc);
         }
 
+# ifdef HAVE_SERVER_SUPPORT
         rc = ptlrpc_start_threads(ldlm_state->ldlm_cancel_service);
         if (rc)
                 GOTO(out_thread, rc);
         rc = ptlrpc_start_threads(ldlm_state->ldlm_cancel_service);
         if (rc)
                 GOTO(out_thread, rc);
+# endif
 
         rc = ptlrpc_start_threads(ldlm_state->ldlm_cb_service);
         if (rc)
 
         rc = ptlrpc_start_threads(ldlm_state->ldlm_cb_service);
         if (rc)
@@ -2653,7 +2657,9 @@ static int ldlm_setup(void)
 
 #ifdef __KERNEL__
  out_thread:
 
 #ifdef __KERNEL__
  out_thread:
+# ifdef HAVE_SERVER_SUPPORT
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
+# endif
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
 #endif
 
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
 #endif
 
@@ -2702,17 +2708,21 @@ static int ldlm_cleanup(void)
         OBD_FREE(blp, sizeof(*blp));
 
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
         OBD_FREE(blp, sizeof(*blp));
 
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
+# ifdef HAVE_SERVER_SUPPORT
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
+# endif
         ldlm_proc_cleanup();
 
         expired_lock_thread.elt_state = ELT_TERMINATE;
         cfs_waitq_signal(&expired_lock_thread.elt_waitq);
         cfs_wait_event(expired_lock_thread.elt_waitq,
                        expired_lock_thread.elt_state == ELT_STOPPED);
         ldlm_proc_cleanup();
 
         expired_lock_thread.elt_state = ELT_TERMINATE;
         cfs_waitq_signal(&expired_lock_thread.elt_waitq);
         cfs_wait_event(expired_lock_thread.elt_waitq,
                        expired_lock_thread.elt_state == ELT_STOPPED);
-#else
+#else /* !__KERNEL__ */
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
         ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
+# ifdef HAVE_SERVER_SUPPORT
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
         ptlrpc_unregister_service(ldlm_state->ldlm_cancel_service);
-#endif
+# endif
+#endif /* __KERNEL__ */
 
         OBD_FREE(ldlm_state, sizeof(*ldlm_state));
         ldlm_state = NULL;
 
         OBD_FREE(ldlm_state, sizeof(*ldlm_state));
         ldlm_state = NULL;
@@ -2776,7 +2786,9 @@ void ldlm_exit(void)
 EXPORT_SYMBOL(ldlm_extent_shift_kms);
 
 /* ldlm_lock.c */
 EXPORT_SYMBOL(ldlm_extent_shift_kms);
 
 /* ldlm_lock.c */
+#ifdef HAVE_SERVER_SUPPORT
 EXPORT_SYMBOL(ldlm_get_processing_policy);
 EXPORT_SYMBOL(ldlm_get_processing_policy);
+#endif
 EXPORT_SYMBOL(ldlm_lock2desc);
 EXPORT_SYMBOL(ldlm_register_intent);
 EXPORT_SYMBOL(ldlm_lockname);
 EXPORT_SYMBOL(ldlm_lock2desc);
 EXPORT_SYMBOL(ldlm_register_intent);
 EXPORT_SYMBOL(ldlm_lockname);
@@ -2827,6 +2839,7 @@ EXPORT_SYMBOL(ldlm_cli_cancel_list_local);
 EXPORT_SYMBOL(ldlm_cli_cancel_list);
 
 /* ldlm_lockd.c */
 EXPORT_SYMBOL(ldlm_cli_cancel_list);
 
 /* ldlm_lockd.c */
+#ifdef HAVE_SERVER_SUPPORT
 EXPORT_SYMBOL(ldlm_server_blocking_ast);
 EXPORT_SYMBOL(ldlm_server_completion_ast);
 EXPORT_SYMBOL(ldlm_server_glimpse_ast);
 EXPORT_SYMBOL(ldlm_server_blocking_ast);
 EXPORT_SYMBOL(ldlm_server_completion_ast);
 EXPORT_SYMBOL(ldlm_server_glimpse_ast);
@@ -2836,11 +2849,12 @@ EXPORT_SYMBOL(ldlm_handle_cancel);
 EXPORT_SYMBOL(ldlm_request_cancel);
 EXPORT_SYMBOL(ldlm_handle_convert);
 EXPORT_SYMBOL(ldlm_handle_convert0);
 EXPORT_SYMBOL(ldlm_request_cancel);
 EXPORT_SYMBOL(ldlm_handle_convert);
 EXPORT_SYMBOL(ldlm_handle_convert0);
+EXPORT_SYMBOL(ldlm_revoke_export_locks);
+#endif
 EXPORT_SYMBOL(ldlm_del_waiting_lock);
 EXPORT_SYMBOL(ldlm_get_ref);
 EXPORT_SYMBOL(ldlm_put_ref);
 EXPORT_SYMBOL(ldlm_refresh_waiting_lock);
 EXPORT_SYMBOL(ldlm_del_waiting_lock);
 EXPORT_SYMBOL(ldlm_get_ref);
 EXPORT_SYMBOL(ldlm_put_ref);
 EXPORT_SYMBOL(ldlm_refresh_waiting_lock);
-EXPORT_SYMBOL(ldlm_revoke_export_locks);
 
 /* ldlm_resource.c */
 EXPORT_SYMBOL(ldlm_namespace_new);
 
 /* ldlm_resource.c */
 EXPORT_SYMBOL(ldlm_namespace_new);
index 9f5c08d..5b5d9e6 100644 (file)
@@ -53,6 +53,7 @@
 
 #include "ldlm_internal.h"
 
 
 #include "ldlm_internal.h"
 
+#ifdef HAVE_SERVER_SUPPORT
 static inline int
 ldlm_plain_compat_queue(cfs_list_t *queue, struct ldlm_lock *req,
                         cfs_list_t *work_list)
 static inline int
 ldlm_plain_compat_queue(cfs_list_t *queue, struct ldlm_lock *req,
                         cfs_list_t *work_list)
@@ -161,6 +162,7 @@ int ldlm_process_plain_lock(struct ldlm_lock *lock, int *flags, int first_enq,
         }
         RETURN(0);
 }
         }
         RETURN(0);
 }
+#endif /* HAVE_SERVER_SUPPORT */
 
 void ldlm_plain_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
                                      ldlm_policy_data_t *lpolicy)
 
 void ldlm_plain_policy_wire_to_local(const ldlm_wire_policy_data_t *wpolicy,
                                      ldlm_policy_data_t *lpolicy)