summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-01-17 05:28:51 +0530
committerAnand Avati <avati@gluster.com>2012-01-24 20:14:17 -0800
commitb02afc6d008f9959db28244eb2b9dd3b9ef92393 (patch)
treec0bad790fb34f8ab2747b480d334cf9af75c5514 /xlators
parent0694749c3e5039be327110a64dd66619b5d9121c (diff)
core: change lk-owner as a 1k buffer
so, NLM can send the lk-owner field directly to the locks translators, while doing the same effort, also enabled sending maximum of 500 aux gid over protocol. Change-Id: I87c2514392748416f7ffe21d5154faad2e413969 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 767229 Reviewed-on: http://review.gluster.com/779 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-lk-common.c27
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c28
-rw-r--r--xlators/cluster/afr/src/pump.c6
-rw-r--r--xlators/features/locks/src/common.c43
-rw-r--r--xlators/features/locks/src/common.h4
-rw-r--r--xlators/features/locks/src/entrylk.c31
-rw-r--r--xlators/features/locks/src/inodelk.c72
-rw-r--r--xlators/features/locks/src/locks.h10
-rw-r--r--xlators/features/locks/src/posix.c93
-rw-r--r--xlators/features/locks/src/reservelk.c20
-rw-r--r--xlators/features/marker/src/marker-quota.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handshake.c1
-rw-r--r--xlators/mount/fuse/src/fuse-bridge.c4
-rw-r--r--xlators/mount/fuse/src/fuse-helpers.c8
-rw-r--r--xlators/nfs/server/src/nfs-fops.c5
-rw-r--r--xlators/nfs/server/src/nfs.h6
-rw-r--r--xlators/protocol/client/src/client-handshake.c1
-rw-r--r--xlators/protocol/client/src/client-lk.c35
-rw-r--r--xlators/protocol/client/src/client.h11
-rw-r--r--xlators/protocol/client/src/client3_1-fops.c8
-rw-r--r--xlators/protocol/server/src/server-helpers.c47
-rw-r--r--xlators/protocol/server/src/server-helpers.h4
-rw-r--r--xlators/protocol/server/src/server.h2
-rw-r--r--xlators/protocol/server/src/server3_1-fops.c20
24 files changed, 252 insertions, 236 deletions
diff --git a/xlators/cluster/afr/src/afr-lk-common.c b/xlators/cluster/afr/src/afr-lk-common.c
index 41fa8a30bab..2fe1349902c 100644
--- a/xlators/cluster/afr/src/afr-lk-common.c
+++ b/xlators/cluster/afr/src/afr-lk-common.c
@@ -62,7 +62,8 @@ afr_set_lk_owner (call_frame_t *frame, xlator_t *this)
gf_log (this->name, GF_LOG_TRACE,
"Setting lk-owner=%llu",
(unsigned long long) (unsigned long)frame->root);
- frame->root->lk_owner = (uint64_t) (unsigned long)frame->root;
+
+ set_lk_owner_from_ptr (&frame->root->lk_owner, frame->root);
}
static int
@@ -115,7 +116,7 @@ internal_lock_count (call_frame_t *frame, xlator_t *this)
static void
afr_print_inodelk (char *str, int size, int cmd,
- struct gf_flock *flock, uint64_t owner)
+ struct gf_flock *flock, gf_lkowner_t *owner)
{
char *cmd_str = NULL;
char *type_str = NULL;
@@ -163,11 +164,11 @@ afr_print_inodelk (char *str, int size, int cmd,
}
snprintf (str, size, "lock=INODELK, cmd=%s, type=%s, "
- "start=%llu, len=%llu, pid=%llu, lk-owner=%llu",
+ "start=%llu, len=%llu, pid=%llu, lk-owner=%s",
cmd_str, type_str, (unsigned long long) flock->l_start,
(unsigned long long) flock->l_len,
(unsigned long long) flock->l_pid,
- (unsigned long long) owner);
+ lkowner_utoa (owner));
}
@@ -183,11 +184,11 @@ afr_print_lockee (char *str, int size, loc_t *loc, fd_t *fd,
void
afr_print_entrylk (char *str, int size, const char *basename,
- uint64_t owner)
+ gf_lkowner_t *owner)
{
- snprintf (str, size, "Basename=%s, lk-owner=%llu",
+ snprintf (str, size, "Basename=%s, lk-owner=%s",
basename ? basename : "<nul>",
- (unsigned long long)owner);
+ lkowner_utoa (owner));
}
static void
@@ -302,7 +303,7 @@ afr_trace_inodelk_in (call_frame_t *frame, afr_lock_call_type_t lock_call_type,
return;
}
- afr_print_inodelk (lock, 256, cmd, flock, frame->root->lk_owner);
+ afr_print_inodelk (lock, 256, cmd, flock, &frame->root->lk_owner);
afr_print_lockee (lockee, 256, &local->loc, local->fd, child_index);
afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
@@ -339,7 +340,7 @@ afr_trace_entrylk_in (call_frame_t *frame, afr_lock_call_type_t lock_call_type,
return;
}
- afr_print_entrylk (lock, 256, basename, frame->root->lk_owner);
+ afr_print_entrylk (lock, 256, basename, &frame->root->lk_owner);
afr_print_lockee (lockee, 256, &local->loc, local->fd, child_index);
afr_set_lock_call_type (lock_call_type, lock_call_type_str, int_lock);
@@ -602,8 +603,8 @@ afr_unlock_inodelk (call_frame_t *frame, xlator_t *this)
flock.l_type = F_UNLCK;
gf_log (this->name, GF_LOG_DEBUG, "attempting data unlock range %"PRIu64
- " %"PRIu64" by %"PRIu64, flock.l_start, flock.l_len,
- frame->root->lk_owner);
+ " %"PRIu64" by %s", flock.l_start, flock.l_len,
+ lkowner_utoa (&frame->root->lk_owner));
call_count = afr_locked_nodes_count (int_lock->inode_locked_nodes,
priv->child_count);
@@ -1422,8 +1423,8 @@ afr_nonblocking_inodelk (call_frame_t *frame, xlator_t *this)
flock.l_type = int_lock->lk_flock.l_type;
gf_log (this->name, GF_LOG_DEBUG, "attempting data lock range %"PRIu64
- " %"PRIu64" by %"PRIu64, flock.l_start, flock.l_len,
- frame->root->lk_owner);
+ " %"PRIu64" by %s", flock.l_start, flock.l_len,
+ lkowner_utoa (&frame->root->lk_owner));
full_flock.l_type = int_lock->lk_flock.l_type;
diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c
index 83920c081b7..c1c1d483e54 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -395,8 +395,8 @@ afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this)
afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success,
priv->child_count, AFR_DATA_TRANSACTION);
- gf_log (this->name, GF_LOG_DEBUG, "Delta matrix for: %"PRIu64,
- frame->root->lk_owner);
+ gf_log (this->name, GF_LOG_DEBUG, "Delta matrix for: %s",
+ lkowner_utoa (&frame->root->lk_owner));
afr_sh_print_pending_matrix (sh->delta_matrix, this);
erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count,
@@ -658,8 +658,9 @@ afr_sh_data_fix (call_frame_t *frame, xlator_t *this)
sh = &local->self_heal;
priv = this->private;
- gf_log (this->name, GF_LOG_DEBUG, "Pending matrix for: %"PRIu64,
- frame->root->lk_owner);
+ gf_log (this->name, GF_LOG_DEBUG, "Pending matrix for: %s",
+ lkowner_utoa (&frame->root->lk_owner));
+
nsources = afr_build_sources (this, sh->xattr, sh->buf, sh->pending_matrix,
sh->sources, sh->success_children,
AFR_DATA_TRANSACTION, NULL, _gf_false);
@@ -1131,14 +1132,16 @@ afr_sh_data_post_blocking_inodelk_cbk (call_frame_t *frame, xlator_t *this)
if (int_lock->lock_op_ret < 0) {
gf_log (this->name, GF_LOG_ERROR, "Blocking data inodelks "
- "failed for %s. by %"PRIu64,
- local->loc.path, frame->root->lk_owner);
+ "failed for %s. by %s",
+ local->loc.path, lkowner_utoa (&frame->root->lk_owner));
+
sh->data_lock_failure_handler (frame, this);
} else {
gf_log (this->name, GF_LOG_DEBUG, "Blocking data inodelks "
- "done for %s by %"PRIu64". Proceding to self-heal",
- local->loc.path, frame->root->lk_owner);
+ "done for %s by %s. Proceding to self-heal",
+ local->loc.path, lkowner_utoa (&frame->root->lk_owner));
+
sh->data_lock_success_handler (frame, this);
}
@@ -1158,15 +1161,16 @@ afr_sh_data_post_nonblocking_inodelk_cbk (call_frame_t *frame, xlator_t *this)
if (int_lock->lock_op_ret < 0) {
gf_log (this->name, GF_LOG_DEBUG, "Non Blocking data inodelks "
- "failed for %s. by %"PRIu64,
- local->loc.path, frame->root->lk_owner);
+ "failed for %s. by %s",
+ local->loc.path, lkowner_utoa (&frame->root->lk_owner));
+
int_lock->lock_cbk = afr_sh_data_post_blocking_inodelk_cbk;
afr_blocking_lock (frame, this);
} else {
gf_log (this->name, GF_LOG_DEBUG, "Non Blocking data inodelks "
- "done for %s by %"PRIu64". Proceeding to self-heal",
- local->loc.path, frame->root->lk_owner);
+ "done for %s by %s. Proceeding to self-heal",
+ local->loc.path, lkowner_utoa (&frame->root->lk_owner));
sh->data_lock_success_handler (frame, this);
}
diff --git a/xlators/cluster/afr/src/pump.c b/xlators/cluster/afr/src/pump.c
index b92c50e851d..73389009d68 100644
--- a/xlators/cluster/afr/src/pump.c
+++ b/xlators/cluster/afr/src/pump.c
@@ -694,7 +694,7 @@ pump_start (call_frame_t *pump_frame, xlator_t *this)
priv = this->private;
pump_priv = priv->pump_private;
- pump_frame->root->lk_owner = (uint64_t) (unsigned long)pump_frame->root;
+ afr_set_lk_owner (pump_frame, this);
pump_pid = (uint64_t) (unsigned long)pump_frame->root;
ret = synctask_new (pump_priv->env, pump_task,
@@ -708,8 +708,8 @@ pump_start (call_frame_t *pump_frame, xlator_t *this)
}
gf_log (this->name, GF_LOG_DEBUG,
- "setting pump as started lk_owner: %"PRIu64" %"PRIu64,
- pump_frame->root->lk_owner, pump_pid);
+ "setting pump as started lk_owner: %s %"PRIu64,
+ lkowner_utoa (&pump_frame->root->lk_owner), pump_pid);
priv->use_afr_in_pump = 1;
out:
diff --git a/xlators/features/locks/src/common.c b/xlators/features/locks/src/common.c
index f6b9c331575..0bc7baa3011 100644
--- a/xlators/features/locks/src/common.c
+++ b/xlators/features/locks/src/common.c
@@ -143,9 +143,9 @@ __pl_inode_is_empty (pl_inode_t *pl_inode)
void
pl_print_locker (char *str, int size, xlator_t *this, call_frame_t *frame)
{
- snprintf (str, size, "Pid=%llu, lk-owner=%llu, Transport=%p, Frame=%llu",
+ snprintf (str, size, "Pid=%llu, lk-owner=%s, Transport=%p, Frame=%llu",
(unsigned long long) frame->root->pid,
- (unsigned long long) frame->root->lk_owner,
+ lkowner_utoa (&frame->root->lk_owner),
(void *)frame->root->trans,
(unsigned long long) frame->root->unique);
}
@@ -187,7 +187,7 @@ pl_print_lockee (char *str, int size, fd_t *fd, loc_t *loc)
void
pl_print_lock (char *str, int size, int cmd,
- struct gf_flock *flock, uint64_t owner)
+ struct gf_flock *flock, gf_lkowner_t *owner)
{
char *cmd_str = NULL;
char *type_str = NULL;
@@ -235,11 +235,11 @@ pl_print_lock (char *str, int size, int cmd,
}
snprintf (str, size, "lock=FCNTL, cmd=%s, type=%s, "
- "start=%llu, len=%llu, pid=%llu, lk-owner=%llu",
+ "start=%llu, len=%llu, pid=%llu, lk-owner=%s",
cmd_str, type_str, (unsigned long long) flock->l_start,
(unsigned long long) flock->l_len,
(unsigned long long) flock->l_pid,
- (unsigned long long) owner);
+ lkowner_utoa (owner));
}
@@ -262,7 +262,7 @@ pl_trace_in (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc,
if (domain)
pl_print_inodelk (pl_lock, 256, cmd, flock, domain);
else
- pl_print_lock (pl_lock, 256, cmd, flock, frame->root->lk_owner);
+ pl_print_lock (pl_lock, 256, cmd, flock, &frame->root->lk_owner);
gf_log (this->name, GF_LOG_INFO,
"[REQUEST] Locker = {%s} Lockee = {%s} Lock = {%s}",
@@ -312,7 +312,7 @@ pl_trace_out (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc,
if (domain)
pl_print_inodelk (pl_lock, 256, cmd, flock, domain);
else
- pl_print_lock (pl_lock, 256, cmd, flock, frame->root->lk_owner);
+ pl_print_lock (pl_lock, 256, cmd, flock, &frame->root->lk_owner);
pl_print_verdict (verdict, 32, op_ret, op_errno);
@@ -342,7 +342,7 @@ pl_trace_block (xlator_t *this, call_frame_t *frame, fd_t *fd, loc_t *loc,
if (domain)
pl_print_inodelk (pl_lock, 256, cmd, flock, domain);
else
- pl_print_lock (pl_lock, 256, cmd, flock, frame->root->lk_owner);
+ pl_print_lock (pl_lock, 256, cmd, flock, &frame->root->lk_owner);
gf_log (this->name, GF_LOG_INFO,
"[BLOCKED] Locker = {%s} Lockee = {%s} Lock = {%s}",
@@ -468,7 +468,7 @@ out:
/* Create a new posix_lock_t */
posix_lock_t *
new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
- uint64_t owner, fd_t *fd)
+ gf_lkowner_t *owner, fd_t *fd)
{
posix_lock_t *lock = NULL;
@@ -494,7 +494,7 @@ new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
lock->fd_num = fd_to_fdnum (fd);
lock->fd = fd;
lock->client_pid = client_pid;
- lock->owner = owner;
+ lock->owner = *owner;
INIT_LIST_HEAD (&lock->list);
@@ -569,8 +569,8 @@ int
same_owner (posix_lock_t *l1, posix_lock_t *l2)
{
- return ((l1->owner == l2->owner) &&
- (l1->transport == l2->transport));
+ return (is_same_lkowner (&l1->owner, &l2->owner) &&
+ (l1->transport == l2->transport));
}
@@ -889,10 +889,9 @@ __grant_blocked_locks (xlator_t *this, pl_inode_t *pl_inode, struct list_head *g
posix_lock_to_flock (l, &conf->user_flock);
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Granted",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => Granted",
l->fl_type == F_UNLCK ? "Unlock" : "Lock",
- l->client_pid,
- l->owner,
+ l->client_pid, lkowner_utoa (&l->owner),
l->user_flock.l_start,
l->user_flock.l_len);
@@ -958,7 +957,7 @@ pl_send_prelock_unlock (xlator_t *this, pl_inode_t *pl_inode,
unlock_lock = new_posix_lock (&flock, old_lock->transport,
- old_lock->client_pid, old_lock->owner,
+ old_lock->client_pid, &old_lock->owner,
old_lock->fd);
GF_VALIDATE_OR_GOTO (this->name, unlock_lock, out);
ret = 0;
@@ -1011,19 +1010,19 @@ pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
if (__is_lock_grantable (pl_inode, lock)) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => OK",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
__insert_and_merge (pl_inode, lock);
} else if (can_block) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Blocked",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => Blocked",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
lock->blocked = 1;
@@ -1031,10 +1030,10 @@ pl_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
ret = -1;
} else {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => NOK",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => NOK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
errno = EAGAIN;
diff --git a/xlators/features/locks/src/common.h b/xlators/features/locks/src/common.h
index d95e287cb94..0c0dd22e7ca 100644
--- a/xlators/features/locks/src/common.h
+++ b/xlators/features/locks/src/common.h
@@ -20,10 +20,12 @@
#ifndef __COMMON_H__
#define __COMMON_H__
+#include "lkowner.h"
+
#define SET_FLOCK_PID(flock, lock) ((flock)->l_pid = lock->client_pid)
posix_lock_t *
new_posix_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
- uint64_t owner, fd_t *fd);
+ gf_lkowner_t *owner, fd_t *fd);
pl_inode_t *
pl_inode_get (xlator_t *this, inode_t *inode);
diff --git a/xlators/features/locks/src/entrylk.c b/xlators/features/locks/src/entrylk.c
index 886a30b0ef2..3e91b9d9467 100644
--- a/xlators/features/locks/src/entrylk.c
+++ b/xlators/features/locks/src/entrylk.c
@@ -35,7 +35,8 @@
static pl_entry_lock_t *
new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
- void *trans, pid_t client_pid, uint64_t owner, const char *volume)
+ void *trans, pid_t client_pid, gf_lkowner_t *owner,
+ const char *volume)
{
pl_entry_lock_t *newlock = NULL;
@@ -46,12 +47,12 @@ new_entrylk_lock (pl_inode_t *pinode, const char *basename, entrylk_type type,
goto out;
}
- newlock->basename = basename ? gf_strdup (basename) : NULL;
- newlock->type = type;
- newlock->trans = trans;
- newlock->volume = volume;
- newlock->client_pid = client_pid;
- newlock->owner = owner;
+ newlock->basename = basename ? gf_strdup (basename) : NULL;
+ newlock->type = type;
+ newlock->trans = trans;
+ newlock->volume = volume;
+ newlock->client_pid = client_pid;
+ newlock->owner = *owner;
INIT_LIST_HEAD (&newlock->domain_list);
INIT_LIST_HEAD (&newlock->blocked_locks);
@@ -81,11 +82,11 @@ names_conflict (const char *n1, const char *n2)
}
-static int
+static inline int
__same_entrylk_owner (pl_entry_lock_t *l1, pl_entry_lock_t *l2)
{
- return ((l1->owner == l2->owner) &&
+ return (is_same_lkowner (&l1->owner, &l2->owner) &&
(l1->trans == l2->trans));
}
@@ -320,15 +321,13 @@ __lock_name (pl_inode_t *pinode, const char *basename, entrylk_type type,
pl_entry_lock_t *conf = NULL;
void *trans = NULL;
pid_t client_pid = 0;
- uint64_t owner = 0;
-
- int ret = -EINVAL;
+ int ret = -EINVAL;
trans = frame->root->trans;
client_pid = frame->root->pid;
- owner = frame->root->lk_owner;
- lock = new_entrylk_lock (pinode, basename, type, trans, client_pid, owner, dom->domain);
+ lock = new_entrylk_lock (pinode, basename, type, trans, client_pid,
+ &frame->root->lk_owner, dom->domain);
if (!lock) {
ret = -ENOMEM;
goto out;
@@ -601,7 +600,6 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
const char *volume, inode_t *inode, const char *basename,
entrylk_cmd cmd, entrylk_type type, loc_t *loc, fd_t *fd)
{
- uint64_t owner = 0;
int32_t op_ret = -1;
int32_t op_errno = 0;
@@ -628,10 +626,9 @@ pl_common_entrylk (call_frame_t *frame, xlator_t *this,
entrylk_trace_in (this, frame, volume, fd, loc, basename, cmd, type);
- owner = frame->root->lk_owner;
transport = frame->root->trans;
- if (owner == 0) {
+ if (frame->root->lk_owner.len == 0) {
/*
this is a special case that means release
all locks from this transport
diff --git a/xlators/features/locks/src/inodelk.c b/xlators/features/locks/src/inodelk.c
index 1db08e05858..5785f1f8e3f 100644
--- a/xlators/features/locks/src/inodelk.c
+++ b/xlators/features/locks/src/inodelk.c
@@ -120,9 +120,10 @@ inodelk_overlap (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
}
/* Returns true if the 2 inodelks have the same owner */
-static int same_inodelk_owner (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
+static inline int
+same_inodelk_owner (pl_inode_lock_t *l1, pl_inode_lock_t *l2)
{
- return ((l1->owner == l2->owner) &&
+ return (is_same_lkowner (&l1->owner, &l2->owner) &&
(l1->transport == l2->transport));
}
@@ -212,10 +213,10 @@ __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
list_add_tail (&lock->blocked_locks, &dom->blocked_inodelks);
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Blocked",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => Blocked",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -234,10 +235,10 @@ __lock_inodelk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
gf_log (this->name, GF_LOG_TRACE,
"Lock is grantable, but blocking to prevent starvation");
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Blocked",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => Blocked",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -352,10 +353,10 @@ grant_blocked_inode_locks (xlator_t *this, pl_inode_t *pl_inode, pl_dom_list_t *
list_for_each_entry_safe (lock, tmp, &granted, blocked_locks) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => Granted",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -405,8 +406,9 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
gf_log (this->name, GF_LOG_DEBUG,
"releasing blocking lock on %s held by "
- "{transport=%p, pid=%"PRId64" lk-owner=%"PRIu64"}",
- file, trans, (uint64_t) l->client_pid, l->owner);
+ "{transport=%p, pid=%"PRId64" lk-owner=%s}",
+ file, trans, (uint64_t) l->client_pid,
+ lkowner_utoa (&l->owner));
list_add (&l->blocked_locks, &released);
if (path) {
@@ -430,8 +432,9 @@ release_inode_locks_of_transport (xlator_t *this, pl_dom_list_t *dom,
gf_log (this->name, GF_LOG_DEBUG,
"releasing granted lock on %s held by "
- "{transport=%p, pid=%"PRId64" lk-owner=%"PRIu64"}",
- file, trans, (uint64_t) l->client_pid, l->owner);
+ "{transport=%p, pid=%"PRId64" lk-owner=%s}",
+ file, trans, (uint64_t) l->client_pid,
+ lkowner_utoa (&l->owner));
if (path) {
GF_FREE (path);
path = NULL;
@@ -468,19 +471,19 @@ pl_inode_setlk (xlator_t *this, pl_inode_t *pl_inode, pl_inode_lock_t *lock,
ret = __lock_inodelk (this, pl_inode, lock, can_block, dom);
if (ret == 0)
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => OK",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->fl_start,
lock->fl_end);
if (ret == -EAGAIN)
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => NOK",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => NOK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -510,7 +513,7 @@ out:
/* Create a new inode_lock_t */
pl_inode_lock_t *
new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
- uint64_t owner, const char *volume)
+ gf_lkowner_t *owner, const char *volume)
{
pl_inode_lock_t *lock = NULL;
@@ -531,8 +534,8 @@ new_inode_lock (struct gf_flock *flock, void *transport, pid_t client_pid,
lock->transport = transport;
lock->client_pid = client_pid;
- lock->owner = owner;
lock->volume = volume;
+ lock->owner = *owner;
INIT_LIST_HEAD (&lock->list);
INIT_LIST_HEAD (&lock->blocked_locks);
@@ -546,16 +549,15 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
const char *volume, inode_t *inode, int32_t cmd,
struct gf_flock *flock, loc_t *loc, fd_t *fd)
{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- int ret = -1;
- int can_block = 0;
- void * transport = NULL;
- pid_t client_pid = -1;
- uint64_t owner = -1;
- pl_inode_t * pinode = NULL;
- pl_inode_lock_t * reqlock = NULL;
- pl_dom_list_t * dom = NULL;
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ int ret = -1;
+ int can_block = 0;
+ pid_t client_pid = -1;
+ void * transport = NULL;
+ pl_inode_t * pinode = NULL;
+ pl_inode_lock_t * reqlock = NULL;
+ pl_dom_list_t * dom = NULL;
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (inode, unwind);
@@ -570,7 +572,6 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
transport = frame->root->trans;
client_pid = frame->root->pid;
- owner = frame->root->lk_owner;
pinode = pl_inode_get (this, inode);
if (!pinode) {
@@ -580,7 +581,7 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
dom = get_domain (pinode, volume);
- if (owner == 0) {
+ if (frame->root->lk_owner.len == 0) {
/*
special case: this means release all locks
from this transport
@@ -594,7 +595,8 @@ pl_common_inodelk (call_frame_t *frame, xlator_t *this,
goto unwind;
}
- reqlock = new_inode_lock (flock, transport, client_pid, owner, volume);
+ reqlock = new_inode_lock (flock, transport, client_pid,
+ &frame->root->lk_owner, volume);
if (!reqlock) {
op_ret = -1;
@@ -687,12 +689,12 @@ __get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode)
gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
+ " domain: %s %s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" "
"state = Active",
dom->domain,
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -703,12 +705,12 @@ __get_inodelk_count (xlator_t *this, pl_inode_t *pl_inode)
gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- " domain: %s %s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" "
+ " domain: %s %s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" "
"state = Blocked",
dom->domain,
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
diff --git a/xlators/features/locks/src/locks.h b/xlators/features/locks/src/locks.h
index 476b9a83cd6..0dcbdf97901 100644
--- a/xlators/features/locks/src/locks.h
+++ b/xlators/features/locks/src/locks.h
@@ -30,6 +30,8 @@
#include "call-stub.h"
#include "locks-mem-types.h"
+#include "lkowner.h"
+
#define POSIX_LOCKS "posix-locks"
struct __pl_fd;
@@ -55,8 +57,8 @@ struct __posix_lock {
across nodes */
void *transport; /* to identify client node */
+ gf_lkowner_t owner;
pid_t client_pid; /* pid of client process */
- uint64_t owner; /* lock owner from fuse */
};
typedef struct __posix_lock posix_lock_t;
@@ -83,8 +85,8 @@ struct __pl_inode_lock {
across nodes */
void *transport; /* to identify client node */
+ gf_lkowner_t owner;
pid_t client_pid; /* pid of client process */
- uint64_t owner;
};
typedef struct __pl_inode_lock pl_inode_lock_t;
@@ -120,9 +122,9 @@ struct __entry_lock {
struct timeval blkd_time; /*time at which lock was queued into blkd list*/
struct timeval granted_time; /*time at which lock was queued into active list*/
- void *trans;
+ void *trans;
+ gf_lkowner_t owner;
pid_t client_pid; /* pid of client process */
- uint64_t owner;
};
typedef struct __entry_lock pl_entry_lock_t;
diff --git a/xlators/features/locks/src/posix.c b/xlators/features/locks/src/posix.c
index 59e2199fb4b..0914d16df41 100644
--- a/xlators/features/locks/src/posix.c
+++ b/xlators/features/locks/src/posix.c
@@ -126,7 +126,7 @@ pl_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
static int
truncate_allowed (pl_inode_t *pl_inode,
void *transport, pid_t client_pid,
- uint64_t owner, off_t offset)
+ gf_lkowner_t *owner, off_t offset)
{
posix_lock_t *l = NULL;
posix_lock_t region = {.list = {0, }, };
@@ -136,7 +136,7 @@ truncate_allowed (pl_inode_t *pl_inode,
region.fl_end = LLONG_MAX;
region.transport = transport;
region.client_pid = client_pid;
- region.owner = owner;
+ region.owner = *owner;
pthread_mutex_lock (&pl_inode->mutex);
{
@@ -192,7 +192,7 @@ truncate_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (priv->mandatory
&& pl_inode->mandatory
&& !truncate_allowed (pl_inode, frame->root->trans,
- frame->root->pid, frame->root->lk_owner,
+ frame->root->pid, &frame->root->lk_owner,
local->offset)) {
op_ret = -1;
op_errno = EAGAIN;
@@ -324,7 +324,7 @@ delete_locks_of_fd (xlator_t *this, pl_inode_t *pl_inode, fd_t *fd)
static void
__delete_locks_of_owner (pl_inode_t *pl_inode,
- void *transport, uint64_t owner)
+ void *transport, gf_lkowner_t *owner)
{
posix_lock_t *tmp = NULL;
posix_lock_t *l = NULL;
@@ -332,14 +332,14 @@ __delete_locks_of_owner (pl_inode_t *pl_inode,
/* TODO: what if it is a blocked lock with pending l->frame */
list_for_each_entry_safe (l, tmp, &pl_inode->ext_list, list) {
- if ((l->transport == transport)
- && (l->owner == owner)) {
+ if ((l->transport == transport) &&
+ is_same_lkowner (&l->owner, owner)) {
gf_log ("posix-locks", GF_LOG_TRACE,
" Flushing lock"
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" state: %s",
l->fl_type == F_UNLCK ? "Unlock" : "Lock",
l->client_pid,
- l->owner,
+ lkowner_utoa (&l->owner),
l->user_flock.l_start,
l->user_flock.l_len,
l->blocked == 1 ? "Blocked" : "Active");
@@ -408,10 +408,7 @@ int
pl_flush (call_frame_t *frame, xlator_t *this,
fd_t *fd)
{
- pl_inode_t *pl_inode = NULL;
- uint64_t owner = -1;
-
- owner = frame->root->lk_owner;
+ pl_inode_t *pl_inode = NULL;
pl_inode = pl_inode_get (this, fd->inode);
@@ -423,7 +420,7 @@ pl_flush (call_frame_t *frame, xlator_t *this,
pl_trace_flush (this, frame, fd);
- if (owner == 0) {
+ if (frame->root->lk_owner.len == 0) {
/* Handle special case when protocol/server sets lk-owner to zero.
* This usually happens due to a client disconnection. Hence, free
* all locks opened with this fd.
@@ -437,7 +434,7 @@ pl_flush (call_frame_t *frame, xlator_t *this,
pthread_mutex_lock (&pl_inode->mutex);
{
__delete_locks_of_owner (pl_inode, frame->root->trans,
- owner);
+ &frame->root->lk_owner);
}
pthread_mutex_unlock (&pl_inode->mutex);
@@ -805,7 +802,7 @@ lock_dup (posix_lock_t *lock)
posix_lock_t *new_lock = NULL;
new_lock = new_posix_lock (&lock->user_flock, lock->transport,
- lock->client_pid, lock->owner,
+ lock->client_pid, &lock->owner,
(fd_t *)lock->fd_num);
return new_lock;
}
@@ -964,20 +961,18 @@ int
pl_lk (call_frame_t *frame, xlator_t *this,
fd_t *fd, int32_t cmd, struct gf_flock *flock)
{
- void *transport = NULL;
- pid_t client_pid = 0;
- uint64_t owner = 0;
- pl_inode_t *pl_inode = NULL;
- int op_ret = 0;
- int op_errno = 0;
- int can_block = 0;
- posix_lock_t *reqlock = NULL;
- posix_lock_t *conf = NULL;
- int ret = 0;
+ void *transport = NULL;
+ pid_t client_pid = 0;
+ pl_inode_t *pl_inode = NULL;
+ int op_ret = 0;
+ int op_errno = 0;
+ int can_block = 0;
+ posix_lock_t *reqlock = NULL;
+ posix_lock_t *conf = NULL;
+ int ret = 0;
transport = frame->root->trans;
client_pid = frame->root->pid;
- owner = frame->root->lk_owner;
if ((flock->l_start < 0) || (flock->l_len < 0)) {
op_ret = -1;
@@ -993,7 +988,7 @@ pl_lk (call_frame_t *frame, xlator_t *this,
}
reqlock = new_posix_lock (flock, transport, client_pid,
- owner, fd);
+ &frame->root->lk_owner, fd);
if (!reqlock) {
op_ret = -1;
@@ -1327,10 +1322,10 @@ __get_posixlk_count (xlator_t *this, pl_inode_t *pl_inode)
gf_log (this->name, GF_LOG_DEBUG,
" XATTR DEBUG"
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" state: %s",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" state: %s",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len,
lock->blocked == 1 ? "Blocked" : "Active");
@@ -1504,7 +1499,7 @@ out:
void
pl_dump_lock (char *str, int size, struct gf_flock *flock,
- uint64_t owner, void *trans, time_t *granted_time,
+ gf_lkowner_t *owner, void *trans, time_t *granted_time,
time_t *blkd_time, gf_boolean_t active)
{
char *type_str = NULL;
@@ -1526,30 +1521,32 @@ pl_dump_lock (char *str, int size, struct gf_flock *flock,
if (active) {
if (blkd_time && *blkd_time == 0) {
- snprintf (str, size, "type=%s, start=%llu, len=%llu, pid=%llu, lk-owner=%llu, transport=%p, "
- "granted at %s",
+ snprintf (str, size, "type=%s, start=%llu, len=%llu, "
+ "pid=%llu, lk-owner=%s, transport=%p, "
+ "granted at %s",
type_str, (unsigned long long) flock->l_start,
(unsigned long long) flock->l_len,
(unsigned long long) flock->l_pid,
- (unsigned long long) owner,
+ lkowner_utoa (owner),
trans, ctime (granted_time));
} else {
- snprintf (str, size, "type=%s, start=%llu, len=%llu, pid=%llu, lk-owner=%llu, transport=%p, "
+ snprintf (str, size, "type=%s, start=%llu, len=%llu, "
+ "pid=%llu, lk-owner=%s, transport=%p, "
"blocked at %s, granted at %s",
type_str, (unsigned long long) flock->l_start,
(unsigned long long) flock->l_len,
(unsigned long long) flock->l_pid,
- (unsigned long long) owner,
+ lkowner_utoa (owner),
trans, ctime (blkd_time), ctime (granted_time));
}
}
else {
- snprintf (str, size, "type=%s, start=%llu, len=%llu, pid=%llu, lk-owner=%llu, transport=%p, "
- "blocked at %s",
+ snprintf (str, size, "type=%s, start=%llu, len=%llu, pid=%llu, "
+ "lk-owner=%s, transport=%p, blocked at %s",
type_str, (unsigned long long) flock->l_start,
(unsigned long long) flock->l_len,
(unsigned long long) flock->l_pid,
- (unsigned long long) owner,
+ lkowner_utoa (owner),
trans, ctime (blkd_time));
}
@@ -1580,20 +1577,20 @@ __dump_entrylks (pl_inode_t *pl_inode)
"xlator.feature.locks.lock-dump.domain.entrylk",
"entrylk[%d](ACTIVE)", count );
if (lock->blkd_time.tv_sec == 0 && lock->blkd_time.tv_usec == 0) {
- snprintf (tmp, 256," %s on %s pid = %llu, owner=%llu, transport=%p,"
+ snprintf (tmp, 256," %s on %s pid = %llu, owner=%s, transport=%p,"
" granted at %s",
lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename,
(unsigned long long) lock->client_pid,
- (unsigned long long) lock->owner, lock->trans,
+ lkowner_utoa (&lock->owner), lock->trans,
ctime (&lock->granted_time.tv_sec));
} else {
- snprintf (tmp, 256," %s on %s pid = %llu, owner=%llu, transport=%p,"
+ snprintf (tmp, 256," %s on %s pid = %llu, owner=%s, transport=%p,"
" blocked at %s, granted at %s",
lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename,
(unsigned long long) lock->client_pid,
- (unsigned long long) lock->owner, lock->trans,
+ lkowner_utoa (&lock->owner), lock->trans,
ctime (&lock->blkd_time.tv_sec),
ctime (&lock->granted_time.tv_sec));
}
@@ -1608,12 +1605,12 @@ __dump_entrylks (pl_inode_t *pl_inode)
gf_proc_dump_build_key(key,
"xlator.feature.locks.lock-dump.domain.entrylk",
"entrylk[%d](BLOCKED)", count );
- snprintf (tmp, 256," %s on %s pid = %llu, owner=%llu, transport=%p,"
+ snprintf (tmp, 256," %s on %s pid = %llu, owner=%s, transport=%p,"
" blocked at %s",
lock->type == ENTRYLK_RDLCK ? "ENTRYLK_RDLCK" :
"ENTRYLK_WRLCK", lock->basename,
(unsigned long long) lock->client_pid,
- (unsigned long long) lock->owner, lock->trans,
+ lkowner_utoa (&lock->owner), lock->trans,
ctime (&lock->blkd_time.tv_sec));
gf_proc_dump_write(key, tmp);
@@ -1663,7 +1660,8 @@ __dump_inodelks (pl_inode_t *pl_inode)
SET_FLOCK_PID (&lock->user_flock, lock);
pl_dump_lock (tmp, 256, &lock->user_flock,
- lock->owner, lock->transport,
+ &lock->owner,
+ lock->transport,
&lock->granted_time.tv_sec,
&lock->blkd_time.tv_sec,
_gf_true);
@@ -1679,7 +1677,8 @@ __dump_inodelks (pl_inode_t *pl_inode)
"inodelk[%d](BLOCKED)",count );
SET_FLOCK_PID (&lock->user_flock, lock);
pl_dump_lock (tmp, 256, &lock->user_flock,
- lock->owner, lock->transport,
+ &lock->owner,
+ lock->transport,
0, &lock->blkd_time.tv_sec,
_gf_false);
gf_proc_dump_write(key, tmp);
@@ -1720,7 +1719,7 @@ __dump_posixlks (pl_inode_t *pl_inode)
count,
lock->blocked ? "BLOCKED" : "ACTIVE");
pl_dump_lock (tmp, 256, &lock->user_flock,
- lock->owner, lock->transport,
+ &lock->owner, lock->transport,
&lock->granted_time.tv_sec, &lock->blkd_time.tv_sec,
(lock->blocked)? _gf_false: _gf_true);
gf_proc_dump_write(key, tmp);
diff --git a/xlators/features/locks/src/reservelk.c b/xlators/features/locks/src/reservelk.c
index 4aac1803d8a..7a75cdea10d 100644
--- a/xlators/features/locks/src/reservelk.c
+++ b/xlators/features/locks/src/reservelk.c
@@ -81,10 +81,10 @@ out:
return ret_lock;
}
-static int
+static inline int
__same_owner_reservelk (posix_lock_t *l1, posix_lock_t *l2)
{
- return ((l1->owner == l2->owner));
+ return (is_same_lkowner (&l1->owner, &l2->owner));
}
@@ -187,10 +187,10 @@ __lock_reservelk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
list_add_tail (&lock->list, &pl_inode->blocked_reservelks);
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) lk-owner:%"PRIu64" %"PRId64" - %"PRId64" => Blocked",
+ "%s (pid=%d) lk-owner:%s %"PRId64" - %"PRId64" => Blocked",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -292,10 +292,10 @@ grant_blocked_reserve_locks (xlator_t *this, pl_inode_t *pl_inode)
list_for_each_entry_safe (lock, tmp, &granted, list) {
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => Granted",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => Granted",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
@@ -429,18 +429,18 @@ pl_reserve_setlk (xlator_t *this, pl_inode_t *pl_inode, posix_lock_t *lock,
ret = __lock_reservelk (this, pl_inode, lock, can_block);
if (ret < 0)
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => NOK",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => NOK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len);
else
gf_log (this->name, GF_LOG_TRACE,
- "%s (pid=%d) (lk-owner=%"PRIu64") %"PRId64" - %"PRId64" => OK",
+ "%s (pid=%d) (lk-owner=%s) %"PRId64" - %"PRId64" => OK",
lock->fl_type == F_UNLCK ? "Unlock" : "Lock",
lock->client_pid,
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->fl_start,
lock->fl_end);
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index 57e8470d67a..227c4951b35 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -152,7 +152,7 @@ mq_assign_lk_owner (xlator_t *this, call_frame_t *frame)
}
UNLOCK (&conf->lock);
- frame->root->lk_owner = lk_owner;
+ set_lk_owner_from_uint64 (&frame->root->lk_owner, lk_owner);
return;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-handshake.c b/xlators/mgmt/glusterd/src/glusterd-handshake.c
index e514f8bc45d..04e5fae7bd5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handshake.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handshake.c
@@ -35,6 +35,7 @@
#include "glusterfs3.h"
#include "protocol-common.h"
#include "rpcsvc.h"
+#include "rpc-common-xdr.h"
extern struct rpc_clnt_program gd_peer_prog;
extern struct rpc_clnt_program gd_mgmt_prog;
diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c
index b8f53a1bc3c..7409488c1f9 100644
--- a/xlators/mount/fuse/src/fuse-bridge.c
+++ b/xlators/mount/fuse/src/fuse-bridge.c
@@ -3110,11 +3110,11 @@ fuse_setlk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
} else if (op_errno == EAGAIN) {
gf_log ("glusterfs-fuse", GF_LOG_DEBUG,
"Returning EAGAIN Flock: "
- "start=%llu, len=%llu, pid=%llu, lk-owner=%llu",
+ "start=%llu, len=%llu, pid=%llu, lk-owner=%s",
(unsigned long long) lock->l_start,
(unsigned long long) lock->l_len,
(unsigned long long) lock->l_pid,
- (unsigned long long) frame->root->lk_owner);
+ lkowner_utoa (&frame->root->lk_owner));
} else {
gf_log ("glusterfs-fuse", GF_LOG_WARNING,
diff --git a/xlators/mount/fuse/src/fuse-helpers.c b/xlators/mount/fuse/src/fuse-helpers.c
index 9bf85f979c3..2070447faa3 100644
--- a/xlators/mount/fuse/src/fuse-helpers.c
+++ b/xlators/mount/fuse/src/fuse-helpers.c
@@ -145,7 +145,7 @@ frame_fill_groups (call_frame_t *frame)
{
#if defined(GF_LINUX_HOST_OS)
char filename[32];
- char line[128];
+ char line[4096];
char *ptr = NULL;
FILE *fp = NULL;
int idx = 0;
@@ -178,7 +178,7 @@ frame_fill_groups (call_frame_t *frame)
if (!endptr || *endptr)
break;
frame->root->groups[idx++] = id;
- if (idx == GF_REQUEST_MAXGROUPS)
+ if (idx == GF_MAX_AUX_GROUPS)
break;
}
@@ -237,7 +237,6 @@ out:
#endif /* GF_LINUX_HOST_OS */
}
-
call_frame_t *
get_call_frame_for_req (fuse_state_t *state)
{
@@ -260,8 +259,9 @@ get_call_frame_for_req (fuse_state_t *state)
frame->root->uid = finh->uid;
frame->root->gid = finh->gid;
frame->root->pid = finh->pid;
- frame->root->lk_owner = state->lk_owner;
frame->root->unique = finh->unique;
+ set_lk_owner_from_uint64 (&frame->root->lk_owner,
+ state->lk_owner);
}
frame_fill_groups (frame);
diff --git a/xlators/nfs/server/src/nfs-fops.c b/xlators/nfs/server/src/nfs-fops.c
index 428c82a8fda..c6199d129eb 100644
--- a/xlators/nfs/server/src/nfs-fops.c
+++ b/xlators/nfs/server/src/nfs-fops.c
@@ -90,7 +90,7 @@ unsigned int cval = 1;
int
nfs_frame_getctr ()
{
- int val = 0;
+ uint64_t val = 0;
pthread_mutex_lock (&ctr);
{
@@ -132,7 +132,8 @@ nfs_create_frame (xlator_t *xl, nfs_user_t *nfu)
gf_log (GF_NFS, GF_LOG_TRACE, "gid: %d", nfu->gids[x]);
frame->root->groups[y] = nfu->gids[x];
}
- frame->root->lk_owner = nfs_frame_getctr ();
+
+ set_lk_owner_from_uint64 (&frame->root->lk_owner, nfs_frame_getctr ());
err:
return frame;
diff --git a/xlators/nfs/server/src/nfs.h b/xlators/nfs/server/src/nfs.h
index a77e772a3e3..3113e32cc0b 100644
--- a/xlators/nfs/server/src/nfs.h
+++ b/xlators/nfs/server/src/nfs.h
@@ -45,6 +45,12 @@
#define GF_NFS_DVM_ON 1
#define GF_NFS_DVM_OFF 2
+/* This corresponds to the max 16 number of group IDs that are sent through an
+ * RPC request. Since NFS is the only one going to set this, we can be safe
+ * in keeping this size hardcoded.
+ */
+#define GF_REQUEST_MAXGROUPS 16
+
/* Callback into a version-specific NFS protocol.
* The return type is used by the nfs.c code to register the protocol.
* with the RPC service.
diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c
index 7bf95e912d0..85e10cb0b97 100644
--- a/xlators/protocol/client/src/client-handshake.c
+++ b/xlators/protocol/client/src/client-handshake.c
@@ -31,6 +31,7 @@
#include "glusterfs3.h"
#include "portmap-xdr.h"
+#include "rpc-common-xdr.h"
extern rpc_clnt_prog_t clnt3_1_fop_prog;
extern rpc_clnt_prog_t clnt_pmap_prog;
diff --git a/xlators/protocol/client/src/client-lk.c b/xlators/protocol/client/src/client-lk.c
index 5334500a96c..d08d2a413b7 100644
--- a/xlators/protocol/client/src/client-lk.c
+++ b/xlators/protocol/client/src/client-lk.c
@@ -20,6 +20,7 @@
#include "common-utils.h"
#include "xlator.h"
#include "client.h"
+#include "lkowner.h"
static void
__insert_and_merge (clnt_fd_ctx_t *fdctx, client_posix_lock_t *lock);
@@ -36,11 +37,11 @@ __dump_client_lock (client_posix_lock_t *lock)
gf_log (this->name, GF_LOG_INFO,
"{fd=%p}"
- "{%s lk-owner:%"PRIu64" %"PRId64" - %"PRId64"}"
+ "{%s lk-owner:%s %"PRId64" - %"PRId64"}"
"{start=%"PRId64" end=%"PRId64"}",
lock->fd,
lock->fl_type == F_WRLCK ? "Write-Lock" : "Read-Lock",
- lock->owner,
+ lkowner_utoa (&lock->owner),
lock->user_flock.l_start,
lock->user_flock.l_len,
lock->fl_start,
@@ -133,12 +134,6 @@ add_locks (client_posix_lock_t *l1, client_posix_lock_t *l2)
return sum;
}
-/* Return true if the locks have the same owner */
-static int
-same_owner (client_posix_lock_t *l1, client_posix_lock_t *l2)
-{
- return ((l1->owner == l2->owner));
-}
/* Return true if the locks overlap, false otherwise */
static int
@@ -285,11 +280,11 @@ __insert_and_merge (clnt_fd_ctx_t *fdctx, client_posix_lock_t *lock)
if (!locks_overlap (conf, lock))
continue;
- if (same_owner (conf, lock)) {
+ if (is_same_lkowner (&conf->owner, &lock->owner)) {
if (conf->fl_type == lock->fl_type) {
sum = add_locks (lock, conf);
- sum->fd = lock->fd;
+ sum->fd = lock->fd;
__delete_client_lock (conf);
__destroy_client_lock (conf);
@@ -301,8 +296,8 @@ __insert_and_merge (clnt_fd_ctx_t *fdctx, client_posix_lock_t *lock)
} else {
sum = add_locks (lock, conf);
- sum->fd = conf->fd;
- sum->owner = conf->owner;
+ sum->fd = conf->fd;
+ sum->owner = conf->owner;
v = subtract_locks (sum, lock);
@@ -365,7 +360,7 @@ destroy_client_lock (client_posix_lock_t *lock)
}
int32_t
-delete_granted_locks_owner (fd_t *fd, uint64_t owner)
+delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner)
{
clnt_fd_ctx_t *fdctx = NULL;
client_posix_lock_t *lock = NULL;
@@ -389,7 +384,7 @@ delete_granted_locks_owner (fd_t *fd, uint64_t owner)
pthread_mutex_lock (&fdctx->mutex);
{
list_for_each_entry_safe (lock, tmp, &fdctx->lock_list, list) {
- if (lock->owner == owner) {
+ if (!is_same_lkowner (&lock->owner, owner)) {
list_del_init (&lock->list);
list_add_tail (&lock->list, &delete_list);
count++;
@@ -486,7 +481,7 @@ client_cmd_to_gf_cmd (int32_t cmd, int32_t *gf_cmd)
}
static client_posix_lock_t *
-new_client_lock (struct gf_flock *flock, uint64_t owner,
+new_client_lock (struct gf_flock *flock, gf_lkowner_t *owner,
int32_t cmd, fd_t *fd)
{
client_posix_lock_t *new_lock = NULL;
@@ -509,7 +504,8 @@ new_client_lock (struct gf_flock *flock, uint64_t owner,
else
new_lock->fl_end = flock->l_start + flock->l_len - 1;
- new_lock->owner = owner;
+ new_lock->owner = *owner;
+
new_lock->cmd = cmd; /* Not really useful */
out:
@@ -527,8 +523,8 @@ client_save_number_fds (clnt_conf_t *conf, int count)
}
int
-client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock, uint64_t owner,
- int32_t cmd)
+client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock,
+ gf_lkowner_t *owner, int32_t cmd)
{
clnt_fd_ctx_t *fdctx = NULL;
xlator_t *this = NULL;
@@ -572,13 +568,13 @@ construct_reserve_unlock (struct gf_flock *lock, call_frame_t *frame,
{
GF_ASSERT (lock);
GF_ASSERT (frame);
- GF_ASSERT (frame->root->lk_owner);
lock->l_type = F_UNLCK;
lock->l_start = 0;
lock->l_whence = SEEK_SET;
lock->l_len = 0; /* Whole file */
lock->l_pid = (uint64_t)(unsigned long)frame->root;
+ lock->l_owner = client_lock->owner;
frame->root->lk_owner = client_lock->owner;
@@ -827,7 +823,6 @@ static int
client_send_recovery_lock (call_frame_t *frame, xlator_t *this,
client_posix_lock_t *lock)
{
-
frame->root->lk_owner = lock->owner;
/* Send all locks as F_SETLK to prevent the frame
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 69830db9dc1..6d0b6491a10 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -111,8 +111,7 @@ typedef struct _client_posix_lock {
off_t fl_end;
short fl_type;
int32_t cmd; /* the cmd for the lock call */
- uint64_t owner; /* lock owner from fuse */
-
+ gf_lkowner_t owner; /* lock owner from fuse */
struct list_head list; /* reference used to add to the fdctx list of locks */
} client_posix_lock_t;
@@ -126,7 +125,7 @@ typedef struct client_local {
struct iobref *iobref;
client_posix_lock_t *client_lock;
- uint64_t owner;
+ gf_lkowner_t owner;
int32_t cmd;
struct list_head lock_list;
pthread_mutex_t mutex;
@@ -190,9 +189,9 @@ int unserialize_rsp_direntp (struct gfs3_readdirp_rsp *rsp, gf_dirent_t *entries
int clnt_readdir_rsp_cleanup (gfs3_readdir_rsp *rsp);
int clnt_readdirp_rsp_cleanup (gfs3_readdirp_rsp *rsp);
int client_attempt_lock_recovery (xlator_t *this, clnt_fd_ctx_t *fdctx);
-int32_t delete_granted_locks_owner (fd_t *fd, uint64_t owner);
-int client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock, uint64_t owner,
- int32_t cmd);
+int32_t delete_granted_locks_owner (fd_t *fd, gf_lkowner_t *owner);
+int client_add_lock_for_recovery (fd_t *fd, struct gf_flock *flock,
+ gf_lkowner_t *owner, int32_t cmd);
uint64_t decrement_reopen_fd_count (xlator_t *this, clnt_conf_t *conf);
int32_t delete_granted_locks_fd (clnt_fd_ctx_t *fdctx);
int32_t client_cmd_to_gf_cmd (int32_t cmd, int32_t *gf_cmd);
diff --git a/xlators/protocol/client/src/client3_1-fops.c b/xlators/protocol/client/src/client3_1-fops.c
index 6300b264fb1..036e297de38 100644
--- a/xlators/protocol/client/src/client3_1-fops.c
+++ b/xlators/protocol/client/src/client3_1-fops.c
@@ -725,10 +725,10 @@ client3_1_flush_cbk (struct rpc_req *req, struct iovec *iov, int count,
if (rsp.op_ret >= 0) {
/* Delete all saved locks of the owner issuing flush */
- ret = delete_granted_locks_owner (local->fd, local->owner);
+ ret = delete_granted_locks_owner (local->fd, &local->owner);
gf_log (this->name, GF_LOG_TRACE,
- "deleting locks of owner (%llu) returned %d",
- (long long unsigned) local->owner, ret);
+ "deleting locks of owner (%s) returned %d",
+ lkowner_utoa (&local->owner), ret);
}
out:
@@ -3655,7 +3655,7 @@ client3_1_flush (call_frame_t *frame, xlator_t *this,
gfs3_flush_req req = {{0,},};
int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
- clnt_local_t *local = NULL;
+ clnt_local_t *local = NULL;
int op_errno = ESTALE;
int ret = 0;
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index f259a651fe1..43f60e0e2e4 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -39,7 +39,7 @@ server_decode_groups (call_frame_t *frame, rpcsvc_request_t *req)
if (frame->root->ngrps == 0)
return 0;
- if (frame->root->ngrps > GF_REQUEST_MAXGROUPS)
+ if (frame->root->ngrps > GF_MAX_AUX_GROUPS)
return -1;
for (; i < frame->root->ngrps; ++i)
@@ -134,7 +134,7 @@ free_state (server_state_t *state)
int
gf_add_locker (struct _lock_table *table, const char *volume,
- loc_t *loc, fd_t *fd, pid_t pid, uint64_t owner,
+ loc_t *loc, fd_t *fd, pid_t pid, gf_lkowner_t *owner,
glusterfs_fop_t type)
{
int32_t ret = -1;
@@ -158,7 +158,7 @@ gf_add_locker (struct _lock_table *table, const char *volume,
}
new->pid = pid;
- new->owner = owner;
+ new->owner = *owner;
LOCK (&table->lock);
{
@@ -175,7 +175,8 @@ out:
int
gf_del_locker (struct _lock_table *table, const char *volume,
- loc_t *loc, fd_t *fd, uint64_t owner, glusterfs_fop_t type)
+ loc_t *loc, fd_t *fd, gf_lkowner_t *owner,
+ glusterfs_fop_t type)
{
struct _locker *locker = NULL;
struct _locker *tmp = NULL;
@@ -197,17 +198,15 @@ gf_del_locker (struct _lock_table *table, const char *volume,
}
list_for_each_entry_safe (locker, tmp, head, lockers) {
- if (locker->fd && fd &&
- (locker->fd == fd) && (locker->owner == owner)
- && !strcmp (locker->volume, volume)) {
+ if (!is_same_lkowner (&locker->owner, owner) ||
+ strcmp (locker->volume, volume))
+ continue;
+
+ if (locker->fd && fd && (locker->fd == fd))
list_move_tail (&locker->lockers, &del);
- } else if (locker->loc.inode &&
- loc &&
- (locker->loc.inode == loc->inode) &&
- (locker->owner == owner)
- && !strcmp (locker->volume, volume)) {
+ else if (locker->loc.inode && loc &&
+ (locker->loc.inode == loc->inode))
list_move_tail (&locker->lockers, &del);
- }
}
}
UNLOCK (&table->lock);
@@ -314,9 +313,9 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
lock owner = 0 is a special case that tells posix-locks
to release all locks from this transport
*/
- tmp_frame->root->pid = 0;
- tmp_frame->root->lk_owner = 0;
- tmp_frame->root->trans = conn;
+ tmp_frame->root->pid = 0;
+ tmp_frame->root->trans = conn;
+ memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t));
if (locker->fd) {
GF_ASSERT (locker->fd->inode);
@@ -361,9 +360,9 @@ do_lock_table_cleanup (xlator_t *this, server_connection_t *conn,
list_for_each_entry_safe (locker, tmp, &entrylk_lockers, lockers) {
tmp_frame = copy_frame (frame);
- tmp_frame->root->lk_owner = 0;
- tmp_frame->root->pid = 0;
- tmp_frame->root->trans = conn;
+ tmp_frame->root->pid = 0;
+ tmp_frame->root->trans = conn;
+ memset (&tmp_frame->root->lk_owner, 0, sizeof (gf_lkowner_t));
if (locker->fd) {
GF_ASSERT (locker->fd->inode);
@@ -480,7 +479,9 @@ do_fd_cleanup (xlator_t *this, server_connection_t *conn, call_frame_t *frame,
tmp_frame->root->pid = 0;
tmp_frame->root->trans = conn;
- tmp_frame->root->lk_owner = 0;
+ memset (&tmp_frame->root->lk_owner, 0,
+ sizeof (gf_lkowner_t));
+
STACK_WIND (tmp_frame,
server_connection_cleanup_flush_cbk,
bound_xl, bound_xl->fops->flush, fd);
@@ -630,8 +631,9 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
lock_owner = 0 is a special case that tells posix-locks
to release all locks from this transport
*/
- tmp_frame->root->lk_owner = 0;
tmp_frame->root->trans = conn;
+ memset (&tmp_frame->root->lk_owner, 0,
+ sizeof (gf_lkowner_t));
if (locker->fd) {
GF_ASSERT (locker->fd->inode);
@@ -676,8 +678,9 @@ server_connection_destroy (xlator_t *this, server_connection_t *conn)
list_for_each_entry_safe (locker, tmp, &entrylk_lockers, lockers) {
tmp_frame = copy_frame (frame);
- tmp_frame->root->lk_owner = 0;
tmp_frame->root->trans = conn;
+ memset (&tmp_frame->root->lk_owner, 0,
+ sizeof (gf_lkowner_t));
if (locker->fd) {
GF_ASSERT (locker->fd->inode);
diff --git a/xlators/protocol/server/src/server-helpers.h b/xlators/protocol/server/src/server-helpers.h
index ac1222ed16b..844c98c27bf 100644
--- a/xlators/protocol/server/src/server-helpers.h
+++ b/xlators/protocol/server/src/server-helpers.h
@@ -52,14 +52,14 @@ gf_add_locker (struct _lock_table *table, const char *volume,
loc_t *loc,
fd_t *fd,
pid_t pid,
- uint64_t owner,
+ gf_lkowner_t *owner,
glusterfs_fop_t type);
int32_t
gf_del_locker (struct _lock_table *table, const char *volume,
loc_t *loc,
fd_t *fd,
- uint64_t owner,
+ gf_lkowner_t *owner,
glusterfs_fop_t type);
void
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index 6a37482f405..f261752171d 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -39,7 +39,7 @@ struct _locker {
char *volume;
loc_t loc;
fd_t *fd;
- uint64_t owner;
+ gf_lkowner_t owner;
pid_t pid;
};
diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index b847d923c77..c2ab3590ed2 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -247,12 +247,13 @@ server_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret >= 0) {
if (state->flock.l_type == F_UNLCK)
gf_del_locker (conn->ltable, state->volume,
- &state->loc, NULL, frame->root->lk_owner,
+ &state->loc, NULL, &frame->root->lk_owner,
GF_FOP_INODELK);
else
gf_add_locker (conn->ltable, state->volume,
&state->loc, NULL, frame->root->pid,
- frame->root->lk_owner, GF_FOP_INODELK);
+ &frame->root->lk_owner,
+ GF_FOP_INODELK);
} else if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) {
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": INODELK %s (%s) ==> %"PRId32" (%s)",
@@ -289,12 +290,12 @@ server_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (state->flock.l_type == F_UNLCK)
gf_del_locker (conn->ltable, state->volume,
NULL, state->fd,
- frame->root->lk_owner, GF_FOP_INODELK);
+ &frame->root->lk_owner, GF_FOP_INODELK);
else
gf_add_locker (conn->ltable, state->volume,
NULL, state->fd,
frame->root->pid,
- frame->root->lk_owner, GF_FOP_INODELK);
+ &frame->root->lk_owner, GF_FOP_INODELK);
} else if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) {
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": FINODELK %"PRId64" (%s) ==> %"PRId32" (%s)",
@@ -329,11 +330,13 @@ server_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret >= 0) {
if (state->cmd == ENTRYLK_UNLOCK)
gf_del_locker (conn->ltable, state->volume,
- &state->loc, NULL, frame->root->lk_owner, GF_FOP_ENTRYLK);
+ &state->loc, NULL, &frame->root->lk_owner,
+ GF_FOP_ENTRYLK);
else
gf_add_locker (conn->ltable, state->volume,
&state->loc, NULL, frame->root->pid,
- frame->root->lk_owner, GF_FOP_ENTRYLK);
+ &frame->root->lk_owner,
+ GF_FOP_ENTRYLK);
} else if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) {
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": ENTRYLK %s (%s) ==> %"PRId32" (%s)",
@@ -367,11 +370,12 @@ server_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (op_ret >= 0) {
if (state->cmd == ENTRYLK_UNLOCK)
gf_del_locker (conn->ltable, state->volume,
- NULL, state->fd, frame->root->lk_owner, GF_FOP_ENTRYLK);
+ NULL, state->fd, &frame->root->lk_owner,
+ GF_FOP_ENTRYLK);
else
gf_add_locker (conn->ltable, state->volume,
NULL, state->fd, frame->root->pid,
- frame->root->lk_owner, GF_FOP_ENTRYLK);
+ &frame->root->lk_owner, GF_FOP_ENTRYLK);
} else if ((op_errno != ENOSYS) && (op_errno != EAGAIN)) {
gf_log (this->name, GF_LOG_INFO,
"%"PRId64": FENTRYLK %"PRId64" (%s) "