all: remove superfluous dealloc tests and clears

This commit is contained in:
Thomas Schoebel-Theuer 2020-07-08 20:55:34 +02:00
parent ceebaf04e5
commit ea4fbc1885
11 changed files with 10 additions and 42 deletions

View File

@ -643,8 +643,5 @@ int __init init_brick(void)
void exit_brick(void)
{
if (nr_table) {
brick_mem_free(nr_table);
nr_table = NULL;
}
brick_mem_free(nr_table);
}

View File

@ -327,7 +327,6 @@ err_free:
if (logst->private) {
// TODO: if callbacks are already registered, call them here with some error code
brick_mem_free(logst->private);
logst->private = NULL;
}
err:
return NULL;
@ -616,7 +615,6 @@ done_put:
if (status == -EAGAIN && old_offset > 0) {
if (*dealloc) {
brick_mem_free(*dealloc);
*dealloc = NULL;
}
goto restart;
}

View File

@ -1127,9 +1127,8 @@ char *aio_statistics(struct aio_brick *brick, int verbose)
atomic_read(&output->tinfo[1].total_enqueue_count),
atomic_read(&output->tinfo[2].total_enqueue_count),
sync ? sync : "");
if (sync)
brick_string_free(sync);
brick_string_free(sync);
return res;
}

View File

@ -390,7 +390,6 @@ void _bio_ref_put(struct bio_output *output, struct mref_object *mref)
if (mref_a->do_dealloc) {
MARS_IO("free page\n");
brick_block_free(mref->ref_data, mref_a->alloc_len);
mref->ref_data = NULL;
}
bio_free_mref(mref);

View File

@ -246,7 +246,6 @@ struct buf_head *_alloc_bf(struct buf_brick *brick)
#endif
if (unlikely(!bf->bf_data)) {
brick_mem_free(bf);
bf = NULL;
goto done;
}

View File

@ -355,7 +355,6 @@ int _setup_bundle(struct client_bundle *bundle, const char *str)
bundle->host = strchr(bundle->path, '@');
if (unlikely(!bundle->host)) {
brick_string_free(bundle->path);
bundle->path = NULL;
MARS_ERR("parameter string '%s' contains no remote specifier with '@'-syntax\n", str);
goto done;
}
@ -1115,7 +1114,6 @@ static int client_output_construct(struct client_output *output)
static int client_output_destruct(struct client_output *output)
{
brick_string_free(output->bundle.path);
output->bundle.path = NULL;
brick_block_free(output->hash_table, PAGE_SIZE);
return 0;
}

View File

@ -353,10 +353,8 @@ void mars_put_socket(struct mars_socket *msock)
sock_release(sock);
}
for (i = 0; i < MAX_DESC_CACHE; i++) {
if (msock->s_desc_send[i])
brick_block_free(msock->s_desc_send[i], PAGE_SIZE);
if (msock->s_desc_recv[i])
brick_block_free(msock->s_desc_recv[i], PAGE_SIZE);
brick_block_free(msock->s_desc_send[i], PAGE_SIZE);
brick_block_free(msock->s_desc_recv[i], PAGE_SIZE);
}
brick_block_free(msock->s_buffer, PAGE_SIZE);
memset(msock, 0, sizeof(struct mars_socket));

View File

@ -169,7 +169,6 @@ int cb_thread(void *data)
if (mref_a->data) {
brick_block_free(mref_a->data, mref_a->len);
mref_a->data = NULL;
mref->ref_data = NULL;
}
if (mref_a->do_put) {

View File

@ -940,7 +940,6 @@ restart:
if (mref_a->do_dealloc) {
brick_block_free(mref_a->shadow_data, mref_a->alloc_len);
atomic64_sub(mref_a->alloc_len, &brick->shadow_mem_used);
mref_a->shadow_data = NULL;
mref_a->do_dealloc = false;
}
if (mref_a->do_buffered) {

View File

@ -243,9 +243,7 @@ void clear_vals(struct key_value_pair *start)
{
while (start->key) {
brick_string_free(start->val);
start->val = NULL;
brick_string_free(start->old_val);
start->old_val = NULL;
start++;
}
}
@ -276,7 +274,6 @@ void show_vals(struct key_value_pair *start, const char *path, const char *add)
memset(&start->system_stamp, 0, sizeof(start->system_stamp));
memset(&start->lamport_stamp, 0, sizeof(start->lamport_stamp));
brick_string_free(start->old_val);
start->old_val = NULL;
}
brick_string_free(dst);
start++;
@ -3332,12 +3329,6 @@ void rot_destruct(void *_rot)
brick_string_free(rot->parent_path);
brick_string_free(rot->parent_rest);
brick_string_free(rot->fetch_next_origin);
rot->fetch_path = NULL;
rot->fetch_peer = NULL;
rot->preferred_peer = NULL;
rot->parent_path = NULL;
rot->parent_rest = NULL;
rot->fetch_next_origin = NULL;
clear_vals(rot->msgs);
}
}
@ -3410,7 +3401,6 @@ int make_log_init(void *buf, struct mars_dent *dent)
rot->prev_log = NULL;
rot->next_log = NULL;
brick_string_free(rot->fetch_next_origin);
rot->fetch_next_origin = NULL;
rot->max_sequence = 0;
// reset the split brain detector only when conflicts have gone for a number of rounds
if (rot->split_brain_serial && rot->split_brain_round++ > 3)
@ -3419,7 +3409,6 @@ int make_log_init(void *buf, struct mars_dent *dent)
rot->has_error = false;
rot->has_symlinks = true;
brick_string_free(rot->preferred_peer);
rot->preferred_peer = NULL;
activate_peer(rot, dent->d_rest);
@ -5043,7 +5032,7 @@ static int _make_direct(void *buf, struct mars_dent *dent)
status = 0;
done:
MARS_DBG("status = %d\n", status);
if (do_dealloc && src_path)
if (do_dealloc)
brick_string_free(src_path);
return status;
}
@ -5085,10 +5074,8 @@ static int _make_copy(void *buf, struct mars_dent *dent)
done:
MARS_DBG("status = %d\n", status);
if (copy_path)
brick_string_free(copy_path);
if (switch_path)
brick_string_free(switch_path);
brick_string_free(copy_path);
brick_string_free(switch_path);
return status;
}
@ -6594,7 +6581,6 @@ done:
brick_string_free(mars_resource_list);
brick_string_free(tmp_resource_list);
brick_mem_free(mars_global);
mars_global = NULL;
MARS_INF("-------- done status = %d ----------\n", status);
//cleanup_mm();

View File

@ -2223,7 +2223,6 @@ void mars_free_dent(struct mars_global *global, struct mars_dent *dent)
mars_free_dent_all(dent->d_subtree,
&dent->d_subtree->dent_anchor);
brick_mem_free(dent->d_subtree);
dent->d_subtree = NULL;
}
for (i = 0; i < MARS_ARGV_MAX; i++) {
@ -3056,12 +3055,9 @@ err:
brick = NULL;
done:
for (i = 0; i < prev_count; i++) {
if (paths[i]) {
brick_string_free(paths[i]);
}
brick_string_free(paths[i]);
}
if (_new_path)
brick_string_free(_new_path);
brick_string_free(_new_path);
return brick;
}