summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/cluster/afr/src/afr-common.c18
-rw-r--r--xlators/cluster/afr/src/afr.h3
-rw-r--r--xlators/features/locks/src/posix.c6
3 files changed, 18 insertions, 9 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index c52701f61..103a683fa 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -2338,13 +2338,13 @@ afr_lk_unlock (call_frame_t *frame, xlator_t *this)
if (call_count == 0) {
AFR_STACK_UNWIND (lk, frame, local->op_ret, local->op_errno,
- &local->cont.lk.flock);
+ &local->cont.lk.ret_flock);
return 0;
}
local->call_count = call_count;
- local->cont.lk.flock.l_type = F_UNLCK;
+ local->cont.lk.user_flock.l_type = F_UNLCK;
for (i = 0; i < priv->child_count; i++) {
if (local->cont.lk.locked_nodes[i]) {
@@ -2352,7 +2352,7 @@ afr_lk_unlock (call_frame_t *frame, xlator_t *this)
priv->children[i],
priv->children[i]->fops->lk,
local->fd, F_SETLK,
- &local->cont.lk.flock);
+ &local->cont.lk.user_flock);
if (!--call_count)
break;
@@ -2392,7 +2392,7 @@ afr_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->op_ret = 0;
local->op_errno = 0;
local->cont.lk.locked_nodes[child_index] = 1;
- local->cont.lk.flock = *lock;
+ local->cont.lk.ret_flock = *lock;
}
child_index++;
@@ -2402,16 +2402,17 @@ afr_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
priv->children[child_index],
priv->children[child_index]->fops->lk,
local->fd, local->cont.lk.cmd,
- &local->cont.lk.flock);
+ &local->cont.lk.user_flock);
} else if (local->op_ret == -1) {
/* all nodes have gone down */
- AFR_STACK_UNWIND (lk, frame, -1, ENOTCONN, &local->cont.lk.flock);
+ AFR_STACK_UNWIND (lk, frame, -1, ENOTCONN,
+ &local->cont.lk.ret_flock);
} else {
/* locking has succeeded on all nodes that are up */
AFR_STACK_UNWIND (lk, frame, local->op_ret, local->op_errno,
- &local->cont.lk.flock);
+ &local->cont.lk.ret_flock);
}
return 0;
@@ -2454,7 +2455,8 @@ afr_lk (call_frame_t *frame, xlator_t *this,
local->fd = fd_ref (fd);
local->cont.lk.cmd = cmd;
- local->cont.lk.flock = *flock;
+ local->cont.lk.user_flock = *flock;
+ local->cont.lk.ret_flock = *flock;
STACK_WIND_COOKIE (frame, afr_lk_cbk, (void *) (long) 0,
priv->children[i],
diff --git a/xlators/cluster/afr/src/afr.h b/xlators/cluster/afr/src/afr.h
index 416cda5eb..ea7b3ba89 100644
--- a/xlators/cluster/afr/src/afr.h
+++ b/xlators/cluster/afr/src/afr.h
@@ -280,7 +280,8 @@ typedef struct _afr_local {
struct {
int32_t cmd;
- struct flock flock;
+ struct flock user_flock;
+ struct flock ret_flock;
unsigned char *locked_nodes;
} lk;
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 0db7623c3..9d4f01a11 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -761,6 +761,12 @@ pl_lk (call_frame_t *frame, xlator_t *this,
client_pid = frame->root->pid;
owner = frame->root->lk_owner;
+ if ((flock->l_start < 0) || (flock->l_len < 0)) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto unwind;
+ }
+
pl_inode = pl_inode_get (this, fd->inode);
if (!pl_inode) {
gf_log (this->name, GF_LOG_ERROR,