From 4e6ef06945c74198c918c1711c82c84a83ddb870 Mon Sep 17 00:00:00 2001 From: Michael Scherle Date: Tue, 13 Sep 2022 17:25:33 +0200 Subject: [FUSE] Fixed cow daemon issue --- src/fuse/cowDoc/readme.md | 3 --- src/fuse/cowfile.c | 20 ++++++++------------ src/fuse/cowfile.h | 2 +- src/fuse/main.c | 5 +++++ 4 files changed, 14 insertions(+), 16 deletions(-) (limited to 'src/fuse') diff --git a/src/fuse/cowDoc/readme.md b/src/fuse/cowDoc/readme.md index 27b6bc6..e7abadf 100644 --- a/src/fuse/cowDoc/readme.md +++ b/src/fuse/cowDoc/readme.md @@ -36,9 +36,6 @@ Example parameters for creating a new cow session: # Implementation Details - - - ## Data structure The data structure is divided into two main parts. The actual data of the writing on the image and the corresponding metadata. It is also important to distinguish between a dnbd3 block, which is 4096 bytes in size, and a cow block, which combines 320 dnbd3 blocks. A cow block has a `cow_block_metadata_t` structure that contains the corresponding metadata. The metadata is used to determine if a dnbd3 block has been written to, where that block is stored in the `data` file, when it was last modified and when it was uploaded. But more on this later. diff --git a/src/fuse/cowfile.c b/src/fuse/cowfile.c index 5b4eb95..b2df74f 100644 --- a/src/fuse/cowfile.c +++ b/src/fuse/cowfile.c @@ -818,18 +818,7 @@ bool cowfile_init( char *path, const char *image_Name, uint16_t imageVersion, at if ( !createSession( image_Name, imageVersion ) ) { return false; } - createCowStatsFile( path ); - if( pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ) != 0 ) { - logadd( LOG_ERROR, "Could not create cow uploader thread"); - return false; - } - if ( statFile || statStdout ) { - if(pthread_create( &tidStatUpdater, NULL, &cowfile_statUpdater, NULL ) != 0 ) { - logadd( LOG_ERROR, "Could not create stat updater thread"); - return false; - } - } return true; } @@ -936,6 +925,14 @@ bool cowfile_load( char *path, atomic_uint_fast64_t **imageSizePtr, char *server cow.firstL2 = (l2 *)( ( (char *)cow.l1 ) + cow.l1Size ); pthread_mutex_init( &cow.l2CreateLock, NULL ); createCowStatsFile( path ); + return true; +} +/** + * @brief Starts the cow BackgroundThreads which are needed for stats and data upload + * + */ +bool cowfile_startBackgroundThreads() { + if( pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ) != 0 ) { logadd( LOG_ERROR, "Could not create cow uploader thread"); return false; @@ -946,7 +943,6 @@ bool cowfile_load( char *path, atomic_uint_fast64_t **imageSizePtr, char *server return false; } } - return true; } diff --git a/src/fuse/cowfile.h b/src/fuse/cowfile.h index c74ab99..d91d122 100644 --- a/src/fuse/cowfile.h +++ b/src/fuse/cowfile.h @@ -118,7 +118,7 @@ bool cowfile_init( char *path, const char *image_Name, uint16_t imageVersion, at char *serverAddress, bool sStdout, bool sFile ); bool cowfile_load( char *path, atomic_uint_fast64_t **imageSizePtr, char *serverAddress, bool sStdout, bool sFile ); - +bool cowfile_startBackgroundThreads(); void cowfile_read( fuse_req_t req, size_t size, off_t offset ); void cowfile_write( fuse_req_t req, cow_request_t *cowRequest, off_t offset, size_t size ); diff --git a/src/fuse/main.c b/src/fuse/main.c index 1ae6d33..6e7977c 100644 --- a/src/fuse/main.c +++ b/src/fuse/main.c @@ -580,6 +580,11 @@ int main( int argc, char *argv[] ) } else { fuse_session_add_chan( _fuseSession, ch ); fuse_daemonize( foreground ); + if ( useCow ) { + if ( !cowfile_startBackgroundThreads() ){ + logadd( LOG_ERROR, "Could not start cow background Threads" ); + } + } if ( single_thread ) { fuse_err = fuse_session_loop( _fuseSession ); } else { -- cgit v1.2.3-55-g7522