summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks
diff options
context:
space:
mode:
authorPavan Vilas Sondur <pavan@gluster.com>2009-12-03 14:51:06 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-03 12:44:56 -0800
commite0c09ea80904a26ac932eec546d7675fc0d2cd08 (patch)
tree65a01c462e580668971def0b3574931996697328 /xlators/features/locks
parent1c8aa56a1bcff7640b65102782641ab0d53861d2 (diff)
features/locks: Use lock_owner from fuse in posix locks.
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/common.c11
-rw-r--r--xlators/features/locks/src/common.h2
-rw-r--r--xlators/features/locks/src/locks.h1
-rw-r--r--xlators/features/locks/src/posix.c13
4 files changed, 20 insertions, 7 deletions
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index fb011fe6a7a..17be81ff24c 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -421,7 +421,7 @@ out:
/* Create a new posix_lock_t */
posix_lock_t *
-new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid)
+new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid, uint64_t owner)
{
posix_lock_t *lock = NULL;
@@ -440,6 +440,7 @@ new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid)
lock->transport = transport;
lock->client_pid = client_pid;
+ lock->owner = owner;
INIT_LIST_HEAD (&lock->list);
@@ -507,8 +508,10 @@ locks_overlap (posix_lock_t *l1, posix_lock_t *l2)
int
same_owner (posix_lock_t *l1, posix_lock_t *l2)
{
- return ((l1->client_pid == l2->client_pid) &&
- (l1->transport == l2->transport));
+
+ return ((l1->owner == l2->owner) &&
+ (l1->transport == l2->transport));
+
}
@@ -680,6 +683,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock)
sum->fl_type = lock->fl_type;
sum->transport = lock->transport;
sum->client_pid = lock->client_pid;
+ sum->owner = lock->owner;
__delete_lock (pl_inode, conf);
__destroy_lock (conf);
@@ -694,6 +698,7 @@ __insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock)
sum->fl_type = conf->fl_type;
sum->transport = conf->transport;
sum->client_pid = conf->client_pid;
+ sum->owner = conf->owner;
v = subtract_locks (sum, lock);
diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h
index 292d82ce8c3..0d847f77029 100644
--- a/xlators/features/locks/src/common.h
+++ b/xlators/features/locks/src/common.h
@@ -21,7 +21,7 @@
#define __COMMON_H__
posix_lock_t *
-new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid);
+new_posix_lock (struct flock *flock, transport_t *transport, pid_t client_pid, uint64_t owner);
pl_inode_t *
pl_inode_get (xlator_t *this, inode_t *inode);
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
index 4738da068c9..1b234dd17fd 100644
--- a/xlators/features/locks/src/locks.h
+++ b/xlators/features/locks/src/locks.h
@@ -51,6 +51,7 @@ struct __posix_lock {
transport_t *transport; /* to identify client node */
pid_t client_pid; /* pid of client process */
+ uint64_t owner; /* lock owner from fuse */
};
typedef struct __posix_lock posix_lock_t;
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 95941994e5c..674485576fd 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -77,7 +77,7 @@ pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
static int
truncate_allowed (pl_inode_t *pl_inode,
transport_t *transport, pid_t client_pid,
- off_t offset)
+ uint64_t owner, off_t offset)
{
posix_lock_t *l = NULL;
posix_lock_t region = {.list = {0, }, };
@@ -87,6 +87,7 @@ truncate_allowed (pl_inode_t *pl_inode,
region.fl_end = LLONG_MAX;
region.transport = transport;
region.client_pid = client_pid;
+ region.owner = owner;
pthread_mutex_lock (&pl_inode->mutex);
{
@@ -142,7 +143,8 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (priv->mandatory
&& pl_inode->mandatory
&& !truncate_allowed (pl_inode, frame->root->trans,
- frame->root->pid, local->offset)) {
+ frame->root->pid, frame->root->lk_owner,
+ local->offset)) {
op_ret = -1;
op_errno = EAGAIN;
goto unwind;
@@ -454,6 +456,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
region.fl_end = offset + size - 1;
region.transport = frame->root->trans;
region.client_pid = frame->root->pid;
+ region.owner = frame->root->lk_owner;
pthread_mutex_lock (&pl_inode->mutex);
{
@@ -549,6 +552,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
region.fl_end = offset + iov_length (vector, count) - 1;
region.transport = frame->root->trans;
region.client_pid = frame->root->pid;
+ region.owner = frame->root->lk_owner;
pthread_mutex_lock (&pl_inode->mutex);
{
@@ -614,6 +618,7 @@ pl_lk (call_frame_t *frame, xlator_t *this,
{
transport_t *transport = NULL;
pid_t client_pid = 0;
+ uint64_t owner = 0;
posix_locks_private_t *priv = NULL;
pl_inode_t *pl_inode = NULL;
int op_ret = 0;
@@ -625,6 +630,7 @@ pl_lk (call_frame_t *frame, xlator_t *this,
transport = frame->root->trans;
client_pid = frame->root->pid;
+ owner = frame->root->lk_owner;
priv = this->private;
pl_inode = pl_inode_get (this, fd->inode);
@@ -636,7 +642,8 @@ pl_lk (call_frame_t *frame, xlator_t *this,
goto unwind;
}
- reqlock = new_posix_lock (flock, transport, client_pid);
+ reqlock = new_posix_lock (flock, transport, client_pid, owner);
+
if (!reqlock) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");