From b02afc6d008f9959db28244eb2b9dd3b9ef92393 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Tue, 17 Jan 2012 05:28:51 +0530 Subject: 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 BUG: 767229 Reviewed-on: http://review.gluster.com/779 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/protocol/client/src/client-handshake.c | 1 + xlators/protocol/client/src/client-lk.c | 35 ++++++++----------- xlators/protocol/client/src/client.h | 11 +++--- xlators/protocol/client/src/client3_1-fops.c | 8 ++--- xlators/protocol/server/src/server-helpers.c | 47 ++++++++++++++------------ xlators/protocol/server/src/server-helpers.h | 4 +-- xlators/protocol/server/src/server.h | 2 +- xlators/protocol/server/src/server3_1-fops.c | 20 ++++++----- 8 files changed, 65 insertions(+), 63 deletions(-) (limited to 'xlators/protocol') 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) " -- cgit