Commit 1a25c5f5 authored by Philip Carns's avatar Philip Carns
Browse files

rename and modularize fn to create raw target

- part of abstracted backend api now
- this function will only be used directly by legacy tools (mkpool),
  otherwise it will be within forthcoming provider-level create
parent 0d343717
......@@ -20,18 +20,6 @@ extern "C" {
typedef struct bake_provider* bake_provider_t;
/**
* Creates a BAKE pool to use for backend PMEM storage.
*
* NOTE: This function must be called on a pool before the pool
* can be passed to 'bake_provider_register'.
*
* @param[in] pool_name path to PMEM backend file
* @param[in] pool_size size of the created pool
* @returns 0 on success, -1 otherwise
*/
int bake_makepool(const char* pool_name, size_t pool_size);
/**
* The bake_provider_init_info structure can be passed in to the
* bake_provider_register() function to configure the provider. The struct
......@@ -135,6 +123,19 @@ int bake_provider_list_targets(bake_provider_t provider,
*/
char* bake_provider_get_config(bake_provider_t provider);
/**
* Creates a raw storage target, not connected to a provider. This would
* mainly be used by external utilities, not a server daemon itself.
*
* @param[in] path path to storage target (could be a file, directory, or
* device depending on the backend type)
* @param[in] size size of the created target (may be ignored for target
* types that can be extended or use a fixed size physical device)
*
* @returns 0 on success, -1 otherwise
*/
int bake_create_raw_target(const char* path, size_t size);
#ifdef __cplusplus
}
#endif
......
......@@ -87,6 +87,8 @@ typedef int (*bake_migrate_region_fn)(backend_context_t context,
bake_target_id_t dest_target_id,
bake_region_id_t* dest_rid);
typedef int (*bake_create_raw_target_fn)(const char* path, size_t size);
#ifdef USE_REMI
typedef int (*bake_create_fileset_fn)(backend_context_t context,
remi_fileset_t* fileset);
......@@ -108,6 +110,7 @@ typedef struct bake_backend {
bake_get_region_data_fn _get_region_data;
bake_remove_fn _remove;
bake_migrate_region_fn _migrate_region;
bake_create_raw_target_fn _create_raw_target;
#ifdef USE_REMI
bake_create_fileset_fn _create_fileset;
#endif
......
......@@ -112,8 +112,7 @@ static int transfer_data(bake_file_entry_t* entry,
static void xfer_ult(void* _args);
/* TODO: reorganize this later into the "admin library" model */
int bake_file_makepool(const char* file_name, size_t file_size)
static int bake_file_makepool(const char* file_name, size_t file_size)
{
int fd = -1;
bake_root_t* root;
......@@ -665,6 +664,7 @@ bake_backend g_bake_file_backend = {
._get_region_data = bake_file_get_region_data,
._remove = bake_file_remove,
._migrate_region = bake_file_migrate_region,
._create_raw_target = bake_file_makepool,
#ifdef USE_REMI
._create_fileset = bake_file_create_fileset,
#endif
......
......@@ -11,7 +11,11 @@
#include <unistd.h>
#include <string.h>
#include <libpmemobj.h>
#include <bake-server.h>
#include "bake-backend.h"
extern bake_backend g_bake_pmem_backend;
extern bake_backend g_bake_file_backend;
struct options {
char* pmem_pool;
......@@ -20,9 +24,10 @@ struct options {
void usage(int argc, char* argv[])
{
fprintf(stderr, "Usage: bake-mkpool [OPTIONS] <pmem_pool>\n");
fprintf(stderr, "Usage: bake-mkpool [OPTIONS] <path>\n");
fprintf(stderr,
" pmem_pool is the path to the pmemobj pool to create\n");
" path may be a file, directory, or device depending on the "
"backend.\n");
fprintf(stderr,
" (prepend pmem: or file: to specify backend format)\n");
fprintf(stderr,
......@@ -30,8 +35,8 @@ void usage(int argc, char* argv[])
"specified size (K, M, G, etc. suffixes allowed)\n");
fprintf(stderr, "Example: ./bake-mkpool -s 16M /dev/shm/foo.dat\n");
fprintf(stderr,
"Note: if -s is not specified, then target file must already exist "
"with desired size.\n");
"-s may be omitted if backend supports extending space, or if pool "
"is being created on existing fixed-size device.\n");
return;
}
......@@ -94,11 +99,6 @@ void parse_args(int argc, char* argv[], struct options* opts)
return;
}
/* TODO: this is temporary until we have a more complete solution for admin
* functions.
*/
extern int bake_file_makepool(const char* file_name, size_t file_size);
int main(int argc, char* argv[])
{
struct options opts;
......@@ -118,9 +118,11 @@ int main(int argc, char* argv[])
}
if (strcmp(backend_type, "pmem") == 0) {
ret = bake_makepool(opts.pmem_pool, opts.pool_size);
ret = g_bake_pmem_backend._create_raw_target(opts.pmem_pool,
opts.pool_size);
} else if (strcmp(backend_type, "file") == 0) {
ret = bake_file_makepool(opts.pmem_pool, opts.pool_size);
ret = g_bake_file_backend._create_raw_target(opts.pmem_pool,
opts.pool_size);
} else {
fprintf(stderr, "ERROR: unknown backend type \"%s\"\n", backend_type);
free(backend_type);
......
......@@ -53,7 +53,7 @@ typedef struct xfer_args {
static void xfer_ult(void* _args);
int bake_makepool(const char* pool_name, size_t pool_size)
static int bake_pmem_makepool(const char* pool_name, size_t pool_size)
{
PMEMobjpool* pool;
PMEMoid root_oid;
......@@ -703,6 +703,7 @@ bake_backend g_bake_pmem_backend = {
._get_region_data = bake_pmem_get_region_data,
._remove = bake_pmem_remove,
._migrate_region = bake_pmem_migrate_region,
._create_raw_target = bake_pmem_makepool,
#ifdef USE_REMI
._create_fileset = bake_pmem_create_fileset,
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment