#include "test/librados_test_stub/TestMemRadosClient.h"
#include "common/Clock.h"
#include "common/RWLock.h"
+#include "include/err.h"
#include <boost/algorithm/string/predicate.hpp>
#include <boost/bind.hpp>
#include <errno.h>
}
-int TestMemIoCtxImpl::omap_get_vals(const std::string& oid,
+int TestMemIoCtxImpl::omap_get_vals2(const std::string& oid,
const std::string& start_after,
const std::string &filter_prefix,
uint64_t max_return,
- std::map<std::string, bufferlist> *out_vals) {
+ std::map<std::string, bufferlist> *out_vals,
+ bool *pmore) {
if (out_vals == NULL) {
return -EINVAL;
} else if (m_client->is_blacklisted()) {
RWLock::RLocker l(file->lock);
TestMemCluster::FileOMaps::iterator o_it = m_pool->file_omaps.find(oid);
if (o_it == m_pool->file_omaps.end()) {
+ if (pmore) {
+ *pmore = false;
+ }
return 0;
}
}
++it;
}
+ if (pmore) {
+ *pmore = (it != omap.end());
+ }
return 0;
}
+int TestMemIoCtxImpl::omap_get_vals(const std::string& oid,
+ const std::string& start_after,
+ const std::string &filter_prefix,
+ uint64_t max_return,
+ std::map<std::string, bufferlist> *out_vals) {
+ return omap_get_vals2(oid, start_after, filter_prefix, max_return, out_vals, nullptr);
+}
+
int TestMemIoCtxImpl::omap_rm_keys(const std::string& oid,
const std::set<std::string>& keys) {
if (get_snap_read() != CEPH_NOSNAP) {
return -EBLACKLISTED;
}
-
if (len == 0 || (len % bl.length())) {
return -EINVAL;
}
return 0;
}
+int TestMemIoCtxImpl::cmpext(const std::string& oid, uint64_t off,
+ bufferlist& cmp_bl) {
+ if (get_snap_read() != CEPH_NOSNAP) {
+ return -EROFS;
+ } else if (m_client->is_blacklisted()) {
+ return -EBLACKLISTED;
+ }
+
+ if (cmp_bl.length() == 0) {
+ return -EINVAL;
+ }
+
+ TestMemCluster::SharedFile file;
+ {
+ RWLock::WLocker l(m_pool->file_lock);
+ file = get_file(oid, true, get_snap_context());
+ }
+
+ RWLock::RLocker l(file->lock);
+ size_t len = cmp_bl.length();
+ ensure_minimum_length(off + len, &file->data);
+ if (len > 0 && off <= len) {
+ for (uint64_t p = off; p < len; p++) {
+ if (file->data[p] != cmp_bl[p])
+ return -MAX_ERRNO - p;
+ }
+ }
+ return 0;
+}
+
int TestMemIoCtxImpl::xattr_get(const std::string& oid,
std::map<std::string, bufferlist>* attrset) {
if (m_client->is_blacklisted()) {