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: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453788
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ziye Yang 2019-05-09 22:13:41 +08:00 committed by Jim Harris
parent 68eda44030
commit bc1495b0f0

View File

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