[sheepdog] [PATCH v1 3/4] sheep/cluster: let local implementation of lock() support embedding
Robin Dong
robin.k.dong at gmail.com
Fri Feb 21 07:47:32 CET 2014
From: Robin Dong <sanbai at taobao.com>
In kv_create_object(), we need to lock bucket and then lock allocator of it, so
all the implementations for ->lock() in cluster must support embeded lock.
Signed-off-by: Robin Dong <sanbai at taobao.com>
---
sheep/cluster/local.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index 7f9a6eb..264afdb 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -627,12 +627,15 @@ static void local_lock(uint64_t lock_id)
if (xflock(entry->fd, LOCK_EX) < 0)
panic("lock failed %"PRIx64", %m", lock_id);
+
+ sd_rw_unlock(&lock_tree_lock);
}
static void local_unlock(uint64_t lock_id)
{
struct lock_entry *entry;
+ sd_write_lock(&lock_tree_lock);
entry = lock_tree_lookup(lock_id);
if (!entry)
panic("can't find fd for lock %"PRIx64, lock_id);
--
1.7.12.4
More information about the sheepdog
mailing list