summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks
diff options
context:
space:
mode:
authorPavan Vilas Sondur <pavan@gluster.com>2009-12-03 14:51:07 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-03 12:44:59 -0800
commit31b18f256fa3972a0cebc51cc15127440321c4c4 (patch)
tree17e820c3f9ef5e6b1163e7b7a1ce36b161a365ab /xlators/features/locks
parente0c09ea80904a26ac932eec546d7675fc0d2cd08 (diff)
features/locks: Use owner field for entrylks.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 336 (Use lock owner field from fuse in locks) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=336
Diffstat (limited to 'xlators/features/locks')
-rw-r--r--xlators/features/locks/src/entrylk.c49
-rw-r--r--xlators/features/locks/src/locks.h1
2 files changed, 35 insertions, 15 deletions
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index 7f890429a5a..6fc45bccede 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -35,7 +35,8 @@
static pl_entry_lock_t *
new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
- transport_t *trans, pid_t client_pid, const char *volume)
+ transport_t *trans, pid_t client_pid, uint64_t owner, const char *volume)
+
{
pl_entry_lock_t *newlock = NULL;
@@ -49,7 +50,7 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
newlock->trans = trans;
newlock->volume = volume;
newlock->client_pid = client_pid;
-
+ newlock->owner = owner;
INIT_LIST_HEAD (&newlock->domain_list);
INIT_LIST_HEAD (&newlock->blocked_locks);
@@ -82,7 +83,8 @@ names_conflict (const char *n1, const char *n2)
static int
__same_entrylk_owner (pl_entry_lock_t *l1, pl_entry_lock_t *l2)
{
- return ((l1->client_pid == l2->client_pid) &&
+
+ return ((l1->owner == l2->owner) &&
(l1->trans == l2->trans));
}
@@ -313,17 +315,19 @@ int
__lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type,
call_frame_t *frame, pl_dom_list_t *dom, xlator_t *this, int nonblock)
{
- pl_entry_lock_t *lock = NULL;
- pl_entry_lock_t *conf = NULL;
- transport_t *trans = NULL;
- pid_t client_pid = 0;
+ pl_entry_lock_t *lock = NULL;
+ pl_entry_lock_t *conf = NULL;
+ transport_t *trans = NULL;
+ pid_t client_pid = 0;
+ uint64_t owner = 0;
int ret = -EINVAL;
trans = frame->root->trans;
client_pid = frame->root->pid;
+ owner = (uint64_t)frame->root;
- lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, dom->domain);
+ lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, owner, dom->domain);
if (!lock) {
ret = -ENOMEM;
goto out;
@@ -508,8 +512,10 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
pl_entry_lock_t *lock = NULL;
pl_entry_lock_t *tmp = NULL;
struct list_head granted;
+ struct list_head released;
INIT_LIST_HEAD (&granted);
+ INIT_LIST_HEAD (&released);
pthread_mutex_lock (&pinode->mutex);
{
@@ -524,8 +530,8 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
"releasing lock on held by "
"{transport=%p}",trans);
- FREE (lock->basename);
- FREE (lock);
+ list_add (&lock->blocked_locks, &released);
+
}
list_for_each_entry_safe (lock, tmp, &dom->entrylk_list,
@@ -549,6 +555,17 @@ release_entry_locks_for_transport (xlator_t *this, pl_inode_t *pinode,
pthread_mutex_unlock (&pinode->mutex);
+ list_for_each_entry_safe (lock, tmp, &released, blocked_locks) {
+ list_del_init (&lock->blocked_locks);
+
+ STACK_UNWIND_STRICT (entrylk, lock->frame, -1, EAGAIN);
+
+ if (lock->basename)
+ FREE (lock->basename);
+ FREE (lock);
+
+ }
+
list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
list_del_init (&lock->blocked_locks);
@@ -572,12 +589,13 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
int32_t op_errno = 0;
transport_t * transport = NULL;
- pid_t pid = -1;
+ pid_t pid = -1;
+ uint64_t owner = -1;
- pl_inode_t * pinode = NULL;
- int ret = -1;
- pl_entry_lock_t *unlocked = NULL;
- char unwind = 1;
+ pl_inode_t * pinode = NULL;
+ int ret = -1;
+ pl_entry_lock_t *unlocked = NULL;
+ char unwind = 1;
pl_dom_list_t *dom = NULL;
@@ -600,6 +618,7 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
entrylk_trace_in (this, frame, volume, fd, loc, basename, cmd, type);
pid = frame->root->pid;
+ owner = (uint64_t) frame->root;
transport = frame->root->trans;
if (pid == 0) {
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
index 1b234dd17fd..31c70c2f1a8 100644
--- a/xlators/features/locks/src/locks.h
+++ b/xlators/features/locks/src/locks.h
@@ -110,6 +110,7 @@ struct __entry_lock {
transport_t *trans;
pid_t client_pid; /* pid of client process */
+ uint64_t owner;
};
typedef struct __entry_lock pl_entry_lock_t;