summaryrefslogtreecommitdiffstats
path: root/src/fuse/connection.c
diff options
context:
space:
mode:
authorSimon Rettberg2023-03-29 12:03:54 +0200
committerSimon Rettberg2024-05-13 18:26:42 +0200
commitec0b9b5f72607335ac19d4ea00c24919943b7970 (patch)
treefaf735a62dff9d88f22c1073b601e5af913cc3e9 /src/fuse/connection.c
parent[FUSE] Fixed cow daemon issue (diff)
downloaddnbd3-ec0b9b5f72607335ac19d4ea00c24919943b7970.tar.gz
dnbd3-ec0b9b5f72607335ac19d4ea00c24919943b7970.tar.xz
dnbd3-ec0b9b5f72607335ac19d4ea00c24919943b7970.zip
[FUSE] cow: Cleanup, comments, fixes, minor refactoring
- Use the term "cluster" for a group of dnbd3-blocks instead of also calling them blocks. - Use term "table" instead of "array" for the L1 and L2 tables. - Use term "index" instead of "offset" when addressing those tables - Fix a few logic bugs, use-after-free - Add TODOs for parts that need better comments
Diffstat (limited to 'src/fuse/connection.c')
-rw-r--r--src/fuse/connection.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/fuse/connection.c b/src/fuse/connection.c
index 018ad89..2264c00 100644
--- a/src/fuse/connection.c
+++ b/src/fuse/connection.c
@@ -506,7 +506,7 @@ static void* connection_receiveThreadMain( void *sockPtr )
}
} else {
// Found a match
- const ssize_t ret = receiveRequest( sockFd, request);
+ const ssize_t ret = receiveRequest( sockFd, request );
if ( ret != (ssize_t)request->length ) {
logadd( LOG_DEBUG1, "receiving payload for a block reply failed" );
connection_read( request );
@@ -527,6 +527,7 @@ static void* connection_receiveThreadMain( void *sockPtr )
}
unlock_rw( &altLock );
}
+ // TODO: See comment in receiveRequest()
if( useCow ) {
cowfile_handleCallback( request );
}
@@ -584,8 +585,8 @@ static void* connection_backgroundThread( void *something UNUSED )
while ( keepRunning ) {
ticks now;
timing_get( &now );
- uint32_t wt1 = timing_diffMs( &now, &nextKeepalive );
- uint32_t wt2 = timing_diffMs( &now, &nextRttCheck );
+ uint32_t wt1 = (uint32_t)timing_diffMs( &now, &nextKeepalive );
+ uint32_t wt2 = (uint32_t)timing_diffMs( &now, &nextRttCheck );
if ( wt1 > 0 && wt2 > 0 ) {
int waitRes = signal_wait( connection.panicSignal, (int)MIN( wt1, wt2 ) + 1 );
if ( !keepRunning )
@@ -955,15 +956,20 @@ fail:
}
}
-static size_t receiveRequest(const int sock, dnbd3_async_t* request ) {
- if(useCow){
+static size_t receiveRequest(const int sock, dnbd3_async_t* request )
+{
+ if( useCow ) {
cow_sub_request_t * cow_request = container_of( request, cow_sub_request_t, dRequest );
- if( cow_request->callback == readRemoteData){
+ // TODO This is ugly, we have a callback so we don't need to special-case receiving the
+ // reply, yet here we check what the callback function is for some reason :-(
+ // Ideally there should be no cow-related code in this file at all.
+ // This requires moving the callback to dnbd3_async_t from cow_sub_request_t though...
+ if( cow_request->callback == readRemoteData ) {
return sock_recv( sock, cow_request->buffer, request->length );
} else{
return sock_recv( sock, &cow_request->writeBuffer, request->length );
}
- } else {
+ } else {
return sock_recv( sock, container_of( request, dnbd3_async_parent_t, request )->buffer, request->length );
}
}