[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 02/12: libdiskfs: fix and improve locking in nrefs/nput.
From: |
Samuel Thibault |
Subject: |
[hurd] 02/12: libdiskfs: fix and improve locking in nrefs/nput. |
Date: |
Tue, 23 Feb 2016 23:53:24 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 0f6a5081d875051e1b6275096d25332e66f0458c
Author: Flavio Cruz <address@hidden>
Date: Sun Feb 14 18:37:16 2016 -0500
libdiskfs: fix and improve locking in nrefs/nput.
* libnetfs/node-nput.c: Do not unlock the node since it will be unlocked
later.
* libnetfs/node-nrele.c: Do not lock the node twice if not needed.
---
libdiskfs/node-nput.c | 1 -
libdiskfs/node-nrele.c | 8 ++++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libdiskfs/node-nput.c b/libdiskfs/node-nput.c
index d23c103..d59769b 100644
--- a/libdiskfs/node-nput.c
+++ b/libdiskfs/node-nput.c
@@ -56,7 +56,6 @@ diskfs_nput (struct node *np)
hold a weak reference ourselves. */
diskfs_try_dropping_softrefs (np);
}
- pthread_mutex_unlock (&np->lock);
}
/* Finally get rid of our reference. */
diff --git a/libdiskfs/node-nrele.c b/libdiskfs/node-nrele.c
index d962846..a96d134 100644
--- a/libdiskfs/node-nrele.c
+++ b/libdiskfs/node-nrele.c
@@ -28,6 +28,7 @@
void
diskfs_nrele (struct node *np)
{
+ int locked = FALSE;
struct references result;
/* While we call the diskfs_try_dropping_softrefs, we need to hold
@@ -37,6 +38,7 @@ diskfs_nrele (struct node *np)
if (result.hard == 0)
{
+ locked = TRUE;
pthread_mutex_lock (&np->lock);
diskfs_lost_hardrefs (np);
if (!np->dn_stat.st_nlink)
@@ -49,7 +51,6 @@ diskfs_nrele (struct node *np)
hold a weak reference ourselves. */
diskfs_try_dropping_softrefs (np);
}
- pthread_mutex_unlock (&np->lock);
}
/* Finally get rid of our reference. */
@@ -57,7 +58,10 @@ diskfs_nrele (struct node *np)
if (result.hard == 0 && result.weak == 0)
{
- pthread_mutex_lock (&np->lock);
+ if (! locked)
+ pthread_mutex_lock (&np->lock);
diskfs_drop_node (np);
}
+ else if (locked)
+ pthread_mutex_unlock (&np->lock);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 06/12: trans/crash: fix suspending task, (continued)
- [hurd] 06/12: trans/crash: fix suspending task, Samuel Thibault, 2016/02/23
- [hurd] 07/12: utils/mount: start translators with stderr closed, Samuel Thibault, 2016/02/23
- [hurd] 09/12: procfs: adapt to kernel interface change, Samuel Thibault, 2016/02/23
- [hurd] 04/12: Make fakeroot forward send errors instead of crashing, Samuel Thibault, 2016/02/23
- [hurd] 12/12: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into upstream, Samuel Thibault, 2016/02/23
- [hurd] 08/12: fix Xioctl-proto.defs creation, Samuel Thibault, 2016/02/23
- [hurd] 10/12: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd into upstream, Samuel Thibault, 2016/02/23
- [hurd] 11/12: libports: preserve the complex message flag, Samuel Thibault, 2016/02/23
- [hurd] 03/12: libnetfs: remove unused fields., Samuel Thibault, 2016/02/23
- [hurd] 05/12: nfs: fix deallocation of struct node., Samuel Thibault, 2016/02/23
- [hurd] 02/12: libdiskfs: fix and improve locking in nrefs/nput.,
Samuel Thibault <=
- [hurd] 01/12: nfs: Use libihash for the node cache., Samuel Thibault, 2016/02/23