return -EBLOCKLISTED;
}
- if (int rc = wait_for_updates(); rc < 0) {
+ if (int rc = wait_for_aios(true); rc < 0) {
+ aios_failure = 0;
return rc;
}
return 0;
}
-int SimpleRADOSStriper::wait_for_updates()
+int SimpleRADOSStriper::wait_for_aios(bool block)
{
- d(10) << dendl;
-
- for (auto& aiocp : updates) {
- if (int rc = aiocp->wait_for_complete(); rc < 0) {
- d(5) << " update failed: " << cpp_strerror(rc) << dendl;
- return rc;
+ while (!aios.empty()) {
+ auto& aiocp = aios.front();
+ int rc;
+ if (block) {
+ rc = aiocp->wait_for_complete();
+ } else {
+ if (aiocp->is_complete()) {
+ rc = aiocp->get_return_value();
+ } else {
+ return 0;
+ }
}
+ if (rc) {
+ d(5) << " aio failed: " << cpp_strerror(rc) << dendl;
+ if (aios_failure == 0) {
+ aios_failure = rc;
+ }
+ }
+ aios.pop();
}
- updates.clear();
-
- return 0;
+ return aios_failure;
}
int SimpleRADOSStriper::flush()
}
}
- if (int rc = wait_for_updates(); rc < 0) {
+ if (int rc = wait_for_aios(true); rc < 0) {
+ aios_failure = 0;
return rc;
}
allocated = new_allocated;
}
if (aiocp) {
- updates.emplace_back(std::move(aiocp));
+ aios.emplace(std::move(aiocp));
}
if (update_size) {
size = new_size;
if (int rc = ioctx.aio_write(ext.soid, aiocp.get(), bl, ext.len, ext.off); rc < 0) {
break;
}
- updates.emplace_back(std::move(aiocp));
+ aios.emplace(std::move(aiocp));
w += ext.len;
}
+ wait_for_aios(false); // clean up finished completions
+
if (size < (len+off)) {
size = len+off;
size_dirty = true;
#ifndef _SIMPLERADOSSTRIPER_H
#define _SIMPLERADOSSTRIPER_H
+#include <queue>
#include <string_view>
#include <thread>
int set_metadata(uint64_t new_size, bool update_size);
int shrink_alloc(uint64_t a);
int maybe_shrink_alloc();
- int wait_for_updates();
+ int wait_for_aios(bool block);
int recover_lock();
extent get_next_extent(uint64_t off, size_t len) const;
extent get_first_extent() const {
bool locked = false;
bool size_dirty = false;
bool blocklist_the_dead = true;
- std::vector<aiocompletionptr> updates;
+ std::queue<aiocompletionptr> aios;
+ int aios_failure = 0;
std::string myaddrs;
};