summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Scherle2022-09-13 17:25:33 +0200
committerMichael Scherle2022-09-13 17:25:33 +0200
commitfcb44e8d858c50580e802e0078ae5d44ea49591b (patch)
tree2952229c67dc77bdfcb038d0d958bb8b0fd15a97
parentremoved rpm from test workflow (diff)
downloaddnbd3-fcb44e8d858c50580e802e0078ae5d44ea49591b.tar.gz
dnbd3-fcb44e8d858c50580e802e0078ae5d44ea49591b.tar.xz
dnbd3-fcb44e8d858c50580e802e0078ae5d44ea49591b.zip
Fixed cow daemon issue
-rw-r--r--src/cowtest/main.c7
-rw-r--r--src/cowtest/readme.md3
-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
6 files changed, 19 insertions, 21 deletions
diff --git a/src/cowtest/main.c b/src/cowtest/main.c
index 842197c..c2e3161 100644
--- a/src/cowtest/main.c
+++ b/src/cowtest/main.c
@@ -1114,10 +1114,8 @@ static const struct option longOpts[] = {
void printUsageStandardTest()
{
printf( "The standard test, tests certain edge cases. Here the previously prepared file (created with -c) must be mounted via the dnbd3 server.\n");
- printf( "\n" );
printf( "The test performs certain read, write and resize operations to ensure functionality and test for edge cases.\n" );
printf( "\n" );
- printf( "\n" );
printf( "Instructions on how to use the standard test: \n" );
printf( "1. Generate the test image with -c <path> and copy it to the image location of the dnbd3 server. Also make sure that the cow servers OriginalImageDirectory points to the same Directory or copied in that Directory too. This step is only needed once for setting up.\n" );
printf( "2. Start the dnbd3 and cow server.\n" );
@@ -1134,14 +1132,13 @@ void printUsageRandomTest()
printf( "For the random test, a test file (created with -c) is mounted via the dnbd3 server and a copy of it on the normal hard disk is required.");
printf( "The test performs random identical write and size changes on both test files. When the test is cancelled (ctrl+c), both files are tested for equality. \n" );
printf( "\n" );
- printf( "\n" );
printf( "Instructions on how to use the random test: \n" );
printf( "1. Generate the test image with -c <path> and copy it to the image location of the dnbd3 server. Also make sure that the cow servers OriginalImageDirectory points to the same Directory or copied in that Directory too. This step is only needed once for setting up.\n" );
printf( "2. Copy the generated image to another location.\n" );
printf( "3. Start the dnbd3 and cow server.\n" );
printf( "4. Mount the image in cow mode.\n" );
printf( "5. Run the test with -t <mountedFile> <normalFile>, where the <mountedFile> points to the mounted image and <normalFile> points to the copied image on the disk.\n" );
- printf( "6. After some time press enter and both images will be compared for equalness." );
+ printf( "6. After some time press strg+c and both images will be compared for equalness.\n" );
printf( "7. Unmount the image and merge.\n" );
printf( "8. Run -x <mergedFile> <normalFile> where the <mergedFile> points to the merged image and <normalFile> points to the copied image on the disk. This will verify that the merged image is equal to the image on the disk.\n" );
}
@@ -1157,7 +1154,7 @@ void printUsage()
printf( " -d --delay <seconds> Delay in Seconds for multiple block write in the standard test.\n" );
printf( " -t --test <file> Runs the standard test procedure. \n" );
printf( " -v --verify <file> verifies a file. \n" );
- printf( " -r --randomTest <mountedFile> <normalFile> randomly writes in both file's and after cancel(ENTER) compares them if they are equal.\n" );
+ printf( " -r --randomTest <mountedFile> <normalFile> randomly writes in both file's and after cancel(strg+c) compares them if they are equal.\n" );
printf( " -y --minSizePercent <percent> sets the minimum size in percent(integer) the file will be reduced to in the random test.\n" );
printf( " -z --maxSizePercent <percent> sets the maximum size in percent(integer) the file will be enlarged to in the random test.\n" );
printf( " -x --compare <mountedFile> <normalFile> compares two files for equalness.\n" );
diff --git a/src/cowtest/readme.md b/src/cowtest/readme.md
index a990f6c..dae6ecf 100644
--- a/src/cowtest/readme.md
+++ b/src/cowtest/readme.md
@@ -20,6 +20,9 @@ This test collection is used to check whether the cow implementation of the fuse
- `-v <file>` checks if previous tests of the image were successful (also reads the image completely).
- `-r <mountedImageFile> <normalImageFile>` writes randomly and changes the size of two images. After pressing ctrl +c, both images are compared for equality.
- `-x <mergedImageFile> <normalImageFile>` Checks if both images are equal.
+
+
+
### Example usage for standard test
1. Generate the test image with `-c <path>` and copy it into the image directory of the dnbd3 server. Also make sure that the `OriginalImageDirectory` of the Cow server points to the same directory or has also been copied to this directory. This step is only required once for the setup.
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 {