3 |
* |
* |
4 |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
* Copyright (C) 2005-2009 NTT DATA CORPORATION |
5 |
* |
* |
6 |
* Version: 1.7.1-pre 2009/11/03 |
* Version: 1.7.1-rc 2009/11/09 |
7 |
* |
* |
8 |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
* This file is applicable to both 2.4.30 and 2.6.11 and later. |
9 |
* See README.ccs for ChangeLog. |
* See README.ccs for ChangeLog. |
11 |
*/ |
*/ |
12 |
|
|
13 |
#include "internal.h" |
#include "internal.h" |
14 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(RHEL_MAJOR) |
15 |
|
#include <linux/hash.h> |
16 |
|
#endif |
17 |
|
|
18 |
void ccs_warn_oom(const char *function) |
void ccs_warn_oom(const char *function) |
19 |
{ |
{ |
141 |
unsigned int hash; |
unsigned int hash; |
142 |
int len; |
int len; |
143 |
int allocated_len; |
int allocated_len; |
144 |
|
struct list_head *head; |
145 |
|
|
146 |
if (!name) |
if (!name) |
147 |
return NULL; |
return NULL; |
148 |
len = strlen(name) + 1; |
len = strlen(name) + 1; |
149 |
hash = full_name_hash((const unsigned char *) name, len - 1); |
hash = full_name_hash((const unsigned char *) name, len - 1); |
150 |
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) || defined(RHEL_MAJOR) |
151 |
|
head = &ccs_name_list[hash_long(hash, CCS_HASH_BITS)]; |
152 |
|
#else |
153 |
|
head = &ccs_name_list[hash % CCS_MAX_HASH]; |
154 |
|
#endif |
155 |
mutex_lock(&ccs_name_list_lock); |
mutex_lock(&ccs_name_list_lock); |
156 |
list_for_each_entry(ptr, &ccs_name_list[hash % CCS_MAX_HASH], list) { |
list_for_each_entry(ptr, head, list) { |
157 |
if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name)) |
if (hash != ptr->entry.hash || strcmp(name, ptr->entry.name)) |
158 |
continue; |
continue; |
159 |
atomic_inc(&ptr->users); |
atomic_inc(&ptr->users); |
175 |
atomic_set(&ptr->users, 1); |
atomic_set(&ptr->users, 1); |
176 |
ccs_fill_path_info(&ptr->entry); |
ccs_fill_path_info(&ptr->entry); |
177 |
ptr->size = allocated_len; |
ptr->size = allocated_len; |
178 |
list_add_tail(&ptr->list, &ccs_name_list[hash % CCS_MAX_HASH]); |
list_add_tail(&ptr->list, head); |
179 |
out: |
out: |
180 |
mutex_unlock(&ccs_name_list_lock); |
mutex_unlock(&ccs_name_list_lock); |
181 |
return ptr ? &ptr->entry : NULL; |
return ptr ? &ptr->entry : NULL; |