diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index ef865a72c8f..eb835e3c405 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -5962,7 +5962,7 @@ glfs_recall_lease_upcall(struct glfs *fs, struct glfs_upcall *up_arg, glfs_h_close(object); /* Set reason to prevent applications from using ->event */ - up_arg->reason = GF_UPCALL_EVENT_NULL; + up_arg->reason = GLFS_UPCALL_EVENT_NULL; } return ret; } @@ -6618,7 +6618,7 @@ void gf_lease_to_glfs_lease(struct gf_lease *gf_lease, struct glfs_lease *lease) { u_int lease_type = gf_lease->lease_type; - lease->cmd = gf_lease->cmd; + lease->cmd = (glfs_lease_cmds_t)gf_lease->cmd; lease->lease_type = lease_type; memcpy(lease->lease_id, gf_lease->lease_id, LEASE_ID_SIZE); } @@ -6627,7 +6627,7 @@ void glfs_lease_to_gf_lease(struct glfs_lease *lease, struct gf_lease *gf_lease) { u_int lease_type = lease->lease_type; - gf_lease->cmd = lease->cmd; + gf_lease->cmd = (gf_lease_cmds_t)lease->cmd; gf_lease->lease_type = lease_type; memcpy(gf_lease->lease_id, lease->lease_id, LEASE_ID_SIZE); } diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index e3976970d9d..c64811c2722 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -163,7 +163,6 @@ cli_cmd_process_line(struct cli_state *state, const char *text) char *token = NULL; char *copy = NULL; char *saveptr = NULL; - int i = 0; int ret = -1; count = cli_cmd_input_token_count(text); @@ -185,7 +184,6 @@ cli_cmd_process_line(struct cli_state *state, const char *text) if (!*tokenp) goto out; tokenp++; - i++; } ret = cli_cmd_process(state, count, tokens); diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index fdd37c5fb62..0c5ff322d04 100644 --- a/glusterfsd/src/glusterfsd-mgmt.c +++ b/glusterfsd/src/glusterfsd-mgmt.c @@ -1584,7 +1584,7 @@ glusterfs_handle_node_status(rpcsvc_request_t *req) default: ret = -1; msg = gf_strdup("Unknown status op"); - gf_log(THIS->name, GF_LOG_ERROR, "%s", msg); + gf_log(THIS->name, GF_LOG_ERROR, "Unknown status op"); break; } rsp.op_ret = ret; diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index dcdf60d843e..abc3bfe0b02 100644 --- a/libglusterfs/src/client_t.c +++ b/libglusterfs/src/client_t.c @@ -598,10 +598,8 @@ gf_client_dump_fdtables(xlator_t *this) clienttable->cliententries[count].next_free) continue; client = clienttable->cliententries[count].client; - if (client->client_uid) { - gf_proc_dump_build_key(key, "conn", "%d.id", count); - gf_proc_dump_write(key, "%s", client->client_uid); - } + gf_proc_dump_build_key(key, "conn", "%d.id", count); + gf_proc_dump_write(key, "%s", client->client_uid); if (client->subdir_mount) { gf_proc_dump_build_key(key, "conn", "%d.subdir", count); diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 01c8a4ed14e..c5a9706ae9d 100644 --- a/libglusterfs/src/common-utils.c +++ b/libglusterfs/src/common-utils.c @@ -1587,7 +1587,7 @@ gf_string2percent_or_bytesize(const char *str, double *n, } /* Error out if we cannot store the value in uint64 */ - if ((UINT64_MAX - value) < 0) { + if ((UINT64_MAX - (unsigned long)value) < 0) { errno = ERANGE; return -1; } diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 243889280ee..767c9d32cc5 100644 --- a/libglusterfs/src/dict.c +++ b/libglusterfs/src/dict.c @@ -406,6 +406,12 @@ dict_setn(dict_t *this, char *key, const int keylen, data_t *value) return -1; } + if (caa_unlikely(!key)) { + gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, + "key is NULL"); + return -1; + } + LOCK(&this->lock); ret = dict_set_lk(this, key, keylen, value, 1); @@ -426,6 +432,12 @@ dict_addn(dict_t *this, char *key, const int keylen, data_t *value) return -1; } + if (caa_unlikely(!key)) { + gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, + "key is NULL"); + return -1; + } + LOCK(&this->lock); ret = dict_set_lk(this, key, keylen, value, 0); @@ -2695,6 +2707,12 @@ dict_rename_key(dict_t *this, char *key, char *replace_key) int ret = -EINVAL; int replacekey_len = 0; + if (caa_unlikely(!replace_key)) { + gf_msg_callingfn("dict", GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ARG, + "key is NULL"); + return -1; + } + /* replacing a key by itself is a NO-OP */ if (strcmp(key, replace_key) == 0) return 0; diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 71a3a097d2b..528a68941d6 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -894,6 +894,9 @@ __is_root_gfid(uuid_t gfid) static uuid_t root = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; const uint64_t *p = (uint64_t *)gfid; + if (caa_unlikely(!p)) + return _gf_false; + if (*p) /*if it doesn't start with zero's, it's not root gfid */ return _gf_false; @@ -1674,7 +1677,6 @@ inode_table_with_invalidator(uint32_t lru_limit, xlator_t *xl, uint32_t inode_hashsize) { inode_table_t *new = NULL; - uint32_t mem_pool_size = lru_limit; size_t diff; int ret = -1; int i = 0; @@ -1729,10 +1731,6 @@ inode_table_with_invalidator(uint32_t lru_limit, xlator_t *xl, new->inode_hashsize, inode_hashsize); } - /* In case FUSE is initing the inode table. */ - if (!mem_pool_size || (mem_pool_size > DEFAULT_INODE_MEMPOOL_ENTRIES)) - mem_pool_size = DEFAULT_INODE_MEMPOOL_ENTRIES; - new->inode_hash = (void *)GF_MALLOC( new->inode_hashsize * sizeof(struct list_head), gf_common_mt_list_head); if (!new->inode_hash) diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 41394922f81..b6d69db4391 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -2454,6 +2454,7 @@ afr_frame_create(xlator_t *this, int32_t *op_errno) call_frame_t *frame = NULL; afr_local_t *local = NULL; pid_t pid = GF_CLIENT_PID_SELF_HEALD; + int ret = 0; frame = create_frame(this, this->ctx->pool); if (!frame) { @@ -2462,9 +2463,11 @@ afr_frame_create(xlator_t *this, int32_t *op_errno) return NULL; } - local = AFR_FRAME_INIT(frame, (*op_errno)); + local = AFR_FRAME_INIT(frame, ret); if (!local) { STACK_DESTROY(frame->root); + if (op_errno) + *op_errno = ret; return NULL; } diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 35e396ebabc..cebac9986cf 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -2256,7 +2256,7 @@ dht_migrate_file(xlator_t *this, loc_t *loc, xlator_t *cached_subvol, if (entrylk_locked) { lk_ret = syncop_entrylk(hashed_subvol, DHT_ENTRY_SYNC_DOMAIN, &parent_loc, loc->name, ENTRYLK_UNLOCK, - ENTRYLK_UNLOCK, NULL, NULL); + ENTRYLK_WRLCK, NULL, NULL); if (lk_ret < 0) { gf_msg(this->name, GF_LOG_WARNING, -lk_ret, DHT_MSG_MIGRATE_FILE_FAILED, diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 684d115ccab..bf77d88d912 100644 --- a/xlators/features/shard/src/shard.c +++ b/xlators/features/shard/src/shard.c @@ -1289,7 +1289,8 @@ shard_refresh_internal_dir_cbk(call_frame_t *frame, void *cookie, { shard_local_t *local = NULL; inode_t *linked_inode = NULL; - shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; + shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long) + cookie; local = frame->local; @@ -1370,7 +1371,8 @@ shard_lookup_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, { inode_t *link_inode = NULL; shard_local_t *local = NULL; - shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; + shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long) + cookie; local = frame->local; @@ -5889,7 +5891,8 @@ shard_mkdir_internal_dir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, { inode_t *link_inode = NULL; shard_local_t *local = NULL; - shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; + shard_internal_dir_type_t type = (shard_internal_dir_type_t)(unsigned long) + cookie; local = frame->local; diff --git a/xlators/features/simple-quota/src/simple-quota.c b/xlators/features/simple-quota/src/simple-quota.c index 139f7c28234..5a928fc7188 100644 --- a/xlators/features/simple-quota/src/simple-quota.c +++ b/xlators/features/simple-quota/src/simple-quota.c @@ -129,7 +129,7 @@ sq_set_ns_hardlimit(xlator_t *this, inode_t *inode, int64_t limit, int64_t size, ret = inode_ctx_put(inode, this, (uint64_t)(uintptr_t)sq_ctx); if (IS_ERROR(ret)) { GF_FREE(sq_ctx); - sq_ctx = NULL; + sq_ctx = NULL; goto out; } @@ -217,7 +217,9 @@ sq_update_brick_usage(xlator_t *this, inode_t *inode) if (!tmp_mq) { goto out; } - loc_t loc = { 0, }; + loc_t loc = { + 0, + }; loc.inode = inode_ref(inode); int ret = syncop_getxattr(FIRST_CHILD(this), &loc, &dict, SQUOTA_SIZE_KEY, NULL, NULL); @@ -262,7 +264,7 @@ sq_update_hard_limit(xlator_t *this, inode_t *ns, int64_t limit, int64_t size) limit, size); sq_ctx->hard_lim = limit; - //GF_ASSERT(size > 0); + // GF_ASSERT(size > 0); out: return; @@ -529,7 +531,7 @@ sq_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, uint32_t nlink = 0; uint64_t blocks = 0; int ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, &nlink); - if ((nlink == 1)) { + if (nlink == 1) { ret = dict_get_uint64(xdata, GF_GET_FILE_BLOCK_COUNT, &blocks); gf_msg(this->name, GF_LOG_DEBUG, 0, 0, "reduce size by %" PRIu64 " blocks (ret: %d)", blocks, ret); @@ -1014,7 +1016,7 @@ sq_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, uint32_t nlink = 0; uint64_t blocks = 0; int ret = dict_get_uint32(xdata, GF_RESPONSE_LINK_COUNT_XDATA, &nlink); - if ((nlink == 1)) { + if (nlink == 1) { ret = dict_get_uint64(xdata, GF_GET_FILE_BLOCK_COUNT, &blocks); gf_msg(this->name, GF_LOG_DEBUG, 0, 0, "reduce size by %" PRIu64 " blocks (ret: %d)", blocks, ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index 52e1d59846a..ef88f61d34a 100644 --- a/xlators/mgmt/glusterd/src/glusterd-locks.c +++ b/xlators/mgmt/glusterd/src/glusterd-locks.c @@ -601,7 +601,6 @@ glusterd_mgmt_v3_lock(const char *name, uuid_t uuid, uint32_t *op_errno, "Failed to save " "the back trace for lock %s granted to %s", key_dup, uuid_utoa(uuid)); - ret = 0; } #endif @@ -627,7 +626,9 @@ gd_mgmt_v3_unlock_timer_cbk(void *data) char *key = NULL; int keylen; int32_t ret = -1; - +#ifdef DEBUG + int bt_key_len = 0; +#endif conf = this->private; GF_VALIDATE_OR_GOTO(this->name, conf, out); @@ -639,7 +640,6 @@ gd_mgmt_v3_unlock_timer_cbk(void *data) #ifdef DEBUG char bt_key[PATH_MAX] = ""; - int bt_key_len = 0; bt_key_len = snprintf(bt_key, PATH_MAX, "debug.last-success-bt-%s", key); if (bt_key_len != SLEN("debug.last-success-bt-") + keylen) { diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index 8b573222de6..498871dbaab 100644 --- a/xlators/mgmt/glusterd/src/glusterd-messages.h +++ b/xlators/mgmt/glusterd/src/glusterd-messages.h @@ -322,7 +322,8 @@ GLFS_MSGID( GD_MSG_ADD_BRICK_MNT_INFO_FAIL, GD_MSG_GET_MNT_ENTRY_INFO_FAIL, GD_MSG_QUORUM_CLUSTER_COUNT_GET_FAIL, GD_MSG_POST_COMMIT_OP_FAIL, GD_MSG_POST_COMMIT_FROM_UUID_REJCT, GD_MSG_POST_COMMIT_REQ_SEND_FAIL, - GD_MSG_GRACEFUL_CLEANUP_SET_FAIL, GD_PMAP_PORT_BIND_FAILED); + GD_MSG_GRACEFUL_CLEANUP_SET_FAIL, GD_PMAP_PORT_BIND_FAILED, + GD_MSG_PLUGIN_NOT_FOUND); #define GD_MSG_INVALID_ENTRY_STR "Invalid data entry" #define GD_MSG_INVALID_ARGUMENT_STR \ @@ -411,6 +412,7 @@ GLFS_MSGID( #define GD_MSG_VOLINFO_IMPORT_FAIL_STR "Volume is not yet imported" #define GD_MSG_BRICK_SET_INFO_FAIL_STR \ "Failed to add brick mount details to dict" +#define GD_MSG_PLUGIN_NOT_FOUND_STR "Plugin not found" #define GD_MSG_SET_XATTR_BRICK_FAIL_STR \ "Glusterfs is not supported on brick. Setting extended attribute failed" #define GD_MSG_SET_XATTR_FAIL_STR "Failed to set extended attribute" diff --git a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c index 028ecbd4d0f..dfe50520865 100644 --- a/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c @@ -300,6 +300,12 @@ glusterd_snap_volinfo_restore(dict_t *dict, dict_t *rsp_dict, /* To use generic functions from the plugin */ glusterd_snapshot_plugin_by_name(snap_volinfo->snap_plugin, &snap_ops); + if (caa_unlikely(!snap_ops)) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PLUGIN_NOT_FOUND, + "Failed to find plugin for %s", + snap_volinfo->snap_plugin); + goto out; + } snap_ops->brick_path(snap_mount_dir, brickinfo->origin_path, 0, snap_volinfo->snapshot->snapname, @@ -3314,6 +3320,11 @@ glusterd_snap_unmount(xlator_t *this, glusterd_volinfo_t *volinfo) GF_ASSERT(volinfo); glusterd_snapshot_plugin_by_name(volinfo->snap_plugin, &snap_ops); + if (caa_unlikely(!snap_ops)) { + gf_msg(this->name, GF_LOG_ERROR, 0, GD_MSG_PLUGIN_NOT_FOUND, + "Failed to find plugin for %s", volinfo->snap_plugin); + goto out; + } cds_list_for_each_entry(brickinfo, &volinfo->bricks, brick_list) { diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index e6371f9be33..6aa3ba90a56 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -534,7 +534,7 @@ wb_enqueue_common(wb_inode_t *wb_inode, call_stub_t *stub, int tempted) req->op_errno = 0; if (stub->args.fd && (stub->args.fd->flags & O_APPEND)) - req->ordering.append = 1; + req->ordering.append = true; } lk_owner_copy(&req->lk_owner, &stub->frame->root->lk_owner); @@ -716,7 +716,7 @@ __wb_fulfill_request(wb_request_t *req) wb_inode = req->wb_inode; - req->ordering.fulfilled = 1; + req->ordering.fulfilled = true; wb_inode->window_current -= req->total_size; wb_inode->transit -= req->total_size; @@ -790,7 +790,7 @@ __wb_add_request_for_retry(wb_request_t *req) list_del_init(&req->wip); /* sanitize ordering flags to retry */ - req->ordering.go = 0; + req->ordering.go = false; /* Add back to todo list to retry */ list_add(&req->todo, &wb_inode->todo); @@ -1267,7 +1267,7 @@ __wb_pick_unwinds(wb_inode_t *wb_inode, list_head_t *lies) /* burden increased */ list_add_tail(&req->lie, &wb_inode->liability); - req->ordering.lied = 1; + req->ordering.lied = true; uuid_utoa_r(req->gfid, gfid); gf_msg_debug(wb_inode->this->name, 0, @@ -1404,7 +1404,7 @@ __wb_preprocess_winds(wb_inode_t *wb_inode) if (wb_requests_conflict(holder, req)) /* do not hold on write if a dependent write is in queue */ - holder->ordering.go = 1; + holder->ordering.go = true; } /* collapse only non-sync writes */ continue; @@ -1417,19 +1417,19 @@ __wb_preprocess_winds(wb_inode_t *wb_inode) offset_expected = holder->stub->args.offset + holder->write_size; if (req->stub->args.offset != offset_expected) { - holder->ordering.go = 1; + holder->ordering.go = true; holder = req; continue; } if (!is_same_lkowner(&req->lk_owner, &holder->lk_owner)) { - holder->ordering.go = 1; + holder->ordering.go = true; holder = req; continue; } if (req->fd != holder->fd) { - holder->ordering.go = 1; + holder->ordering.go = true; holder = req; continue; } @@ -1437,7 +1437,7 @@ __wb_preprocess_winds(wb_inode_t *wb_inode) space_left = page_size - holder->write_size; if (space_left < req->write_size) { - holder->ordering.go = 1; + holder->ordering.go = true; holder = req; continue; } @@ -1467,7 +1467,7 @@ __wb_preprocess_winds(wb_inode_t *wb_inode) */ if (conf->trickling_writes && !wb_inode->transit && holder) - holder->ordering.go = 1; + holder->ordering.go = true; if (wb_inode->dontsync > 0) wb_inode->dontsync--; diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index 87b0721528c..2e8d24b1415 100644 --- a/xlators/protocol/client/src/client-helpers.c +++ b/xlators/protocol/client/src/client-helpers.c @@ -15,32 +15,6 @@ #include #include -int -client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t try_lock) -{ - int ret = 1; - - if (!lk_ctx) { - ret = -1; - goto out; - } - - if (try_lock) { - ret = TRY_LOCK(&lk_ctx->lock); - if (ret != 0) { - ret = -1; - goto out; - } - } else { - LOCK(&lk_ctx->lock); - } - - ret = list_empty(&lk_ctx->lk_list); - UNLOCK(&lk_ctx->lock); -out: - return ret; -} - clnt_fd_ctx_t * this_fd_del_ctx(fd_t *file, xlator_t *this) { diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index e0508776546..46abdb5ce82 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -34,14 +34,11 @@ client_filter_o_direct(clnt_conf_t *conf, int32_t *flags) *flags = (*flags & ~O_DIRECT); } -static int -client_fini_complete(xlator_t *this) +static void +client_fini_complete(clnt_conf_t *conf) { - GF_VALIDATE_OR_GOTO(this->name, this->private, out); - - clnt_conf_t *conf = this->private; if (!conf->destroy) - return 0; + return; pthread_mutex_lock(&conf->lock); { @@ -49,9 +46,6 @@ client_fini_complete(xlator_t *this) pthread_cond_broadcast(&conf->fini_complete_cond); } pthread_mutex_unlock(&conf->lock); - -out: - return 0; } static int @@ -2315,7 +2309,7 @@ client_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, } break; case RPC_CLNT_DESTROY: - ret = client_fini_complete(this); + client_fini_complete(conf); break; default: @@ -2729,9 +2723,8 @@ fini(xlator_t *this) } static void -client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) +client_fd_lk_ctx_dump(fd_lk_ctx_t *lk_ctx) { - gf_boolean_t use_try_lock = _gf_true; int ret = -1; int lock_no = 0; fd_lk_ctx_t *lk_ctx_ref = NULL; @@ -2744,18 +2737,15 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) if (!lk_ctx_ref) return; - ret = client_fd_lk_list_empty(lk_ctx_ref, (use_try_lock = _gf_true)); - if (ret != 0) - return; - gf_proc_dump_write("------", "------"); - lock_no = 0; - ret = TRY_LOCK(&lk_ctx_ref->lock); if (ret) return; + if (list_empty(&lk_ctx_ref->lk_list)) + goto unlock; + list_for_each_entry(plock, &lk_ctx_ref->lk_list, next) { snprintf(key, sizeof(key), "granted-posix-lock[%d]", lock_no++); @@ -2770,6 +2760,7 @@ client_fd_lk_ctx_dump(xlator_t *this, fd_lk_ctx_t *lk_ctx, int nth_fd) get_lk_type(plock->user_flock.l_type), plock->user_flock.l_start, plock->user_flock.l_len); } +unlock: UNLOCK(&lk_ctx_ref->lock); gf_proc_dump_write("------", "------"); @@ -2809,7 +2800,7 @@ client_priv_dump(xlator_t *this) { sprintf(key, "fd.%d.remote_fd", i); gf_proc_dump_write(key, "%" PRId64, tmp->remote_fd); - client_fd_lk_ctx_dump(this, tmp->lk_ctx, i); + client_fd_lk_ctx_dump(tmp->lk_ctx); i++; } pthread_spin_unlock(&conf->fd_lock); diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index 880d3f8b173..96bf86fc833 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -95,8 +95,8 @@ typedef struct clnt_conf { rpc_clnt_prog_t *dump; int client_id; - int event_threads; /* # of event threads - * configured */ + int event_threads; /* # of event threads + * configured */ uint64_t reopen_fd_count; /* Count of fds reopened after a connection is established */ gf_lock_t rec_lock; @@ -123,7 +123,7 @@ typedef struct clnt_conf { */ gf_boolean_t filter_o_direct; /* if set, filter O_DIRECT from the flags list of open() */ - gf_boolean_t send_gids; /* let the server resolve gids */ + gf_boolean_t send_gids; /* let the server resolve gids */ gf_boolean_t destroy; /* if enabled implies fini was called * on @this xlator instance */ @@ -136,7 +136,7 @@ typedef struct clnt_conf { * logged */ - gf_boolean_t old_protocol; /* used only for old-protocol testing */ + gf_boolean_t old_protocol; /* used only for old-protocol testing */ gf_boolean_t fini_completed; gf_boolean_t strict_locks; /* When set, doesn't reopen saved fds after reconnect if POSIX locks are held on them. @@ -145,8 +145,8 @@ typedef struct clnt_conf { complaince as bricks cleanup any granted locks when a client disconnects. */ - gf_boolean_t connection_to_brick; /*True from attempt to connect to brick - till disconnection to brick*/ + gf_boolean_t connection_to_brick; /*True from attempt to connect to brick + till disconnection to brick*/ pthread_cond_t fini_complete_cond; /* Used to wait till we finsh the fini compltely, ie client_fini_complete to return*/ @@ -271,8 +271,6 @@ client_submit_request(xlator_t *this, void *req, call_frame_t *frame, int client_fdctx_destroy(xlator_t *this, clnt_fd_ctx_t *fdctx); -int -client_fd_lk_list_empty(fd_lk_ctx_t *lk_ctx, gf_boolean_t use_try_lock); void client_default_reopen_done(clnt_fd_ctx_t *fdctx, int64_t rfd, xlator_t *this); void diff --git a/xlators/protocol/server/src/server-rpc-fops_v2.c b/xlators/protocol/server/src/server-rpc-fops_v2.c index 84c54f7f043..c8f9f5ad3b2 100644 --- a/xlators/protocol/server/src/server-rpc-fops_v2.c +++ b/xlators/protocol/server/src/server-rpc-fops_v2.c @@ -6174,28 +6174,28 @@ static rpcsvc_actor_t glusterfs4_0_fop_actors[] = { GFS3_OP_RELEASEDIR, 0}, [GFS3_OP_FREMOVEXATTR] = {"FREMOVEXATTR", server4_0_fremovexattr, NULL, GFS3_OP_FREMOVEXATTR, 0}, - [GFS3_OP_FALLOCATE] = {"FALLOCATE", server4_0_fallocate, NULL, DRC_NA, - GFS3_OP_FALLOCATE, 0}, - [GFS3_OP_DISCARD] = {"DISCARD", server4_0_discard, NULL, DRC_NA, - GFS3_OP_DISCARD, 0}, - [GFS3_OP_ZEROFILL] = {"ZEROFILL", server4_0_zerofill, NULL, DRC_NA, - GFS3_OP_ZEROFILL, 0}, - [GFS3_OP_IPC] = {"IPC", server4_0_ipc, NULL, DRC_NA, GFS3_OP_IPC, 0}, - [GFS3_OP_SEEK] = {"SEEK", server4_0_seek, NULL, DRC_NA, GFS3_OP_SEEK, 0}, - [GFS3_OP_LEASE] = {"LEASE", server4_0_lease, NULL, DRC_NA, GFS3_OP_LEASE, + [GFS3_OP_FALLOCATE] = {"FALLOCATE", server4_0_fallocate, NULL, + GFS3_OP_FALLOCATE, DRC_NA, 0}, + [GFS3_OP_DISCARD] = {"DISCARD", server4_0_discard, NULL, GFS3_OP_DISCARD, + DRC_NA, 0}, + [GFS3_OP_ZEROFILL] = {"ZEROFILL", server4_0_zerofill, NULL, + GFS3_OP_ZEROFILL, DRC_NA, 0}, + [GFS3_OP_IPC] = {"IPC", server4_0_ipc, NULL, GFS3_OP_IPC, DRC_NA, 0}, + [GFS3_OP_SEEK] = {"SEEK", server4_0_seek, NULL, GFS3_OP_SEEK, DRC_NA, 0}, + [GFS3_OP_LEASE] = {"LEASE", server4_0_lease, NULL, GFS3_OP_LEASE, DRC_NA, 0}, - [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", server4_0_getactivelk, NULL, DRC_NA, - GFS3_OP_GETACTIVELK, 0}, - [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", server4_0_setactivelk, NULL, DRC_NA, - GFS3_OP_SETACTIVELK, 0}, - [GFS3_OP_COMPOUND] = {"COMPOUND", server4_0_compound, NULL, DRC_NA, - GFS3_OP_COMPOUND, 0}, - [GFS3_OP_ICREATE] = {"ICREATE", server4_0_icreate, NULL, DRC_NA, - GFS3_OP_ICREATE, 0}, - [GFS3_OP_NAMELINK] = {"NAMELINK", server4_0_namelink, NULL, DRC_NA, - GFS3_OP_NAMELINK, 0}, + [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", server4_0_getactivelk, NULL, + GFS3_OP_GETACTIVELK, DRC_NA, 0}, + [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", server4_0_setactivelk, NULL, + GFS3_OP_SETACTIVELK, DRC_NA, 0}, + [GFS3_OP_COMPOUND] = {"COMPOUND", server4_0_compound, NULL, + GFS3_OP_COMPOUND, DRC_NA, 0}, + [GFS3_OP_ICREATE] = {"ICREATE", server4_0_icreate, NULL, GFS3_OP_ICREATE, + DRC_NA, 0}, + [GFS3_OP_NAMELINK] = {"NAMELINK", server4_0_namelink, NULL, + GFS3_OP_NAMELINK, DRC_NA, 0}, [GFS3_OP_COPY_FILE_RANGE] = {"COPY-FILE-RANGE", server4_0_copy_file_range, - NULL, DRC_NA, GFS3_OP_COPY_FILE_RANGE, 0}, + NULL, GFS3_OP_COPY_FILE_RANGE, DRC_NA, 0}, }; struct rpcsvc_program glusterfs4_0_fop_prog = { diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 45485579bc1..ea910525149 100644 --- a/xlators/storage/posix/src/posix-entry-ops.c +++ b/xlators/storage/posix/src/posix-entry-ops.c @@ -87,20 +87,14 @@ posix_unlink_stale_linkto(call_frame_t *frame, xlator_t *this, static gf_boolean_t posix_symlinks_match(xlator_t *this, loc_t *loc, uuid_t gfid) { - struct posix_private *priv = NULL; char linkname_actual[PATH_MAX] = { 0, }; char linkname_expected[PATH_MAX] = {0}; char *dir_handle = NULL; ssize_t len = 0; - size_t handle_size = 0; gf_boolean_t ret = _gf_false; - priv = this->private; - handle_size = POSIX_GFID_HANDLE_SIZE(priv->base_path_length); - dir_handle = alloca0(handle_size); - snprintf(linkname_expected, PATH_MAX, "../../%02x/%02x/%s/%s", loc->pargfid[0], loc->pargfid[1], uuid_utoa(loc->pargfid), loc->name); @@ -219,7 +213,7 @@ posix_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata) op_ret = -1; if (gf_uuid_is_null(loc->pargfid) || (loc->name == NULL)) { /* nameless lookup */ - op_ret = op_errno = errno = 0; + errno = 0; MAKE_INODE_HANDLE(real_path, this, loc, &buf); /* The gfid will be renamed to ".glusterfs/unlink" in case @@ -1214,7 +1208,6 @@ posix_unlink_gfid_handle_and_entry(call_frame_t *frame, xlator_t *this, err: if (locked) { UNLOCK(&loc->inode->lock); - locked = _gf_false; } return -1; } @@ -2064,7 +2057,6 @@ posix_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, unlock: if (locked) { pthread_mutex_unlock(&ctx_new->pgfid_lock); - locked = _gf_false; } pthread_mutex_unlock(&ctx_old->pgfid_lock); @@ -2079,7 +2071,7 @@ posix_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc, if (was_dir) posix_handle_unset_gfid(this, victim); - if (was_present && !was_dir && nlink == 1) { + if (was_present && !was_dir && nlink == 1 && newloc->inode) { LOCK(&newloc->inode->lock); if (newloc->inode->fd_count == 0) { UNLOCK(&newloc->inode->lock);