summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks
diff options
context:
space:
mode:
authorAnand Avati <avati@gluster.com>2009-10-16 23:56:55 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-19 23:14:45 -0700
commit0fa1305ed3e3943b22d9a3340a4464daf7742ab3 (patch)
tree8330485ef16956b28ca873fe37e0e249408bce4d /xlators/features/locks
parent04de4b6063617d4ad31b31fb0d24fe2242deb7f0 (diff)
locks: trace support for entrylk
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 306 (Enhance locks to aid debugging) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=306
Diffstat (limited to 'xlators/features/locks')
-rw-r--r--xlators/features/locks/src/common.c131
-rw-r--r--xlators/features/locks/src/common.h13
-rw-r--r--xlators/features/locks/src/internal.c21
3 files changed, 160 insertions, 5 deletions
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index 3681c31f5..105422271 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -636,9 +636,13 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
return;
}
- ret = inode_path (inode, NULL, &ipath);
- if (ret <= 0)
- ipath = NULL;
+ if (loc && loc->path) {
+ ipath = strdup (loc->path);
+ } else {
+ ret = inode_path (inode, NULL, &ipath);
+ if (ret <= 0)
+ ipath = NULL;
+ }
snprintf (str, size, "ino=%llu, fd=%p, path=%s",
(unsigned long long) inode->ino, fd,
@@ -825,3 +829,124 @@ pl_trace_flush (xlator_t *this, call_frame_t *frame, fd_t *fd)
pl_locker, pl_lockee);
}
+
+
+void
+pl_print_entrylk (char *str, int size, entrylk_cmd cmd, entrylk_type type,
+ const char *basename)
+{
+ char *cmd_str = NULL;
+ char *type_str = NULL;
+
+ switch (cmd) {
+ case ENTRYLK_LOCK:
+ cmd_str = "LOCK";
+ break;
+
+ case ENTRYLK_LOCK_NB:
+ cmd_str = "LOCK_NB";
+ break;
+
+ case ENTRYLK_UNLOCK:
+ cmd_str = "UNLOCK";
+ break;
+
+ default:
+ cmd_str = "UNKNOWN";
+ break;
+ }
+
+ switch (type) {
+ case ENTRYLK_RDLCK:
+ type_str = "READ";
+ break;
+ case ENTRYLK_WRLCK:
+ type_str = "WRITE";
+ break;
+ default:
+ type_str = "UNKNOWN";
+ break;
+ }
+
+ snprintf (str, size, "cmd=%s, type=%s, basename=%s",
+ cmd_str, type_str, basename);
+}
+
+
+void
+entrylk_trace_in (xlator_t *this, call_frame_t *frame, const char *domain,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type)
+{
+ posix_locks_private_t *priv = NULL;
+ char pl_locker[256];
+ char pl_lockee[256];
+ char pl_entrylk[256];
+
+ priv = this->private;
+
+ if (!priv->trace)
+ return;
+
+ pl_print_locker (pl_locker, 256, this, frame);
+ pl_print_lockee (pl_lockee, 256, fd, loc);
+ pl_print_entrylk (pl_entrylk, 256, cmd, type, basename);
+
+ gf_log (this->name, GF_LOG_NORMAL,
+ "[REQUEST] Locker = {%s} Lockee = {%s} Lock = {%s}",
+ pl_locker, pl_lockee, pl_entrylk);
+}
+
+
+void
+entrylk_trace_out (xlator_t *this, call_frame_t *frame, const char *domain,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type, int op_ret, int op_errno)
+{
+ posix_locks_private_t *priv = NULL;
+ char pl_locker[256];
+ char pl_lockee[256];
+ char pl_entrylk[256];
+ char verdict[32];
+
+ priv = this->private;
+
+ if (!priv->trace)
+ return;
+
+ pl_print_locker (pl_locker, 256, this, frame);
+ pl_print_lockee (pl_lockee, 256, fd, loc);
+ pl_print_entrylk (pl_entrylk, 256, cmd, type, basename);
+ pl_print_verdict (verdict, 32, op_ret, op_errno);
+
+ gf_log (this->name, GF_LOG_NORMAL,
+ "[%s] Locker = {%s} Lockee = {%s} Lock = {%s}",
+ verdict, pl_locker, pl_lockee, pl_entrylk);
+}
+
+
+void
+entrylk_trace_block (xlator_t *this, call_frame_t *frame, const char *volume,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type)
+
+{
+ posix_locks_private_t *priv = NULL;
+ char pl_locker[256];
+ char pl_lockee[256];
+ char pl_entrylk[256];
+
+ priv = this->private;
+
+ if (!priv->trace)
+ return;
+
+ pl_print_locker (pl_locker, 256, this, frame);
+ pl_print_lockee (pl_lockee, 256, fd, loc);
+ pl_print_entrylk (pl_entrylk, 256, cmd, type, basename);
+
+ gf_log (this->name, GF_LOG_NORMAL,
+ "[BLOCKED] Locker = {%s} Lockee = {%s} Lock = {%s}",
+ pl_locker, pl_lockee, pl_entrylk);
+}
+
diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h
index 9f3b0cf0c..89d8701bf 100644
--- a/xlators/features/locks/src/common.h
+++ b/xlators/features/locks/src/common.h
@@ -62,4 +62,17 @@ void pl_trace_block (xlator_t *this, call_frame_t *frame, fd_t *fd, int cmd,
void pl_trace_flush (xlator_t *this, call_frame_t *frame, fd_t *fd);
+void entrylk_trace_in (xlator_t *this, call_frame_t *frame, const char *volume,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type);
+
+void entrylk_trace_out (xlator_t *this, call_frame_t *frame, const char *volume,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type,
+ int op_ret, int op_errno);
+
+void entrylk_trace_block (xlator_t *this, call_frame_t *frame, const char *volume,
+ fd_t *fd, loc_t *loc, const char *basename,
+ entrylk_cmd cmd, entrylk_type type);
+
#endif /* __COMMON_H__ */
diff --git a/xlators/features/locks/src/internal.c b/xlators/features/locks/src/internal.c
index 487826587..34087da6e 100644
--- a/xlators/features/locks/src/internal.c
+++ b/xlators/features/locks/src/internal.c
@@ -618,6 +618,9 @@ grant_blocked_entry_locks (xlator_t *this, pl_inode_t *pl_inode,
list_for_each_entry_safe (lock, tmp, &granted_list, blocked_locks) {
list_del_init (&lock->blocked_locks);
+ entrylk_trace_out (this, lock->frame, NULL, NULL, NULL,
+ lock->basename, ENTRYLK_LOCK, lock->type,
+ 0, 0);
STACK_UNWIND (lock->frame, 0, 0);
FREE (lock->basename);
@@ -715,6 +718,8 @@ pl_entrylk (call_frame_t *frame, xlator_t *this,
pid = frame->root->pid;
transport = frame->root->trans;
+ entrylk_trace_in (this, frame, volume, NULL, loc, basename, cmd, type);
+
if (pid == 0) {
/*
this is a special case that means release
@@ -786,8 +791,13 @@ pl_entrylk (call_frame_t *frame, xlator_t *this,
out:
pl_update_refkeeper (this, loc->inode);
if (unwind) {
+ entrylk_trace_out (this, frame, volume, NULL, loc, basename,
+ cmd, type, op_ret, op_errno);
STACK_UNWIND (frame, op_ret, op_errno);
- }
+ } else {
+ entrylk_trace_block (this, frame, volume, NULL, loc, basename,
+ cmd, type);
+ }
return 0;
}
@@ -825,6 +835,8 @@ pl_fentrylk (call_frame_t *frame, xlator_t *this,
pid = frame->root->pid;
transport = frame->root->trans;
+ entrylk_trace_in (this, frame, volume, fd, NULL, basename, cmd, type);
+
if (pid == 0) {
/*
this is a special case that means release
@@ -893,8 +905,13 @@ pl_fentrylk (call_frame_t *frame, xlator_t *this,
out:
pl_update_refkeeper (this, fd->inode);
if (unwind) {
+ entrylk_trace_out (this, frame, volume, fd, NULL, basename,
+ cmd, type, op_ret, op_errno);
STACK_UNWIND (frame, op_ret, op_errno);
- }
+ } else {
+ entrylk_trace_block (this, frame, volume, fd, NULL, basename,
+ cmd, type);
+ }
return 0;
}