Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / obdclass / lustre_handles.c
index 0a08a3d..96fc122 100644 (file)
@@ -52,7 +52,16 @@ static struct handle_bucket {
 
 static atomic_t handle_count = ATOMIC_INIT(0);
 
+#ifdef __arch_um__
+/* For unknown reason, UML uses kmalloc rather than vmalloc to allocate
+ * memory(OBD_VMALLOC). Therefore, we have to redefine the
+ * HANDLE_HASH_SIZE to make the hash heads don't exceed 128K.
+ */
+#define HANDLE_HASH_SIZE 4096
+#else
 #define HANDLE_HASH_SIZE (1 << 14)
+#endif /* ifdef __arch_um__ */
+
 #define HANDLE_HASH_MASK (HANDLE_HASH_SIZE - 1)
 
 /*
@@ -93,6 +102,7 @@ void class_handle_hash(struct portals_handle *h, portals_handle_addref_cb cb)
         bucket = &handle_hash[h->h_cookie & HANDLE_HASH_MASK];
         spin_lock(&bucket->lock);
         list_add_rcu(&h->h_link, &bucket->head);
+        h->h_in = 1;
         spin_unlock(&bucket->lock);
 
         CDEBUG(D_INFO, "added object %p with handle "LPX64" to hash\n",
@@ -112,11 +122,11 @@ static void class_handle_unhash_nolock(struct portals_handle *h)
                h, h->h_cookie);
 
         spin_lock(&h->h_lock);
-        if (h->h_cookie == 0) {
+        if (h->h_in == 0) {
                 spin_unlock(&h->h_lock);
                 return;
         }
-        h->h_cookie = 0;
+        h->h_in = 0;
         spin_unlock(&h->h_lock);
         list_del_rcu(&h->h_link);
 }
@@ -143,6 +153,7 @@ void class_handle_hash_back(struct portals_handle *h)
         atomic_inc(&handle_count);
         spin_lock(&bucket->lock);
         list_add_rcu(&h->h_link, &bucket->head);
+        h->h_in = 1;
         spin_unlock(&bucket->lock);
 
         EXIT;