bake-server.h 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * (C) 2016 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

#ifndef __BAKE_SERVER_H
#define __BAKE_SERVER_H

#include <margo.h>
#include <libpmemobj.h>
#include "bake.h"

#ifdef __cplusplus
extern "C" {
#endif

18 19 20 21 22 23
#define BAKE_ABT_POOL_DEFAULT ABT_POOL_NULL
#define BAKE_MPLEX_ID_DEFAULT 0
#define BAKE_PROVIDER_IGNORE NULL

typedef struct bake_server_context_t* bake_provider_t;

24 25 26 27
/**
 * Creates a BAKE pool to use for backend PMEM storage.
 * 
 * NOTE: This function must be called on a pool before the pool
28
 * can be passed to 'bake_provider_register'.
29 30 31 32 33 34
 *
 * @param[in] pool_name path to PMEM backend file
 * @param[in] pool_size size of the created pool
 * @param[in] pool_mode mode of the created pool
 * @returns 0 on success, -1 otherwise
 */
35
int bake_makepool(
36 37 38 39 40
    const char *pool_name,
    size_t pool_size,
    mode_t pool_mode);

/**
41
 * Initializes a BAKE provider.
42 43
 *
 * @param[in] mid Margo instance identifier
44 45
 * @param[in] mplex_id Multiplex id
 * @param[in] pool Pool on which to run the RPC handlers
46
 * @param[in] target_name path to PMEM backend file
47
 * @param[out] provider resulting provider
48 49
 * @returns 0 on success, -1 otherwise
 */
50
int bake_provider_register(
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
        margo_instance_id mid,
        uint8_t mplex_id,
        ABT_pool pool,
        bake_provider_t* provider);

/**
 * Makes the provider start managing a target.
 * The target must have been previously created with bake_makepool,
 * and it should not be managed by another provider (whether in this
 * proccess or another).
 *
 * @param provider Bake provider
 * @param target_name path to pmem target
 * @param target_id resulting id identifying the target
 *
 * @return 0 on success, -1 on failure
 */
int bake_provider_add_storage_target(
        bake_provider_t provider,
        const char *target_name,
        bake_target_id_t* target_id);

/**
 * Makes the provider stop managing a target.
 *
 * @param provider Bake provider
 * @param target_id id of the target to remove
 *
 * @return 0 on success, -1 on failure
 */
int bake_provider_remove_storage_target(
        bake_provider_t provider,
        bake_target_id_t target_id);

/**
 * Removes all the targets associated with a provider.
 *
 * @param provider Bake provider
 *
 * @return 0 on success, -1 on failure
 */
int bake_provider_remove_all_storage_targets(
        bake_provider_t provider);

/**
 * Returns the number of targets that this provider manages.
 *
 * @param provider Bake provider
 * @param num_targets resulting number of targets
 *
 * @return 0 on success, -1 on failure
 */
int bake_provider_count_storage_targets(
        bake_provider_t provider,
        uint64_t* num_targets);

/**
 * List the target ids of the targets managed by this provider.
 * The targets array must be pre-allocated with at least enough
 * space to hold all the targets (use bake_provider_count_storage_targets
 * to know how many storage targets are managed).
 *
 * @param provider Bake provider
 * @param targets resulting targer ids
 *
 * @return 0 on success, -1 on failure
 */
int bake_provider_list_storage_targets(
        bake_provider_t provider,
        bake_target_id_t* targets);
121 122 123 124 125 126

#ifdef __cplusplus
}
#endif

#endif /* __BAKE_SERVER_H */