diff options
author | Justus Winter <4winter@informatik.uni-hamburg.de> | 2014-05-14 11:19:35 +0200 |
---|---|---|
committer | Justus Winter <4winter@informatik.uni-hamburg.de> | 2015-04-17 14:06:46 +0200 |
commit | c16eed2cb64089bf7d958db0fe85352f4ceefb4d (patch) | |
tree | 3240f6e025fa4c4fb47d7d270f285a7f0f9612e4 /ext2fs/inode.c | |
parent | 8c050fb080c6e1981dc8e5a97a2313cd24e9b4b4 (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 'ext2fs/inode.c')
-rw-r--r-- | ext2fs/inode.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/ext2fs/inode.c b/ext2fs/inode.c index 7c8d5a8c..2a0c3cff 100644 --- a/ext2fs/inode.c +++ b/ext2fs/inode.c @@ -57,7 +57,6 @@ through the nodehash. */ static struct node *nodehash[INOHSZ]; static size_t nodehash_nr_items; -/* nodecache_lock must be acquired before diskfs_node_refcnt_lock. */ static pthread_rwlock_t nodecache_lock = PTHREAD_RWLOCK_INITIALIZER; static error_t read_node (struct node *np); @@ -207,14 +206,10 @@ diskfs_try_dropping_softrefs (struct node *np) { /* Check if someone reacquired a reference through the nodehash. */ - unsigned int references; - pthread_spin_lock (&diskfs_node_refcnt_lock); - references = np->references; - pthread_spin_unlock (&diskfs_node_refcnt_lock); - - /* An additional reference is acquired by libdiskfs across calls - to diskfs_try_dropping_softrefs. */ - if (references > 1) + struct references result; + refcounts_references (&np->refcounts, &result); + + if (result.hard > 0) { /* A reference was reacquired through a hash table lookup. It's fine, we didn't touch anything yet. */ @@ -636,7 +631,7 @@ diskfs_node_iterate (error_t (*fun)(struct node *)) /* We acquire a hard reference for node, but without using diskfs_nref. We do this so that diskfs_new_hardrefs will not get called. */ - node->references++; + refcounts_ref (&node->refcounts, NULL); } pthread_rwlock_unlock (&nodecache_lock); |