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/dht/src/dht-rebalance.c | |
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/dht/src/dht-rebalance.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-rebalance.c | 64 |
1 files changed, 29 insertions, 35 deletions
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! */ |