dht: coverity fixes
CID: 1356541 Issue: Dereference null return value CID: 1382411 Issue: Dereference after null check CID: 1391409 Issue: Unchecked return value Change-Id: Id3d4feb4e88df424003cc8e8a1540e77bbe030e3 Updates: bz#789278 Signed-off-by: Susant Palai <spalai@redhat.com>
This commit is contained in:
parent
f87d1a1e33
commit
07cb6a4865
@ -1530,12 +1530,11 @@ dht_revalidate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
GF_VALIDATE_OR_GOTO("dht", this, err);
|
||||
GF_VALIDATE_OR_GOTO("dht", frame->local, err);
|
||||
GF_VALIDATE_OR_GOTO("dht", cookie, err);
|
||||
GF_VALIDATE_OR_GOTO("dht", this->private, err);
|
||||
|
||||
local = frame->local;
|
||||
prev = cookie;
|
||||
conf = this->private;
|
||||
if (!conf)
|
||||
goto out;
|
||||
|
||||
if (!conf->vch_forced) {
|
||||
ret = dict_get_uint32(xattr, conf->commithash_xattr_name,
|
||||
@ -1728,7 +1727,6 @@ unlock:
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
this_call_cnt = dht_frame_return(frame);
|
||||
|
||||
if (is_last_call(this_call_cnt)) {
|
||||
@ -7560,7 +7558,18 @@ dht_handle_parent_layout_change(xlator_t *this, call_stub_t *stub)
|
||||
local = frame->local;
|
||||
|
||||
refresh_frame = copy_frame(frame);
|
||||
if (!refresh_frame) {
|
||||
gf_msg(this->name, GF_LOG_ERROR, ENOMEM, DHT_MSG_NO_MEMORY,
|
||||
"mem allocation failed for refresh_frame");
|
||||
return -1;
|
||||
}
|
||||
|
||||
refresh_local = dht_local_init(refresh_frame, NULL, NULL, stub->fop);
|
||||
if (!refresh_local) {
|
||||
gf_msg(this->name, GF_LOG_ERROR, ENOMEM, DHT_MSG_NO_MEMORY,
|
||||
"mem allocation failed for refresh_local");
|
||||
return -1;
|
||||
}
|
||||
|
||||
refresh_local->loc.inode = inode_ref(local->loc.parent);
|
||||
gf_uuid_copy(refresh_local->loc.gfid, local->loc.parent->gfid);
|
||||
@ -9027,7 +9036,11 @@ dht_mkdir_hashed_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
|
||||
goto err;
|
||||
}
|
||||
|
||||
dht_handle_parent_layout_change(this, stub);
|
||||
ret = dht_handle_parent_layout_change(this, stub);
|
||||
if (ret) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
stub = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -867,7 +867,7 @@ int32_t
|
||||
dht_migration_needed(xlator_t *this);
|
||||
int
|
||||
dht_layout_normalize(xlator_t *this, loc_t *loc, dht_layout_t *layout);
|
||||
int
|
||||
void
|
||||
dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout,
|
||||
uint32_t *holes_p, uint32_t *overlaps_p,
|
||||
uint32_t *missing_p, uint32_t *down_p, uint32_t *misc_p,
|
||||
|
@ -497,7 +497,7 @@ dht_layout_sort_volname(dht_layout_t *layout)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
void
|
||||
dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout,
|
||||
uint32_t *holes_p, uint32_t *overlaps_p,
|
||||
uint32_t *missing_p, uint32_t *down_p, uint32_t *misc_p,
|
||||
@ -510,7 +510,6 @@ dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout,
|
||||
uint32_t hole_cnt = 0;
|
||||
uint32_t overlap_cnt = 0;
|
||||
int i = 0;
|
||||
int ret = 0;
|
||||
uint32_t prev_stop = 0;
|
||||
uint32_t last_stop = 0;
|
||||
char is_virgin = 1;
|
||||
@ -593,8 +592,6 @@ dht_layout_anomalies(xlator_t *this, loc_t *loc, dht_layout_t *layout,
|
||||
|
||||
if (no_space_p)
|
||||
*no_space_p = no_space;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
@ -637,14 +634,8 @@ dht_layout_normalize(xlator_t *this, loc_t *loc, dht_layout_t *layout)
|
||||
|
||||
gf_uuid_unparse(loc->gfid, gfid);
|
||||
|
||||
ret = dht_layout_anomalies(this, loc, layout, &holes, &overlaps, &missing,
|
||||
&down, &misc, NULL);
|
||||
if (ret == -1) {
|
||||
gf_msg(this->name, GF_LOG_WARNING, 0,
|
||||
DHT_MSG_FIND_LAYOUT_ANOMALIES_ERROR,
|
||||
"Error finding anomalies in %s, gfid = %s", loc->path, gfid);
|
||||
goto out;
|
||||
}
|
||||
dht_layout_anomalies(this, loc, layout, &holes, &overlaps, &missing, &down,
|
||||
&misc, NULL);
|
||||
|
||||
if (holes || overlaps) {
|
||||
if (missing == layout->cnt) {
|
||||
|
@ -349,7 +349,7 @@ dht_should_heal_layout(call_frame_t *frame, dht_layout_t **heal,
|
||||
{
|
||||
gf_boolean_t fixit = _gf_true;
|
||||
dht_local_t *local = NULL;
|
||||
int ret = -1, heal_missing_dirs = 0;
|
||||
int heal_missing_dirs = 0;
|
||||
|
||||
local = frame->local;
|
||||
|
||||
@ -357,14 +357,11 @@ dht_should_heal_layout(call_frame_t *frame, dht_layout_t **heal,
|
||||
(*ondisk == NULL))
|
||||
goto out;
|
||||
|
||||
ret = dht_layout_anomalies(
|
||||
dht_layout_anomalies(
|
||||
frame->this, &local->loc, *ondisk, &local->selfheal.hole_cnt,
|
||||
&local->selfheal.overlaps_cnt, &local->selfheal.missing_cnt,
|
||||
&local->selfheal.down, &local->selfheal.misc, NULL);
|
||||
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
/* Directories might've been created as part of this self-heal. We've to
|
||||
* sync non-layout xattrs and set range 0-0 on new directories
|
||||
*/
|
||||
@ -485,7 +482,6 @@ dht_should_fix_layout(call_frame_t *frame, dht_layout_t **inmem,
|
||||
dht_local_t *local = NULL;
|
||||
int layout_span = 0;
|
||||
int decommissioned_bricks = 0;
|
||||
int ret = 0;
|
||||
dht_conf_t *conf = NULL;
|
||||
dht_distribution_type_t inmem_dist_type = 0;
|
||||
dht_distribution_type_t ondisk_dist_type = 0;
|
||||
@ -498,14 +494,10 @@ dht_should_fix_layout(call_frame_t *frame, dht_layout_t **inmem,
|
||||
(*ondisk == NULL))
|
||||
goto out;
|
||||
|
||||
ret = dht_layout_anomalies(
|
||||
frame->this, &local->loc, *ondisk, &local->selfheal.hole_cnt,
|
||||
&local->selfheal.overlaps_cnt, NULL, &local->selfheal.down,
|
||||
&local->selfheal.misc, NULL);
|
||||
if (ret < 0) {
|
||||
fixit = _gf_false;
|
||||
goto out;
|
||||
}
|
||||
dht_layout_anomalies(frame->this, &local->loc, *ondisk,
|
||||
&local->selfheal.hole_cnt,
|
||||
&local->selfheal.overlaps_cnt, NULL,
|
||||
&local->selfheal.down, &local->selfheal.misc, NULL);
|
||||
|
||||
if (local->selfheal.down || local->selfheal.misc) {
|
||||
fixit = _gf_false;
|
||||
@ -1745,7 +1737,6 @@ dht_fix_layout_of_directory(call_frame_t *frame, loc_t *loc,
|
||||
dht_conf_t *priv = NULL;
|
||||
dht_local_t *local = NULL;
|
||||
uint32_t subvol_down = 0;
|
||||
int ret = 0;
|
||||
gf_boolean_t maximize_overlap = _gf_true;
|
||||
char gfid[GF_UUID_BUF_SIZE] = {0};
|
||||
|
||||
@ -1768,10 +1759,10 @@ dht_fix_layout_of_directory(call_frame_t *frame, loc_t *loc,
|
||||
}
|
||||
|
||||
/* If a subvolume is down, do not re-write the layout. */
|
||||
ret = dht_layout_anomalies(this, loc, layout, NULL, NULL, NULL,
|
||||
&subvol_down, NULL, NULL);
|
||||
dht_layout_anomalies(this, loc, layout, NULL, NULL, NULL, &subvol_down,
|
||||
NULL, NULL);
|
||||
|
||||
if (subvol_down || (ret == -1)) {
|
||||
if (subvol_down) {
|
||||
gf_uuid_unparse(loc->gfid, gfid);
|
||||
gf_msg(this->name, GF_LOG_WARNING, 0, DHT_MSG_LAYOUT_FIX_FAILED,
|
||||
"Layout fix failed: %u subvolume(s) are down"
|
||||
|
Loading…
x
Reference in New Issue
Block a user