summaryrefslogtreecommitdiffstats
path: root/src/fuse/cowfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fuse/cowfile.c')
-rw-r--r--src/fuse/cowfile.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fuse/cowfile.c b/src/fuse/cowfile.c
index 90ea568..4e27f56 100644
--- a/src/fuse/cowfile.c
+++ b/src/fuse/cowfile.c
@@ -1355,12 +1355,15 @@ static bool padBlockForWrite( fuse_req_t req, cow_request_t *cowRequest,
sub->dRequest.offset = startOffset & ~DNBD3_BLOCK_MASK;
sub->dRequest.fuse_req = req;
+ atomic_fetch_add( &cowRequest->workCounter, 1 );
+
if ( !connection_read( &sub->dRequest ) ) {
free( sub );
errno = ENOTSOCK;
+ // Don't need to go via finishWriteRequest here since the caller will take care of error handling
+ atomic_fetch_sub( &cowRequest->workCounter, 1 );
return false;
}
- atomic_fetch_add( &cowRequest->workCounter, 1 );
return true;
}
@@ -1560,6 +1563,7 @@ fail:
if ( cowRequest->errorCode == 0 ) {
cowRequest->errorCode = errno != 0 ? errno : EIO;
}
+ // Fallthrough
success:
finishWriteRequest( req, cowRequest );
}