From 645e57c22d898623b6a470d44ee15ef9d9ca5546 Mon Sep 17 00:00:00 2001 From: Sagar Vemuri Date: Thu, 21 Jun 2018 14:45:49 -0700 Subject: [PATCH] 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 --- env/io_posix.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/env/io_posix.cc b/env/io_posix.cc index 216fc897ee..70dd7e9b08 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -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(offset)); if (r <= 0) {