From 36e70d1a942cede9da8b81b6c9b0f01847a0e7a0 Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Thu, 13 Feb 2025 15:30:11 +0200 Subject: [PATCH 01/17] posix-entry-ops.c: fix clang warnings Fix: make[4]: Entering directory '/home/ykaul/github/glusterfs/xlators/storage/posix/src' CC posix-entry-ops.lo posix-entry-ops.c:102:5: warning: Value stored to 'dir_handle' is never read [deadcode.DeadStores] 102 | dir_handle = alloca0(handle_size); | ^ ~~~~~~~~~~~~~~~~~~~~ posix-entry-ops.c:222:9: warning: Value stored to 'op_ret' is never read [deadcode.DeadStores] 222 | op_ret = op_errno = errno = 0; | ^ ~~~~~~~~~~~~~~~~~~~~ posix-entry-ops.c:222:18: warning: Although the value stored to 'op_errno' is used in the enclosing expression, the value is never actually read from 'op_errno' [deadcode.DeadStores] 222 | op_ret = op_errno = errno = 0; | ^ ~~~~~~~~~ posix-entry-ops.c:1217:9: warning: Value stored to 'locked' is never read [deadcode.DeadStores] 1217 | locked = _gf_false; | ^ ~~~~~~~~~ posix-entry-ops.c:2067:9: warning: Value stored to 'locked' is never read [deadcode.DeadStores] 2067 | locked = _gf_false; | ^ ~~~~~~~~~ posix-entry-ops.c:2083:9: warning: Null pointer passed to 1st parameter expecting 'nonnull' [core.NonNullParamChecker] 2083 | LOCK(&newloc->inode->lock); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../../../../libglusterfs/src/glusterfs/locking.h:28:17: note: expanded from macro 'LOCK' 28 | #define LOCK(x) pthread_mutex_lock(x) | ^~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- xlators/storage/posix/src/posix-entry-ops.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/xlators/storage/posix/src/posix-entry-ops.c b/xlators/storage/posix/src/posix-entry-ops.c index 45485579bc..ea91052514 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); From 4a4bb2b4796769cbd84875c95e907840071c93cf Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Thu, 13 Feb 2025 09:59:35 +0200 Subject: [PATCH 02/17] glusterd-snapshot-utils.c: fix clang warnings Fix: glusterd-snapshot-utils.c:304:13: warning: Access to field 'brick_path' results in a dereference of a null pointer (loaded from variable 'snap_ops') [core.NullDereference] 304 | snap_ops->brick_path(snap_mount_dir, brickinfo->origin_path, 0, | ^~~~~~~~~~~~~~~~~~~~ glusterd-snapshot-utils.c:3345:19: warning: Access to field 'deactivate' results in a dereference of a null pointer (loaded from variable 'snap_ops') [core.NullDereference] 3345 | ret = snap_ops->deactivate(brickinfo, volinfo->snapshot->snapname, | ^~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- xlators/mgmt/glusterd/src/glusterd-messages.h | 4 +++- xlators/mgmt/glusterd/src/glusterd-snapshot-utils.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h index 8b573222de..498871dbaa 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 028ecbd4d0..dfe5052086 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) { From fd2457d2c8736d99e52abdb6fb6cb052f33fb821 Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Wed, 12 Feb 2025 19:01:09 +0200 Subject: [PATCH 03/17] client.c/client-helpers.c: fix clang warnings Fix: client.c:2747:48: warning: Although the value stored to 'use_try_lock' is used in the enclosing expression, the value is never actually read from 'use_try_lock' [deadcode.DeadStores] 2747 | ret = client_fd_lk_list_empty(lk_ctx_ref, (use_try_lock = _gf_true)); | ^ ~~~~~~~~ While at it - simplify the code. There's no need for a whole function just to TRY_LOCK. Fix: client.c:2318:13: warning: Value stored to 'ret' is never read [deadcode.DeadStores] 2318 | ret = client_fini_complete(this); | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- xlators/protocol/client/src/client-helpers.c | 26 ------------------ xlators/protocol/client/src/client.c | 29 +++++++------------- xlators/protocol/client/src/client.h | 2 -- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/xlators/protocol/client/src/client-helpers.c b/xlators/protocol/client/src/client-helpers.c index 87b0721528..2e8d24b141 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 e050877654..46abdb5ce8 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 880d3f8b17..d974650fa0 100644 --- a/xlators/protocol/client/src/client.h +++ b/xlators/protocol/client/src/client.h @@ -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 From 4eb100ce391f5879cc54915572f437c0a899009b Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Wed, 12 Feb 2025 09:34:42 +0200 Subject: [PATCH 04/17] afr-self-heal-common.c: fix clang warning Fix: afr-self-heal-common.c:2465:13: warning: Dereference of null pointer (loaded from variable 'op_errno') [core.NullDereference] 2465 | local = AFR_FRAME_INIT(frame, (*op_errno)); | ^ ~~~~~~~~ ./afr.h:1075:22: note: expanded from macro 'AFR_FRAME_INIT' 1075 | op_errno = ENOMEM; \ | ~~~~~~~~ ^ Signed-off-by: Yaniv Kaul --- xlators/cluster/afr/src/afr-self-heal-common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index 41394922f8..b6d69db439 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; } From 3565678b1420f224376f290cc02cf483a371f237 Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Tue, 11 Feb 2025 12:51:16 +0200 Subject: [PATCH 05/17] glusterfsd-mgmt.c: fix clang warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix: glusterfsd-mgmt.c:1587:46: warning: ‘%s’ directive argument is null [-Wformat-overflow=] 1587 | gf_log(THIS->name, GF_LOG_ERROR, "%s", msg); | ^~~~ ../../libglusterfs/src/glusterfs/logging.h:248:65: note: in definition of macro ‘gf_log’ 248 | _gf_log(dom, __FILE__, __FUNCTION__, __LINE__, level, ##fmt); \ | ^~~ glusterfsd-mgmt.c:1587:47: note: format string is defined here 1587 | gf_log(THIS->name, GF_LOG_ERROR, "%s", msg); | ^~ Signed-off-by: Yaniv Kaul --- glusterfsd/src/glusterfsd-mgmt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c index fdd37c5fb6..0c5ff322d0 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; From f5677819337804c3df4e9f43585028d9f1cbc6e3 Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Tue, 11 Feb 2025 12:12:27 +0200 Subject: [PATCH 06/17] glusterd-locks.c: fix clang warnings Fix: glusterd-locks.c: In function 'gd_mgmt_v3_unlock_timer_cbk': glusterd-locks.c:668:9: warning: 'bt_key_len' may be used uninitialized [-Wmaybe-uninitialized] 668 | dict_deln(conf->mgmt_v3_lock_timer, bt_key, bt_key_len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glusterd-locks.c:642:9: note: 'bt_key_len' was declared here 642 | int bt_key_len = 0; | ^~~~~~~~~~ As well as: glusterd-locks.c:604:9: warning: Value stored to 'ret' is never read [deadcode.DeadStores] 604 | ret = 0; Signed-off-by: Yaniv Kaul --- xlators/mgmt/glusterd/src/glusterd-locks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index 52e1d59846..ef88f61d34 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) { From 552760836928bf667157db33c4d1d9197eb2c58e Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Tue, 11 Feb 2025 09:54:27 +0200 Subject: [PATCH 07/17] inode.c: fix clang's scan-build warning Fix: inode.c:1734:9: warning: Value stored to 'mem_pool_size' is never read [deadcode.DeadStores] 1734 | mem_pool_size = DEFAULT_INODE_MEMPOOL_ENTRIES; | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix: Add a check to ensure the pointer pointing to the gfid is not NULL in __is_root_gfid(), as pointed out by scan-analyzer Signed-off-by: Yaniv Kaul --- libglusterfs/src/inode.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 71a3a097d2..528a68941d 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) From bce8279d4c9c869dc7f3b3c8a779fdad986207ae Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Tue, 11 Feb 2025 09:18:37 +0200 Subject: [PATCH 08/17] dict.c: fix clang scan-build warning Fix: make[4]: Entering directory '/home/ykaul/github/glusterfs/libglusterfs/src' CC libglusterfs_la-dict.lo dict.c:384:5: warning: Null pointer passed to 2nd parameter expecting 'nonnull' [core.NonNullParamChecker] 384 | memcpy(pair->key, key, key_len + 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- libglusterfs/src/dict.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c index 243889280e..767c9d32cc 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; From c6df3612b2150ffcf82a4dd87f8b8bc040e8d26e Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Mon, 10 Feb 2025 15:43:10 +0200 Subject: [PATCH 09/17] cli-cmd.c: fix clang warning Fix: cli-cmd.c:166:9: warning: variable 'i' set but not used [-Wunused-but-set-variable] 166 | int i = 0; | ^ Signed-off-by: Yaniv Kaul --- cli/src/cli-cmd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index e3976970d9..c64811c272 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); From bd4c8894e201fa0111b92378507e4d1054b3b71c Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Mon, 10 Feb 2025 15:38:19 +0200 Subject: [PATCH 10/17] simple-quota: fix clang warning Fix: make[5]: Entering directory '/home/ykaul/github/glusterfs/xlators/features/simple-quota/src' CC simple-quota.lo simple-quota.c:532:20: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] 532 | if ((nlink == 1)) { | ~~~~~~^~~~ simple-quota.c:532:20: note: remove extraneous parentheses around the comparison to silence this warning 532 | if ((nlink == 1)) { | ~ ^ ~ simple-quota.c:532:20: note: use '=' to turn this equality comparison into an assignment 532 | if ((nlink == 1)) { | ^~ | = simple-quota.c:1017:20: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] 1017 | if ((nlink == 1)) { | ~~~~~~^~~~ simple-quota.c:1017:20: note: remove extraneous parentheses around the comparison to silence this warning 1017 | if ((nlink == 1)) { | ~ ^ ~ simple-quota.c:1017:20: note: use '=' to turn this equality comparison into an assignment 1017 | if ((nlink == 1)) { | ^~ | = Signed-off-by: Yaniv Kaul simple-quota.c: fix clang-format --- xlators/features/simple-quota/src/simple-quota.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/xlators/features/simple-quota/src/simple-quota.c b/xlators/features/simple-quota/src/simple-quota.c index 139f7c2823..5a928fc718 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); From 7da2b84295cd8374b3101bad7c60a1a785f23d8a Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Mon, 10 Feb 2025 15:29:57 +0200 Subject: [PATCH 11/17] write-behind.c: fix clang warning Fix: make[5]: Entering directory '/home/ykaul/github/glusterfs/xlators/performance/write-behind/src' CC write-behind.lo write-behind.c:537:34: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 537 | req->ordering.append = 1; | ^ ~ write-behind.c:719:29: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 719 | req->ordering.fulfilled = 1; | ^ ~ write-behind.c:1270:32: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1270 | req->ordering.lied = 1; | ^ ~ write-behind.c:1407:41: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1407 | holder->ordering.go = 1; | ^ ~ write-behind.c:1420:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1420 | holder->ordering.go = 1; | ^ ~ write-behind.c:1426:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1426 | holder->ordering.go = 1; | ^ ~ write-behind.c:1432:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1432 | holder->ordering.go = 1; | ^ ~ write-behind.c:1440:33: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1440 | holder->ordering.go = 1; | ^ ~ write-behind.c:1470:29: warning: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion] 1470 | holder->ordering.go = 1; | ^ ~ Signed-off-by: Yaniv Kaul --- .../write-behind/src/write-behind.c | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index e6371f9be3..6aa3ba90a5 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--; From c4794c268d1e162a6e5cf854adf7dc0baabe667b Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Mon, 10 Feb 2025 14:41:52 +0200 Subject: [PATCH 12/17] server-rpc-fops_v2.c: fix clang warnings Fix: make[5]: Entering directory '/home/ykaul/github/glusterfs/xlators/protocol/server/src' CC server-rpc-fops_v2.lo server-rpc-fops_v2.c:6198:48: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6197 | [GFS3_OP_COPY_FILE_RANGE] = {"COPY-FILE-RANGE", server4_0_copy_file_range, | ~ 6198 | NULL, DRC_NA, GFS3_OP_COPY_FILE_RANGE, 0}, | ^~~~~~~~~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6196:27: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6195 | [GFS3_OP_NAMELINK] = {"NAMELINK", server4_0_namelink, NULL, DRC_NA, | ~ 6196 | GFS3_OP_NAMELINK, 0}, | ^~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6194:26: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6193 | [GFS3_OP_ICREATE] = {"ICREATE", server4_0_icreate, NULL, DRC_NA, | ~ 6194 | GFS3_OP_ICREATE, 0}, | ^~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6190:30: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6189 | [GFS3_OP_SETACTIVELK] = {"SETACTIVELK", server4_0_setactivelk, NULL, DRC_NA, | ~ 6190 | GFS3_OP_SETACTIVELK, 0}, | ^~~~~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6188:30: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6187 | [GFS3_OP_GETACTIVELK] = {"GETACTIVELK", server4_0_getactivelk, NULL, DRC_NA, | ~ 6188 | GFS3_OP_GETACTIVELK, 0}, | ^~~~~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6185:64: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6185 | [GFS3_OP_LEASE] = {"LEASE", server4_0_lease, NULL, DRC_NA, GFS3_OP_LEASE, | ~ ^~~~~~~~~~~~~ server-rpc-fops_v2.c:6192:27: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6191 | [GFS3_OP_COMPOUND] = {"COMPOUND", server4_0_compound, NULL, DRC_NA, | ~ 6192 | GFS3_OP_COMPOUND, 0}, | ^~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6184:61: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6184 | [GFS3_OP_SEEK] = {"SEEK", server4_0_seek, NULL, DRC_NA, GFS3_OP_SEEK, 0}, | ~ ^~~~~~~~~~~~ server-rpc-fops_v2.c:6183:58: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6183 | [GFS3_OP_IPC] = {"IPC", server4_0_ipc, NULL, DRC_NA, GFS3_OP_IPC, 0}, | ~ ^~~~~~~~~~~ server-rpc-fops_v2.c:6182:27: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6181 | [GFS3_OP_ZEROFILL] = {"ZEROFILL", server4_0_zerofill, NULL, DRC_NA, | ~ 6182 | GFS3_OP_ZEROFILL, 0}, | ^~~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6180:26: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6179 | [GFS3_OP_DISCARD] = {"DISCARD", server4_0_discard, NULL, DRC_NA, | ~ 6180 | GFS3_OP_DISCARD, 0}, | ^~~~~~~~~~~~~~~ server-rpc-fops_v2.c:6178:28: warning: implicit conversion from enumeration type 'enum gf_fop_procnum' to different enumeration type 'drc_op_type_t' (aka 'enum drc_op_type') [-Wenum-conversion] 6177 | [GFS3_OP_FALLOCATE] = {"FALLOCATE", server4_0_fallocate, NULL, DRC_NA, | ~ 6178 | GFS3_OP_FALLOCATE, 0}, | ^~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- .../protocol/server/src/server-rpc-fops_v2.c | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/xlators/protocol/server/src/server-rpc-fops_v2.c b/xlators/protocol/server/src/server-rpc-fops_v2.c index 84c54f7f04..c8f9f5ad3b 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 = { From dae26db356c210b3115cd6a6b971e4291ea81bd4 Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Sun, 9 Feb 2025 18:11:18 +0200 Subject: [PATCH 13/17] dht-rebalance.c: fix clang compilation warning Fix: dht-rebalance.c:2259:33: warning: implicit conversion from enumeration type 'enum entrylk_cmd' to different enumeration type 'entrylk_type' (aka 'enum entrylk_type') [-Wenum-conversion] 2257 | lk_ret = syncop_entrylk(hashed_subvol, DHT_ENTRY_SYNC_DOMAIN, | ~~~~~~~~~~~~~~ 2258 | &parent_loc, loc->name, ENTRYLK_UNLOCK, 2259 | ENTRYLK_UNLOCK, NULL, NULL); | ^~~~~~~~~~~~~~ This is not very clear - there's a very clear copy-pasta here, but is the fix to turn it into ENTRYLK_WRLCK ? Every other caller seem to think so, so this is the change. Signed-off-by: Yaniv Kaul --- xlators/cluster/dht/src/dht-rebalance.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index 35e396ebab..cebac9986c 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, From 606dbd07d3dd1194688d201508bc3a5d785bf39e Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Sun, 9 Feb 2025 17:59:15 +0200 Subject: [PATCH 14/17] glfs-fops.c: fix clang compilation warnings Fix: glfs-fops.c:5965:26: warning: implicit conversion from enumeration type 'gf_upcall_event_t' to different enumeration type 'enum glfs_upcall_reason' [-Wenum-conversion] 5965 | up_arg->reason = GF_UPCALL_EVENT_NULL; | ~ ^~~~~~~~~~~~~~~~~~~~ CC libgfapi_la-glfs-fops.lo glfs-fops.c:6621:28: warning: implicit conversion from enumeration type 'gf_lease_cmds_t' (aka 'enum gf_lease_cmds_t') to different enumeration type 'glfs_lease_cmds_t' (aka 'enum glfs_lease_cmds') [-Wenum-conversion] 6621 | lease->cmd = gf_lease->cmd; | ~ ~~~~~~~~~~^~~ glfs-fops.c:6630:28: warning: implicit conversion from enumeration type 'glfs_lease_cmds_t' (aka 'enum glfs_lease_cmds') to different enumeration type 'gf_lease_cmds_t' (aka 'enum gf_lease_cmds_t') [-Wenum-conversion] 6630 | gf_lease->cmd = lease->cmd; | ~ ~~~~~~~^~~ Signed-off-by: Yaniv Kaul --- api/src/glfs-fops.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index ef865a72c8..eb835e3c40 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); } From 75e8a4cf9adb069b0e0196fcb0150141195391dd Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Sun, 9 Feb 2025 17:45:41 +0200 Subject: [PATCH 15/17] client_t.c: fix clang warning Fix: client_t.c:601:25: warning: address of array 'client->client_uid' will always evaluate to 'true' [-Wpointer-bool-conversion] 601 | if (client->client_uid) { | ~~ ~~~~~~~~^~~~~~~~~~ Signed-off-by: Yaniv Kaul client.c/h: clang-format fixes --- libglusterfs/src/client_t.c | 6 ++---- xlators/protocol/client/src/client.h | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c index dcdf60d843..abc3bfe0b0 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/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h index d974650fa0..96bf86fc83 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*/ From 3e0a8cbf1cf7e6bced30138e8996cf407ede15ff Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Sun, 9 Feb 2025 17:40:20 +0200 Subject: [PATCH 16/17] common-utils.c: fix clang warning Fix: common-utils.c:1590:10: warning: implicit conversion from 'unsigned long' to 'double' changes value from 18446744073709551615 to 18446744073709551616 [-Wimplicit-const-int-float-conversion] 1590 | if ((UINT64_MAX - value) < 0) { | ^~~~~~~~~~ ~ /usr/include/stdint.h:119:23: note: expanded from macro 'UINT64_MAX' 119 | # define UINT64_MAX (__UINT64_C(18446744073709551615)) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/stdint.h:96:25: note: expanded from macro '__UINT64_C' 96 | # define __UINT64_C(c) c ## UL | ^~~~~~~ :38:1: note: expanded from here 38 | 18446744073709551615UL | ^~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- libglusterfs/src/common-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c index 01c8a4ed14..c5a9706ae9 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; } From 6c389ef334968386d0a00fda67c628c7340f900b Mon Sep 17 00:00:00 2001 From: Yaniv Michael Kaul Date: Sun, 9 Feb 2025 17:18:29 +0200 Subject: [PATCH 17/17] shard.c: fix clang warnings Fix the following warning that are seen when compiling with clang: make[4]: Entering directory '/home/ykaul/github/glusterfs/xlators/features/shard/src' CC shard.lo shard.c:1292:38: warning: cast to smaller integer type 'shard_internal_dir_type_t' from 'void *' [-Wvoid-pointer-to-enum-cast] 1292 | shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shard.c:1373:38: warning: cast to smaller integer type 'shard_internal_dir_type_t' from 'void *' [-Wvoid-pointer-to-enum-cast] 1373 | shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ shard.c:5892:38: warning: cast to smaller integer type 'shard_internal_dir_type_t' from 'void *' [-Wvoid-pointer-to-enum-cast] 5892 | shard_internal_dir_type_t type = (shard_internal_dir_type_t)cookie; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Yaniv Kaul --- xlators/features/shard/src/shard.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c index 684d115cca..bf77d88d91 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;