summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2010-02-12 04:08:03 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-02-18 08:39:55 -0800
commitf823b85d80bd2c9563a7a9d8762ea668dee13176 (patch)
treea4d566b21c2bb8b8ada6e5c18cd497f37014ae58
parent090a96d0a5963bc62efc3354480e277610cab7e6 (diff)
features/locks: Set dummy fd ctx in all relevant places so that release callback in locks is always called.
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
-rw-r--r--xlators/features/locks/src/common.c18
-rw-r--r--xlators/features/locks/src/common.h3
-rw-r--r--xlators/features/locks/src/posix.c64
3 files changed, 82 insertions, 3 deletions
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index d82e47aa36f..3df1312e55e 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -359,6 +359,24 @@ pl_trace_flush (xlator_t *this, call_frame_t *frame, fd_t *fd)
}
void
+pl_trace_release (xlator_t *this, fd_t *fd)
+{
+ posix_locks_private_t *priv = NULL;
+ char pl_lockee[256];
+
+ priv = this->private;
+
+ if (!priv->trace)
+ return;
+
+ pl_print_lockee (pl_lockee, 256, fd, NULL);
+
+ gf_log (this->name, GF_LOG_NORMAL,
+ "[RELEASE] Lockee = {%s}", pl_lockee);
+}
+
+
+void
pl_update_refkeeper (xlator_t *this, inode_t *inode)
{
pl_inode_t *pl_inode = NULL;
diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h
index 00532ea6f92..133a4f7227a 100644
--- a/xlators/features/locks/src/common.h
+++ b/xlators/features/locks/src/common.h
@@ -110,6 +110,9 @@ pl_print_locker (char *str, int size, xlator_t *this, call_frame_t *frame);
void
pl_print_inodelk (char *str, int size, int cmd, struct flock *flock, const char *domain);
+void
+pl_trace_release (xlator_t *this, fd_t *fd);
+
unsigned long
fd_to_fdnum (fd_t *fd);
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 60724d5c377..abd7248c636 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -303,6 +303,46 @@ __delete_locks_of_owner (pl_inode_t *pl_inode,
return;
}
+int32_t
+pl_opendir_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;
+
+ if (op_ret < 0)
+ goto unwind;
+
+ ret = fd_ctx_set (fd, this, dummy);
+ if (ret != 0)
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting context for fd=%p in locks failed.", fd);
+
+unwind:
+ STACK_UNWIND_STRICT (opendir,
+ frame,
+ op_ret,
+ op_errno,
+ fd);
+ return 0;
+}
+
+int32_t
+pl_opendir (call_frame_t *frame, xlator_t *this,
+ loc_t *loc, fd_t *fd)
+{
+ STACK_WIND (frame,
+ pl_opendir_cbk,
+ FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir,
+ loc, fd);
+ return 0;
+
+}
int
pl_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
@@ -371,11 +411,15 @@ pl_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int dummy = 1;
int ret = -1;
+ if (op_ret < 0)
+ goto unwind;
+
ret = fd_ctx_set (fd, this, dummy);
if (ret != 0)
- gf_log (this->name, GF_LOG_DEBUG,
- "fd_ctx_set failed");
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting context for fd=%p in locks failed.", fd);
+unwind:
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
return 0;
@@ -401,6 +445,18 @@ pl_create_cbk (call_frame_t *frame, void *cookie,
fd_t *fd, inode_t *inode, struct stat *buf,
struct stat *preparent, struct stat *postparent)
{
+ int dummy = 1;
+ int ret = -1;
+
+ if (op_ret < 0)
+ goto unwind;
+
+ ret = fd_ctx_set (fd, this, dummy);
+ if (ret != 0)
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting context for fd=%p in locks failed.", fd);
+
+unwind:
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);
@@ -746,7 +802,6 @@ pl_lk (call_frame_t *frame, xlator_t *this,
can_block = 1;
reqlock->frame = frame;
reqlock->this = this;
- reqlock->fd_num = fd_to_fdnum(fd);
/* fall through */
@@ -921,6 +976,8 @@ pl_release (xlator_t *this, fd_t *fd)
pl_inode = (pl_inode_t *)(long)tmp_pl_inode;
+ pl_trace_release (this, fd);
+
gf_log (this->name, GF_LOG_TRACE,
"Releasing all locks with fd %p", fd);
@@ -1478,6 +1535,7 @@ struct xlator_fops fops = {
.entrylk = pl_entrylk,
.fentrylk = pl_fentrylk,
.flush = pl_flush,
+ .opendir = pl_opendir,
};