* in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see [sun.com URL with a
- * copy of GPLv2].
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
# define list_for_each_safe_rcu list_for_each_safe
# define rcu_read_lock() spin_lock(&bucket->lock)
# define rcu_read_unlock() spin_unlock(&bucket->lock)
+# define list_for_each_entry_rcu list_for_each_entry
#endif /* ifndef HAVE_RCU */
static __u64 handle_base;
handle_base += HANDLE_INCR;
}
spin_unlock(&handle_base_lock);
-
+
atomic_inc(&handle_count);
h->h_addref = cb;
spin_lock_init(&h->h_lock);
atomic_dec(&handle_count);
}
-void class_handle_hash_back(struct portals_handle *h)
-{
- struct handle_bucket *bucket;
- ENTRY;
-
- bucket = handle_hash + (h->h_cookie & HANDLE_HASH_MASK);
-
- 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;
-}
-
void *class_handle2object(__u64 cookie)
{
struct handle_bucket *bucket;
- struct list_head *tmp;
+ struct portals_handle *h;
void *retval = NULL;
ENTRY;
bucket = handle_hash + (cookie & HANDLE_HASH_MASK);
rcu_read_lock();
- list_for_each_rcu(tmp, &bucket->head) {
- struct portals_handle *h;
- h = list_entry(tmp, struct portals_handle, h_link);
+ list_for_each_entry_rcu(h, &bucket->head, h_link) {
if (h->h_cookie != cookie)
continue;
spin_lock(&h->h_lock);
- if (likely(h->h_cookie != 0)) {
+ if (likely(h->h_in != 0)) {
h->h_addref(h);
retval = h;
}
}
}
+
int class_handle_init(void)
{
struct handle_bucket *bucket;
+ struct timeval tv;
+ int seed[2];
LASSERT(handle_hash == NULL);
CFS_INIT_LIST_HEAD(&bucket->head);
spin_lock_init(&bucket->lock);
}
+
+ /** bug 21430: add randomness to the initial base */
+ ll_get_random_bytes(seed, sizeof(seed));
+ do_gettimeofday(&tv);
+ ll_srand(tv.tv_sec ^ seed[0], tv.tv_usec ^ seed[1]);
+
ll_get_random_bytes(&handle_base, sizeof(handle_base));
LASSERT(handle_base != 0ULL);
int i;
for (i = 0; i < HANDLE_HASH_SIZE; i++) {
- struct list_head *tmp, *pos;
+ struct portals_handle *h;
spin_lock(&handle_hash[i].lock);
- list_for_each_safe_rcu(tmp, pos, &(handle_hash[i].head)) {
- struct portals_handle *h;
- h = list_entry(tmp, struct portals_handle, h_link);
-
+ list_for_each_entry_rcu(h, &(handle_hash[i].head), h_link) {
CERROR("force clean handle "LPX64" addr %p addref %p\n",
h->h_cookie, h, h->h_addref);