summaryrefslogtreecommitdiffstats
path: root/xlators/features/locks/src/inodelk.c
diff options
context:
space:
mode:
authorPavan Sondur <pavan@gluster.com>2009-10-28 12:27:54 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-28 23:00:43 -0700
commitb3b4fc4afb7d206d0a481f3234bf83c768f02aa2 (patch)
tree4e2b94a3395c19cd296c0092e6da3ff9ab9de5c6 /xlators/features/locks/src/inodelk.c
parent53ff4f0299cf14c6c413d3e49991a6f05f9cda19 (diff)
Implement lookup in locks to return lock count in a dict value.
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/src/inodelk.c')
-rw-r--r--xlators/features/locks/src/inodelk.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
index 1ec5b00417f..78e4154bcc5 100644
--- a/xlators/features/locks/src/inodelk.c
+++ b/xlators/features/locks/src/inodelk.c
@@ -552,3 +552,70 @@ pl_finodelk (call_frame_t *frame, xlator_t *this,
return 0;
}
+
+
+static int32_t
+__get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode)
+{
+ int32_t count = 0;
+ pl_inode_lock_t *lock = NULL;
+ pl_dom_list_t *dom = NULL;
+
+ list_for_each_entry (dom, &pl_inode->dom_list, inode_list) {
+ list_for_each_entry (lock, &dom->inodelk_list, list) {
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ " XATTR DEBUG"
+ " domain: %s %s (pid=%d) %"PRId64" - %"PRId64" state = Active",
+ dom->domain,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
+
+ count++;
+ }
+
+ list_for_each_entry (lock, &dom->blocked_inodelks, blocked_locks) {
+
+ gf_log (this->name, GF_LOG_DEBUG,
+ " XATTR DEBUG"
+ " domain: %s %s (pid=%d) %"PRId64" - %"PRId64" state = Blocked",
+ dom->domain,
+ lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
+ lock->client_pid,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len);
+
+ count++;
+ }
+
+ }
+
+ return count;
+}
+
+int32_t
+get_inodelk_count (xlator_t *this, inode_t *inode)
+{
+ pl_inode_t *pl_inode = NULL;
+ uint64_t tmp_pl_inode = 0;
+ int ret = 0;
+ int32_t count = 0;
+
+ ret = inode_ctx_get (inode, this, &tmp_pl_inode);
+ if (ret != 0) {
+ goto out;
+ }
+
+ pl_inode = (pl_inode_t *)(long) tmp_pl_inode;
+
+ pthread_mutex_lock (&pl_inode->mutex);
+ {
+ count = __get_inodelk_count (this, pl_inode);
+ }
+ pthread_mutex_unlock (&pl_inode->mutex);
+
+out:
+ return count;
+}