Skip to content

Commit

Permalink
Assert for Direct IO at the beginning in PositionedRead (facebook#3891)
Browse files Browse the repository at this point in the history
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 facebook#3891

Differential Revision: D8267972

Pulled By: sagar0

fbshipit-source-id: 0ecf77c0fb5c35747a4ddbc15e278918c0849af7
  • Loading branch information
sagar0 authored and facebook-github-bot committed Jun 21, 2018
1 parent 58c2214 commit 645e57c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions env/io_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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(IsSectorAligned(offset, GetRequiredBufferAlignment()));
assert(IsSectorAligned(n, GetRequiredBufferAlignment()));
assert(IsSectorAligned(scratch, GetRequiredBufferAlignment()));
}
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) {
Expand Down

0 comments on commit 645e57c

Please sign in to comment.