Check alignment of MultiRead requests in direct IO mode (#6739)

Summary:
Add assertions to check direct IO's alignment requirements in MultiRead.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/6739

Test Plan: make check

Reviewed By: siying

Differential Revision: D21143825

Pulled By: cheng-chang

fbshipit-source-id: 26f1623b062a1851080771128feac0669a61f5e9
This commit is contained in:
Cheng Chang 2020-04-23 15:17:00 -07:00 committed by Facebook GitHub Bot
parent bc51e33d9c
commit 51bdfae010

9
env/io_posix.cc vendored
View File

@ -608,6 +608,15 @@ IOStatus PosixRandomAccessFile::MultiRead(FSReadRequest* reqs,
size_t num_reqs, size_t num_reqs,
const IOOptions& options, const IOOptions& options,
IODebugContext* dbg) { IODebugContext* dbg) {
if (use_direct_io()) {
for (size_t i = 0; i < num_reqs; i++) {
const FSReadRequest& r = reqs[i];
assert(IsSectorAligned(r.offset, GetRequiredBufferAlignment()));
assert(IsSectorAligned(r.len, GetRequiredBufferAlignment()));
assert(IsSectorAligned(r.scratch, GetRequiredBufferAlignment()));
}
}
#if defined(ROCKSDB_IOURING_PRESENT) #if defined(ROCKSDB_IOURING_PRESENT)
struct io_uring* iu = nullptr; struct io_uring* iu = nullptr;
if (thread_local_io_urings_) { if (thread_local_io_urings_) {