diff options
author | Harpreet Lalwani <hlalwani@redhat.com> | 2018-10-04 16:09:08 +0530 |
---|---|---|
committer | N Balachandran <nbalacha@redhat.com> | 2018-10-31 09:42:14 +0000 |
commit | d2d3c37fa8efca74e375b8a0dc7fa720c3b84dcc (patch) | |
tree | a5adbe9849a1e40e41bbee046369f080d10ce8e5 /xlators/cluster | |
parent | 9be6bf3d90e3783b3ba559c93d41b933f8d53f03 (diff) |
cluster/dht: NULL pointer dereferencing clang fix
Dereferencing NUll pointers this,local and stbuf.
1.Replaced this->name with "dht".
2.Removed GF_VALIDATE_OR_GOTO.
3.Removed the check for "stbuf" and "this".
Updates: bz#1622665
Change-Id: Id2fb2270d5ec37b76fa2aae1f1c8dca72dcc728a
Signed-off-by: Harpreet Lalwani <hlalwani@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r-- | xlators/cluster/dht/src/dht-helper.c | 2 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-inode-read.c | 10 | ||||
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 64 |
3 files changed, 32 insertions, 44 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c index 4764ac5fdd3..22ce8bc4d4c 100644 --- a/xlators/cluster/dht/src/dht-helper.c +++ b/xlators/cluster/dht/src/dht-helper.c @@ -938,7 +938,7 @@ dht_subvol_get_cached(xlator_t *this, inode_t *inode) dht_layout_t *layout = NULL; xlator_t *subvol = NULL; - GF_VALIDATE_OR_GOTO(this->name, this, out); + GF_VALIDATE_OR_GOTO("dht", this, out); GF_VALIDATE_OR_GOTO(this->name, inode, out); layout = dht_layout_get(this, inode); diff --git a/xlators/cluster/dht/src/dht-inode-read.c b/xlators/cluster/dht/src/dht-inode-read.c index f2be5120e37..f46370a9208 100644 --- a/xlators/cluster/dht/src/dht-inode-read.c +++ b/xlators/cluster/dht/src/dht-inode-read.c @@ -265,12 +265,6 @@ dht_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, dht_local_t *local = NULL; int this_call_cnt = 0; xlator_t *prev = NULL; - - GF_VALIDATE_OR_GOTO("dht", frame, err); - GF_VALIDATE_OR_GOTO("dht", this, out); - GF_VALIDATE_OR_GOTO("dht", frame->local, out); - GF_VALIDATE_OR_GOTO("dht", cookie, out); - local = frame->local; prev = cookie; @@ -290,13 +284,13 @@ dht_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, } unlock: UNLOCK(&frame->lock); -out: + this_call_cnt = dht_frame_return(frame); if (is_last_call(this_call_cnt)) { DHT_STACK_UNWIND(stat, frame, local->op_ret, local->op_errno, &local->stbuf, xdata); } -err: + return 0; } diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c index c9f41442f15..0b85ac9ae15 100644 --- a/xlators/cluster/dht/src/dht-rebalance.c +++ b/xlators/cluster/dht/src/dht-rebalance.c @@ -972,43 +972,40 @@ __dht_check_free_space(xlator_t *this, xlator_t *to, xlator_t *from, loc_t *loc, prevent any files being migrated to newly added bricks if they are smaller then the free space available on the existing bricks. */ - if (stbuf) { - if (!conf->use_fallocate) { - file_blocks = stbuf->ia_size + GF_DISK_SECTOR_SIZE - 1; - file_blocks /= GF_DISK_SECTOR_SIZE; + if (!conf->use_fallocate) { + file_blocks = stbuf->ia_size + GF_DISK_SECTOR_SIZE - 1; + file_blocks /= GF_DISK_SECTOR_SIZE; - if (file_blocks >= dst_statfs_blocks) { - dst_statfs_blocks = 0; - } else { - dst_statfs_blocks -= file_blocks; - } + if (file_blocks >= dst_statfs_blocks) { + dst_statfs_blocks = 0; + } else { + dst_statfs_blocks -= file_blocks; } + } - src_post_availspacepercent = ((src_statfs_blocks + file_blocks) * 100) / - src_total_blocks; + src_post_availspacepercent = ((src_statfs_blocks + file_blocks) * 100) / + src_total_blocks; - dst_post_availspacepercent = (dst_statfs_blocks * 100) / - dst_total_blocks; + dst_post_availspacepercent = (dst_statfs_blocks * 100) / dst_total_blocks; - if (dst_post_availspacepercent < src_post_availspacepercent) { - gf_msg(this->name, GF_LOG_WARNING, 0, DHT_MSG_MIGRATE_FILE_FAILED, - "data movement of file " - "{blocks:%" PRIu64 - " name:(%s)} would result in " - "dst node (%s:%" PRIu64 - ") having lower disk " - "space than the source node (%s:%" PRIu64 - ")" - ".Skipping file.", - stbuf->ia_blocks, loc->path, to->name, dst_statfs_blocks, - from->name, src_statfs_blocks); - - /* this is not a 'failure', but we don't want to - consider this as 'success' too :-/ */ - *fop_errno = ENOSPC; - ret = 1; - goto out; - } + if (dst_post_availspacepercent < src_post_availspacepercent) { + gf_msg(this->name, GF_LOG_WARNING, 0, DHT_MSG_MIGRATE_FILE_FAILED, + "data movement of file " + "{blocks:%" PRIu64 + " name:(%s)} would result in " + "dst node (%s:%" PRIu64 + ") having lower disk " + "space than the source node (%s:%" PRIu64 + ")" + ".Skipping file.", + stbuf->ia_blocks, loc->path, to->name, dst_statfs_blocks, + from->name, src_statfs_blocks); + + /* this is not a 'failure', but we don't want to + consider this as 'success' too :-/ */ + *fop_errno = ENOSPC; + ret = 1; + goto out; } check_avail_space: @@ -4293,9 +4290,6 @@ gf_defrag_subvol_file_size(xlator_t *this, loc_t *root_loc) 0, }; - if (!this) - return 0; - ret = syncop_statfs(this, root_loc, &buf, NULL, NULL); if (ret) { /* Aargh! */ |