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 <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/367265
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Ben Walker 2017-06-27 10:09:34 -07:00 committed by Jim Harris
parent 596f92f583
commit 45f7571a08

View File

@ -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) {