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:
parent
68eda44030
commit
bc1495b0f0
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user