From 3551d4159392aa03668ed65bc83ce39d25030829 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 13 Nov 2013 17:27:19 +0100 Subject: [SERVER] Don't lock on image array when saving cache maps --- src/server/image.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/image.c b/src/server/image.c index f9e8ea1..4c296af 100644 --- a/src/server/image.c +++ b/src/server/image.c @@ -160,11 +160,9 @@ void image_markComplete(dnbd3_image_t *image) */ void image_saveAllCacheMaps() { - spin_lock( &_images_lock ); for (int i = 0; i < _num_images; ++i) { image_saveCacheMap( _images[i] ); } - spin_unlock( &_images_lock ); } /** @@ -638,7 +636,11 @@ static int image_try_load(char *base, char *path, int withUplink) goto load_error; } else if ( existing->cache_map != NULL && cache_map == NULL ) { // Image seems complete now! + memlogf( "[INFO] Image %s is complete on disk now!", existing->lower_name ); memset( existing->cache_map, -1, IMGSIZE_TO_MAPBYTES(existing->filesize) ); + spin_lock( &existing->lock ); + image_markComplete( existing ); + spin_unlock( &existing->lock ); function_return = TRUE; goto load_error; } else { // Nothing changed about the existing image, so do nothing -- cgit v1.2.3-55-g7522