From edc5610fbc70a08c4b52f5c42a1ab22622319fcb Mon Sep 17 00:00:00 2001 From: Cunyin Chang Date: Thu, 4 Jan 2018 15:50:20 +0800 Subject: [PATCH] blobfs: release the lock before send the flush request when try to write file. This makes spdk_file_write consistent with _file_sync. The lock should not be held across calls to send_request. Change-Id: I2a2987bbfe2688b520901267aa5a197bd55565a8 Signed-off-by: Cunyin Chang Reviewed-on: https://review.gerrithub.io/393599 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index a4eed47f1..5811ee3a4 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -2075,20 +2075,19 @@ spdk_file_write(struct spdk_file *file, struct spdk_io_channel *_channel, } } + pthread_spin_unlock(&file->lock); + if (cache_buffers_filled == 0) { - pthread_spin_unlock(&file->lock); return 0; } args = calloc(1, sizeof(*args)); if (args == NULL) { - pthread_spin_unlock(&file->lock); return -ENOMEM; } args->file = file; file->fs->send_request(__file_flush, args); - pthread_spin_unlock(&file->lock); return 0; }