commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 01/01: Fix inode hashing for FS with inode numbers bigger than 4


From: Samuel Thibault
Subject: [hurd] 01/01: Fix inode hashing for FS with inode numbers bigger than 4 billion
Date: Fri, 05 Jan 2018 23:57:30 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch master
in repository hurd.

commit 438e3ad1456cb1d81d25c112e507bfde1ff57fdd
Author: Samuel Thibault <address@hidden>
Date:   Fri Jan 5 23:56:51 2018 +0000

    Fix inode hashing for FS with inode numbers bigger than 4 billion
---
 debian/changelog                      |   7 +++
 debian/patches/get-identity_hash.diff | 101 ++++++++++++++++++++++++++++++++++
 debian/patches/series                 |   1 +
 3 files changed, 109 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 3a8498b..276a432 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+hurd (1:0.9.git20171119-4) UNRELEASED; urgency=medium
+
+  * patches/get-identity_hash.diff: Fix inode hashing for FS with inode
+    numbers bigger than 4 billion.
+
+ -- Samuel Thibault <address@hidden>  Fri, 05 Jan 2018 23:55:59 +0000
+
 hurd (1:0.9.git20171119-3) unstable; urgency=medium
 
   * patches/hash-weakref: New patch to fix use-after-free. Closes: Bug#882507.
diff --git a/debian/patches/get-identity_hash.diff 
b/debian/patches/get-identity_hash.diff
new file mode 100644
index 0000000..64a944c
--- /dev/null
+++ b/debian/patches/get-identity_hash.diff
@@ -0,0 +1,101 @@
+commit 0c2f60d3cbc3a23736f65dd96308dabdde43d9b2
+Author: Samuel Thibault <address@hidden>
+Date:   Fri Jan 5 23:55:48 2018 +0100
+
+    libfshelp/get-identity.c: add FIXME
+    
+    * libfshelp/get-identity.c (fshelp_get_identity): Add FIXME for FS with
+    inode numbers bigger than 4 billion.
+
+diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c
+index 9f92272e..3ca2379c 100644
+--- a/libfshelp/get-identity.c
++++ b/libfshelp/get-identity.c
+@@ -70,6 +70,7 @@ 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);
+   if (i == NULL)
+     {
+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.
+
+diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c
+index 3ca2379c..f88e0f82 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;
+ 
diff --git a/debian/patches/series b/debian/patches/series
index 1cba2e7..a130fb5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -31,3 +31,4 @@ exec_filename_rpctrace.patch
 exec_set_exe.patch
 pie-core
 hash-weakref
+get-identity_hash.diff

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]