Loading ifs/src/api/CMakeLists.txt +10 −0 Original line number Diff line number Diff line cmake_minimum_required(VERSION 3.6) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 11) set(WARNINGS_FLAGS "-Wall -Wextra --pedantic -Wno-unused-parameter") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O3") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${WARNINGS_FLAGS} -g -O0") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${WARNINGS_FLAGS} -g -O0") add_library(gekkofs_api SHARED "") add_library(gekkofs_capi SHARED "") target_sources(gekkofs_api PUBLIC Loading @@ -14,3 +17,10 @@ target_sources(gekkofs_api PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libgekkofs-api.cpp ) target_sources(gekkofs_capi PUBLIC ${CMAKE_CURRENT_LIST_DIR}/gekkofs.h PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libgekkofs-api.c ) ifs/src/api/gekkofs.h +197 −6 Original line number Diff line number Diff line #ifndef __GEKKOFS_API_H__ #define __GEKKOFS_API_H__ 1 #include <sys/types.h> #include <stdint.h> #ifndef GEKKOFS_API_VERSION #define GEKKOFS_API_VERSION 10 #endif Loading @@ -9,14 +12,202 @@ extern "C" { #endif enum gekkofs_error_t { /******************************************************************************/ /** Common types */ /******************************************************************************/ /** Server ID type */ typedef uint32_t gfs_server_id_t; /** Server name type */ typedef const char* gfs_server_name_t; /** File version ID type */ typedef const char* gfs_vid_t; /** Error codes */ typedef enum { /* Generic */ GEKKOFS_SUCCESS = 0 //TODO add more error codes } gfs_error_t; /******************************************************************************/ /** Definitions for file distribution policies */ /******************************************************************************/ /** * Pseudo-randomized file chunking: * * This policy splits a file imported into GekkoFS into fixed-sized chunks which * are then pseudo-randomly distributed among all available data servers. * */ typedef struct { /** The algorithm to use for chunk distribution */ enum { /** Use C++ std::hash() function */ FA_CHUNKING_ALGO_STDHASH //TODO add more algorithms } fa_chunk_algo; /** The chunk size in bytes used for splitting files */ size_t fa_chunk_size; } gfs_falloc_chunking_args_t; /** * File striping: * * This policy splits a file imported into GekkoFS into fixed-sized stripes * which are then distributed in a round-robin fashion among all available data * servers. * */ typedef struct { /** The stripe size in bytes used for splitting files */ size_t fa_stripe_size; } gfs_falloc_striping_args_t; /** * File allocation policy: * * This structure defines the file allocation policy to use when importing a * file into GekkoFS. * */ typedef struct { /** Desired file allocation policy */ enum { /** The file is considered as an indivisible unit by GekkoFS, * and hence will be managed by only one data server */ GEKKOFS_FILE_UNIT, /** Pseudo-random file chunking (requires initializing the * .fa_chunking_args field ) */ GEKKOFS_FILE_CHUNKING, /** Round robin file striping (requires initializing the * .fa_striping field ) */ GEKKOFS_FILE_STRIPING } fa_type; /** Specific arguments for the file allocation policy */ union { /** Arguments for GEKKOFS_FILE_CHUNKING */ gfs_falloc_chunking_args_t fa_chunking_args; /** Arguments for GEKKOFS_FILE_STRIPING */ gfs_falloc_striping_args_t fa_striping_args; }; } gfs_falloc_t; /******************************************************************************/ /** Basic GekkoFS API */ /******************************************************************************/ /** * Import a file into GekkoFS * * @param: in_pathname the path to the file to import * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: alloc_policy the data allocation policy for the file * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_import(const char* in_pathname, const char* gekkofs_pathname, gfs_falloc_t alloc_policy); /** * Export a file out of GekkoFS into another POSIX filesystem, and remove it * from GekkoFS when finished * * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: out_pathname the path where the file should be exported * @param: alloc_policy the data allocation policy for the file * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_export(const char* gekkofs_pathname, const char* out_pathname); /** * Commands supported by gfs_fcntl() * */ typedef enum { /** Retrieve list of data server IDs where the file is located. * Expected arguments: * * gfs_server_name_t* list[]: an input/output argument that can be * initialized by the API with a NULL terminated array containing the * names of the servers involved with this file. The array returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. **/ F_GET_LOCATIONS, /** Create a new version of the file. * Expected arguments: * * gfs_vid_t* new_vid: an input/output argument to be filled by the API * with the ID generated for the new version. The argument returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. * */ F_NEW_VERSION, /** Get the current version of the file. * Expected arguments: * * gfs_vid_t* vid: an input/output argument to be filled by the API * with the ID generated for the new version. The argument returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. * */ F_GET_CURRENT_VERSION, /** Set the current version of the file. * Expected arguments: * * const gfs_vid_t* vid: an input argument specifying the VID desired * by the caller. * */ F_SET_CURRENT_VERSION } gfs_cmd_t; // TODO: add interfaces here // gekkofs_error_t gekkofs_import(const char* pathname); /** * Manipulate a GekkoFS file * * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: cmd the command to perform on the file (see the definition of * gfs_cmd_t for details) * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_fcntl(const char* gekkofs_pathname, gfs_cmd_t cmd, gfs_server_name_t* foo[], ... /* arg */); #ifdef __cplusplus } Loading ifs/src/api/libgekkofs-api.c 0 → 120000 +1 −0 Original line number Diff line number Diff line libgekkofs-api.cpp No newline at end of file ifs/src/api/libgekkofs-api.cpp +28 −4 Original line number Diff line number Diff line #include "gekkofs.h" gekkofs_error_t gekkofs_import(const char* pathname) { gfs_error_t gfs_import(const char* in_pathname, const char* gekkofs_pathname, gfs_falloc_t alloc_policy) { int b = 2; unsigned int a = b; (void) in_pathname; (void) gekkofs_pathname; return GEKKOFS_SUCCESS; } gfs_error_t gfs_export(const char* gekkofs_pathname, const char* out_pathname) { (void) gekkofs_pathname; (void) out_pathname; return GEKKOFS_SUCCESS; } gfs_error_t gfs_fcntl(const char* gekkofs_pathname, gfs_cmd_t cmd, gfs_server_name_t* foo[], ... /* arg */) { (void) gekkofs_pathname; (void) cmd; return GEKKOFS_SUCCESS; } Loading
ifs/src/api/CMakeLists.txt +10 −0 Original line number Diff line number Diff line cmake_minimum_required(VERSION 3.6) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_C_STANDARD 11) set(WARNINGS_FLAGS "-Wall -Wextra --pedantic -Wno-unused-parameter") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -O3") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${WARNINGS_FLAGS} -g -O0") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${WARNINGS_FLAGS} -g -O0") add_library(gekkofs_api SHARED "") add_library(gekkofs_capi SHARED "") target_sources(gekkofs_api PUBLIC Loading @@ -14,3 +17,10 @@ target_sources(gekkofs_api PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libgekkofs-api.cpp ) target_sources(gekkofs_capi PUBLIC ${CMAKE_CURRENT_LIST_DIR}/gekkofs.h PRIVATE ${CMAKE_CURRENT_LIST_DIR}/libgekkofs-api.c )
ifs/src/api/gekkofs.h +197 −6 Original line number Diff line number Diff line #ifndef __GEKKOFS_API_H__ #define __GEKKOFS_API_H__ 1 #include <sys/types.h> #include <stdint.h> #ifndef GEKKOFS_API_VERSION #define GEKKOFS_API_VERSION 10 #endif Loading @@ -9,14 +12,202 @@ extern "C" { #endif enum gekkofs_error_t { /******************************************************************************/ /** Common types */ /******************************************************************************/ /** Server ID type */ typedef uint32_t gfs_server_id_t; /** Server name type */ typedef const char* gfs_server_name_t; /** File version ID type */ typedef const char* gfs_vid_t; /** Error codes */ typedef enum { /* Generic */ GEKKOFS_SUCCESS = 0 //TODO add more error codes } gfs_error_t; /******************************************************************************/ /** Definitions for file distribution policies */ /******************************************************************************/ /** * Pseudo-randomized file chunking: * * This policy splits a file imported into GekkoFS into fixed-sized chunks which * are then pseudo-randomly distributed among all available data servers. * */ typedef struct { /** The algorithm to use for chunk distribution */ enum { /** Use C++ std::hash() function */ FA_CHUNKING_ALGO_STDHASH //TODO add more algorithms } fa_chunk_algo; /** The chunk size in bytes used for splitting files */ size_t fa_chunk_size; } gfs_falloc_chunking_args_t; /** * File striping: * * This policy splits a file imported into GekkoFS into fixed-sized stripes * which are then distributed in a round-robin fashion among all available data * servers. * */ typedef struct { /** The stripe size in bytes used for splitting files */ size_t fa_stripe_size; } gfs_falloc_striping_args_t; /** * File allocation policy: * * This structure defines the file allocation policy to use when importing a * file into GekkoFS. * */ typedef struct { /** Desired file allocation policy */ enum { /** The file is considered as an indivisible unit by GekkoFS, * and hence will be managed by only one data server */ GEKKOFS_FILE_UNIT, /** Pseudo-random file chunking (requires initializing the * .fa_chunking_args field ) */ GEKKOFS_FILE_CHUNKING, /** Round robin file striping (requires initializing the * .fa_striping field ) */ GEKKOFS_FILE_STRIPING } fa_type; /** Specific arguments for the file allocation policy */ union { /** Arguments for GEKKOFS_FILE_CHUNKING */ gfs_falloc_chunking_args_t fa_chunking_args; /** Arguments for GEKKOFS_FILE_STRIPING */ gfs_falloc_striping_args_t fa_striping_args; }; } gfs_falloc_t; /******************************************************************************/ /** Basic GekkoFS API */ /******************************************************************************/ /** * Import a file into GekkoFS * * @param: in_pathname the path to the file to import * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: alloc_policy the data allocation policy for the file * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_import(const char* in_pathname, const char* gekkofs_pathname, gfs_falloc_t alloc_policy); /** * Export a file out of GekkoFS into another POSIX filesystem, and remove it * from GekkoFS when finished * * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: out_pathname the path where the file should be exported * @param: alloc_policy the data allocation policy for the file * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_export(const char* gekkofs_pathname, const char* out_pathname); /** * Commands supported by gfs_fcntl() * */ typedef enum { /** Retrieve list of data server IDs where the file is located. * Expected arguments: * * gfs_server_name_t* list[]: an input/output argument that can be * initialized by the API with a NULL terminated array containing the * names of the servers involved with this file. The array returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. **/ F_GET_LOCATIONS, /** Create a new version of the file. * Expected arguments: * * gfs_vid_t* new_vid: an input/output argument to be filled by the API * with the ID generated for the new version. The argument returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. * */ F_NEW_VERSION, /** Get the current version of the file. * Expected arguments: * * gfs_vid_t* vid: an input/output argument to be filled by the API * with the ID generated for the new version. The argument returned * is malloc()'ed by the API and it is the callers responsibility to * free() it when done. * */ F_GET_CURRENT_VERSION, /** Set the current version of the file. * Expected arguments: * * const gfs_vid_t* vid: an input argument specifying the VID desired * by the caller. * */ F_SET_CURRENT_VERSION } gfs_cmd_t; // TODO: add interfaces here // gekkofs_error_t gekkofs_import(const char* pathname); /** * Manipulate a GekkoFS file * * @param: gekkofs_pathname the path used in GekkoFS to refer to the file * @param: cmd the command to perform on the file (see the definition of * gfs_cmd_t for details) * * @return: GEKKOFS_SUCCESS on success, * TODO, otherwise * */ gfs_error_t gfs_fcntl(const char* gekkofs_pathname, gfs_cmd_t cmd, gfs_server_name_t* foo[], ... /* arg */); #ifdef __cplusplus } Loading
ifs/src/api/libgekkofs-api.c 0 → 120000 +1 −0 Original line number Diff line number Diff line libgekkofs-api.cpp No newline at end of file
ifs/src/api/libgekkofs-api.cpp +28 −4 Original line number Diff line number Diff line #include "gekkofs.h" gekkofs_error_t gekkofs_import(const char* pathname) { gfs_error_t gfs_import(const char* in_pathname, const char* gekkofs_pathname, gfs_falloc_t alloc_policy) { int b = 2; unsigned int a = b; (void) in_pathname; (void) gekkofs_pathname; return GEKKOFS_SUCCESS; } gfs_error_t gfs_export(const char* gekkofs_pathname, const char* out_pathname) { (void) gekkofs_pathname; (void) out_pathname; return GEKKOFS_SUCCESS; } gfs_error_t gfs_fcntl(const char* gekkofs_pathname, gfs_cmd_t cmd, gfs_server_name_t* foo[], ... /* arg */) { (void) gekkofs_pathname; (void) cmd; return GEKKOFS_SUCCESS; }