1 --- linux-2.6.22.19-chopstix/fs/dcookies.c 2009-02-28 03:10:05.000000000 -0500
2 +++ linux-2.6.22.19-chopstix/fs/dcookies.c.orig 2008-02-25 18:59:40.000000000 -0500
4 static LIST_HEAD(dcookie_users);
5 static DEFINE_MUTEX(dcookie_mutex);
6 static struct kmem_cache *dcookie_cache __read_mostly;
7 -static struct list_head *dcookie_hashtable[2] __read_mostly;
8 +static struct list_head *dcookie_hashtable __read_mostly;
9 static size_t hash_size __read_mostly;
10 -unsigned int current_hash = 0;
12 static inline int is_live(void)
14 return !(list_empty(&dcookie_users));
17 -static inline int is_shared(void)
19 - return !(list_empty(&dcookie_users)) && !(list_empty(dcookie_users.next));
22 /* The dentry is locked, its address will do for the cookie */
23 static inline unsigned long dcookie_value(struct dcookie_struct * dcs)
25 struct list_head * pos;
26 struct list_head * list;
28 - list = dcookie_hashtable[current_hash] + dcookie_hash(dcookie);
29 + list = dcookie_hashtable + dcookie_hash(dcookie);
31 list_for_each(pos, list) {
32 dcs = list_entry(pos, struct dcookie_struct, hash_list);
35 static void hash_dcookie(struct dcookie_struct * dcs)
37 - struct list_head * list = dcookie_hashtable[current_hash] + dcookie_hash(dcookie_value(dcs));
38 + struct list_head * list = dcookie_hashtable + dcookie_hash(dcookie_value(dcs));
39 list_add(&dcs->hash_list, list);
43 static struct dcookie_struct * alloc_dcookie(struct dentry * dentry,
44 struct vfsmount * vfsmnt)
46 - struct dcookie_struct * dcs = kmem_cache_alloc(dcookie_cache, GFP_ATOMIC);
47 + struct dcookie_struct * dcs = kmem_cache_alloc(dcookie_cache, GFP_KERNEL);
55 - dcookie_hashtable[0] = kmalloc(PAGE_SIZE, GFP_KERNEL);
56 - if (!dcookie_hashtable[0])
59 - dcookie_hashtable[1] = kmalloc(PAGE_SIZE, GFP_KERNEL);
60 - if (!dcookie_hashtable[1])
61 + dcookie_hashtable = kmalloc(PAGE_SIZE, GFP_KERNEL);
62 + if (!dcookie_hashtable)
67 hash_size = 1UL << hash_bits;
69 /* And initialize the newly allocated array */
70 - d = dcookie_hashtable[0];
78 - d = dcookie_hashtable[1];
79 + d = dcookie_hashtable;
84 kmem_cache_free(dcookie_cache, dcs);
87 -/* Switch to the second hash */
88 -int garbage_collect(void) {
89 - struct list_head * list;
90 - struct list_head * pos;
91 - struct list_head * pos2;
92 - struct dcookie_struct * dcs;
98 - for (i = 0; i < hash_size; ++i) {
99 - list = dcookie_hashtable[current_hash] + i;
100 - list_for_each_safe(pos, pos2, list) {
101 - dcs = list_entry(pos, struct dcookie_struct, hash_list);
102 - list_del(&dcs->hash_list);
107 - current_hash = (current_hash & 1) ^ 1;
112 static void dcookie_exit(void)
117 for (i = 0; i < hash_size; ++i) {
118 - list = dcookie_hashtable[0] + i;
119 - list_for_each_safe(pos, pos2, list) {
120 - dcs = list_entry(pos, struct dcookie_struct, hash_list);
121 - list_del(&dcs->hash_list);
125 - list = dcookie_hashtable[1] + i;
126 + list = dcookie_hashtable + i;
127 list_for_each_safe(pos, pos2, list) {
128 dcs = list_entry(pos, struct dcookie_struct, hash_list);
129 list_del(&dcs->hash_list);
134 - kfree(dcookie_hashtable[0]);
135 - kfree(dcookie_hashtable[1]);
136 + kfree(dcookie_hashtable);
137 kmem_cache_destroy(dcookie_cache);