Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
CORTX-32859: Fix m0_fid_arr_copy memory leak
Browse files Browse the repository at this point in the history
	- During profile_decode, m0_fid_arr_copy is allocating
	  memory for af_elems and it is not freed in profile_delete
	- Explicit free of af_elems in profile_delete

Signed-off-by: Vinoth.V <vinoth.v@seagate.com>
  • Loading branch information
Vinoth2101 committed Aug 3, 2022
1 parent e98e264 commit ec2de06
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
1 change: 1 addition & 0 deletions conf/objs/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ static void profile_delete(struct m0_conf_obj *obj)
struct m0_conf_profile *x = M0_CONF_CAST(obj, m0_conf_profile);

m0_conf_profile_bob_fini(x);
m0_fid_arr_free(&x->cp_pools);
m0_free(x);
}

Expand Down
6 changes: 6 additions & 0 deletions fid/fid.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ M0_INTERNAL int m0_fid_arr_copy(struct m0_fid_arr *to,
return M0_RC(0);
}

M0_INTERNAL void m0_fid_arr_free(struct m0_fid_arr *a)
{
m0_free(a->af_elems);
}


M0_INTERNAL bool m0_fid_arr_eq(const struct m0_fid_arr *a,
const struct m0_fid_arr *b)
{
Expand Down
1 change: 1 addition & 0 deletions fid/fid.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ M0_INTERNAL uint64_t m0_fid_hash(const struct m0_fid *fid);

M0_INTERNAL int m0_fid_arr_copy(struct m0_fid_arr *to,
const struct m0_fid_arr *from);
M0_INTERNAL void m0_fid_arr_free(struct m0_fid_arr *a);
M0_INTERNAL bool m0_fid_arr_eq(const struct m0_fid_arr *a,
const struct m0_fid_arr *b);
M0_INTERNAL bool m0_fid_arr_all_unique(const struct m0_fid_arr *a);
Expand Down
38 changes: 21 additions & 17 deletions scripts/install/opt/seagate/cortx/motr/bin/motr_mini_prov.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,9 @@ def motr_tune_memory_config(self):
create_dirs(self, [f"{MOTR_LOCAL_SYSCONFIG_DIR}"])

MOTR_M0D_CONF_FILE_PATH = f"{MOTR_LOCAL_SYSCONFIG_DIR}/{machine_id}/motr"
# Copy motr to motr-io
cmd = f"cp {MOTR_M0D_CONF_FILE_PATH} {MOTR_M0D_CONF_FILE_PATH}-io"
execute_command(self, cmd)

if not os.path.exists(MOTR_M0D_CONF_FILE_PATH):
self.logger.info(f"FILE not founf {MOTR_M0D_CONF_FILE_PATH}\n")
self.logger.debug(f"FILE not found {MOTR_M0D_CONF_FILE_PATH}\n")
return

# collect the memory and cpu limits.
Expand All @@ -525,33 +522,40 @@ def motr_tune_memory_config(self):
cpu_min = arr_elem['cpu']['min']
cpu_max = arr_elem['cpu']['max']

self.logger.info(f"Avaiable memory {mem_min} {mem_max}\n")
self.logger.info(f"Avaiable CPU {cpu_min} {cpu_max}\n")
self.logger.debug(f"memory for io {mem_min} {mem_max}\n")
self.logger.debug(f"Avaiable memory {mem_min} {mem_max}\n")
self.logger.debug(f"Avaiable CPU {cpu_min} {cpu_max}\n")
M1 = int(calc_resource_sz(self, mem_min) / (1024 * 1024))
M2 = int(calc_resource_sz(self, mem_max) / (1024 * 1024))

if M1 == 0 or M2 == 0:
self.logger.info(f"memory for io mem req:{M1} mem limit: {M2}\n")
self.logger.debug(f"memory for io mem req:{M1} mem limit: {M2}\n")
return

if M2 > 4096:
# update motr config using formula
factor_1 = math.floor(M2/512)
self.logger.info(f"memory for io {M1} {M2} {factor_1}\n")

if M2 < 4096:
MIN_RPC_RECVQ_LEN = 2 ** factor_1
else:
MIN_RPC_RECVQ_LEN = 512
self.logger.info(f"setting MOTR_M0D_MIN_RPC_RECVQ_LEN to {MIN_RPC_RECVQ_LEN}\n")
cmd = f'sed -i "/MOTR_M0D_MIN_RPC_RECVQ_LEN=/s/.*/MOTR_M0D_MIN_RPC_RECVQ_LEN={MIN_RPC_RECVQ_LEN}/" {MOTR_M0D_CONF_FILE_PATH}'
execute_command(self, cmd)
self.logger.debug(f"setting MOTR_M0D_MIN_RPC_RECVQ_LEN to {MIN_RPC_RECVQ_LEN}\n")
cmd = f'sed -i "/MOTR_M0D_MIN_RPC_RECVQ_LEN/s/.*/MOTR_M0D_MIN_RPC_RECVQ_LEN={MIN_RPC_RECVQ_LEN}/" {MOTR_M0D_CONF_FILE_PATH}'
execute_command(self, cmd)

IOS_BUFFER_POOL_SIZE = MIN_RPC_RECVQ_LEN * 2
self.logger.info(f"setting MOTR_M0D_IOS_BUFFER_POOL_SIZE to {IOS_BUFFER_POOL_SIZE}\n")
cmd = f'sed -i "/MOTR_M0D_IOS_BUFFER_POOL_SIZE=/s/.*/MOTR_M0D_IOS_BUFFER_POOL_SIZE={IOS_BUFFER_POOL_SIZE}/" {MOTR_M0D_CONF_FILE_PATH}'
execute_command(self, cmd)
IOS_BUFFER_POOL_SIZE = 16 * (2 ** (factor_1 - 1))
self.logger.debug(f"setting MOTR_M0D_IOS_BUFFER_POOL_SIZE to {IOS_BUFFER_POOL_SIZE}\n")
cmd = f'sed -i "/MOTR_M0D_IOS_BUFFER_POOL_SIZE/s/.*/MOTR_M0D_IOS_BUFFER_POOL_SIZE={IOS_BUFFER_POOL_SIZE}/" {MOTR_M0D_CONF_FILE_PATH}'
execute_command(self, cmd)

if M2 <= 1024:
SNS_BUFFER_POOL_SIZE = 32
else:
SNS_BUFFER_POOL_SIZE = 64

self.logger.info(f"setting MOTR_M0D_SNS_BUFFER_POOL_SIZE to {SNS_BUFFER_POOL_SIZE}\n")
cmd = f'sed -i "/MOTR_M0D_SNS_BUFFER_POOL_SIZE=/s/.*/MOTR_M0D_SNS_BUFFER_POOL_SIZE={SNS_BUFFER_POOL_SIZE}/" {MOTR_M0D_CONF_FILE_PATH}'
self.logger.debug(f"setting MOTR_M0D_SNS_BUFFER_POOL_SIZE to {SNS_BUFFER_POOL_SIZE}\n")
cmd = f'sed -i "/MOTR_M0D_SNS_BUFFER_POOL_SIZE/s/.*/MOTR_M0D_SNS_BUFFER_POOL_SIZE={SNS_BUFFER_POOL_SIZE}/" {MOTR_M0D_CONF_FILE_PATH}'
execute_command(self, cmd)

# Get lists of metadata disks from Confstore of all cvgs
Expand Down

0 comments on commit ec2de06

Please # to comment.