From 9602ade76907adf2218a78abfd02e6f0956f3ca0 Mon Sep 17 00:00:00 2001 From: Ziye Yang Date: Fri, 26 Apr 2019 11:08:53 +0800 Subject: [PATCH] blobfs: pass sync_req instead of file as the parameter This avoids to get the first sync_req in the list, instead of make sure which sync_req we want to make it complete. Also release the request early. Change-Id: If6f9b2ab10f0a93e6c45088d33f2aa78d25f66cb Signed-off-by: Ziye Yang Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452136 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Changpeng Liu --- lib/blobfs/blobfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 4aecd2ea2..f29eb9758 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -1992,13 +1992,13 @@ static void __check_sync_reqs(struct spdk_file *file); static void __file_cache_finish_sync(void *ctx, int bserrno) { - struct spdk_file *file = ctx; - struct spdk_fs_request *sync_req; + struct spdk_file *file; + struct spdk_fs_request *sync_req = ctx; struct spdk_fs_cb_args *sync_args; - pthread_spin_lock(&file->lock); - sync_req = TAILQ_FIRST(&file->sync_requests); sync_args = &sync_req->args; + file = sync_args->file; + pthread_spin_lock(&file->lock); assert(sync_args->op.sync.offset <= file->length_flushed); spdk_trace_record(TRACE_BLOBFS_XATTR_END, 0, sync_args->op.sync.offset, 0, file->trace_arg_name); @@ -2007,11 +2007,11 @@ __file_cache_finish_sync(void *ctx, int bserrno) pthread_spin_unlock(&file->lock); sync_args->fn.file_op(sync_args->arg, bserrno); - __check_sync_reqs(file); - pthread_spin_lock(&file->lock); free_fs_request(sync_req); pthread_spin_unlock(&file->lock); + + __check_sync_reqs(file); } static void @@ -2036,7 +2036,7 @@ __check_sync_reqs(struct spdk_file *file) pthread_spin_unlock(&file->lock); spdk_trace_record(TRACE_BLOBFS_XATTR_START, 0, file->length_flushed, 0, file->trace_arg_name); - spdk_blob_sync_md(file->blob, __file_cache_finish_sync, file); + spdk_blob_sync_md(file->blob, __file_cache_finish_sync, sync_req); } else { pthread_spin_unlock(&file->lock); }