/* * pool_data_alloc -- allocate pool data and open set_file */ struct pool_data * pool_data_alloc(PMEMpoolcheck *ppc) { LOG(3, NULL); struct pool_data *pool = malloc(sizeof(*pool)); if (!pool) { ERR("!malloc"); return NULL; } TAILQ_INIT(&pool->arenas); pool->narenas = 0; pool->blk_no_layout = 0; pool->uuid_op = UUID_NOP; pool->set_file = NULL; pool->bttc.valid = false; if (pool_params_parse(ppc, &pool->params, 0)) goto error; int rdonly = CHECK_WITHOUT_FIXING(ppc); pool->set_file = pool_set_file_open(ppc->path, &pool->params, rdonly); if (!pool->set_file) goto error; return pool; error: pool_data_free(pool); return NULL; }
/* * pool_data_alloc -- allocate pool data and open set_file */ struct pool_data * pool_data_alloc(PMEMpoolcheck *ppc) { LOG(3, NULL); struct pool_data *pool = malloc(sizeof(*pool)); if (!pool) { ERR("!malloc"); return NULL; } TAILQ_INIT(&pool->arenas); pool->narenas = 0; pool->blk_no_layout = 0; pool->uuid_op = UUID_NOP; pool->set_file = NULL; pool->bttc.valid = false; if (pool_params_parse(ppc, &pool->params, 0)) goto error; int rdonly = CHECK_IS_NOT(ppc, REPAIR); int prv = CHECK_IS(ppc, DRY_RUN); if (prv && pool->params.is_device_dax) { errno = ENOTSUP; ERR("!cannot perform a dry run on dax device"); goto error; } pool->set_file = pool_set_file_open(ppc->path, &pool->params, prv); if (pool->set_file == NULL) goto error; /* * XXX mprotect for device dax with length not aligned to its * page granularity causes SIGBUS on the next page fault. * The length argument of this call should be changed to * pool->set_file->poolsize once the kernel issue is solved. */ if (rdonly && mprotect(pool->set_file->addr, pool->set_file->poolset->replica[0]->repsize, PROT_READ) < 0) goto error; if (pool->params.type != POOL_TYPE_BTT) { if (pool_set_file_map_headers(pool->set_file, rdonly, prv)) goto error; } return pool; error: pool_data_free(pool); return NULL; }