summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src/posix.c
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2009-12-06 13:29:08 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-12-06 11:33:03 -0800
commit9e38b5066d42d47f1011e1d1bc32ed9c41df57ec (patch)
treee37976b8068ddd3135ba3c085ff754fc6302d7a4 /xlators/features/locks/src/posix.c
parentfe37a56dd42294e26158a29c15a35aeb8cb38be2 (diff)
features/locks: Implement release xlator callback.
This patch solves the lock bailout problem seen recently when autoconf tools were run. This is a workaround, where 'flock' locks are removed in pl_release, if an explicit UNLCK call does not come. The complete fix would be to allow 'fcntl' and 'flock' locks to operate in different domains. Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 449 (Handle flock calls in a different domain from fcntl calls) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=449
Diffstat (limited to 'xlators/features/locks/src/posix.c')
-rw-r--r--xlators/features/locks/src/posix.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 4a1a2a76376..d4e1b152f48 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -248,7 +248,7 @@ delete_locks_of_fd (xlator_t *this, pl_inode_t *pl_inode, fd_t *fd)
{
list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) {
- if ((l->fd == fd)) {
+ if ((l->fd_num == fd_to_fdnum(fd))) {
if (l->blocked) {
list_move_tail (&l->list, &blocked_list);
continue;
@@ -368,6 +368,14 @@ int
pl_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, fd_t *fd)
{
+ int dummy = 1;
+ int ret = -1;
+
+ ret = fd_ctx_set (fd, this, dummy);
+ if (ret != 0)
+ gf_log (this->name, GF_LOG_DEBUG,
+ "fd_ctx_set failed");
+
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
return 0;
@@ -517,7 +525,7 @@ pl_readv (call_frame_t *frame, xlator_t *this,
region.fl_start = offset;
region.fl_end = offset + size - 1;
region.transport = frame->root->trans;
- region.fd = fd;
+ region.fd_num = fd_to_fdnum(fd);
region.client_pid = frame->root->pid;
region.owner = frame->root->lk_owner;
@@ -614,7 +622,7 @@ pl_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
region.fl_start = offset;
region.fl_end = offset + iov_length (vector, count) - 1;
region.transport = frame->root->trans;
- region.fd = fd;
+ region.fd_num = fd_to_fdnum(fd);
region.client_pid = frame->root->pid;
region.owner = frame->root->lk_owner;
@@ -736,9 +744,9 @@ pl_lk (call_frame_t *frame, xlator_t *this,
#endif
case F_SETLKW:
can_block = 1;
- reqlock->frame = frame;
- reqlock->this = this;
- reqlock->fd = fd;
+ reqlock->frame = frame;
+ reqlock->this = this;
+ reqlock->fd_num = fd_to_fdnum(fd);
/* fall through */
@@ -859,6 +867,27 @@ pl_forget (xlator_t *this,
return 0;
}
+int
+pl_release (xlator_t *this, fd_t *fd)
+{
+ pl_inode_t *pl_inode = NULL;
+ uint64_t tmp_pl_inode = 0;
+ int ret = -1;
+
+ ret = inode_ctx_get (fd->inode, this, &tmp_pl_inode);
+ if (ret != 0)
+ goto out;
+
+ pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
+
+ gf_log (this->name, GF_LOG_TRACE,
+ "Releasing all locks with fd %p", fd);
+
+ delete_locks_of_fd (this, pl_inode, fd);
+
+out:
+ return ret;
+}
static int32_t
__get_posixlk_count (xlator_t *this, pl_inode_t *pl_inode)
{
@@ -1420,6 +1449,7 @@ struct xlator_dumpops dumpops = {
struct xlator_cbks cbks = {
.forget = pl_forget,
+ .release = pl_release,
};