Hello,

My apologies; I forgot to include these two libnetfs-related patches in the previous message storeio won't work without them. Also, here is a small change to netfs_attempt_lookup in storeio to avoid unnecessary lock and unlock calls.

Thanks,

--
Mikhail Karpov
From 0aba87af10bb923fa8e09188c5bb84625a06076e Mon Sep 17 00:00:00 2001
From: Mikhail Karpov <[email protected]>
Date: Wed, 26 Aug 2026 16:06:46 +0700
Subject: [PATCH 1/3] Change the order of calling the maptime_map function

---
 libnetfs/init-init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libnetfs/init-init.c b/libnetfs/init-init.c
index 19ed0d3d..f64c7bba 100644
--- a/libnetfs/init-init.c
+++ b/libnetfs/init-init.c
@@ -38,9 +38,9 @@ void
 netfs_init (void)
 {
   error_t err;
-  err = maptime_map (0, 0, &netfs_mtime);
+  err = maptime_map (1, 0, &netfs_mtime);
   if (err)
-    err = maptime_map (1, 0, &netfs_mtime);
+    err = maptime_map (0, 0, &netfs_mtime);
   if (err)
     error (2, err, "mapping time");
 
-- 
2.43.0
From c5bc6ac329c4dc5e63e4d4eb6e8854a4c97b7112 Mon Sep 17 00:00:00 2001
From: Mikhail Karpov <[email protected]>
Date: Thu, 3 Sep 2026 11:01:09 +0700
Subject: [PATCH] Removing unnecessary thread_mutex_lock/unlock

---
 storeio/storeio.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/storeio/storeio.c b/storeio/storeio.c
index b146742..3302c5c 100644
--- a/storeio/storeio.c
+++ b/storeio/storeio.c
@@ -688,15 +688,11 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir,
           return err;
         }
     }
-  pthread_mutex_unlock (&dir->lock);
 
   if (*name == '\0' || strcmp (name, ".") == 0)
     {
       *np = dir;
-      pthread_mutex_lock (&dir->lock);
       netfs_nref (*np);
-      pthread_mutex_unlock (&dir->lock);
-      pthread_mutex_lock (&(*np)->lock);
       return 0;
     }
 
@@ -716,7 +712,6 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir,
   if (current_node)
     {
       *np = current_node;
-      pthread_mutex_lock (&dir->lock);
       netfs_nref (*np);
       pthread_mutex_unlock (&dir->lock);
       pthread_mutex_lock (&(*np)->lock);
@@ -724,6 +719,7 @@ netfs_attempt_lookup (struct iouser *user, struct node *dir,
     }
 
   *np = NULL;
+  pthread_mutex_unlock (&dir->lock);
   debug ("netfs_attempt_lookup (user: %p, dir: %p, name: %s):\n",
           user, dir, name);
   debug ("netfs_attempt_lookup return: ENOENT\n");
-- 
2.43.0

From f9f844c98c0d6eea72905846d84989b11247b82f Mon Sep 17 00:00:00 2001
From: Mikhail Karpov <[email protected]>
Date: Wed, 26 Aug 2026 16:52:50 +0700
Subject: [PATCH 2/3] Adding hooks for create and destroy peropen

---
 libnetfs/Makefile          |  2 +-
 libnetfs/make-peropen.c    |  9 +++++++++
 libnetfs/netfs.h           |  8 ++++++++
 libnetfs/priv.c            | 26 ++++++++++++++++++++++++++
 libnetfs/release-peropen.c |  8 ++++++++
 5 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 libnetfs/priv.c

diff --git a/libnetfs/Makefile b/libnetfs/Makefile
index 24606ff9..8f947a3c 100644
--- a/libnetfs/Makefile
+++ b/libnetfs/Makefile
@@ -53,7 +53,7 @@ OTHERSRCS= drop-node.c init-init.c make-node.c make-peropen.c make-protid.c   \
 	runtime-argp.c std-runtime-argp.c std-startup-argp.c		      \
 	append-std-options.c trans-callback.c set-get-trans.c		      \
 	nref.c nrele.c nput.c file-get-storage-info-default.c dead-name.c     \
-	get-source.c
+	get-source.c priv.c
 
 SRCS= $(OTHERSRCS) $(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(IFSOCKSRCS)
 
diff --git a/libnetfs/make-peropen.c b/libnetfs/make-peropen.c
index 3b127881..9bb48923 100644
--- a/libnetfs/make-peropen.c
+++ b/libnetfs/make-peropen.c
@@ -43,6 +43,15 @@ netfs_make_peropen (struct node *np, int flags, struct peropen *context)
   po->np = np;
   po->path = NULL;
 
+  if (netfs_peropen_create_hook)
+    err = (*netfs_peropen_create_hook) (po);
+  if (err)
+    {
+      fshelp_rlock_po_fini (&po->lock_status);
+      free (po);
+      return NULL;
+    }
+
   if (context)
     {
       if (context->path)
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
index 6fc53ce4..1f1d5c2c 100644
--- a/libnetfs/netfs.h
+++ b/libnetfs/netfs.h
@@ -113,6 +113,14 @@ extern char *netfs_server_name;
    version number.  */
 extern char *netfs_server_version;
 
+/* If this variable is set, it is called internally every time a new peropen
+   structure is created and initialized.  */
+extern error_t (*netfs_peropen_create_hook) (struct peropen *po);
+
+/* If this variable is set, it is called internally every time a peropen
+   structure is about to be destroyed.  */
+extern void (*netfs_peropen_destroy_hook) (struct peropen *po);
+
 /* The user must define this function.  Make sure that NP->nn_stat is
    filled with the most current information.  CRED identifies the user
    responsible for the operation. NP is locked.  */
diff --git a/libnetfs/priv.c b/libnetfs/priv.c
new file mode 100644
index 00000000..4a46606f
--- /dev/null
+++ b/libnetfs/priv.c
@@ -0,0 +1,26 @@
+/* Default values for weak variables
+   Copyright (C) 2026 Free Software Foundation, Inc.
+
+   This file is part of the GNU Hurd.
+
+   The GNU Hurd is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   The GNU Hurd is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. */
+
+#include "netfs.h"
+
+error_t (*netfs_peropen_create_hook) (struct peropen *po)
+  __attribute__ ((weak));
+
+void (*netfs_peropen_destroy_hook) (struct peropen *po)
+  __attribute__ ((weak));
diff --git a/libnetfs/release-peropen.c b/libnetfs/release-peropen.c
index 43f4cba7..3dfca368 100644
--- a/libnetfs/release-peropen.c
+++ b/libnetfs/release-peropen.c
@@ -26,6 +26,14 @@ netfs_release_peropen (struct peropen *po)
   if (refcount_deref (&po->refcnt) > 0)
     return;
 
+  if (netfs_peropen_destroy_hook)
+    {
+      refcount_unsafe_ref (&po->refcnt);
+      (*netfs_peropen_destroy_hook) (po);
+      if (refcount_deref (&po->refcnt) > 0)
+        return;
+    }
+
   pthread_mutex_lock (&po->np->lock);
   if (po->root_parent)
     mach_port_deallocate (mach_task_self (), po->root_parent);
-- 
2.43.0


Reply via email to