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

Commit 3fa2a2a

Browse files
committed
CORTX-32172: Fixes ADDB client logs to bundled it in rgw support bundle
Signed-off-by: Rahul Kumar <[email protected]>
1 parent 0cd7e68 commit 3fa2a2a

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

motr/client_init.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "lib/arith.h" /* M0_CNT_INC */
2828
#include "lib/mutex.h" /* m0_mutex_lock */
2929
#include "lib/time.h" /* m0_nanosleep */
30+
#include "lib/string.h" /* To get the enviroment value for M0_CLIENT_ADDB_DIR */
3031
#include "addb2/global.h"
3132
#include "addb2/sys.h"
3233
#include "fid/fid.h" /* m0_fid */
@@ -1528,7 +1529,6 @@ M0_INTERNAL int m0_client_global_init(void)
15281529
}
15291530

15301531
#define NOT_EMPTY(x) (x != NULL && *x != '\0')
1531-
15321532
static struct m0 m0_client_motr_instance;
15331533
int m0_client_init(struct m0_client **m0c_p,
15341534
struct m0_config *conf, bool init_m0)
@@ -1678,16 +1678,35 @@ int m0_client_init(struct m0_client **m0c_p,
16781678
}
16791679

16801680
if (conf->mc_is_addb_init) {
1681-
char buf[64];
1681+
char buf[128];
1682+
const char *addb_stob_location = NULL;
16821683
/* Default client addb record file size set to 128M */
16831684
m0_bcount_t size = DEFAULT_CLIENT_ADDB2_RECORD_SIZE;
1685+
/* uint64 max character size */
1686+
enum { MAX_PID_IN_CHAR_SIZE = 20 };
1687+
16841688
if (conf->mc_addb_size != 0) {
16851689
if (conf->mc_addb_size > MAX_ADDB2_RECORD_SIZE)
16861690
M0_LOG(M0_WARN, "ADDB size is more than recommended");
16871691
size = conf->mc_addb_size;
16881692
M0_LOG(M0_DEBUG, "ADDB size = %" PRIu64 "", size);
16891693
}
1690-
sprintf(buf, "linuxstob:./addb_%d", (int)m0_pid());
1694+
#ifndef __KERNEL__
1695+
addb_stob_location = getenv("M0_CLIENT_ADDB_DIR");
1696+
#endif
1697+
/* checking for buf size overflow */
1698+
if (addb_stob_location != NULL && sizeof(&addb_stob_location) >=
1699+
sizeof(buf) - (sizeof("linuxstob:/addb_") +
1700+
MAX_PID_IN_CHAR_SIZE))
1701+
{
1702+
M0_LOG(M0_WARN, "ADDB location is more than defined "
1703+
"size .. ignoring it.");
1704+
}
1705+
if (addb_stob_location == NULL)
1706+
addb_stob_location = ".";
1707+
1708+
snprintf(buf, 1024, "linuxstob:%s/addb_%d",
1709+
addb_stob_location, (int)m0_pid());
16911710
M0_LOG(M0_DEBUG, "addb size=%llu\n", (unsigned long long)size);
16921711
rc = m0_reqh_addb2_init(&m0c->m0c_reqh, buf,
16931712
0xaddbf11e, true, true, size);

0 commit comments

Comments
 (0)