summaryrefslogtreecommitdiff
path: root/libdiskfs/node-drop.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-05-14 11:19:35 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-04-17 14:06:46 +0200
commitc16eed2cb64089bf7d958db0fe85352f4ceefb4d (patch)
tree3240f6e025fa4c4fb47d7d270f285a7f0f9612e4 /libdiskfs/node-drop.c
parent8c050fb080c6e1981dc8e5a97a2313cd24e9b4b4 (diff)
libdiskfs: lock-less reference counting of nodes
* libdiskfs/diskfs.h (struct node): Use refcounts_t for reference counting. (diskfs_node_refcnt_lock): Remove. (diskfs_node_norefs,diskfs_drop_node): Change comments accordingly. * libdiskfs/init-init.c: Adjust accordingly. * libdiskfs/node-drop.c: Likewise. * libdiskfs/node-make.c: Likewise. * libdiskfs/node-nput.c: Likewise. * libdiskfs/node-nputl.c: Likewise. * libdiskfs/node-nref.c: Likewise. * libdiskfs/node-nrefl.c: Likewise. * libdiskfs/node-nrele.c: Likewise. * libdiskfs/node-nrelel.c: Likewise. * ext2fs/inode.c: Likewise. * fatfs/inode.c: Likewise. * isofs/inode.c: Likewise. * tmpfs/node.c: Likewise. * doc/hurd.texi: Likewise.
Diffstat (limited to 'libdiskfs/node-drop.c')
-rw-r--r--libdiskfs/node-drop.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/libdiskfs/node-drop.c b/libdiskfs/node-drop.c
index 83eb5909..455031bc 100644
--- a/libdiskfs/node-drop.c
+++ b/libdiskfs/node-drop.c
@@ -31,9 +31,8 @@ free_modreqs (struct modreq *mr)
}
-/* Node NP now has no more references; clean all state. The
- diskfs_node_refcnt_lock must be held, and will be released
- upon return. NP must be locked. */
+/* Node NP now has no more references; clean all state. NP must be
+ locked. */
void
diskfs_drop_node (struct node *np)
{
@@ -60,8 +59,7 @@ diskfs_drop_node (struct node *np)
and an nput. The next time through, this routine
will notice that the size is zero, and not have to
do anything. */
- np->references++;
- pthread_spin_unlock (&diskfs_node_refcnt_lock);
+ refcounts_unsafe_ref (&np->refcounts, NULL);
diskfs_truncate (np, 0);
/* Force allocsize to zero; if truncate consistently fails this
@@ -93,6 +91,7 @@ diskfs_drop_node (struct node *np)
assert (!np->sockaddr);
+ pthread_mutex_unlock(&np->lock);
+ pthread_mutex_destroy(&np->lock);
diskfs_node_norefs (np);
- pthread_spin_unlock (&diskfs_node_refcnt_lock);
}