33
44std::unordered_map<std::string, daos_size_t > DFS::size_map;
55
6- #include " absl/strings/str_cat.h"
7- #include " absl/synchronization/mutex.h"
86#include < dlfcn.h>
97#include < stdio.h>
8+
9+ #include " absl/strings/str_cat.h"
10+ #include " absl/synchronization/mutex.h"
1011#undef NDEBUG
1112#include < cassert>
1213
@@ -592,7 +593,7 @@ int DFS::DisconnectContainer(std::string pool_string, std::string cont_string) {
592593 return rc;
593594}
594595
595- ReadBuffer::ReadBuffer (size_t aId, DFS * daos, daos_handle_t aEqh, size_t size)
596+ ReadBuffer::ReadBuffer (size_t aId, DFS* daos, daos_handle_t aEqh, size_t size)
596597 : id(aId), daos(daos), buffer_size(size), eqh(aEqh) {
597598 buffer = new char [size];
598599 buffer_offset = ULONG_MAX;
@@ -651,9 +652,8 @@ int ReadBuffer::ReadAsync(dfs_t* daos_fs, dfs_obj_t* file, const size_t off,
651652 assert (rc == 0 );
652653 rc = daos->libdfs ->daos_event_init (event, eqh, nullptr );
653654 assert (rc == 0 );
654- event->ev_error =
655- daos->libdfs ->dfs_read (daos_fs, file, &rsgl, buffer_offset, &read_size,
656- event);
655+ event->ev_error = daos->libdfs ->dfs_read (daos_fs, file, &rsgl, buffer_offset,
656+ &read_size, event);
657657 return 0 ;
658658}
659659
@@ -691,51 +691,49 @@ int64_t ReadBuffer::CopyFromCache(char* ret, const size_t ret_offset,
691691 return static_cast <int64_t >(aRead_size);
692692}
693693
694- static void *
695- LoadSharedLibrary (const char * library_filename, TF_Status* status)
696- {
697- std::string full_path;
698- char * libdir;
699- void * handle;
700-
701- if ((libdir = std::getenv (" TF_IO_DAOS_LIBRARY_DIR" )) != nullptr ) {
702- full_path = libdir;
703- if (full_path.back () != ' /' ) full_path.push_back (' /' );
704- full_path.append (library_filename);
705- handle = dlopen (full_path.c_str (), RTLD_NOW | RTLD_LOCAL);
706- if (handle != nullptr ) {
707- TF_SetStatus (status, TF_OK, " " );
708- return handle;
709- }
710- }
694+ static void * LoadSharedLibrary (const char * library_filename,
695+ TF_Status* status) {
696+ std::string full_path;
697+ char * libdir;
698+ void * handle;
711699
712- // Check for the library in the installation location used by rpms.
713- full_path = " /usr/lib64/" ;
714- full_path += library_filename;
700+ if ((libdir = std::getenv (" TF_IO_DAOS_LIBRARY_DIR" )) != nullptr ) {
701+ full_path = libdir;
702+ if (full_path.back () != ' /' ) full_path.push_back (' /' );
703+ full_path.append (library_filename);
715704 handle = dlopen (full_path.c_str (), RTLD_NOW | RTLD_LOCAL);
716705 if (handle != nullptr ) {
717- TF_SetStatus (status, TF_OK, " " );
718- return handle;
706+ TF_SetStatus (status, TF_OK, " " );
707+ return handle;
719708 }
709+ }
720710
721- // Check for the library in the location used when building DAOS fom source .
722- full_path = " /opt/daos /lib64/" ;
723- full_path += library_filename;
724- handle = dlopen (full_path.c_str (), RTLD_NOW | RTLD_LOCAL);
725- if (handle != nullptr ) {
726- TF_SetStatus (status, TF_OK, " " );
727- return handle;
728- }
711+ // Check for the library in the installation location used by rpms .
712+ full_path = " /usr /lib64/" ;
713+ full_path += library_filename;
714+ handle = dlopen (full_path.c_str (), RTLD_NOW | RTLD_LOCAL);
715+ if (handle != nullptr ) {
716+ TF_SetStatus (status, TF_OK, " " );
717+ return handle;
718+ }
729719
730- std::string error_message =
731- absl::StrCat (" Library (" , library_filename, " ) not found: " , dlerror ());
732- TF_SetStatus (status, TF_NOT_FOUND, error_message.c_str ());
733- return nullptr ;
720+ // Check for the library in the location used when building DAOS fom source.
721+ full_path = " /opt/daos/lib64/" ;
722+ full_path += library_filename;
723+ handle = dlopen (full_path.c_str (), RTLD_NOW | RTLD_LOCAL);
724+ if (handle != nullptr ) {
725+ TF_SetStatus (status, TF_OK, " " );
726+ return handle;
727+ }
728+
729+ std::string error_message =
730+ absl::StrCat (" Library (" , library_filename, " ) not found: " , dlerror ());
731+ TF_SetStatus (status, TF_NOT_FOUND, error_message.c_str ());
732+ return nullptr ;
734733}
735734
736- static void *
737- GetSymbolFromLibrary (void * handle, const char * symbol_name, TF_Status* status)
738- {
735+ static void * GetSymbolFromLibrary (void * handle, const char * symbol_name,
736+ TF_Status* status) {
739737 if (handle == nullptr ) {
740738 TF_SetStatus (status, TF_INVALID_ARGUMENT, " library handle cannot be null" );
741739 return nullptr ;
@@ -759,70 +757,67 @@ void BindFunc(void* handle, const char* name, std::function<R(Args...)>* func,
759757 GetSymbolFromLibrary (handle, name, status));
760758}
761759
762- libDFS::
763- ~libDFS ()
764- {
765- if (libdaos_handle_ != nullptr ) {
766- dlclose (libdaos_handle_);
767- }
768- if (libdfs_handle_ != nullptr ) {
769- dlclose (libdfs_handle_);
770- }
771- if (libduns_handle_ != nullptr ) {
772- dlclose (libduns_handle_);
773- }
760+ libDFS::~libDFS () {
761+ if (libdaos_handle_ != nullptr ) {
762+ dlclose (libdaos_handle_);
763+ }
764+ if (libdfs_handle_ != nullptr ) {
765+ dlclose (libdfs_handle_);
766+ }
767+ if (libduns_handle_ != nullptr ) {
768+ dlclose (libduns_handle_);
769+ }
774770}
775771
776- void libDFS::LoadAndBindDaosLibs (TF_Status* status)
777- {
778- #define LOAD_DFS_LIBRARY (handle, library_filename, status ) \
779- do { \
780- handle = LoadSharedLibrary (library_filename, status); \
781- if (TF_GetCode (status) != TF_OK) return ; \
772+ void libDFS::LoadAndBindDaosLibs (TF_Status* status) {
773+ #define LOAD_DFS_LIBRARY (handle, library_filename, status ) \
774+ do { \
775+ handle = LoadSharedLibrary (library_filename, status); \
776+ if (TF_GetCode (status) != TF_OK) return ; \
782777 } while (0 );
783778
784- LOAD_DFS_LIBRARY (libdaos_handle_, " libdaos.so" , status);
785- LOAD_DFS_LIBRARY (libdfs_handle_, " libdfs.so" , status);
786- LOAD_DFS_LIBRARY (libduns_handle_, " libduns.so" , status);
779+ LOAD_DFS_LIBRARY (libdaos_handle_, " libdaos.so" , status);
780+ LOAD_DFS_LIBRARY (libdfs_handle_, " libdfs.so" , status);
781+ LOAD_DFS_LIBRARY (libduns_handle_, " libduns.so" , status);
787782
788783#undef LOAD_DFS_LIBRARY
789784
790- #define BIND_DFS_FUNC (handle, function ) \
791- do { \
792- BindFunc (handle, #function, &function, status); \
793- if (TF_GetCode (status) != TF_OK) return ; \
785+ #define BIND_DFS_FUNC (handle, function ) \
786+ do { \
787+ BindFunc (handle, #function, &function, status); \
788+ if (TF_GetCode (status) != TF_OK) return ; \
794789 } while (0 );
795790
796- BIND_DFS_FUNC (libdaos_handle_, daos_cont_close);
797- BIND_DFS_FUNC (libdaos_handle_, daos_cont_open2);
798- BIND_DFS_FUNC (libdaos_handle_, daos_cont_query);
799- BIND_DFS_FUNC (libdaos_handle_, daos_event_init);
800- BIND_DFS_FUNC (libdaos_handle_, daos_event_fini);
801- BIND_DFS_FUNC (libdaos_handle_, daos_event_test);
802- BIND_DFS_FUNC (libdaos_handle_, daos_eq_create);
803- BIND_DFS_FUNC (libdaos_handle_, daos_eq_destroy);
804- BIND_DFS_FUNC (libdaos_handle_, daos_fini);
805- BIND_DFS_FUNC (libdaos_handle_, daos_init);
806- BIND_DFS_FUNC (libdaos_handle_, daos_pool_connect2);
807- BIND_DFS_FUNC (libdaos_handle_, daos_pool_disconnect);
808- BIND_DFS_FUNC (libdaos_handle_, daos_pool_query);
809-
810- BIND_DFS_FUNC (libdfs_handle_, dfs_cont_create_with_label);
811- BIND_DFS_FUNC (libdfs_handle_, dfs_get_size);
812- BIND_DFS_FUNC (libdfs_handle_, dfs_mkdir);
813- BIND_DFS_FUNC (libdfs_handle_, dfs_mount);
814- BIND_DFS_FUNC (libdfs_handle_, dfs_move);
815- BIND_DFS_FUNC (libdfs_handle_, dfs_open);
816- BIND_DFS_FUNC (libdfs_handle_, dfs_ostat);
817- BIND_DFS_FUNC (libdfs_handle_, dfs_read);
818- BIND_DFS_FUNC (libdfs_handle_, dfs_readdir);
819- BIND_DFS_FUNC (libdfs_handle_, dfs_release);
820- BIND_DFS_FUNC (libdfs_handle_, dfs_remove);
821- BIND_DFS_FUNC (libdfs_handle_, dfs_umount);
822- BIND_DFS_FUNC (libdfs_handle_, dfs_write);
823-
824- BIND_DFS_FUNC (libduns_handle_, duns_destroy_attr);
825- BIND_DFS_FUNC (libduns_handle_, duns_resolve_path);
791+ BIND_DFS_FUNC (libdaos_handle_, daos_cont_close);
792+ BIND_DFS_FUNC (libdaos_handle_, daos_cont_open2);
793+ BIND_DFS_FUNC (libdaos_handle_, daos_cont_query);
794+ BIND_DFS_FUNC (libdaos_handle_, daos_event_init);
795+ BIND_DFS_FUNC (libdaos_handle_, daos_event_fini);
796+ BIND_DFS_FUNC (libdaos_handle_, daos_event_test);
797+ BIND_DFS_FUNC (libdaos_handle_, daos_eq_create);
798+ BIND_DFS_FUNC (libdaos_handle_, daos_eq_destroy);
799+ BIND_DFS_FUNC (libdaos_handle_, daos_fini);
800+ BIND_DFS_FUNC (libdaos_handle_, daos_init);
801+ BIND_DFS_FUNC (libdaos_handle_, daos_pool_connect2);
802+ BIND_DFS_FUNC (libdaos_handle_, daos_pool_disconnect);
803+ BIND_DFS_FUNC (libdaos_handle_, daos_pool_query);
804+
805+ BIND_DFS_FUNC (libdfs_handle_, dfs_cont_create_with_label);
806+ BIND_DFS_FUNC (libdfs_handle_, dfs_get_size);
807+ BIND_DFS_FUNC (libdfs_handle_, dfs_mkdir);
808+ BIND_DFS_FUNC (libdfs_handle_, dfs_mount);
809+ BIND_DFS_FUNC (libdfs_handle_, dfs_move);
810+ BIND_DFS_FUNC (libdfs_handle_, dfs_open);
811+ BIND_DFS_FUNC (libdfs_handle_, dfs_ostat);
812+ BIND_DFS_FUNC (libdfs_handle_, dfs_read);
813+ BIND_DFS_FUNC (libdfs_handle_, dfs_readdir);
814+ BIND_DFS_FUNC (libdfs_handle_, dfs_release);
815+ BIND_DFS_FUNC (libdfs_handle_, dfs_remove);
816+ BIND_DFS_FUNC (libdfs_handle_, dfs_umount);
817+ BIND_DFS_FUNC (libdfs_handle_, dfs_write);
818+
819+ BIND_DFS_FUNC (libduns_handle_, duns_destroy_attr);
820+ BIND_DFS_FUNC (libduns_handle_, duns_resolve_path);
826821
827822#undef BIND_DFS_FUNC
828823}
0 commit comments