commit-hurd
[Top][All Lists]
Advanced

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

[hurd] 01/05: New upstream snapshot


From: Samuel Thibault
Subject: [hurd] 01/05: New upstream snapshot
Date: Tue, 23 Feb 2016 23:53:23 +0000

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

sthibault pushed a commit to branch master
in repository hurd.

commit d2930a3a6b11fbb7d6caed6434cf0b8267491f68
Author: Samuel Thibault <address@hidden>
Date:   Tue Feb 23 22:19:25 2016 +0000

    New upstream snapshot
---
 hurd/Makefile          |  4 +--
 hurd/gensym.awk        |  6 ++--
 libdiskfs/node-nput.c  |  1 -
 libdiskfs/node-nrele.c |  8 +++--
 libnetfs/netfs.h       |  2 --
 nfs/cache.c            | 87 ++++++++++++++++++++------------------------------
 nfs/nfs.c              | 11 ++++---
 nfs/nfs.h              |  5 +--
 procfs/rootdir.c       |  9 +++---
 trans/crash.c          |  2 +-
 trans/fakeroot.c       |  8 +++--
 utils/mount.c          | 33 +++++++++++++++++--
 12 files changed, 95 insertions(+), 81 deletions(-)

diff --git a/hurd/Makefile b/hurd/Makefile
index 4273ff3..2902d47 100644
--- a/hurd/Makefile
+++ b/hurd/Makefile
@@ -58,7 +58,7 @@ hurd.msgids: $(patsubst %.defs,%.msgids,$(filter 
%.defs,$(INSTHDRS)))
 %.symc.o: %.symc
        $(CC) -S $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS-$@) -x c -o $@ $<
 %.h: %.symc.o
-       sed <$< -e 's/^[^*].*$$//' | \
+       sed <$< -e 's/^[[:space:]]*//' -e 's/^[^*].*$$//' | \
            sed -e 's/^[*]/#define/' -e 's/mAgIc[^-0-9]*//' -e '/^ *$$/d' >$@
 
 %-ioctls.sym: tmpl-ioctls.sym
@@ -69,7 +69,7 @@ cpp = $(CC) $(CPPFLAGS) $(CFLAGS) $(CPPFLAGS-$@) -E -x c
 %ioctl-requests.list: %ioctl-headers.h
        $(cpp) $< | sed -n 's/^#.*"\([^"]*\)".*$$/\1/p' | sort | uniq | \
        while read f; do \
-         sed -n 's/^[  ]*#[    ]*define[       
]*\([A-Z0-9_]*\)[^A-Z0-9_][^A-Z0-9_]*_IO.*'\'$*\'.*$$'/\1/p' $$f; \
+         sed -n 's/^[  ]*#[    ]*define[       
]*\([A-Z0-9_]*\)[^A-Z0-9_][^A-Z0-9_]*_IO.*'\'$*\''.*$$/\1/p' $$f; \
        done | sort | uniq > $@
 
 %ioctl.defs: %ioctl.sym
diff --git a/hurd/gensym.awk b/hurd/gensym.awk
index 6c6e1a1..e5157c3 100644
--- a/hurd/gensym.awk
+++ b/hurd/gensym.awk
@@ -34,7 +34,7 @@ BEGIN {
 
 # Take an arbitrarily complex C symbol or expression and constantize it.
 /^expr/ {
-       print "__asm (\"";
+       printf "__asm (\"";
        if ($3 == "")
                printf "* %s mAgIc%%0\" : : \"i\" (%s));\n", $2, $2;
        else
@@ -43,7 +43,7 @@ BEGIN {
 
 # Output a symbol defining the size of a C structure.
 /^size/ {
-       print "__asm (\"";
+       printf "__asm (\"";
        if ($4 == "")
                printf "* %s_SIZE mAgIc%%0\" : : \"i\" (sizeof(struct %s)));\n",
                        toupper($3), $2;
@@ -54,7 +54,7 @@ BEGIN {
 
 # Output a symbol defining the byte offset of an element of a C structure.
 /^offset/ {
-       print "__asm (\"";
+       printf "__asm (\"";
        if ($5 == "")
        {
                printf "* %s_%s mAgIc%%0\" : : \"i\" (&((struct 
%s*)0)->%s));\n",
diff --git a/libdiskfs/node-nput.c b/libdiskfs/node-nput.c
index d23c103..d59769b 100644
--- a/libdiskfs/node-nput.c
+++ b/libdiskfs/node-nput.c
@@ -56,7 +56,6 @@ diskfs_nput (struct node *np)
             hold a weak reference ourselves. */
          diskfs_try_dropping_softrefs (np);
        }
-      pthread_mutex_unlock (&np->lock);
     }
 
   /* Finally get rid of our reference.  */
diff --git a/libdiskfs/node-nrele.c b/libdiskfs/node-nrele.c
index d962846..a96d134 100644
--- a/libdiskfs/node-nrele.c
+++ b/libdiskfs/node-nrele.c
@@ -28,6 +28,7 @@
 void
 diskfs_nrele (struct node *np)
 {
+  int locked = FALSE;
   struct references result;
 
   /* While we call the diskfs_try_dropping_softrefs, we need to hold
@@ -37,6 +38,7 @@ diskfs_nrele (struct node *np)
 
   if (result.hard == 0)
     {
+      locked = TRUE;
       pthread_mutex_lock (&np->lock);
       diskfs_lost_hardrefs (np);
       if (!np->dn_stat.st_nlink)
@@ -49,7 +51,6 @@ diskfs_nrele (struct node *np)
             hold a weak reference ourselves. */
          diskfs_try_dropping_softrefs (np);
        }
-      pthread_mutex_unlock (&np->lock);
     }
 
   /* Finally get rid of our reference.  */
