summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
Diffstat (limited to 'debian')
-rw-r--r--debian/patches/series5
-rw-r--r--debian/patches/translators-list0001-fu_gki.patch26
-rw-r--r--debian/patches/translators-list0002-libfshelp-acquire-references-to-control-ports.patch59
-rw-r--r--debian/patches/translators-list0003-libihash-add-general-purpose-hash-functions.patch144
-rw-r--r--debian/patches/translators-list0004-libfshelp-improve-translator-list.patch127
-rw-r--r--debian/patches/translators-list0005-add-iteration.patch28
6 files changed, 389 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series
index 04e8bde9..920d9f58 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -62,3 +62,8 @@ nodeihash0002-xxx-fix-node-iteration.patch
ext2fs-optimize-bcache0001-ext2fs-improve-the-block-cache.patch
ext2fs-optimize-bcache0002-ext2fs-disable-block-cache-debugging-by-default.patch
ext2fs-optimize-bcache0003-ext2fs-keep-list-of-reusable-disk-cache-entries.patch
+translators-list0001-fu_gki.patch
+translators-list0002-libfshelp-acquire-references-to-control-ports.patch
+translators-list0003-libihash-add-general-purpose-hash-functions.patch
+translators-list0004-libfshelp-improve-translator-list.patch
+translators-list0005-add-iteration.patch
diff --git a/debian/patches/translators-list0001-fu_gki.patch b/debian/patches/translators-list0001-fu_gki.patch
new file mode 100644
index 00000000..deb4a1d1
--- /dev/null
+++ b/debian/patches/translators-list0001-fu_gki.patch
@@ -0,0 +1,26 @@
+From c65b42c1f589fe99129b7be08350ba6565d68376 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 24 Nov 2015 01:33:29 +0100
+Subject: [PATCH hurd 1/5] fu_gki
+
+---
+ libihash/ihash.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/libihash/ihash.c b/libihash/ihash.c
+index ae9f970..292743b 100644
+--- a/libihash/ihash.c
++++ b/libihash/ihash.c
+@@ -44,7 +44,8 @@ hash (hurd_ihash_t ht, hurd_ihash_key_t k)
+ static inline int
+ compare (hurd_ihash_t ht, hurd_ihash_key_t a, hurd_ihash_key_t b)
+ {
+- return ht->fct_cmp ? (a && ht->fct_cmp (a, b)) : a == b;
++ return
++ ht->fct_cmp ? (a && ht->fct_cmp ((void *) a, (void *) b)) : a == b;
+ }
+
+ /* Return 1 if the slot with the index IDX in the hash table HT is
+--
+2.1.4
+
diff --git a/debian/patches/translators-list0002-libfshelp-acquire-references-to-control-ports.patch b/debian/patches/translators-list0002-libfshelp-acquire-references-to-control-ports.patch
new file mode 100644
index 00000000..bd906408
--- /dev/null
+++ b/debian/patches/translators-list0002-libfshelp-acquire-references-to-control-ports.patch
@@ -0,0 +1,59 @@
+From 271da35911f35184cc0f3d77321794cf680cf6b6 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 20 Nov 2015 12:46:56 +0100
+Subject: [PATCH hurd 2/5] libfshelp: acquire references to control ports
+
+* libfshelp/translator-list.c (translator_ihash_cleanup): Release reference.
+(fshelp_set_active_translator): Acquire reference
+---
+ libfshelp/translator-list.c | 16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
+index c87bbaa..87d7f6a 100644
+--- a/libfshelp/translator-list.c
++++ b/libfshelp/translator-list.c
+@@ -49,12 +49,13 @@ static pthread_mutex_t translator_ihash_lock = PTHREAD_MUTEX_INITIALIZER;
+ static void
+ translator_ihash_cleanup (void *element, void *arg)
+ {
++ error_t err;
+ struct translator *translator = element;
+
+ if (translator->pi)
+ ports_port_deref (translator->pi);
+- /* No need to deallocate translator->active, we only keep the name of
+- the port, not a reference. */
++ err = mach_port_deallocate (mach_task_self (), translator->active);
++ assert_perror (err);
+ free (translator->name);
+ free (translator);
+ }
+@@ -124,8 +125,14 @@ fshelp_set_active_translator (struct port_info *pi,
+ t->pi = pi;
+ }
+
+- /* No need to increment the reference count, we only keep the
+- name, not a reference. */
++ if (MACH_PORT_VALID (t->active))
++ {
++ err = mach_port_deallocate (mach_task_self (), t->active);
++ assert_perror (err);
++ }
++ err = mach_port_mod_refs (mach_task_self (), active,
++ MACH_PORT_RIGHT_SEND, +1);
++ assert_perror (err);
+ t->active = active;
+ }
+ else
+@@ -143,6 +150,7 @@ error_t
+ fshelp_remove_active_translator (mach_port_t active)
+ {
+ error_t err = 0;
++
+ pthread_mutex_lock (&translator_ihash_lock);
+
+ struct translator *t = NULL;
+--
+2.1.4
+
diff --git a/debian/patches/translators-list0003-libihash-add-general-purpose-hash-functions.patch b/debian/patches/translators-list0003-libihash-add-general-purpose-hash-functions.patch
new file mode 100644
index 00000000..2d095777
--- /dev/null
+++ b/debian/patches/translators-list0003-libihash-add-general-purpose-hash-functions.patch
@@ -0,0 +1,144 @@
+From 217f0c33da62cb96e12873a8f80a673caefac4c3 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 24 Nov 2015 01:07:32 +0100
+Subject: [PATCH hurd 3/5] libihash: add general purpose hash functions
+
+* libihash/Makefile (SRCS): Add new file.
+* libihash/fasthash.c: New file.
+* libihash/ihash.h (hurd_ihash_fasthash{32,64}): New prototypes.
+---
+ libihash/Makefile | 2 +-
+ libihash/fasthash.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++
+ libihash/ihash.h | 14 ++++++++++
+ 3 files changed, 91 insertions(+), 1 deletion(-)
+ create mode 100644 libihash/fasthash.c
+
+diff --git a/libihash/Makefile b/libihash/Makefile
+index 09bb136..eb5d87e 100644
+--- a/libihash/Makefile
++++ b/libihash/Makefile
+@@ -20,7 +20,7 @@ dir := libihash
+ makemode := library
+
+ libname := libihash
+-SRCS = ihash.c
++SRCS = ihash.c fasthash.c
+ installhdrs = ihash.h
+
+ OBJS = $(SRCS:.c=.o)
+diff --git a/libihash/fasthash.c b/libihash/fasthash.c
+new file mode 100644
+index 0000000..9295cf1
+--- /dev/null
++++ b/libihash/fasthash.c
+@@ -0,0 +1,76 @@
++/* The MIT License
++
++ Copyright (C) 2012 Zilong Tan (eric.zltan@gmail.com)
++
++ Permission is hereby granted, free of charge, to any person
++ obtaining a copy of this software and associated documentation
++ files (the "Software"), to deal in the Software without
++ restriction, including without limitation the rights to use, copy,
++ modify, merge, publish, distribute, sublicense, and/or sell copies
++ of the Software, and to permit persons to whom the Software is
++ furnished to do so, subject to the following conditions:
++
++ The above copyright notice and this permission notice shall be
++ included in all copies or substantial portions of the Software.
++
++ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
++ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
++ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
++ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
++ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
++ SOFTWARE.
++*/
++
++#include <stdint.h>
++#include <stdio.h>
++
++// Compression function for Merkle-Damgard construction.
++// This function is generated using the framework provided.
++#define mix(h) ({ \
++ (h) ^= (h) >> 23; \
++ (h) *= 0x2127599bf4325c37ULL; \
++ (h) ^= (h) >> 47; })
++
++uint64_t hurd_ihash_fasthash64(const void *buf, size_t len, uint64_t seed)
++{
++ const uint64_t m = 0x880355f21e6d1965ULL;
++ const uint64_t *pos = (const uint64_t *)buf;
++ const uint64_t *end = pos + (len / 8);
++ const unsigned char *pos2;
++ uint64_t h = seed ^ (len * m);
++ uint64_t v;
++
++ while (pos != end) {
++ v = *pos++;
++ h ^= mix(v);
++ h *= m;
++ }
++
++ pos2 = (const unsigned char*)pos;
++ v = 0;
++
++ switch (len & 7) {
++ case 7: v ^= (uint64_t)pos2[6] << 48;
++ case 6: v ^= (uint64_t)pos2[5] << 40;
++ case 5: v ^= (uint64_t)pos2[4] << 32;
++ case 4: v ^= (uint64_t)pos2[3] << 24;
++ case 3: v ^= (uint64_t)pos2[2] << 16;
++ case 2: v ^= (uint64_t)pos2[1] << 8;
++ case 1: v ^= (uint64_t)pos2[0];
++ h ^= mix(v);
++ h *= m;
++ }
++
++ return mix(h);
++}
++
++uint32_t hurd_ihash_fasthash32(const void *buf, size_t len, uint32_t seed)
++{
++ // the following trick converts the 64-bit hashcode to Fermat
++ // residue, which shall retain information from both the higher
++ // and lower parts of hashcode.
++ uint64_t h = hurd_ihash_fasthash64(buf, len, seed);
++ return h - (h >> 32);
++}
+diff --git a/libihash/ihash.h b/libihash/ihash.h
+index 986291b..50676a6 100644
+--- a/libihash/ihash.h
++++ b/libihash/ihash.h
+@@ -136,6 +136,13 @@ typedef struct hurd_ihash *hurd_ihash_t;
+ .max_load = HURD_IHASH_MAX_LOAD_DEFAULT, \
+ .locp_offset = (locp_offs)}
+
++#define HURD_IHASH_INITIALIZER_GKI(locp_offs, cleanup, hash, compare) \
++ { .nr_items = 0, .size = 0, .cleanup = (cleanup), \
++ .max_load = HURD_IHASH_MAX_LOAD_DEFAULT, \
++ .locp_offset = (locp_offs), \
++ .fct_hash = (hash), \
++ .fct_cmp = (compare)} \
++
+ /* Initialize the hash table at address HT. If LOCP_OFFSET is not
+ HURD_IHASH_NO_LOCP, then this is an offset (in bytes) from the
+ address of a hash value where a location pointer can be found. The
+@@ -339,5 +346,12 @@ int hurd_ihash_remove (hurd_ihash_t ht, hurd_ihash_key_t key);
+ was provided to hurd_ihash_add(). This call is faster than
+ hurd_ihash_remove(). */
+ void hurd_ihash_locp_remove (hurd_ihash_t ht, hurd_ihash_locp_t locp);
++
++/* General purpose hash functions. */
++
++/* Zilong Tans fast-hash. Based on 'Marsaglia, George. "Xorshift
++ rngs." Journal of Statistical Software 8.14 (2003): 1-6.' */
++uint32_t hurd_ihash_fasthash32 (const void *buf, size_t len, uint32_t seed);
++uint64_t hurd_ihash_fasthash64 (const void *buf, size_t len, uint64_t seed);
+
+ #endif /* _HURD_IHASH_H */
+--
+2.1.4
+
diff --git a/debian/patches/translators-list0004-libfshelp-improve-translator-list.patch b/debian/patches/translators-list0004-libfshelp-improve-translator-list.patch
new file mode 100644
index 00000000..4ff57631
--- /dev/null
+++ b/debian/patches/translators-list0004-libfshelp-improve-translator-list.patch
@@ -0,0 +1,127 @@
+From 8352b022201c7446e90e5cc1d9f0e2f8651543f3 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 24 Nov 2015 01:20:57 +0100
+Subject: [PATCH hurd 4/5] libfshelp: improve translator list
+
+Use the path names of active translators as keys in the hash table.
+
+* libfshelp/translator-list.c (hash, compare): New functions.
+(translator_ihash): Use generalized key interface.
+(fshelp_set_active_translator): Update accordingly.
+(fshelp_remove_active_translator): Likewise.
+---
+ libfshelp/translator-list.c | 59 +++++++++++++++++++++++++++------------------
+ 1 file changed, 35 insertions(+), 24 deletions(-)
+
+diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
+index 87d7f6a..fa754ae 100644
+--- a/libfshelp/translator-list.c
++++ b/libfshelp/translator-list.c
+@@ -1,6 +1,6 @@
+ /* A list of active translators.
+
+- Copyright (C) 2013,14 Free Software Foundation, Inc.
++ Copyright (C) 2013,14,15 Free Software Foundation, Inc.
+
+ Written by Justus Winter <4winter@informatik.uni-hamburg.de>
+
+@@ -39,18 +39,12 @@ struct translator
+ mach_port_t active;
+ };
+
+-/* The list of active translators. */
+-static struct hurd_ihash translator_ihash
+- = HURD_IHASH_INITIALIZER (HURD_IHASH_NO_LOCP);
+-
+-/* The lock protecting the translator_ihash. */
+-static pthread_mutex_t translator_ihash_lock = PTHREAD_MUTEX_INITIALIZER;
+-
++/* The hash table requires some callback functions. */
+ static void
+-translator_ihash_cleanup (void *element, void *arg)
++cleanup (void *value, void *arg)
+ {
+ error_t err;
+- struct translator *translator = element;
++ struct translator *translator = value;
+
+ if (translator->pi)
+ ports_port_deref (translator->pi);
+@@ -60,6 +54,26 @@ translator_ihash_cleanup (void *element, void *arg)
+ free (translator);
+ }
+
++static hurd_ihash_key_t
++hash (void *key)
++{
++ const char *path = key;
++ return (hurd_ihash_key_t) hurd_ihash_fasthash32 (path, strlen (path), 0);
++}
++
++static int
++compare (void *a, void *b)
++{
++ return strcmp ((const char *) a, (const char *) b) == 0;
++}
++
++/* The list of active translators. */
++static struct hurd_ihash translator_ihash
++ = HURD_IHASH_INITIALIZER_GKI (HURD_IHASH_NO_LOCP, cleanup, hash, compare);
++
++/* The lock protecting the translator_ihash. */
++static pthread_mutex_t translator_ihash_lock = PTHREAD_MUTEX_INITIALIZER;
++
+ /* Record an active translator being bound to the given file name
+ NAME. ACTIVE is the control port of the translator. */
+ error_t
+@@ -68,20 +82,16 @@ fshelp_set_active_translator (struct port_info *pi,
+ mach_port_t active)
+ {
+ error_t err = 0;
+- pthread_mutex_lock (&translator_ihash_lock);
+-
+- if (! translator_ihash.cleanup)
+- hurd_ihash_set_cleanup (&translator_ihash, translator_ihash_cleanup, NULL);
++ struct translator *t;
++ hurd_ihash_locp_t slot;
+
+- struct translator *t = NULL;
+- HURD_IHASH_ITERATE (&translator_ihash, value)
+- {
+- t = value;
+- if (strcmp (name, t->name) == 0)
+- goto update; /* Entry exists. */
+- }
++ pthread_mutex_lock (&translator_ihash_lock);
++ t = hurd_ihash_locp_find (&translator_ihash, (hurd_ihash_key_t) name,
++ &slot);
++ if (t)
++ goto update; /* Entry exists. */
+
+- t = malloc (sizeof (struct translator));
++ t = malloc (sizeof *t);
+ if (! t)
+ {
+ err = errno;
+@@ -98,7 +108,8 @@ fshelp_set_active_translator (struct port_info *pi,
+ goto out;
+ }
+
+- err = hurd_ihash_add (&translator_ihash, (hurd_ihash_key_t) t, t);
++ err = hurd_ihash_locp_add (&translator_ihash, slot,
++ (hurd_ihash_key_t) t->name, t);
+ if (err)
+ goto out;
+
+@@ -165,7 +176,7 @@ fshelp_remove_active_translator (mach_port_t active)
+ }
+
+ if (t)
+- hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t);
++ hurd_ihash_remove (&translator_ihash, (hurd_ihash_key_t) t->name);
+
+ pthread_mutex_unlock (&translator_ihash_lock);
+ return err;
+--
+2.1.4
+
diff --git a/debian/patches/translators-list0005-add-iteration.patch b/debian/patches/translators-list0005-add-iteration.patch
new file mode 100644
index 00000000..b43c8d40
--- /dev/null
+++ b/debian/patches/translators-list0005-add-iteration.patch
@@ -0,0 +1,28 @@
+From 6a8f2f282679a41d56aac7775b0ecd6cc434a565 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri, 20 Nov 2015 12:47:06 +0100
+Subject: [PATCH hurd 5/5] add iteration
+
+---
+ libfshelp/translator-list.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c
+index fa754ae..5c137d7 100644
+--- a/libfshelp/translator-list.c
++++ b/libfshelp/translator-list.c
+@@ -235,3 +235,11 @@ fshelp_get_active_translators (char **translators,
+ pthread_mutex_unlock (&translator_ihash_lock);
+ return err;
+ }
++
++/* For each active node, call FUN. The node is to be locked around the call
++ to FUN. If FUN returns non-zero for any node, then immediately stop, and
++ return that value. */
++error_t __attribute__ ((weak))
++fshelp_iterate_active_translators (error_t (*fun)(struct node *))
++{
++}
+--
+2.1.4
+