aboutsummaryrefslogtreecommitdiff
path: root/libnetfs/netfs.h
diff options
context:
space:
mode:
Diffstat (limited to 'libnetfs/netfs.h')
-rw-r--r--libnetfs/netfs.h42
1 files changed, 27 insertions, 15 deletions
diff --git a/libnetfs/netfs.h b/libnetfs/netfs.h
index 67a6a9a0..6c989a48 100644
--- a/libnetfs/netfs.h
+++ b/libnetfs/netfs.h
@@ -82,8 +82,8 @@ struct node
pthread_mutex_t lock;
- /* The number of references to this node. */
- int references;
+ /* Hard and soft references to this node. */
+ refcounts_t refcounts;
mach_port_t sockaddr;
@@ -397,10 +397,6 @@ netfs_netnode_node (struct netnode *netnode)
return (struct node *) ((char *) netnode - _netfs_sizeof_struct_node);
}
-/* Whenever node->references is to be touched, this lock must be
- held. Cf. netfs_nrele, netfs_nput, netfs_nref and netfs_drop_node. */
-extern pthread_spinlock_t netfs_node_refcnt_lock;
-
/* Normally called in main. This function sets up some of the netfs
server's internal state. */
void netfs_init (void);
@@ -425,22 +421,38 @@ struct protid *netfs_make_protid (struct peropen *po, struct iouser *user);
struct peropen *netfs_make_peropen (struct node *, int,
struct peropen *context);
-/* Add a reference to node NP. Unless you already hold a reference,
+/* Add a hard reference to node NP. Unless you already hold a reference,
NP must be locked. */
void netfs_nref (struct node *np);
-/* Releases a node. Drops a reference to node NP, which must not be
- locked by the caller. If this was the last reference, drops the
- node. The node cannot be used again without first obtaining a
- reference to it. */
+/* Add a light reference to a node. */
+void netfs_nref_light (struct node *np);
+
+/* Releases 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 then request soft references to be dropped. */
void netfs_nrele (struct node *np);
-/* Puts a node back. Drops a reference to the node NP, which must be
- locked by the caller (this lock will be released by netfs_nput).
- If this was the last reference, drops the node. The node cannot be
- used again without first obtaining a reference to it. */
+/* Release a soft 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 netfs_nrele_light (struct node *np);
+
+/* Puts a node back by releasing a hard reference on NP, which must
+ be locked by the caller (this lock will be released by netfs_nput).
+ If this was the last reference, then request soft references to be
+ dropped. */
void netfs_nput (struct node *np);
+/* The user must define this function in order to drop the soft references
+ that this node may have. When this function is called, node NP has just
+ lost its hard references and is now trying to also drop its soft references.
+ If the node is stored in another data structure (for caching purposes),
+ this allows the user to remove it so that the node can be safely deleted
+ from memory. */
+void netfs_try_dropping_softrefs (struct node *np);
+
/* Called internally when no more references to node NP exist. */
void netfs_drop_node (struct node *np);