@@ -57,7 +58,10 @@ diskfs_nrele (struct node *np)
 
   if (result.hard == 0 && result.weak == 0)
     {
-      pthread_mutex_lock (&np->lock);
+      if (! locked)
+        pthread_mutex_lock (&np->lock);
       diskfs_drop_node (np);
     }
+  else if (locked)
+    pthread_mutex_unlock (&np->lock);
 }
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
index 3f94ccd..67a6a9a 100644
--- a/libnetfs/netfs.h
+++ b/libnetfs/netfs.h
@@ -70,8 +70,6 @@ struct peropen
 /* A unique one of these exists for each node currently in use. */
 struct node
 {
-  struct node *next, **prevp;
-
   /* Protocol specific stuff; defined by user.  */
   struct netnode *nn;
 
diff --git a/nfs/cache.c b/nfs/cache.c
index 506b90f..b48152e 100644
--- a/nfs/cache.c
+++ b/nfs/cache.c
@@ -24,49 +24,46 @@
 #include <stdio.h>
 #include <netinet/in.h>
 
-/* Hash table containing all the nodes currently active.  XXX Was 512,
-   however, a prime is much nicer for the hash function.  509 is nice
-   as not only is it prime, it also keeps the array within a page or
-   two.  */
-#define CACHESIZE 509
-static struct node *nodehash [CACHESIZE];
-
-/* Compute and return a hash key for NFS file handle DATA of LEN
-   bytes.  */
-static inline int
-hash (int *data, size_t len)
+/* Compute and return a hash key for NFS file handle.  */
+static hurd_ihash_key_t
+ihash_hash (const void *data)
 {
-  unsigned int h = 0;
-  char *cp = (char *)data;
-  int i;
-  
-  for (i = 0; i < len; i++)
-    h += cp[i];
-  
-  return h % CACHESIZE;
+  const struct fhandle *handle = (struct fhandle *) data;
+  return (hurd_ihash_key_t) hurd_ihash_hash32 (handle->data, handle->size, 0);
+}
+
+/* Compare two handles which are used as keys.  */
+static int
+ihash_compare (const void *key1, const void *key2)
+{
+  const struct fhandle *handle1 = (struct fhandle *) key1;
+  const struct fhandle *handle2 = (struct fhandle *) key2;
+
+  return handle1->size == handle2->size &&
+    memcmp (handle1->data, handle2->data, handle1->size) == 0;
 }
 
-/* Lookup the file handle P (length LEN) in the hash table.  If it is
+/* Hash table containing all the nodes currently active.  */
+static struct hurd_ihash nodehash =
+  HURD_IHASH_INITIALIZER_GKI (sizeof (struct node)
+                              + offsetof (struct netnode, slot), NULL, NULL,
+                              ihash_hash, ihash_compare);
+
+/* Lookup the file handle HANDLE in the hash table.  If it is
    not present, initialize a new node structure and insert it into the
    hash table.  Whichever course, a new reference is generated and the
    node is returned in *NPP; the lock on the node, (*NPP)->LOCK, is
    held.  */
 void
-lookup_fhandle (void *p, size_t len, struct node **npp)
+lookup_fhandle (struct fhandle *handle, struct node **npp)
 {
   struct node *np;
   struct netnode *nn;
-  int h;
-
-  h = hash (p, len);
 
   pthread_spin_lock (&netfs_node_refcnt_lock);
-  for (np = nodehash[h]; np; np = np->nn->hnext)
+  np = hurd_ihash_find (&nodehash, (hurd_ihash_key_t) handle);
+  if (np)
     {
-      if (np->nn->handle.size != len
-         || memcmp (np->nn->handle.data, p, len) != 0)
-       continue;
-      
       np->references++;
       pthread_spin_unlock (&netfs_node_refcnt_lock);
       pthread_mutex_lock (&np->lock);
@@ -75,23 +72,19 @@ lookup_fhandle (void *p, size_t len, struct node **npp)
     }
   
   /* Could not find it */
-  nn = malloc (sizeof (struct netnode));
-  assert (nn);
+  np = netfs_make_node_alloc (sizeof (struct netnode));
+  assert (np);
+  nn = netfs_node_netnode (np);
 
-  nn->handle.size = len;
-  memcpy (nn->handle.data, p, len);
+  nn->handle.size = handle->size;
+  memcpy (nn->handle.data, handle->data, handle->size);
   nn->stat_updated = 0;
   nn->dtrans = NOT_POSSIBLE;
   nn->dead_dir = 0;
   nn->dead_name = 0;
   
-  np = netfs_make_node (nn);
+  hurd_ihash_add (&nodehash, (hurd_ihash_key_t) &nn->handle, np);
   pthread_mutex_lock (&np->lock);
-  nn->hnext = nodehash[h];
-  if (nn->hnext)
-    nn->hnext->nn->hprevp = &nn->hnext;
-  nn->hprevp = &nodehash[h];
-  nodehash[h] = np;
 
   pthread_spin_unlock (&netfs_node_refcnt_lock);
   
@@ -162,12 +155,9 @@ netfs_node_norefs (struct node *np)
     }
   else
     {
-      *np->nn->hprevp = np->nn->hnext;
-      if (np->nn->hnext)
-       np->nn->hnext->nn->hprevp = np->nn->hprevp;
+      hurd_ihash_locp_remove (&nodehash, np->nn->slot);
       if (np->nn->dtrans == SYMLINK)
        free (np->nn->transarg.name);
-      free (np->nn);
       free (np);
     }
 }
