summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server
diff options
context:
space:
mode:
authorPranith Kumar K <pranithk@gluster.com>2012-03-18 13:07:30 +0530
committerAnand Avati <avati@redhat.com>2012-03-18 01:09:43 -0700
commit9fd44bd90ecb60760919bda85308132341f857f9 (patch)
tree0ed134e638c906ca8ae66153a1f5f00ddde28c12 /xlators/protocol/server
parentf20d895a8ed2a3ee032bd0f85d5bfaf645575fd7 (diff)
protocol/server: Clear internal locks on disconnect
If there is a disconnect observed on the client when the inode/entry unlock is issued, but the reconnection to server happens with in the grace-time period the inode/entry lk will live and the unlock will never come from that client. The internal locks should be cleared on disconnect. Change-Id: Ib45b1035cfe3b1de381ef3b331c930011e7403be BUG: 803209 Signed-off-by: Pranith Kumar K <pranithk@gluster.com> Reviewed-on: http://review.gluster.com/2966 Reviewed-by: Anand Avati <avati@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/protocol/server')
-rw-r--r--xlators/protocol/server/src/server-handshake.c3
-rw-r--r--xlators/protocol/server/src/server-helpers.c20
-rw-r--r--xlators/protocol/server/src/server.c7
-rw-r--r--xlators/protocol/server/src/server.h8
4 files changed, 26 insertions, 12 deletions
diff --git a/xlators/protocol/server/src/server-handshake.c b/xlators/protocol/server/src/server-handshake.c
index 1698a3f5cda..d951aad9cad 100644
--- a/xlators/protocol/server/src/server-handshake.c
+++ b/xlators/protocol/server/src/server-handshake.c
@@ -436,7 +436,8 @@ server_setvolume (rpcsvc_request_t *req)
server_connection_put (this, conn, NULL);
if (conn->lk_version != 0 &&
conn->lk_version != lk_version) {
- (void) server_connection_cleanup (this, conn);
+ (void) server_connection_cleanup (this, conn,
+ INTERNAL_LOCKS | POSIX_LOCKS);
}
if (req->trans->xl_private != conn)
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 40b1efc9b95..adcf9c1f1ed 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -506,15 +506,17 @@ do_connection_cleanup (xlator_t *this, server_connection_t *conn,
GF_VALIDATE_OR_GOTO ("server", this, out);
GF_VALIDATE_OR_GOTO ("server", conn, out);
- GF_VALIDATE_OR_GOTO ("server", fdentries, out);
- GF_VALIDATE_OR_GOTO ("server", ltable, out);
+
+ if (!ltable && !fdentries)
+ goto out;
frame = create_frame (this, this->ctx->pool);
if (frame == NULL) {
goto out;
}
- saved_ret = do_lock_table_cleanup (this, conn, frame, ltable);
+ if (ltable)
+ saved_ret = do_lock_table_cleanup (this, conn, frame, ltable);
if (fdentries != NULL) {
ret = do_fd_cleanup (this, conn, frame, fdentries, fd_count);
@@ -536,24 +538,26 @@ out:
int
-server_connection_cleanup (xlator_t *this, server_connection_t *conn)
+server_connection_cleanup (xlator_t *this, server_connection_t *conn,
+ int32_t flags)
{
struct _lock_table *ltable = NULL;
fdentry_t *fdentries = NULL;
uint32_t fd_count = 0;
int ret = 0;
- GF_VALIDATE_OR_GOTO ("server", this, out);
- GF_VALIDATE_OR_GOTO ("server", conn, out);
+ GF_VALIDATE_OR_GOTO (this->name, this, out);
+ GF_VALIDATE_OR_GOTO (this->name, conn, out);
+ GF_VALIDATE_OR_GOTO (this->name, flags, out);
pthread_mutex_lock (&conn->lock);
{
- if (conn->ltable) {
+ if (conn->ltable && (flags & INTERNAL_LOCKS)) {
ltable = conn->ltable;
conn->ltable = gf_lock_table_new ();
}
- if (conn->fdtable)
+ if (conn->fdtable && (flags & POSIX_LOCKS))
fdentries = gf_fd_fdtable_get_all_fds (conn->fdtable,
&fd_count);
}
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 33889fd9b15..3c3147a19d4 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -58,7 +58,8 @@ grace_time_handler (void *data)
server_conn_ref (conn);
server_connection_put (this, conn, &detached);
if (detached)//reconnection did not happen :-(
- server_connection_cleanup (this, conn);
+ server_connection_cleanup (this, conn,
+ INTERNAL_LOCKS | POSIX_LOCKS);
server_conn_unref (conn);
}
out:
@@ -170,7 +171,8 @@ server_submit_reply (call_frame_t *frame, rpcsvc_request_t *req, void *arg,
if (ret == -1) {
gf_log_callingfn ("", GF_LOG_ERROR, "Reply submission failed");
if (frame && conn)
- server_connection_cleanup (frame->this, conn);
+ server_connection_cleanup (frame->this, conn,
+ INTERNAL_LOCKS | POSIX_LOCKS);
goto ret;
}
@@ -644,6 +646,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
put_server_conn_state (this, xprt);
gf_log (this->name, GF_LOG_INFO, "disconnecting connection"
"from %s", xprt->peerinfo.identifier);
+ server_connection_cleanup (this, conn, INTERNAL_LOCKS);
pthread_mutex_lock (&conf->mutex);
{
list_del (&xprt->list);
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index 831c309a245..4213faa174d 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -35,6 +35,11 @@
#define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB)
#define GF_MIN_SOCKET_WINDOW_SIZE (0)
+typedef enum {
+ INTERNAL_LOCKS = 1,
+ POSIX_LOCKS = 2,
+} server_lock_flags_t;
+
typedef struct _server_state server_state_t;
struct _locker {
@@ -86,7 +91,8 @@ server_connection_t*
server_conn_ref (server_connection_t *conn);
int
-server_connection_cleanup (xlator_t *this, server_connection_t *conn);
+server_connection_cleanup (xlator_t *this, server_connection_t *conn,
+ int32_t flags);
int server_null (rpcsvc_request_t *req);