summaryrefslogtreecommitdiffstats
path: root/src/fuse
diff options
context:
space:
mode:
authorMichael Scherle2022-09-13 17:25:33 +0200
committerSimon Rettberg2024-05-13 18:26:36 +0200
commit4e6ef06945c74198c918c1711c82c84a83ddb870 (patch)
treef687ae516639d9f36c9a3540cfdbd3159c6a16f9 /src/fuse
parentgithub: removed rpm from test workflow (diff)
downloaddnbd3-4e6ef06945c74198c918c1711c82c84a83ddb870.tar.gz
dnbd3-4e6ef06945c74198c918c1711c82c84a83ddb870.tar.xz
dnbd3-4e6ef06945c74198c918c1711c82c84a83ddb870.zip
[FUSE] Fixed cow daemon issue
Diffstat (limited to 'src/fuse')
-rw-r--r--src/fuse/cowDoc/readme.md3
-rw-r--r--src/fuse/cowfile.c20
-rw-r--r--src/fuse/cowfile.h2
-rw-r--r--src/fuse/main.c5
4 files changed, 14 insertions, 16 deletions
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 {