summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdiskfs/ChangeLog17
-rw-r--r--libdiskfs/Makefile4
-rw-r--r--libdiskfs/diskfs.c2
-rw-r--r--libdiskfs/diskfs.h142
-rw-r--r--libdiskfs/node-nput.c69
-rw-r--r--libdiskfs/node-nputl.c38
-rw-r--r--libdiskfs/node-nref.c40
-rw-r--r--libdiskfs/node-nrefl.c30
-rw-r--r--libdiskfs/node-nrele.c65
-rw-r--r--libdiskfs/node-nrelel.c39
10 files changed, 307 insertions, 139 deletions
diff --git a/libdiskfs/ChangeLog b/libdiskfs/ChangeLog
index 686f49a3..26e7e714 100644
--- a/libdiskfs/ChangeLog
+++ b/libdiskfs/ChangeLog
@@ -1,3 +1,20 @@
+1999-07-01 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * node-nref.c: New file; guts from diskfs.h.
+ * node-nput.c: Likewise.
+ * node-nrele.c: Likewise.
+ * node-nrefl.c: Likewise.
+ * node-nputl.c: Likewise.
+ * node-nrelel.c: LIkewise.
+ * diskfs.h (diskfs_nref, diskfs_nput, diskfs_nrele,
+ diskfs_nref_light, diskfs_nput_light, diskfs_nrele_light): Replace
+ inline definitions with ordinary declarations.
+ (DISKFS_EI): Removed macro.
+ * diskfs.c: Deleted file.
+ * Makefile (OTHERSRCS): Added node-nref.c, node-nput.c
+ node-nrele.c, node-nrefl.c, node-nputl.c, node-nrelel.c. Removed
+ diskfs.c.
+
1999-06-29 Thomas Bushnell, BSG <tb@mit.edu>
* dev-globals.c, dev-io.c, dev-open.c: Files removed.
diff --git a/libdiskfs/Makefile b/libdiskfs/Makefile
index 6e92e174..612aaea2 100644
--- a/libdiskfs/Makefile
+++ b/libdiskfs/Makefile
@@ -38,6 +38,8 @@ FSYSSRCS=fsys-getroot.c fsys-goaway.c fsys-startup.c fsys-getfile.c \
IFSOCKSRCS=ifsock.c
OTHERSRCS = conch-fetch.c conch-set.c dir-clear.c dir-init.c dir-renamed.c \
node-create.c node-drop.c node-make.c node-rdwr.c node-update.c \
+ node-nref.c node-nput.c node-nrele.c node-nrefl.c node-nputl.c \
+ node-nrelel.c \
peropen-make.c peropen-rele.c protid-make.c protid-rele.c \
init-init.c init-startup.c init-first.c init-main.c \
rdwr-internal.c boot-start.c demuxer.c node-times.c shutdown.c \
@@ -47,7 +49,7 @@ OTHERSRCS = conch-fetch.c conch-set.c dir-clear.c dir-init.c dir-renamed.c \
trans-callback.c readonly.c remount.c console.c disk-pager.c \
name-cache.c direnter.c dirrewrite.c dirremove.c lookup.c dead-name.c \
validate-mode.c validate-group.c validate-author.c validate-flags.c \
- validate-rdev.c validate-owner.c extra-version.c diskfs.c
+ validate-rdev.c validate-owner.c extra-version.c
SRCS = $(OTHERSRCS) $(FSSRCS) $(IOSRCS) $(FSYSSRCS) $(IFSOCKSRCS)
LCLHDRS = diskfs.h priv.h lithp.h fsmutations.h diskfs-pager.h fhandle.h
installhdrs = diskfs.h diskfs-pager.h
diff --git a/libdiskfs/diskfs.c b/libdiskfs/diskfs.c
deleted file mode 100644
index 934fd168..00000000
--- a/libdiskfs/diskfs.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#define DISKFS_EI
-#include "diskfs.h"
diff --git a/libdiskfs/diskfs.h b/libdiskfs/diskfs.h
index 2332bf9c..73c55faf 100644
--- a/libdiskfs/diskfs.h
+++ b/libdiskfs/diskfs.h
@@ -26,10 +26,6 @@
#include <hurd/iohelp.h>
#include <idvec.h>
-#ifndef DISKFS_EI
-#define DISKFS_EI extern inline
-#endif
-
/* Each user port referring to a file points to one of these
(with the aid of the ports library). */
struct protid
@@ -577,156 +573,30 @@ void diskfs_node_update (struct node *np, int wait);
/* Add a hard reference to a node. If there were no hard
references previously, then the node cannot be locked
(because you must hold a hard reference to hold the lock). */
-DISKFS_EI void
-diskfs_nref (struct node *np)
-{
- int new_hardref;
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- new_hardref = (np->references == 1);
- spin_unlock (&diskfs_node_refcnt_lock);
- if (new_hardref)
- {
- mutex_lock (&np->lock);
- diskfs_new_hardrefs (np);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nref (struct node *np);
/* Unlock node NP and release a hard reference; if this is the last
hard reference and there are no links to the file then request
soft references to be dropped. */
-DISKFS_EI void
-diskfs_nput (struct node *np)
-{
- int tried_drop_softrefs = 0;
-
- loop:
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->references);
- np->references--;
- if (np->references + np->light_references == 0)
- diskfs_drop_node (np);
- else if (np->references == 0 && !tried_drop_softrefs)
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- diskfs_lost_hardrefs (np);
- if (!np->dn_stat.st_nlink)
- {
- /* There are no links. If there are soft references that
- can be dropped, we can't let them postpone deallocation.
- So attempt to drop them. But that's a user-supplied
- routine, which might result in further recursive calls to
- the ref-counting system. So we have to reacquire our
- reference around the call to forestall disaster. */
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-
- diskfs_try_dropping_softrefs (np);
-
- /* But there's no value in looping forever in this
- routine; only try to drop soft refs once. */
- tried_drop_softrefs = 1;
-
- /* Now we can drop the reference back... */
- goto loop;
- }
- mutex_unlock (&np->lock);
- }
- else
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nput (struct node *np);
/* Release a hard reference on NP. If NP is locked by anyone, then
this cannot be the last hard reference (because you must hold a
hard reference in order to hold the lock). If this is the last
hard reference and there are no links, then request soft references
to be dropped. */
-DISKFS_EI void
-diskfs_nrele (struct node *np)
-{
- int tried_drop_softrefs = 0;
-
- loop:
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->references);
- np->references--;
- if (np->references + np->light_references == 0)
- {
- mutex_lock (&np->lock);
- diskfs_drop_node (np);
- }
- else if (np->references == 0)
- {
- mutex_lock (&np->lock);
- spin_unlock (&diskfs_node_refcnt_lock);
- diskfs_lost_hardrefs (np);
- if (!np->dn_stat.st_nlink && !tried_drop_softrefs)
- {
- /* Same issue here as in nput; see that for explanation */
- spin_lock (&diskfs_node_refcnt_lock);
- np->references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-
- diskfs_try_dropping_softrefs (np);
- tried_drop_softrefs = 1;
-
- /* Now we can drop the reference back... */
- mutex_unlock (&np->lock);
- goto loop;
- }
- mutex_unlock (&np->lock);
- }
- else
- spin_unlock (&diskfs_node_refcnt_lock);
-}
+void diskfs_nrele (struct node *np);
/* Add a light reference to a node. */
-DISKFS_EI void
-diskfs_nref_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- np->light_references++;
- spin_unlock (&diskfs_node_refcnt_lock);
-}
+void diskfs_nref_light (struct node *np);
/* Unlock node NP and release a light reference */
-DISKFS_EI void
-diskfs_nput_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->light_references);
- np->light_references--;
- if (np->references + np->light_references == 0)
- diskfs_drop_node (np);
- else
- {
- spin_unlock (&diskfs_node_refcnt_lock);
- mutex_unlock (&np->lock);
- }
-}
+void diskfs_nput_light (struct node *np);
/* Release a light reference on NP. If NP is locked by anyone, then
this cannot be the last reference (because you must hold a
hard reference in order to hold the lock). */
-DISKFS_EI void
-diskfs_nrele_light (struct node *np)
-{
- spin_lock (&diskfs_node_refcnt_lock);
- assert (np->light_references);
- np->light_references--;
- if (np->references + np->light_references == 0)
- {
- mutex_lock (&np->lock);
- diskfs_drop_node (np);
- }
- else
- spin_unlock (&diskfs_node_refcnt_lock);
-}
+void diskfs_nrele_light (struct node *np);
/* Reading and writing of files. this is called by other filesystem
routines and handles extension of files automatically. NP is the
diff --git a/libdiskfs/node-nput.c b/libdiskfs/node-nput.c
new file mode 100644
index 00000000..425b2216
--- /dev/null
+++ b/libdiskfs/node-nput.c
@@ -0,0 +1,69 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Unlock node NP and release a hard reference; if this is the last
+ hard reference and there are no links to the file then request
+ soft references to be dropped. */
+void
+diskfs_nput (struct node *np)
+{
+ int tried_drop_softrefs = 0;
+
+ loop:
+ spin_lock (&diskfs_node_refcnt_lock);
+ assert (np->references);
+ np->references--;
+ if (np->references + np->light_references == 0)
+ diskfs_drop_node (np);
+ else if (np->references == 0 && !tried_drop_softrefs)
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ diskfs_lost_hardrefs (np);
+ if (!np->dn_stat.st_nlink)
+ {
+ /* There are no links. If there are soft references that
+ can be dropped, we can't let them postpone deallocation.
+ So attempt to drop them. But that's a user-supplied
+ routine, which might result in further recursive calls to
+ the ref-counting system. So we have to reacquire our
+ reference around the call to forestall disaster. */
+ spin_lock (&diskfs_node_refcnt_lock);
+ np->references++;
+ spin_unlock (&diskfs_node_refcnt_lock);
+
+ diskfs_try_dropping_softrefs (np);
+
+ /* But there's no value in looping forever in this
+ routine; only try to drop soft refs once. */
+ tried_drop_softrefs = 1;
+
+ /* Now we can drop the reference back... */
+ goto loop;
+ }
+ mutex_unlock (&np->lock);
+ }
+ else
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ mutex_unlock (&np->lock);
+ }
+}
diff --git a/libdiskfs/node-nputl.c b/libdiskfs/node-nputl.c
new file mode 100644
index 00000000..337bb25d
--- /dev/null
+++ b/libdiskfs/node-nputl.c
@@ -0,0 +1,38 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Unlock node NP and release a light reference */
+DISKFS_EI void
+diskfs_nput_light (struct node *np)
+{
+ spin_lock (&diskfs_node_refcnt_lock);
+ assert (np->light_references);
+ np->light_references--;
+ if (np->references + np->light_references == 0)
+ diskfs_drop_node (np);
+ else
+ {
+ spin_unlock (&diskfs_node_refcnt_lock);
+ mutex_unlock (&np->lock);
+ }
+}
diff --git a/libdiskfs/node-nref.c b/libdiskfs/node-nref.c
new file mode 100644
index 00000000..753de65f
--- /dev/null
+++ b/libdiskfs/node-nref.c
@@ -0,0 +1,40 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Add a hard reference to a node. If there were no hard
+ references previously, then the node cannot be locked
+ (because you must hold a hard reference to hold the lock). */
+void
+diskfs_nref (struct node *np)
+{
+ int new_hardref;
+ spin_lock (&diskfs_node_refcnt_lock);
+ np->references++;
+ new_hardref = (np->references == 1);
+ spin_unlock (&diskfs_node_refcnt_lock);
+ if (new_hardref)
+ {
+ mutex_lock (&np->lock);
+ diskfs_new_hardrefs (np);
+ mutex_unlock (&np->lock);
+ }
+}
diff --git a/libdiskfs/node-nrefl.c b/libdiskfs/node-nrefl.c
new file mode 100644
index 00000000..ce3b39dd
--- /dev/null
+++ b/libdiskfs/node-nrefl.c
@@ -0,0 +1,30 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Add a light reference to a node. */
+void
+diskfs_nref_light (struct node *np)
+{
+ spin_lock (&diskfs_node_refcnt_lock);
+ np->light_references++;
+ spin_unlock (&diskfs_node_refcnt_lock);
+}
diff --git a/libdiskfs/node-nrele.c b/libdiskfs/node-nrele.c
new file mode 100644
index 00000000..9dbc5d8c
--- /dev/null
+++ b/libdiskfs/node-nrele.c
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Release a hard reference on NP. If NP is locked by anyone, then
+ this cannot be the last hard reference (because you must hold a
+ hard reference in order to hold the lock). If this is the last
+ hard reference and there are no links, then request soft references
+ to be dropped. */
+void
+diskfs_nrele (struct node *np)
+{
+ int tried_drop_softrefs = 0;
+
+ loop:
+ spin_lock (&diskfs_node_refcnt_lock);
+ assert (np->references);
+ np->references--;
+ if (np->references + np->light_references == 0)
+ {
+ mutex_lock (&np->lock);
+ diskfs_drop_node (np);
+ }
+ else if (np->references == 0)
+ {
+ mutex_lock (&np->lock);
+ spin_unlock (&diskfs_node_refcnt_lock);
+ diskfs_lost_hardrefs (np);
+ if (!np->dn_stat.st_nlink && !tried_drop_softrefs)
+ {
+ /* Same issue here as in nput; see that for explanation */
+ spin_lock (&diskfs_node_refcnt_lock);
+ np->references++;
+ spin_unlock (&diskfs_node_refcnt_lock);
+
+ diskfs_try_dropping_softrefs (np);
+ tried_drop_softrefs = 1;
+
+ /* Now we can drop the reference back... */
+ mutex_unlock (&np->lock);
+ goto loop;
+ }
+ mutex_unlock (&np->lock);
+ }
+ else
+ spin_unlock (&diskfs_node_refcnt_lock);
+}
diff --git a/libdiskfs/node-nrelel.c b/libdiskfs/node-nrelel.c
new file mode 100644
index 00000000..e61f6378
--- /dev/null
+++ b/libdiskfs/node-nrelel.c
@@ -0,0 +1,39 @@
+/*
+ Copyright (C) 1999 Free Software Foundation, Inc.
+ Written by Thomas Bushnell, BSG.
+
+ 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 "priv.h"
+
+/* Release a light reference on NP. If NP is locked by anyone, then
+ this cannot be the last reference (because you must hold a
+ hard reference in order to hold the lock). */
+void
+diskfs_nrele_light (struct node *np)
+{
+ spin_lock (&diskfs_node_refcnt_lock);
+ assert (np->light_references);
+ np->light_references--;
+ if (np->references + np->light_references == 0)
+ {
+ mutex_lock (&np->lock);
+ diskfs_drop_node (np);
+ }
+ else
+ spin_unlock (&diskfs_node_refcnt_lock);
+}