[Gluster-devel] [PATCH] posix/locks: refactorise lock dumps and add some informations
Corentin Chary
corentin.chary at gmail.com
Thu Oct 15 12:08:09 UTC 2009
Signed-off-by: Corentin Chary <corentin.chary at gmail.com>
---
xlators/features/locks/src/common.c | 45 +++++++++++++++-------------------
1 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index 5f115f6..17c69c3 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -43,6 +43,9 @@ __is_lock_grantable (pl_inode_t *pl_inode, posix_lock_t *lock,
static void
__insert_and_merge (pl_inode_t *pl_inode, posix_lock_t *lock,
gf_lk_domain_t dom);
+static void
+__pl_dump (xlator_t *this, posix_lock_t *lock, pl_inode_t *pl_inode,
+ char *txt);
#define DOMAIN_HEAD(pl_inode, dom) (dom == GF_LOCK_POSIX \
? &pl_inode->ext_list \
@@ -448,13 +451,7 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode,
posix_lock_to_flock (l, &conf->user_flock);
- gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) %"PRId64" - %"PRId64" => Granted",
- l->fl_type == F_UNLCK ? "Unlock" : "Lock",
- l->client_pid,
- l->user_flock.l_start,
- l->user_flock.l_len);
-
+ __pl_dump(this, l, pl_inode, "Granted");
__insert_and_merge (pl_inode, l, dom);
list_add (&conf->list, granted);
@@ -492,6 +489,19 @@ grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, gf_lk_domain_t dom)
return;
}
+static void
+__pl_dump (xlator_t *this, posix_lock_t *lock, pl_inode_t *pl_inode, char *txt)
+{
+ gf_log (this->name, GF_LOG_TRACE,
+ "%s (pid=%d,inode=%p) %"PRId64" - %"PRId64" => %s",
+ lock->fl_type == F_UNLCK ? "Unlock" :
+ (lock->fl_type == F_RDLCK ? "RdLock" : "WrLock"),
+ lock->client_pid,
+ pl_inode,
+ lock->user_flock.l_start,
+ lock->user_flock.l_len,
+ txt);
+}
int
pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
@@ -504,30 +514,15 @@ pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
pthread_mutex_lock (&pl_inode->mutex);
{
if (__is_lock_grantable (pl_inode, lock, dom)) {
- gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) %"PRId64" - %"PRId64" => OK",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ __pl_dump(this, lock, pl_inode, "OK");
__insert_and_merge (pl_inode, lock, dom);
} else if (can_block) {
- gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) %"PRId64" - %"PRId64" => Blocked",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ __pl_dump(this, lock, pl_inode, "Blocked");
lock->blocked = 1;
__insert_lock (pl_inode, lock, dom);
ret = -1;
} else {
- gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) %"PRId64" - %"PRId64" => NOK",
- lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
- lock->client_pid,
- lock->user_flock.l_start,
- lock->user_flock.l_len);
+ __pl_dump(this, lock, pl_inode, "NOK");
errno = EAGAIN;
ret = -1;
}
--
1.5.4.3
More information about the Gluster-devel
mailing list