summaryrefslogtreecommitdiff
path: root/libdiskfs/node-nputl.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-nputl.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-nputl.c')
-rw-r--r--libdiskfs/node-nputl.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/libdiskfs/node-nputl.c b/libdiskfs/node-nputl.c
index 19596654..8dac16e3 100644
--- a/libdiskfs/node-nputl.c
+++ b/libdiskfs/node-nputl.c
@@ -25,14 +25,10 @@
void
diskfs_nput_light (struct node *np)
{
- pthread_spin_lock (&diskfs_node_refcnt_lock);
- assert (np->light_references);
- np->light_references--;
- if (np->references + np->light_references == 0)
+ struct references result;
+ refcounts_deref_weak (&np->refcounts, &result);
+ if (result.hard == 0 && result.weak == 0)
diskfs_drop_node (np);
else
- {
- pthread_spin_unlock (&diskfs_node_refcnt_lock);
- pthread_mutex_unlock (&np->lock);
- }
+ pthread_mutex_unlock (&np->lock);
}