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.

Signed-off-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453788 (master)

(cherry picked from commit bc1495b0f0)
Change-Id: I05281a74bef78e4f80ce8d202b47849d1e6c2009
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457285
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Ziye Yang 2019-05-09 22:13:41 +08:00 committed by Ben Walker
parent 91096c9e4f
commit 880cbc5da3

View File

@ -2456,6 +2456,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;
@ -2464,7 +2466,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) {