From 45f7571a08ed25a4d3f9453f4a4ee245835feeb8 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Tue, 27 Jun 2017 10:09:34 -0700 Subject: [PATCH] blobfs: Fix bug when reading unwritten region after truncate If a file is extended and then the new region is immediately read without being written, there as a math error in the buffer cache. Change-Id: Ibd2bbe98c734f98df43eada799ed62de4081964b Signed-off-by: Ben Walker Reviewed-on: https://review.gerrithub.io/367265 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris --- lib/blobfs/blobfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 54e8375b54..36538ef722 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -2075,13 +2075,13 @@ spdk_file_read(struct spdk_file *file, struct spdk_io_channel *_channel, file->open_for_writing = false; - if (length == 0 || offset >= file->length) { + if (length == 0 || offset >= file->append_pos) { pthread_spin_unlock(&file->lock); return 0; } - if (offset + length > file->length) { - length = file->length - offset; + if (offset + length > file->append_pos) { + length = file->append_pos - offset; } if (offset != file->next_seq_offset) {