From patchwork Mon Nov 29 17:00:27 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 589 Return-Path: Received: from nm3-vm0.bullet.mail.ukl.yahoo.com (nm3-vm0.bullet.mail.ukl.yahoo.com [217.146.183.228]) by open-mesh.org (Postfix) with SMTP id CFFED1545E6 for ; Mon, 29 Nov 2010 18:03:27 +0100 (CET) Received: from [217.146.183.210] by nm3.bullet.mail.ukl.yahoo.com with NNFMP; 29 Nov 2010 17:03:27 -0000 Received: from [77.238.184.72] by tm3.bullet.mail.ukl.yahoo.com with NNFMP; 29 Nov 2010 17:03:27 -0000 Received: from [127.0.0.1] by smtp141.mail.ukl.yahoo.com with NNFMP; 29 Nov 2010 17:03:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1291050207; bh=ZMlmECrmzwPMIKsQi/YoAyGjYMHBpXJu3edWvsztods=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=yuFlNmuZDBszeeuhwisrFCpZDJpK/mBqlA6+cvjnj0oED1T6hwy2LBr/n6DTYDh3FE3g6PreTn5ymUmczIpWN6mNQP+ho0UeMOjWnXEg1QS0a1N14o0w7l8C+dCpfqxhouFDDyBfAedCH9J3e4w8MBIHdVoo5VcBsHv7qbifKLk= X-Yahoo-Newman-Id: 1734.64502.bm@smtp141.mail.ukl.yahoo.com Received: from localhost (lindner_marek@81.57.254.118 with plain) by smtp141.mail.ukl.yahoo.com with SMTP; 29 Nov 2010 09:03:23 -0800 PST X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: PE5idt4VM1mLT.FsPPlzhbQG2UQuG6Su_6FFpU3efY9PGOM 7luQa0_0072ZYdmhph_.QxyJ40l8U6amSc9jS7MHyblhNfeg9dkxBasBiTc3 2a8cYdIiR3Qth8E.lDYbDblP_cEGiVeJmbdiYC8Y2sevsOgTEqC5Z7W2WPLE zGD_0N4XKi7sAfKZuNQlHxJKkBqam43f8fMcsjWbd4RTsWtlW7JIGegi2n_f YX6z.pAY89_NOQjH4xA9zg7pxRND34LQKTMbAt8B37raLk6hrdXb8hPEp4cq 9gYOGpi1jKWFhdom0GoGKGEmy5Q-- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Mon, 29 Nov 2010 18:00:27 +0100 Message-Id: <1291050032-20169-4-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <201011291800.02971.lindner_marek@yahoo.de> References: <201011291800.02971.lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 4/9] batman-adv: remove hash resize functions X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Nov 2010 17:03:28 -0000 Signed-off-by: Marek Lindner --- batman-adv/hash.h | 38 -------------------------------------- batman-adv/originator.c | 14 +------------- batman-adv/translation-table.c | 32 ++------------------------------ 3 files changed, 3 insertions(+), 81 deletions(-) diff --git a/batman-adv/hash.h b/batman-adv/hash.h index 0b61c6e..ab67dcf 100644 --- a/batman-adv/hash.h +++ b/batman-adv/hash.h @@ -181,44 +181,6 @@ static inline void *hash_find(struct hashtable_t *hash, return NULL; } -/* resize the hash, returns the pointer to the new hash or NULL on - * error. removes the old hash on success */ -static inline struct hashtable_t *hash_resize(struct hashtable_t *hash, - hashdata_choose_cb choose, - int size) -{ - struct hashtable_t *new_hash; - struct hlist_head *head, *new_head; - struct hlist_node *walk, *safe; - struct element_t *bucket; - int i, new_index; - - /* initialize a new hash with the new size */ - new_hash = hash_new(size); - - if (new_hash == NULL) - return NULL; - - /* copy the elements */ - for (i = 0; i < hash->size; i++) { - head = &hash->table[i]; - - hlist_for_each_safe(walk, safe, head) { - bucket = hlist_entry(walk, struct element_t, hlist); - - new_index = choose(bucket->data, size); - new_head = &new_hash->table[new_index]; - - hlist_del(walk); - hlist_add_head(walk, new_head); - } - } - - hash_destroy(hash); - - return new_hash; -} - /* iterate though the hash. First element is selected if an iterator * initialized with HASHIT() is supplied as iter. Use the returned * (or supplied) iterator to access the elements until hash_iterate returns diff --git a/batman-adv/originator.c b/batman-adv/originator.c index 71480af..0150566 100644 --- a/batman-adv/originator.c +++ b/batman-adv/originator.c @@ -45,7 +45,7 @@ int originator_init(struct bat_priv *bat_priv) return 1; spin_lock_bh(&bat_priv->orig_hash_lock); - bat_priv->orig_hash = hash_new(128); + bat_priv->orig_hash = hash_new(1024); if (!bat_priv->orig_hash) goto err; @@ -147,7 +147,6 @@ void originator_free(struct bat_priv *bat_priv) struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) { struct orig_node *orig_node; - struct hashtable_t *swaphash; int size; int hash_added; @@ -196,17 +195,6 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) if (hash_added < 0) goto free_bcast_own_sum; - if (bat_priv->orig_hash->elements * 4 > bat_priv->orig_hash->size) { - swaphash = hash_resize(bat_priv->orig_hash, choose_orig, - bat_priv->orig_hash->size * 2); - - if (!swaphash) - bat_dbg(DBG_BATMAN, bat_priv, - "Couldn't resize orig hash table\n"); - else - bat_priv->orig_hash = swaphash; - } - return orig_node; free_bcast_own_sum: kfree(orig_node->bcast_own_sum); diff --git a/batman-adv/translation-table.c b/batman-adv/translation-table.c index 4b0a107..72448c9 100644 --- a/batman-adv/translation-table.c +++ b/batman-adv/translation-table.c @@ -42,7 +42,7 @@ int hna_local_init(struct bat_priv *bat_priv) if (bat_priv->hna_local_hash) return 1; - bat_priv->hna_local_hash = hash_new(128); + bat_priv->hna_local_hash = hash_new(1024); if (!bat_priv->hna_local_hash) return 0; @@ -58,7 +58,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) struct bat_priv *bat_priv = netdev_priv(soft_iface); struct hna_local_entry *hna_local_entry; struct hna_global_entry *hna_global_entry; - struct hashtable_t *swaphash; int required_bytes; spin_lock_bh(&bat_priv->hna_lhash_lock); @@ -113,17 +112,6 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) bat_priv->num_local_hna++; atomic_set(&bat_priv->hna_local_changed, 1); - if (bat_priv->hna_local_hash->elements * 4 > - bat_priv->hna_local_hash->size) { - swaphash = hash_resize(bat_priv->hna_local_hash, choose_orig, - bat_priv->hna_local_hash->size * 2); - - if (!swaphash) - pr_err("Couldn't resize local hna hash table\n"); - else - bat_priv->hna_local_hash = swaphash; - } - spin_unlock_bh(&bat_priv->hna_lhash_lock); /* remove address from global hash if present */ @@ -302,7 +290,7 @@ int hna_global_init(struct bat_priv *bat_priv) if (bat_priv->hna_global_hash) return 1; - bat_priv->hna_global_hash = hash_new(128); + bat_priv->hna_global_hash = hash_new(1024); if (!bat_priv->hna_global_hash) return 0; @@ -316,7 +304,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, { struct hna_global_entry *hna_global_entry; struct hna_local_entry *hna_local_entry; - struct hashtable_t *swaphash; int hna_buff_count = 0; unsigned char *hna_ptr; @@ -382,21 +369,6 @@ void hna_global_add_orig(struct bat_priv *bat_priv, orig_node->hna_buff_len = hna_buff_len; } } - - spin_lock_bh(&bat_priv->hna_ghash_lock); - - if (bat_priv->hna_global_hash->elements * 4 > - bat_priv->hna_global_hash->size) { - swaphash = hash_resize(bat_priv->hna_global_hash, choose_orig, - bat_priv->hna_global_hash->size * 2); - - if (!swaphash) - pr_err("Couldn't resize global hna hash table\n"); - else - bat_priv->hna_global_hash = swaphash; - } - - spin_unlock_bh(&bat_priv->hna_ghash_lock); } int hna_global_seq_print_text(struct seq_file *seq, void *offset)