From 1ad41c4ca167e4600f163408c1f859d55cdbdc07 Mon Sep 17 00:00:00 2001 From: Poornima Date: Wed, 12 Feb 2014 03:18:43 +0000 Subject: protocol/client: Fix the possible resource leaks. Change-Id: Ib86dee366f5a6f0971c6472d1fb2c32dbf7f0102 BUG: 789278 Signed-off-by: Poornima Reviewed-on: http://review.gluster.org/6985 Reviewed-by: Vijay Bellur Reviewed-by: Raghavendra Talur Tested-by: Gluster Build System --- xlators/protocol/client/src/client-rpc-fops.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 01590d73a..99a6f6d74 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -3068,13 +3068,13 @@ client3_3_lookup (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; if (!(args->loc && args->loc->inode)) goto unwind; loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (args->loc->parent) { if (!uuid_is_null (args->loc->parent->gfid)) @@ -3792,13 +3792,13 @@ client3_3_mknod (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; if (!(args->loc && args->loc->parent)) goto unwind; loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) memcpy (req.pargfid, args->loc->parent->gfid, 16); @@ -3860,13 +3860,13 @@ client3_3_mkdir (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; if (!(args->loc && args->loc->parent)) goto unwind; loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) memcpy (req.pargfid, args->loc->parent->gfid, 16); @@ -3927,6 +3927,8 @@ client3_3_create (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; + if (!(args->loc && args->loc->parent)) goto unwind; @@ -3935,7 +3937,6 @@ client3_3_create (call_frame_t *frame, xlator_t *this, loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (!uuid_is_null (args->loc->parent->gfid)) memcpy (req.pargfid, args->loc->parent->gfid, 16); @@ -3998,6 +3999,8 @@ client3_3_open (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; + if (!(args->loc && args->loc->inode)) goto unwind; @@ -4005,7 +4008,6 @@ client3_3_open (call_frame_t *frame, xlator_t *this, local->flags = args->flags; loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) memcpy (req.gfid, args->loc->inode->gfid, 16); @@ -4388,13 +4390,14 @@ client3_3_opendir (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; + if (!(args->loc && args->loc->inode)) goto unwind; local->fd = fd_ref (args->fd); loc_copy (&local->loc, args->loc); loc_path (&local->loc, NULL); - frame->local = local; if (!uuid_is_null (args->loc->inode->gfid)) memcpy (req.gfid, args->loc->inode->gfid, 16); @@ -5251,6 +5254,7 @@ client3_3_lk (call_frame_t *frame, xlator_t *this, op_errno = ENOMEM; goto unwind; } + frame->local = local; CLIENT_GET_REMOTE_FD (this, args->fd, DEFAULT_REMOTE_FD, remote_fd, op_errno, unwind); @@ -5278,7 +5282,6 @@ client3_3_lk (call_frame_t *frame, xlator_t *this, local->owner = frame->root->lk_owner; local->cmd = args->cmd; local->fd = fd_ref (args->fd); - frame->local = local; req.fd = remote_fd; req.cmd = gf_cmd; -- cgit From 4a14159e82d7b736dec686a170b06e961d7aff53 Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Wed, 8 Jan 2014 17:01:44 +0530 Subject: protocol/client: conn-id should be unique when lk-heal is off Problem: It was observed that in some cases client disconnects and re-connects before server xlator could detect that a disconnect happened. So it still uses previous fdtable and ltable. But it can so happen that in between disconnect and re-connect an 'unlock' fop may fail because the fds are marked 'bad' in client xlator upon disconnect. Due to this stale locks remain on the brick which lead to hangs/self-heals not happening etc. For the exact bug RCA please look at https://bugzilla.redhat.com/show_bug.cgi?id=1049932#c0 Fix: When lk-heal is not enabled make sure connection-id is different for every setvolume. This will make sure that a previous connection's resources are not re-used in server xlator. Change-Id: Id844aaa76dfcf2740db72533bca53c23b2fe5549 BUG: 1049932 Signed-off-by: Pranith Kumar K Reviewed-on: http://review.gluster.org/6669 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Vijay Bellur --- xlators/protocol/client/src/client-handshake.c | 34 ++++++++++++++++++++------ xlators/protocol/client/src/client.h | 5 ++++ 2 files changed, 31 insertions(+), 8 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/client/src/client-handshake.c b/xlators/protocol/client/src/client-handshake.c index b2aa66422..7c8be42ed 100644 --- a/xlators/protocol/client/src/client-handshake.c +++ b/xlators/protocol/client/src/client-handshake.c @@ -465,17 +465,23 @@ client_set_lk_version (xlator_t *this) clnt_conf_t *conf = NULL; call_frame_t *frame = NULL; gf_set_lk_ver_req req = {0, }; + char *process_uuid = NULL; GF_VALIDATE_OR_GOTO ("client", this, err); conf = (clnt_conf_t *) this->private; req.lk_ver = client_get_lk_ver (conf); - ret = gf_asprintf (&req.uid, "%s-%s-%d", - this->ctx->process_uuid, this->name, - this->graph->id); - if (ret == -1) + ret = dict_get_str (this->options, "process-uuid", &process_uuid); + if (!process_uuid) { + ret = -1; goto err; + } + req.uid = gf_strdup (process_uuid); + if (!req.uid) { + ret = -1; + goto err; + } frame = create_frame (this, this->ctx->pool); if (!frame) { @@ -1524,6 +1530,7 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) char *process_uuid_xl = NULL; clnt_conf_t *conf = NULL; dict_t *options = NULL; + char counter_str[32] = {0}; options = this->options; conf = this->private; @@ -1549,13 +1556,24 @@ client_setvolume (xlator_t *this, struct rpc_clnt *rpc) } } - /* With multiple graphs possible in the same process, we need a + /* When lock-heal is enabled: + * With multiple graphs possible in the same process, we need a field to bring the uniqueness. Graph-ID should be enough to get the - job done + job done. + * When lock-heal is disabled, connection-id should always be unique so + * that server never gets to reuse the previous connection resources + * so it cleans up the resources on every disconnect. Otherwise + * it may lead to stale resources, i.e. leaked file desciptors, + * inode/entry locks */ - ret = gf_asprintf (&process_uuid_xl, "%s-%s-%d", + if (!conf->lk_heal) { + snprintf (counter_str, sizeof (counter_str), + "-%"PRIu64, conf->setvol_count); + conf->setvol_count++; + } + ret = gf_asprintf (&process_uuid_xl, "%s-%s-%d%s", this->ctx->process_uuid, this->name, - this->graph->id); + this->graph->id, counter_str); if (-1 == ret) { gf_log (this->name, GF_LOG_ERROR, "asprintf failed while setting process_uuid"); diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index afab2d74f..bc0f5d0e9 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -120,6 +120,11 @@ typedef struct clnt_conf { */ gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from the flags list of open() */ + /* set volume is the op which results in creating/re-using + * the conn-id and is called once per connection, this remembers + * how manytimes set_volume is called + */ + uint64_t setvol_count; } clnt_conf_t; typedef struct _client_fd_ctx { -- cgit From 9e0ec224148e1d3e0406eb5aa4479f3dca0d597b Mon Sep 17 00:00:00 2001 From: Raghavendra Talur Date: Thu, 13 Feb 2014 12:31:58 +0530 Subject: protocol/auth: Fix a possible double free. Assign NULL to addr_cpy to avoid double free. Fix for coverity CID: 1124891 Change-Id: I0cd6721f066170190d8b5441ecdbc1704ed5e75b BUG: 789278 Signed-off-by: Raghavendra Talur Reviewed-on: http://review.gluster.org/6993 Tested-by: Gluster Build System Reviewed-by: Krishnan Parthasarathi Reviewed-by: Anand Avati --- xlators/protocol/auth/addr/src/addr.c | 1 + 1 file changed, 1 insertion(+) (limited to 'xlators/protocol') diff --git a/xlators/protocol/auth/addr/src/addr.c b/xlators/protocol/auth/addr/src/addr.c index 64e8d0fc6..181d091bd 100644 --- a/xlators/protocol/auth/addr/src/addr.c +++ b/xlators/protocol/auth/addr/src/addr.c @@ -181,6 +181,7 @@ gf_auth (dict_t *input_params, dict_t *config_params) addr_str = strtok_r (NULL, ADDR_DELIMITER, &tmp); } GF_FREE (addr_cpy); + addr_cpy = NULL; } if (allow_addr) { -- cgit From 7b3399cd462d0fca6509168f13a67f43e8b2c7d2 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 28 Feb 2014 17:34:03 +0100 Subject: Reduce logging caused by non-existing extended attributes This changes the following log messages from INFO (default value) to DEBUG. We do not really care if someone tries to read extended attributes that do not exist. [2013-12-09 12:19:05.924497] E [posix.c:3539:posix_fgetxattr] 0-dis-rep-posix: fgetxattr failed on key system.posix_acl_access (No data available) [2013-12-09 12:19:05.924545] I [server-rpc-fops.c:863:server_fgetxattr_cbk] 0-dis-rep-server: 13074: FGETXATTR 1 (b8381953-ffa5-40fa-90dd-ae122335cc4b) (system.posix_acl_access) ==> (No data available) Change-Id: Idbbeb026f81e67025a2b36d7bfeb125ad2a1f61b BUG: 1027174 Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/7171 Tested-by: Gluster Build System Reviewed-by: Harshavardhana Reviewed-by: Anand Avati --- xlators/protocol/server/src/server-rpc-fops.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/server/src/server-rpc-fops.c b/xlators/protocol/server/src/server-rpc-fops.c index c56da30a7..8bdadec6b 100644 --- a/xlators/protocol/server/src/server-rpc-fops.c +++ b/xlators/protocol/server/src/server-rpc-fops.c @@ -810,7 +810,9 @@ server_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, if (op_ret == -1) { state = CALL_STATE (frame); - gf_log (this->name, ((op_errno == ENOTSUP) ? + gf_log (this->name, (((op_errno == ENOTSUP) || + (op_errno == ENODATA) || + (op_errno == ENOENT)) ? GF_LOG_DEBUG : GF_LOG_INFO), "%"PRId64": FGETXATTR %"PRId64" (%s) (%s) ==> (%s)", frame->root->unique, state->resolve.fd_no, -- cgit