[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/8] ftpfs: Use refcounts_t to track node references.
From: |
Flavio Cruz |
Subject: |
[PATCH 2/8] ftpfs: Use refcounts_t to track node references. |
Date: |
Sun, 6 Mar 2016 17:05:42 -0500 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
* ftpfs/dir.c: Use netfs_nref without locking the old
netfs_node_refcnt_lock.
* ftpfs/node.c: Likewise.
---
ftpfs/dir.c | 27 ++++++---------------------
ftpfs/node.c | 8 +-------
2 files changed, 7 insertions(+), 28 deletions(-)
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index 733a2dc..2ea29b5 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -654,10 +654,8 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
{
/* If there's already a node, add a ref so that it doesn't go
away. */
- pthread_spin_lock (&netfs_node_refcnt_lock);
- if (e->node)
- e->node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
+ if (e->node)
+ netfs_nref (e->node);
if (! e->node)
/* No node; make one and install it into E. */
@@ -682,11 +680,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
if (!err && dir->num_live_entries++ == 0)
/* Keep a reference to dir's node corresponding to
children. */
- {
- pthread_spin_lock (&netfs_node_refcnt_lock);
- dir->node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
- }
+ netfs_nref (dir->node);
}
}
@@ -737,10 +731,8 @@ ftpfs_dir_null_lookup (struct ftpfs_dir *dir, struct node
**node)
/* We've got a dir entry, get a node for it. */
{
/* If there's already a node, add a ref so that it doesn't go away. */
- pthread_spin_lock (&netfs_node_refcnt_lock);
if (e->node)
- e->node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
+ netfs_nref (e->node);
if (! e->node)
/* No node; make one and install it into E. */
@@ -749,11 +741,7 @@ ftpfs_dir_null_lookup (struct ftpfs_dir *dir, struct node
**node)
if (!err && dir->num_live_entries++ == 0)
/* Keep a reference to dir's node corresponding to children. */
- {
- pthread_spin_lock (&netfs_node_refcnt_lock);
- dir->node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
- }
+ netfs_nref (dir->node);
}
if (! err)
@@ -783,10 +771,7 @@ ftpfs_dir_create (struct ftpfs *fs, struct node *node,
const char *rmt_path,
return ENOMEM;
}
- /* Hold a reference to the new dir's node. */
- pthread_spin_lock (&netfs_node_refcnt_lock);
- node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
+ netfs_nref (node);
hurd_ihash_init (&new->htable, offsetof (struct ftpfs_dir_entry, dir_locp));
hurd_ihash_set_gki (&new->htable, ihash_hash, ihash_compare);
diff --git a/ftpfs/node.c b/ftpfs/node.c
index 74cd402..cc9bf43 100644
--- a/ftpfs/node.c
+++ b/ftpfs/node.c
@@ -84,10 +84,7 @@ netfs_node_norefs (struct node *node)
{
struct netnode *nn = node->nn;
- /* Ftpfs_detach_node does ref count frobbing (of other nodes), so we have
- to unlock NETFS_NODE_REFCNT_LOCK during it. */
- node->references++;
- pthread_spin_unlock (&netfs_node_refcnt_lock);
+ netfs_nref (node);
/* Remove NODE from any entry it is attached to. */
ftpfs_detach_node (node);
@@ -108,7 +105,4 @@ netfs_node_norefs (struct node *node)
free (nn);
free (node);
-
- /* Caller expects us to leave this locked... */
- pthread_spin_lock (&netfs_node_refcnt_lock);
}
--
2.6.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH 2/8] ftpfs: Use refcounts_t to track node references.,
Flavio Cruz <=