[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 06/16: libfshelp/get-identity: Use 64bit hashing for inodes
From: |
Samuel Thibault |
Subject: |
[hurd] 06/16: libfshelp/get-identity: Use 64bit hashing for inodes |
Date: |
Tue, 09 Jan 2018 01:35:29 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 051c0a77360a629e047d5267b05cde4cdba0e064
Author: Samuel Thibault <address@hidden>
Date: Sat Jan 6 00:22:38 2018 +0100
libfshelp/get-identity: Use 64bit hashing for inodes
Reported by Brent W. Baccala.
hurd_ihash_key_t is 32bit only on 32bit platforms, so we need the same
hashing functions as in libdiskfs/node-cache.c.
* libfshelp/get-identity.c (mix_fasthash): New macro.
(hash, compare): New functions.
(idhash): Use HURD_IHASH_INITIALIZER_GKI instead of HURD_IHASH_INITIALIZER
to pass hash and compare.
(fshelp_get_identity): Pass address of fileno to hurd_ihash_find and
hurd_ihash_add instead of fileno itself.
---
libfshelp/get-identity.c | 36 ++++++++++++++++++++++++++++++++----
1 file changed, 32 insertions(+), 4 deletions(-)
diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c
index 3ca2379..f88e0f8 100644
--- a/libfshelp/get-identity.c
+++ b/libfshelp/get-identity.c
@@ -32,10 +32,38 @@ struct idspec
{
struct port_info pi;
hurd_ihash_locp_t id_hashloc;
+ ino_t cache_id;
};
+/* The size of ino_t is larger than hurd_ihash_key_t on 32 bit
+ platforms. We therefore have to use libihashs generalized key
+ interface. */
+
+/* This is the mix function of fasthash, see
+ https://code.google.com/p/fast-hash/ for reference. */
+#define mix_fasthash(h) ({ \
+ (h) ^= (h) >> 23; \
+ (h) *= 0x2127599bf4325c37ULL; \
+ (h) ^= (h) >> 47; })
+
+static hurd_ihash_key_t
+hash (const void *key)
+{
+ ino_t i;
+ i = *(ino_t *) key;
+ mix_fasthash (i);
+ return (hurd_ihash_key_t) i;
+}
+
+static int
+compare (const void *a, const void *b)
+{
+ return *(ino_t *) a == *(ino_t *) b;
+}
+
static struct hurd_ihash idhash
- = HURD_IHASH_INITIALIZER (offsetof (struct idspec, id_hashloc));
+ = HURD_IHASH_INITIALIZER_GKI (offsetof (struct idspec, id_hashloc),
+ NULL, NULL, hash, compare);
static void
id_clean (void *cookie)
@@ -70,14 +98,14 @@ fshelp_get_identity (struct port_bucket *bucket,
if (!idclass)
id_initialize ();
- /* FIXME: ino_t is 64bit, hurd_ihash_key_t is 32bit. */
- i = hurd_ihash_find (&idhash, (hurd_ihash_key_t) fileno);
+ i = hurd_ihash_find (&idhash, (hurd_ihash_key_t) &fileno);
if (i == NULL)
{
err = ports_create_port (idclass, bucket, sizeof (struct idspec), &i);
if (err)
goto lose;
- err = hurd_ihash_add (&idhash, (hurd_ihash_key_t) fileno, i);
+ i->cache_id = fileno;
+ err = hurd_ihash_add (&idhash, (hurd_ihash_key_t) &i->cache_id, i);
if (err)
goto lose_port;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (83fef6c -> 104f312), Samuel Thibault, 2018/01/08
- [hurd] 07/16: libfshelp/get-identity.c: Avoid spurious ihash removal, Samuel Thibault, 2018/01/08
- [hurd] 09/16: libfshelp/get-identity.c: Simplify checking weak references, Samuel Thibault, 2018/01/08
- [hurd] 06/16: libfshelp/get-identity: Use 64bit hashing for inodes,
Samuel Thibault <=
- [hurd] 08/16: libihash: Make sure we do not remove a locp several times, Samuel Thibault, 2018/01/08
- [hurd] 02/16: Record executable entry for PIE core dumps, Samuel Thibault, 2018/01/08
- [hurd] 04/16: libfshelp: Add weak reference for hash table reference, Samuel Thibault, 2018/01/08
- [hurd] 13/16: rpctrace: Pass prefixed_name to _hurd_exec_paths., Samuel Thibault, 2018/01/08
- [hurd] 05/16: libfshelp/get-identity.c: add FIXME, Samuel Thibault, 2018/01/08
- [hurd] 01/16: Reserve IDs for proc_set_exe and proc_get_exe, Samuel Thibault, 2018/01/08
- [hurd] 12/16: Use the new _hurd_exec_file_name function, Samuel Thibault, 2018/01/08
- [hurd] 16/16: Implement /proc/<pid>/exe, Samuel Thibault, 2018/01/08
- [hurd] 14/16: Fix exec_paths through fakeroot or chroot, Samuel Thibault, 2018/01/08
- [hurd] 10/16: Add a new exec_exec_paths RPC, Samuel Thibault, 2018/01/08