mirror of https://github.com/facebook/rocksdb.git
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:
parent
58c221440c
commit
645e57c22d
|
@ -184,16 +184,15 @@ Status PosixSequentialFile::Read(size_t n, Slice* result, char* scratch) {
|
||||||
|
|
||||||
Status PosixSequentialFile::PositionedRead(uint64_t offset, size_t n,
|
Status PosixSequentialFile::PositionedRead(uint64_t offset, size_t n,
|
||||||
Slice* result, char* scratch) {
|
Slice* result, char* scratch) {
|
||||||
if (use_direct_io()) {
|
assert(use_direct_io());
|
||||||
assert(IsSectorAligned(offset, GetRequiredBufferAlignment()));
|
assert(IsSectorAligned(offset, GetRequiredBufferAlignment()));
|
||||||
assert(IsSectorAligned(n, GetRequiredBufferAlignment()));
|
assert(IsSectorAligned(n, GetRequiredBufferAlignment()));
|
||||||
assert(IsSectorAligned(scratch, GetRequiredBufferAlignment()));
|
assert(IsSectorAligned(scratch, GetRequiredBufferAlignment()));
|
||||||
}
|
|
||||||
Status s;
|
Status s;
|
||||||
ssize_t r = -1;
|
ssize_t r = -1;
|
||||||
size_t left = n;
|
size_t left = n;
|
||||||
char* ptr = scratch;
|
char* ptr = scratch;
|
||||||
assert(use_direct_io());
|
|
||||||
while (left > 0) {
|
while (left > 0) {
|
||||||
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
|
r = pread(fd_, ptr, left, static_cast<off_t>(offset));
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
|
|
Loading…
Reference in New Issue