Commit bc1495b0 authored by Ziye Yang's avatar Ziye Yang Committed by Jim Harris
Browse files

blobfs: fix the semphore usage issue in spdk_file_read



We need to move sub_reads++ statement earlier. Otherwise if
the read fails, the sem_wait(&channel->sem) call number
is not correct.

Change-Id: I05281a74bef78e4f80ce8d202b47849d1e6c2009
Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453788


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 68eda440
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -2539,6 +2539,8 @@ spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
		if (length > (final_offset - offset)) {
			length = final_offset - offset;
		}

		sub_reads++;
		rc = __file_read(file, payload, offset, length, channel);
		if (rc == 0) {
			final_length += length;
@@ -2547,7 +2549,6 @@ spdk_file_read(struct spdk_file *file, struct spdk_fs_thread_ctx *ctx,
		}
		payload += length;
		offset += length;
		sub_reads++;
	}
	pthread_spin_unlock(&file->lock);
	while (sub_reads-- > 0) {