summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Rettberg2024-05-15 16:06:06 +0200
committerSimon Rettberg2024-05-15 16:06:06 +0200
commit757280ff1d06174325cc706c7b91d3f9791ce15e (patch)
tree429a408c7973d46f4e371f4b3f72dbc84d18ba6c /src
parent[FUSE] Buffer upload reply contents and conditionally print (diff)
downloaddnbd3-757280ff1d06174325cc706c7b91d3f9791ce15e.tar.gz
dnbd3-757280ff1d06174325cc706c7b91d3f9791ce15e.tar.xz
dnbd3-757280ff1d06174325cc706c7b91d3f9791ce15e.zip
[FUSE] cow: stats.txt -> stats
Diffstat (limited to 'src')
-rw-r--r--src/fuse/cowDoc/readme.md16
-rw-r--r--src/fuse/cowfile.c15
2 files changed, 17 insertions, 14 deletions
diff --git a/src/fuse/cowDoc/readme.md b/src/fuse/cowDoc/readme.md
index 2b752bb..51a0052 100644
--- a/src/fuse/cowDoc/readme.md
+++ b/src/fuse/cowDoc/readme.md
@@ -24,12 +24,12 @@ A typical use case is updating or adding software to an existing image.
- `- L <path>` Similar to `-c <path>`, but instead of creating a new session, an existing one is loaded from the specified path.
- `-m` the client requests a merge after the image has been unmounted and all changes have been uploaded.
-- `--cowStatFile` creates a status file at the same location as the data and meta file. The file contains information about the current session, for more information see [here](#status).
-- `--cowStatStdout` similar to `--cowStatFile` but the information will be printed in the stdout.
+- `--cow-stats-file` creates a status file at the same location as the data and meta file. The file contains information about the current session, for more information see [here](#status).
+- `--cow-stats-stdout` similar to `--cow-stats-file` but the information will be printed in the stdout.
Example parameters for creating a new cow session:
```
-./dnbd3-fuse "/home/user/VMs/mount" -f -h localhost -i imagename -c "/home/user/temp" -C "192.168.178.20:5000" --cowStatStdout -m
+./dnbd3-fuse "/home/user/VMs/mount" -f -h localhost -i imagename -c "/home/user/temp" -C "192.168.178.20:5000" --cow-stats-stdout -m
```
@@ -117,11 +117,11 @@ There are two different limits for the number of parallel uploads in the [config
## Files
-When a new CoW session is started, a new `meta`, `data` and, if so set in the command line arguments, a `status.txt` file is created.
+When a new CoW session is started, a new `meta`, `data` and, if so set in the command line arguments, a `status` file is created.
### status
-The file `status.txt` can be activated with the command line parameter `--cowStatFile`.
+The file `status` can be activated with the command line parameter `--cow-stats-file`.
The file will contain the following:
@@ -147,9 +147,9 @@ It is `done` when the image has been unmounted and all clusters have been upload
- `ulspeed` the current upload speed in kb/s.
Once all clusters have been uploaded, the status is set to `done`.
-If you define `COW_DUMP_BLOCK_UPLOADS`, a list of all clusters, sorted by the number of uploads, is copied to the status.txt file after the cluster upload is completed.
+If you define `COW_DUMP_BLOCK_UPLOADS`, a list of all clusters, sorted by the number of uploads, is copied to the status file after the cluster upload is completed.
-With the command line parameter `--cowStatStdout` the same output of the stats file will be printed in stdout.
+With the command line parameter `--cow-stats-stdout` the same output of the stats file will be printed in stdout.
### meta
@@ -231,7 +231,7 @@ The following configuration variables have been added to `config/cow.h`.
- `COW_MIN_UPLOAD_DELAY` sets the minimum time in seconds that must have elapsed since the last change to a cow cluster before it is uploaded.
This value can be fine-tuned. A larger value usually reduces redundant uploading of clusters.
A smaller value reduces the time for the final upload after the image has been unmounted.
-If you set `COW_DUMP_BLOCK_UPLOADS` and set the command line parameter `--cowStatFile`, then a list of all clusters, sorted by the number of uploads, will be written to the status.txt file after the cluster upload is complete.
+If you set `COW_DUMP_BLOCK_UPLOADS` and set the command line parameter `--cow-stats-file`, then a list of all clusters, sorted by the number of uploads, will be written to the status file after the cluster upload is complete.
This can help in fine-tuning `COW_MIN_UPLOAD_DELAY`.
- `COW_STATS_UPDATE_TIME` defines the update frequency of the stdout output/statistics file in seconds. Setting it too low could affect performance as a loop runs over all clusters.
- `COW_MAX_PARALLEL_BACKGROUND_UPLOADS` defines the maximum number of parallel cluster uploads. This number is used when the image is still mounted and the user is still using it.
diff --git a/src/fuse/cowfile.c b/src/fuse/cowfile.c
index b183202..525eef0 100644
--- a/src/fuse/cowfile.c
+++ b/src/fuse/cowfile.c
@@ -424,9 +424,10 @@ static void dumpBlockUploads()
}
qsort( blockUploads, currentBlock, sizeof( cow_cluster_statistics_t ), cmpfunc );
- dprintf( cow.fdStats, "\n\nclusterNumber: uploads\n==Block Upload Dump===\n" );
+ dprintf( cow.fdStats, "\n\n[BlockStats]\n" );
for ( uint64_t i = 0; i < currentBlock; i++ ) {
- dprintf( cow.fdStats, "%" PRIu64 ": %" PRIu64 " \n", blockUploads[i].clusterNumber, blockUploads[i].uploads );
+ dprintf( cow.fdStats, "%" PRIu64 "=%" PRIu64 " \n",
+ blockUploads[i].clusterNumber, blockUploads[i].uploads );
}
}
#endif
@@ -454,6 +455,7 @@ static void updateCowStatsFile( uint64_t inQueue, uint64_t modified, uint64_t id
int len = snprintf( buffer, sizeof buffer,
"[General]\n"
+ "uuid=%s\n"
"state=%s\n"
"inQueue=%" PRIu64 "\n"
"modifiedClusters=%" PRIu64 "\n"
@@ -461,6 +463,7 @@ static void updateCowStatsFile( uint64_t inQueue, uint64_t modified, uint64_t id
"totalClustersUploaded=%" PRIu64 "\n"
"activeUploads=%i\n"
"%s%s\n",
+ metadata->uuid,
state, inQueue, modified, idle, totalBlocksUploaded, activeUploads,
COW_SHOW_UL_SPEED ? "avgSpeedKb=" : "",
speedBuffer );
@@ -478,12 +481,12 @@ static void updateCowStatsFile( uint64_t inQueue, uint64_t modified, uint64_t id
// Pad with a bunch of newlines so we don't change the file size all the time
ssize_t extra = MIN( 20, (ssize_t)sizeof(buffer) - len - 1 );
memset( buffer + len, '\n', extra );
- lseek( cow.fdStats, 43, SEEK_SET );
- if ( write( cow.fdStats, buffer, len + extra ) != len + extra ) {
+ if ( pwrite( cow.fdStats, buffer, len + extra, 0 ) != len + extra ) {
logadd( LOG_WARNING, "Could not update cow status file" );
}
#ifdef COW_DUMP_BLOCK_UPLOADS
if ( !uploadLoop && uploadLoopDone ) {
+ lseek( cow.fdStats, len + extra, SEEK_SET );
dumpBlockUploads();
}
#endif
@@ -883,10 +886,10 @@ static bool createCowStatsFile( char *path )
{
char pathStatus[strlen( path ) + 12];
- snprintf( pathStatus, strlen( path ) + 12, "%s%s", path, "/status.txt" );
+ snprintf( pathStatus, strlen( path ) + 12, "%s%s", path, "/status" );
char buffer[100];
- int len = snprintf( buffer, 100, "uuid=%s\nstate: active\n", metadata->uuid );
+ int len = snprintf( buffer, 100, "[General]\nuuid=%s\nstate=active\n", metadata->uuid );
if ( statStdout ) {
logadd( LOG_INFO, "%s", buffer );
}