diff --git a/HISTORY.md b/HISTORY.md index e725ac9fa..75ed19b2e 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,7 @@ # Rocksdb Change Log ## Unreleased +### Bug Fixes +* Fix a bug in io_uring_prep_cancel in AbortIO API for posix which expects sqe->addr to match with read request submitted and wrong paramter was being passed. ## 7.7.0 (09/18/2022) ### Bug Fixes diff --git a/env/fs_posix.cc b/env/fs_posix.cc index e1b1400d0..a6f7b9c08 100644 --- a/env/fs_posix.cc +++ b/env/fs_posix.cc @@ -1115,10 +1115,11 @@ class PosixFileSystem : public FileSystem { // Prepare the cancel request. struct io_uring_sqe* sqe; sqe = io_uring_get_sqe(iu); - // prep_cancel changed API in liburing, but we need to support both old - // and new versions so do it by hand - io_uring_prep_cancel(sqe, 0, 0); - sqe->addr = reinterpret_cast(posix_handle); + + // In order to cancel the request, sqe->addr of cancel request should + // match with the read request submitted which is posix_handle->iov. + io_uring_prep_cancel(sqe, &posix_handle->iov, 0); + // Sets sqe->user_data to posix_handle. io_uring_sqe_set_data(sqe, posix_handle); // submit the request. @@ -1146,6 +1147,7 @@ class PosixFileSystem : public FileSystem { } assert(cqe != nullptr); + // Returns cqe->user_data. Posix_IOHandle* posix_handle = static_cast(io_uring_cqe_get_data(cqe)); assert(posix_handle->iu == iu); diff --git a/env/io_posix.cc b/env/io_posix.cc index 7a23f9e54..59a94acd4 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -899,8 +899,10 @@ IOStatus PosixRandomAccessFile::ReadAsync( struct io_uring_sqe* sqe; sqe = io_uring_get_sqe(iu); - io_uring_prep_readv(sqe, fd_, &posix_handle->iov, 1, posix_handle->offset); + io_uring_prep_readv(sqe, fd_, /*sqe->addr=*/&posix_handle->iov, + /*sqe->len=*/1, /*sqe->offset=*/posix_handle->offset); + // Sets sqe->user_data to posix_handle. io_uring_sqe_set_data(sqe, posix_handle); // Step 4: io_uring_submit