Direct I/O Reads Handle the last sector correctly.
Summary: Currently, in the Direct I/O read mode, the last sector of the file, if not full, is not handled correctly. If the return value of pread is not multiplier of kSectorSize, we still go ahead and continue reading, even if the buffer is not aligned. With the commit, if the return value is not multiplier of kSectorSize, and all but the last sector has been read, we simply return. Closes https://github.com/facebook/rocksdb/pull/1550 Differential Revision: D4209609 Pulled By: lightmark fbshipit-source-id: cb0b439
This commit is contained in:
parent
9d60151b04
commit
73843aa636
@ -105,6 +105,11 @@ Status ReadAligned(int fd, Slice* data, const uint64_t offset,
|
||||
break;
|
||||
}
|
||||
bytes_read += status;
|
||||
if (status % static_cast<ssize_t>(kSectorSize) != 0) {
|
||||
// Bytes reads don't fill sectors. Should only happen at the end
|
||||
// of the file.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
*data = Slice(scratch, bytes_read);
|
||||
|
Loading…
x
Reference in New Issue
Block a user