[PATCH] ocfs2: Alloc at least a page for the DLM hash
authorJoel Becker <Joel.Becker@oracle.com>
Fri, 17 Mar 2006 01:40:37 +0000 (17:40 -0800)
committerMark Fasheh <mark.fasheh@oracle.com>
Mon, 26 Jun 2006 21:42:42 +0000 (14:42 -0700)
The OCFS2 DLM allocates a number of pages for a hash to lookup locks.
There was a bug where a PAGE_SIZE bigger than the hash size (eg, 64K
pages) would result in zero pages allocated.

Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
fs/ocfs2/dlm/dlmcommon.h
fs/ocfs2/dlm/dlmdomain.c

index 0378ddbc8a8cc8f6f652be9a7caf79683294f617..4fc1be3a3fa20ffabea8838190d7cd9ccac3a7f4 100644 (file)
 #define DLM_THREAD_SHUFFLE_INTERVAL    5     // flush everything every 5 passes
 #define DLM_THREAD_MS                  200   // flush at least every 200 ms
 
-#define DLM_HASH_SIZE          (1 << 14)
-#define DLM_HASH_PAGES         (DLM_HASH_SIZE / PAGE_SIZE)
+#define DLM_HASH_SIZE_DEFAULT  (1 << 14)
+#if DLM_HASH_SIZE_DEFAULT < PAGE_SIZE
+# define DLM_HASH_PAGES                1
+#else
+# define DLM_HASH_PAGES                (DLM_HASH_SIZE_DEFAULT / PAGE_SIZE)
+#endif
 #define DLM_BUCKETS_PER_PAGE   (PAGE_SIZE / sizeof(struct hlist_head))
 #define DLM_HASH_BUCKETS       (DLM_HASH_PAGES * DLM_BUCKETS_PER_PAGE)
 
index 80b8cce9cf3c7ddd90fca506f67067187a216006..a074ec6f193fb17538b5767c628f083811cdf2ef 100644 (file)
@@ -67,6 +67,9 @@ static void **dlm_alloc_pagevec(int pages)
        for (i = 0; i < pages; i++)
                if (!(vec[i] = (void *)__get_free_page(GFP_KERNEL)))
                        goto out_free;
+
+       mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %Zd buckets per page\n",
+            pages, DLM_HASH_PAGES, DLM_BUCKETS_PER_PAGE);
        return vec;
 out_free:
        dlm_free_pagevec(vec, i);