summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src
diff options
context:
space:
mode:
authorVikas Gorur <vikas@gluster.com>2009-05-18 03:02:54 -0700
committerAnand V. Avati <avati@amp.gluster.com>2009-05-18 17:10:48 +0530
commit0346e3e889d854f6f96d9f9b162a8d65ddb35f52 (patch)
tree70952f80d29184719d1b28fa9e8f0920524793ea /xlators/features/locks/src
parent49523c834f075007352d07bf09463af9499b59f5 (diff)
Bug fix in pl_readv/writev to handle the mandatory lock case properly.
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/features/locks/src')
-rw-r--r--xlators/features/locks/src/posix.c44
1 files changed, 21 insertions, 23 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 271fda64a..cffdbbb1f 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -131,6 +131,7 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!pl_inode) {
gf_log (this->name, GF_LOG_ERROR,
"Out of memory.");
+ op_ret = -1;
op_errno = ENOMEM;
goto unwind;
}
@@ -139,6 +140,7 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
&& pl_inode->mandatory
&& !truncate_allowed (pl_inode, frame->root->trans,
frame->root->pid, local->offset)) {
+ op_ret = -1;
op_errno = EAGAIN;
goto unwind;
}
@@ -162,7 +164,7 @@ unwind:
if (local->op == TRUNCATE)
loc_wipe (&local->loc);
- STACK_UNWIND (frame, -1, ENOMEM, buf);
+ STACK_UNWIND (frame, op_ret, op_errno, buf);
return 0;
}
@@ -441,7 +443,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
posix_lock_t region = {.list = {0, }, };
int op_ret = 0;
int op_errno = 0;
- char allowable = 0;
+ char wind_needed = 1;
priv = this->private;
@@ -455,10 +457,11 @@ pl_readv (call_frame_t *frame, xlator_t *this,
pthread_mutex_lock (&pl_inode->mutex);
{
- allowable = __rw_allowable (pl_inode, &region,
- GF_FOP_READ);
- if (allowable)
+ wind_needed = __rw_allowable (pl_inode, &region,
+ GF_FOP_READ);
+ if (wind_needed) {
goto unlock;
+ }
if (fd->flags & O_NONBLOCK) {
gf_log (this->name, GF_LOG_DEBUG,
@@ -494,17 +497,15 @@ pl_readv (call_frame_t *frame, xlator_t *this,
}
unlock:
pthread_mutex_unlock (&pl_inode->mutex);
-
- goto unwind;
}
- STACK_WIND (frame, pl_readv_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv,
- fd, size, offset);
- return 0;
+ if (wind_needed) {
+ STACK_WIND (frame, pl_readv_cbk,
+ FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv,
+ fd, size, offset);
+ }
-unwind:
if (op_ret == -1)
STACK_UNWIND (frame, -1, op_errno, NULL, 0, NULL, NULL);
@@ -536,7 +537,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
posix_lock_t region = {.list = {0, }, };
int op_ret = 0;
int op_errno = 0;
- char allowable = 0;
+ char wind_needed = 1;
priv = this->private;
@@ -550,9 +551,9 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
pthread_mutex_lock (&pl_inode->mutex);
{
- allowable = __rw_allowable (pl_inode, &region,
- GF_FOP_WRITE);
- if (allowable)
+ wind_needed = __rw_allowable (pl_inode, &region,
+ GF_FOP_WRITE);
+ if (wind_needed)
goto unlock;
if (fd->flags & O_NONBLOCK) {
@@ -590,17 +591,14 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
}
unlock:
pthread_mutex_unlock (&pl_inode->mutex);
-
- goto unwind;
}
- STACK_WIND (frame, pl_writev_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,
- fd, vector, count, offset, iobref);
- return 0;
+ if (wind_needed)
+ STACK_WIND (frame, pl_writev_cbk,
+ FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,
+ fd, vector, count, offset, iobref);
-unwind:
if (op_ret == -1)
STACK_UNWIND (frame, -1, op_errno, NULL, 0, NULL);