@@ -178,7 +168,6 @@ netfs_node_norefs (struct node *np)
 int *
 recache_handle (int *p, struct node *np)
 {
-  int h;
   size_t len;
 
   if (protocol_version == 2)
@@ -191,20 +180,14 @@ recache_handle (int *p, struct node *np)
   
   /* Unlink it */
   pthread_spin_lock (&netfs_node_refcnt_lock);
-  *np->nn->hprevp = np->nn->hnext;
-  if (np->nn->hnext)
-    np->nn->hnext->nn->hprevp = np->nn->hprevp;
+  hurd_ihash_locp_remove (&nodehash, np->nn->slot);
 
   /* Change the name */
   np->nn->handle.size = len;
   memcpy (np->nn->handle.data, p, len);
   
   /* Reinsert it */
-  h = hash (p, len);
-  np->nn->hnext = nodehash[h];
-  if (np->nn->hnext)
-    np->nn->hnext->nn->hprevp = &np->nn->hnext;
-  np->nn->hprevp = &nodehash[h];
+  hurd_ihash_add (&nodehash, (hurd_ihash_key_t) &np->nn->handle, np);
   
   pthread_spin_unlock (&netfs_node_refcnt_lock);
   return p + len / sizeof (int);
diff --git a/nfs/nfs.c b/nfs/nfs.c
index 4916df6..7728156 100644
--- a/nfs/nfs.c
+++ b/nfs/nfs.c
@@ -383,18 +383,19 @@ xdr_decode_64bit (int *p, long long *n)
 int *
 xdr_decode_fhandle (int *p, struct node **npp)
 {
-  size_t len;
+  struct fhandle handle;
 
   if (protocol_version == 2)
-    len = NFS2_FHSIZE;
+    handle.size = NFS2_FHSIZE;
   else
     {
-      len = ntohl (*p);
+      handle.size = ntohl (*p);
       p++;
     }
+  memcpy (&handle.data, p, handle.size);
   /* Enter into cache.  */
-  lookup_fhandle (p, len, npp);
-  return p + len / sizeof (int);
+  lookup_fhandle (&handle, npp);
+  return p + handle.size / sizeof (int);
 }
 
 /* Decode *P into a stat structure; return the address of the
diff --git a/nfs/nfs.h b/nfs/nfs.h
index 18dec00..8424acb 100644
--- a/nfs/nfs.h
+++ b/nfs/nfs.h
@@ -24,6 +24,7 @@
 #include <pthread.h>
 #include <sys/mman.h>
 #include "nfs-spec.h"
+#include <hurd/ihash.h>
 #include <hurd/netfs.h>
 
 /* A file handle */
@@ -39,9 +40,9 @@ struct fhandle
    node. */
 struct netnode
 {
+  hurd_ihash_locp_t slot;
   struct fhandle handle;
   time_t stat_updated;
-  struct node *hnext, **hprevp;
 
   /* These two fields handle translators set internally but
      unknown to the server. */
@@ -192,7 +193,7 @@ void *timeout_service_thread (void *);
 void *rpc_receive_thread (void *);
 
 /* cache.c */
-void lookup_fhandle (void *, size_t, struct node **);
+void lookup_fhandle (struct fhandle *, struct node **);
 int *recache_handle (int *, struct node *);
 
 /* name-cache.c */
diff --git a/procfs/rootdir.c b/procfs/rootdir.c
index 1e9ec8f..93fef8d 100644
--- a/procfs/rootdir.c
+++ b/procfs/rootdir.c
@@ -446,12 +446,11 @@ rootdir_gc_slabinfo (void *hook, char **contents, ssize_t 
*contents_len)
 
   for (i = 0; i < cache_info_count; i++)
     {
-      mem_usage = (cache_info[i].nr_slabs * cache_info[i].slab_size)
-       >> 10;
+      mem_usage =
+       (cache_info[i].nr_slabs * cache_info[i].slab_size) >> 10;
       mem_total += mem_usage;
-      mem_reclaimable = (cache_info[i].flags & CACHE_FLAGS_NO_RECLAIM)
-       ? 0 : (cache_info[i].nr_free_slabs
-              * cache_info[i].slab_size) >> 10;
+      mem_reclaimable =
+       (cache_info[i].nr_free_slabs * cache_info[i].slab_size) >> 10;
       mem_total_reclaimable += mem_reclaimable;
       fprintf (m,
                "%-21s %04x %7zu %3zuk  %4lu %6lu %6lu %7zuk %10zuk\n",
diff --git a/trans/crash.c b/trans/crash.c
index 23f2a2d..9279bab 100644
--- a/trans/crash.c
+++ b/trans/crash.c
@@ -186,7 +186,7 @@ S_crash_dump_task (mach_port_t port,
       if (err)
        break;
 
-      if (user_proc != MACH_PORT_NULL)
+      if (! MACH_PORT_VALID (user_proc))
        err = proc_task2proc (procserver, task, &user_proc);
       if (! err)
        {
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 64f3208..cb4f818 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -1032,10 +1032,12 @@ netfs_demuxer (mach_msg_header_t *inp,
          err = mach_msg (inp, MACH_SEND_MSG, inp->msgh_size, 0,
                          MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE,
                          MACH_PORT_NULL);
-         assert_perror (err);  /* XXX should synthesize reply */
+         if (err)
+           ((mig_reply_header_t *) outp)->RetCode = err;
+         else
+           /* We already sent the message, so the server loop shouldn't do it 
again.  */
+           ((mig_reply_header_t *) outp)->RetCode = MIG_NO_REPLY;
          ports_port_deref (cred);
-         /* We already sent the message, so the server loop shouldn't do it 
again.  */
-         ((mig_reply_header_t *) outp)->RetCode = MIG_NO_REPLY;
          return 1;
        }
     }
diff --git a/utils/mount.c b/utils/mount.c
index c5736ba..5fa35bc 100644
--- a/utils/mount.c
+++ b/utils/mount.c
@@ -420,9 +420,36 @@ do_mount (struct fs *fs, int remount)
       }
 
       explain ("settrans -a");
-      err = fshelp_start_translator (open_node, NULL, fsopts,
-                                    fsopts, fsopts_len, timeout,
-                                    &active_control);
+      {
+       mach_port_t ports[INIT_PORT_MAX];
+       mach_port_t fds[STDERR_FILENO + 1];
+       int ints[INIT_INT_MAX];
+       int i;
+
+       for (i = 0; i < INIT_PORT_MAX; i++)
+         ports[i] = MACH_PORT_NULL;
+       for (i = 0; i < STDERR_FILENO + 1; i++)
+         fds[i] = MACH_PORT_NULL;
+       memset (ints, 0, INIT_INT_MAX * sizeof(int));
+
+       ports[INIT_PORT_CWDIR] = getcwdir ();
+       ports[INIT_PORT_CRDIR] = getcrdir ();
+       ports[INIT_PORT_AUTH] = getauth ();
+
+       err = fshelp_start_translator_long (open_node, NULL,
+                                           fsopts, fsopts, fsopts_len,
+                                           fds, MACH_MSG_TYPE_COPY_SEND,
+                                           STDERR_FILENO + 1,
+                                           ports, MACH_MSG_TYPE_COPY_SEND,
+                                           INIT_PORT_MAX,
+                                           ints, INIT_INT_MAX,
+                                           geteuid (),
+                                           timeout, &active_control);
+       for (i = 0; i < INIT_PORT_MAX; i++)
+         mach_port_deallocate (mach_task_self (), ports[i]);
+       for (i = 0; i <= STDERR_FILENO; i++)
+         mach_port_deallocate (mach_task_self (), fds[i]);
+      }
       /* If ERR is due to a problem opening the translated node, we print
         that name, otherwise, the name of the translator.  */
       if (open_err)

-- 
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]