Assert for Direct IO at the beginning in PositionedRead (#3891)

Summary:
Moved the direct-IO assertion to the top in `PosixSequentialFile::PositionedRead`, as it doesn't make sense to check for sector alignments before checking for direct IO.
Closes https://github.com/facebook/rocksdb/pull/3891

Differential Revision: D8267972

Pulled By: sagar0

fbshipit-source-id: 0ecf77c0fb5c35747a4ddbc15e278918c0849af7
This commit is contained in:
Sagar Vemuri 2018-06-21 14:45:49 -07:00 committed by Facebook Github Bot
parent 58c221440c
commit 645e57c22d
1 changed files with 5 additions and 6 deletions

5
env/io_posix.cc vendored
View File

@ -184,16 +184,15 @@ Status PosixSequentialFile::Read(size_t n, Slice* result, char* scratch) {
Status PosixSequentialFile::PositionedRead(uint64_t offset, size_t n,
Slice* result, char* scratch) {
if (use_direct_io()) {
assert(use_direct_io());
assert(IsSectorAligned(offset, GetRequiredBufferAlignment()));
assert(IsSectorAligned(n, GetRequiredBufferAlignment()));
assert(IsSectorAligned(scratch, GetRequiredBufferAlignment()));
}
Status s;
ssize_t r = -1;
size_t left = n;
char* ptr = scratch;
assert(use_direct_io());
while (left > 0) {
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
if (r <= 0) {