summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2019-08-30 09:25:28 +0200
committerSimon Rettberg2019-08-30 09:25:28 +0200
commitebde623c2cdb84eb36e06bbf944efa54aef0e461 (patch)
tree66cfee8ae04039af28176d35b9f7885670bdc336
parent[SERVER] Tear down whole uplink on idle timeout (diff)
downloaddnbd3-ebde623c2cdb84eb36e06bbf944efa54aef0e461.tar.gz
dnbd3-ebde623c2cdb84eb36e06bbf944efa54aef0e461.tar.xz
dnbd3-ebde623c2cdb84eb36e06bbf944efa54aef0e461.zip
[SERVER] No uplink_init when checking working state; improve logging
-rw-r--r--src/server/image.c18
-rw-r--r--src/server/uplink.c1
2 files changed, 11 insertions, 8 deletions
diff --git a/src/server/image.c b/src/server/image.c
index 1972f48..b349058 100644
--- a/src/server/image.c
+++ b/src/server/image.c
@@ -237,7 +237,9 @@ bool image_ensureOpen(dnbd3_image_t *image)
{
if ( image->readFd != -1 ) return image;
int newFd = open( image->path, O_RDONLY );
- if ( newFd != -1 ) {
+ if ( newFd == -1 ) {
+ logadd( LOG_WARNING, "Cannot open %s for reading", image->path );
+ } else {
// Check size
const off_t flen = lseek( newFd, 0, SEEK_END );
if ( flen == -1 ) {
@@ -349,14 +351,14 @@ dnbd3_image_t* image_get(char *name, uint16_t revision, bool checkIfWorking)
logadd( LOG_WARNING, "lseek() on %s failed (errno=%d)%s.", candidate->path, errno, removingText );
reload = true;
} else if ( (uint64_t)len != candidate->realFilesize ) {
- logadd( LOG_DEBUG1, "Size of %s changed at runtime, keeping disabled! Expected: %" PRIu64 ", found: %" PRIu64
+ logadd( LOG_WARNING, "Size of %s changed at runtime, keeping disabled! Expected: %" PRIu64 ", found: %" PRIu64
". Try sending SIGHUP to server if you know what you're doing.",
candidate->path, candidate->realFilesize, (uint64_t)len );
} else {
// Seek worked, file size is same, now see if we can read from file
char buffer[100];
if ( pread( candidate->readFd, buffer, sizeof(buffer), 0 ) == -1 ) {
- logadd( LOG_DEBUG2, "Reading first %d bytes from %s failed (errno=%d)%s.",
+ logadd( LOG_WARNING, "Reading first %d bytes from %s failed (errno=%d)%s.",
(int)sizeof(buffer), candidate->path, errno, removingText );
reload = true;
} else if ( !candidate->working ) {
@@ -370,6 +372,7 @@ dnbd3_image_t* image_get(char *name, uint16_t revision, bool checkIfWorking)
// Could not access the image with exising fd - mark for reload which will re-open the file.
// make a copy of the image struct but keep the old one around. If/When it's not being used
// anymore, it will be freed automatically.
+ logadd( LOG_DEBUG1, "Reloading image file %s", candidate->path );
dnbd3_image_t *img = calloc( sizeof(dnbd3_image_t), 1 );
img->path = strdup( candidate->path );
img->name = strdup( candidate->name );
@@ -400,17 +403,16 @@ dnbd3_image_t* image_get(char *name, uint16_t revision, bool checkIfWorking)
img->users = 0;
image_free( img );
}
+ // Check if image is incomplete, initialize uplink
+ if ( candidate->ref_cacheMap != NULL ) {
+ uplink_init( candidate, -1, NULL, -1 );
+ }
// readFd == -1 and working == FALSE at this point,
// this function needs some splitting up for handling as we need to run most
// of the above code again. for now we know that the next call for this
// name:rid will get ne newly inserted "img" and try to re-open the file.
}
- // Check if image is incomplete, handle
- if ( candidate->ref_cacheMap != NULL ) {
- uplink_init( candidate, -1, NULL, -1 );
- }
-
return candidate; // We did all we can, hopefully it's working
}
diff --git a/src/server/uplink.c b/src/server/uplink.c
index 58f8ea5..52cf417 100644
--- a/src/server/uplink.c
+++ b/src/server/uplink.c
@@ -604,6 +604,7 @@ static void* uplink_mainloop(void *data)
atomic_compare_exchange_strong( &uplink->rttTestResult, &rttTestResult, RTT_IDLE );
discoverFailCount++;
if ( uplink->current.fd == -1 && discoverFailCount > (SERVER_RTT_MAX_UNREACH / 2) ) {
+ logadd( LOG_DEBUG1, "Disabling %s:%d since no uplink is available", uplink->image->name, (int)uplink->image->rid );
uplink->image->working = false;
}
timing_set( &nextAltCheck, &now, (discoverFailCount < SERVER_RTT_MAX_UNREACH ? altCheckInterval : SERVER_RTT_INTERVAL_FAILED) );