Re: [PATCH] libnetfs: remove unused fields.

2016-02-14 Thread Justus Winter
Quoting Flavio Cruz (2016-02-15 01:31:50)
> * libnetfs/netfs.h: Remove prevp and next fields from struct node.

Merged, thanks!



Re: [PATCH] libdiskfs: fix and improve locking in nrefs/nput.

2016-02-14 Thread Justus Winter
Quoting Flavio Cruz (2016-02-15 00:37:16)
> * libnetfs/node-nput.c: Do not unlock the node since it will be unlocked
> later.
> * libnetfs/node-nrele.c: Do not lock the node twice if not needed.

Good one :)  Merged, thanks!

Justus



Re: [PATCH] nfs: Use libihash for the node cache.

2016-02-14 Thread Justus Winter
Quoting Flavio Cruz (2016-02-15 00:37:54)
> * nfs/cache.c: Remove old node cache and use libihash. Use a pointer to
> the node handle as the key and the node itself as the value. Use
> netfs_make_node_alloc to allow libihash to set 'slot'.
> * nfs/nfs.c: Pass in a struct handle instead.
> * nfs/nfs.h: Add a hurd_ihash_locp_t field and remove hnext and hprevp.

Merged, thanks!

Justus



[bug #17134] fakeroot; ports

2016-02-14 Thread Samuel Thibault
Update of bug #17134 (project hurd):

  Status:None => Works For Me   
 Open/Closed:Open => Closed 
Wiki-like text discussion box: => I seems to be
working fine now indeed.


___

Reply to this item at:

  

___
  Message posté via/par Savannah
  http://savannah.gnu.org/




[bug #17134] fakeroot; ports

2016-02-14 Thread Justus Winter
Follow-up Comment #1, bug #17134 (project hurd):

Samuel, can you still reproduce this?

I observed id ports being created and destroyed like they should.  The large
number of ports after doing find / are likely all pager ports.

___

Reply to this item at:

  

___
  Message sent via/by Savannah
  http://savannah.gnu.org/




[PATCH] libnetfs: remove unused fields.

2016-02-14 Thread Flavio Cruz
* libnetfs/netfs.h: Remove prevp and next fields from struct node.
---
 libnetfs/netfs.h | 2 --
 1 file changed, 2 deletions(-)

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;
 
-- 
2.6.4




[PATCH] nfs: Use libihash for the node cache.

2016-02-14 Thread Flavio Cruz
* nfs/cache.c: Remove old node cache and use libihash. Use a pointer to
the node handle as the key and the node itself as the value. Use
netfs_make_node_alloc to allow libihash to set 'slot'.
* nfs/nfs.c: Pass in a struct handle instead.
* nfs/nfs.h: Add a hurd_ihash_locp_t field and remove hnext and hprevp.
---
 nfs/cache.c | 86 +
 nfs/nfs.c   | 11 
 nfs/nfs.h   |  5 ++--
 3 files changed, 44 insertions(+), 58 deletions(-)

diff --git a/nfs/cache.c b/nfs/cache.c
index 506b90f..4719ae3 100644
--- a/nfs/cache.c
+++ b/nfs/cache.c
@@ -24,49 +24,46 @@
 #include 
 #include 
 
-/* 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 (_node_refcnt_lock);
-  for (np = nodehash[h]; np; np = np->nn->hnext)
+  np = hurd_ihash_find (, (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 (_node_refcnt_lock);
   pthread_mutex_lock (>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 (, (hurd_ihash_key_t) >handle, np);
   pthread_mutex_lock (>lock);
-  nn->hnext = nodehash[h];
-  if (nn->hnext)
-nn->hnext->nn->hprevp = >hnext;
-  nn->hprevp = [h];
-  nodehash[h] = np;
 
   pthread_spin_unlock (_node_refcnt_lock);
   
@@ -162,9 +155,7 @@ 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 (, np->nn->slot);
   if (np->nn->dtrans == SYMLINK)
free (np->nn->transarg.name);
   free (np->nn);
@@ -178,7 +169,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 +181,14 @@ recache_handle (int *p, struct node *np)
   
   /* Unlink it */
   pthread_spin_lock (_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 (, 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 = >nn->hnext;
-  np->nn->hprevp = [h];
+  hurd_ihash_add (, (hurd_ihash_key_t) 

[PATCH] libdiskfs: fix and improve locking in nrefs/nput.

2016-02-14 Thread Flavio Cruz
* libnetfs/node-nput.c: Do not unlock the node since it will be unlocked
later.
* libnetfs/node-nrele.c: Do not lock the node twice if not needed.
---
 libdiskfs/node-nput.c  | 1 -
 libdiskfs/node-nrele.c | 8 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

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 (>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 (>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 (>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 (>lock);
+  if (! locked)
+pthread_mutex_lock (>lock);
   diskfs_drop_node (np);
 }
+  else if (locked)
+pthread_mutex_unlock (>lock);
 }
-- 
2.6.4




active translators stdout/stderr

2016-02-14 Thread Samuel Thibault
Hello,

We have various issues with the active translators' stdout/stderr:

- When mounting /proc from /etc/init.d/rc, stdout/stderr is closed, and
  thus as soon as e.g. mtab reports a warning, it gets SIGLOST and dies.
- When mounting the cdrom image from debian installer scripts, the
  script is not considered finished since the isofs translator is still
  running and possibly emitting output.

So, what should we do about stdout/stderr output?  Do we require their
output to be explicitly redirected by callers of mount and settrans?
In the mount case, people used to Linux will not think of doing it, so
perhaps we need it to do it for the user?

Samuel



Re: [gscriv...@gnu.org: [IMPORTANT] Ideas for Summer of Code 2016]

2016-02-14 Thread Manolis Ragkousis
Hey

On Feb 14, 2016 12:40 PM, "Justus Winter" <4win...@informatik.uni-hamburg.de>
wrote:
> *
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/package_manager.html
>
> This talks about replacing Guix symlink-tree with a specialized
> translator.

That would be a nice addition.

Manolis


Re: [gscriv...@gnu.org: [IMPORTANT] Ideas for Summer of Code 2016]

2016-02-14 Thread Justus Winter
Hi,

Quoting Samuel Thibault (2016-02-10 19:10:58)
> Any ideas/mentors for the summer of code?

I'd be happy to mentor someone.

I went over the list of our project ideas, and the ones I'd like to
see tackled the most are:

* 
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/virtualization.html

I have a unprivileged-subhurds prototype that "just" needs finishing.

* 
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/secure_chroot.html

I have factored out the proxying-bits from fakeroot so that it can be
shared.  The most simple chrooting translator is the identity
translator, which proxies RPCs without really modifying them.
Combining the identity translator with settrans --chroot gives us
chroot(8).  With a little more work, I believe that can be used to
implement chroot(2).  Whether or not that is secure remains to be
seen, maybe that is even an ill-conceived goal.

* 
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/package_manager.html

This talks about replacing Guix symlink-tree with a specialized
translator.

* https://www.gnu.org/software/hurd/community/gsoc/project_ideas/xattr.html

That would shut the Linux ext2 developers up...

* 
https://www.gnu.org/software/hurd/community/gsoc/project_ideas/driver_glue_code.html

s/dde/rump/g of course.


Cheers,
Justus