diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-11-27 15:34:19 +0100 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-11-27 15:34:19 +0100 |
commit | 248c87f2ed7f3daaec3d8fef53ee4bb02c1bb837 (patch) | |
tree | 896c2b565ed7f4aabe28fb2f9114315c408514d3 | |
parent | a785d73379789f57e130fcce6712311b114ca470 (diff) |
add patch series
4 files changed, 218 insertions, 0 deletions
diff --git a/debian/patches/series b/debian/patches/series index 98f5eed6..a41abc52 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -63,3 +63,6 @@ ext2fs-optimize-bcache0002-ext2fs-disable-block-cache-debugging-by-default.patch ext2fs-optimize-bcache0003-ext2fs-keep-list-of-reusable-disk-cache-entries.patch nodeihash0001-libdiskfs-use-ihash-for-the-node-cache.patch nodeihash0002-xxx-fix-node-iteration.patch +translators-list0001-libfshelp-acquire-references-to-control-ports.patch +translators-list0002-libfshelp-improve-translator-list.patch +translators-list0003-add-iteration.patch diff --git a/debian/patches/translators-list0001-libfshelp-acquire-references-to-control-ports.patch b/debian/patches/translators-list0001-libfshelp-acquire-references-to-control-ports.patch new file mode 100644 index 00000000..7ce4f705 --- /dev/null +++ b/debian/patches/translators-list0001-libfshelp-acquire-references-to-control-ports.patch @@ -0,0 +1,59 @@ +From 3ca5ff92bfa08b55b5c41feea81612d4e7b468a0 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 1/3] 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-list0002-libfshelp-improve-translator-list.patch b/debian/patches/translators-list0002-libfshelp-improve-translator-list.patch new file mode 100644 index 00000000..542d90c2 --- /dev/null +++ b/debian/patches/translators-list0002-libfshelp-improve-translator-list.patch @@ -0,0 +1,128 @@ +From a41d8c6b3cf52af943c922455d302e24bcada33b 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 2/3] 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 | 60 +++++++++++++++++++++++++++------------------ + 1 file changed, 36 insertions(+), 24 deletions(-) + +diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c +index 87d7f6a..d1bf13e 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,27 @@ 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_hash32 (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, NULL, ++ 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 +83,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 +109,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 +177,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-list0003-add-iteration.patch b/debian/patches/translators-list0003-add-iteration.patch new file mode 100644 index 00000000..85146235 --- /dev/null +++ b/debian/patches/translators-list0003-add-iteration.patch @@ -0,0 +1,28 @@ +From e770feb26418adca826fe5740c9bf83ca329b036 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 3/3] 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 d1bf13e..1a01218 100644 +--- a/libfshelp/translator-list.c ++++ b/libfshelp/translator-list.c +@@ -236,3 +236,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 + |