Extend the block pool with a new region (with different region ID)
| 183 | |
| 184 | // Extend the block pool with a new region (with different region ID) |
| 185 | static void* ExtendBlockPool(size_t region_size, int block_type) { |
| 186 | if (region_size < 1) { |
| 187 | errno = EINVAL; |
| 188 | return NULL; |
| 189 | } |
| 190 | |
| 191 | if (FLAGS_rdma_memory_pool_user_specified_memory) { |
| 192 | LOG_EVERY_SECOND(ERROR) << "Fail to extend new region, " |
| 193 | "rdma_memory_pool_user_specified_memory is " |
| 194 | "true, ExtendBlockPool is disabled"; |
| 195 | return NULL; |
| 196 | } |
| 197 | |
| 198 | // Regularize region size |
| 199 | region_size = region_size * BYTES_IN_MB / g_block_size[block_type] / g_buckets; |
| 200 | region_size *= g_block_size[block_type] * g_buckets; |
| 201 | |
| 202 | LOG(INFO) << "Start extend rdma memory " << region_size / BYTES_IN_MB << "MB"; |
| 203 | |
| 204 | void* region_base = NULL; |
| 205 | if (posix_memalign(®ion_base, 4096, region_size) != 0) { |
| 206 | PLOG_EVERY_SECOND(ERROR) << "Memory not enough"; |
| 207 | return NULL; |
| 208 | } |
| 209 | |
| 210 | return ExtendBlockPoolImpl(region_base, region_size, block_type); |
| 211 | } |
| 212 | |
| 213 | void* ExtendBlockPoolByUser(void* region_base, size_t region_size, int block_type) { |
| 214 | auto region_base_guard = butil::MakeScopeGuard([region_base]() { |
no test coverage detected