|
27 | 27 | #include "lib/arith.h" /* M0_CNT_INC */ |
28 | 28 | #include "lib/mutex.h" /* m0_mutex_lock */ |
29 | 29 | #include "lib/time.h" /* m0_nanosleep */ |
| 30 | +#include "lib/string.h" /* To get the enviroment value for M0_CLIENT_ADDB_DIR */ |
30 | 31 | #include "addb2/global.h" |
31 | 32 | #include "addb2/sys.h" |
32 | 33 | #include "fid/fid.h" /* m0_fid */ |
@@ -1528,7 +1529,6 @@ M0_INTERNAL int m0_client_global_init(void) |
1528 | 1529 | } |
1529 | 1530 |
|
1530 | 1531 | #define NOT_EMPTY(x) (x != NULL && *x != '\0') |
1531 | | - |
1532 | 1532 | static struct m0 m0_client_motr_instance; |
1533 | 1533 | int m0_client_init(struct m0_client **m0c_p, |
1534 | 1534 | struct m0_config *conf, bool init_m0) |
@@ -1678,16 +1678,35 @@ int m0_client_init(struct m0_client **m0c_p, |
1678 | 1678 | } |
1679 | 1679 |
|
1680 | 1680 | if (conf->mc_is_addb_init) { |
1681 | | - char buf[64]; |
| 1681 | + char buf[128]; |
| 1682 | + const char *addb_stob_location = NULL; |
1682 | 1683 | /* Default client addb record file size set to 128M */ |
1683 | 1684 | m0_bcount_t size = DEFAULT_CLIENT_ADDB2_RECORD_SIZE; |
| 1685 | + /* uint64 max character size */ |
| 1686 | + enum { MAX_PID_IN_CHAR_SIZE = 20 }; |
| 1687 | + |
1684 | 1688 | if (conf->mc_addb_size != 0) { |
1685 | 1689 | if (conf->mc_addb_size > MAX_ADDB2_RECORD_SIZE) |
1686 | 1690 | M0_LOG(M0_WARN, "ADDB size is more than recommended"); |
1687 | 1691 | size = conf->mc_addb_size; |
1688 | 1692 | M0_LOG(M0_DEBUG, "ADDB size = %" PRIu64 "", size); |
1689 | 1693 | } |
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()); |
1691 | 1710 | M0_LOG(M0_DEBUG, "addb size=%llu\n", (unsigned long long)size); |
1692 | 1711 | rc = m0_reqh_addb2_init(&m0c->m0c_reqh, buf, |
1693 | 1712 | 0xaddbf11e, true, true, size); |
|
0 commit comments