mirror of
https://github.com/ceph/ceph
synced 2025-02-19 00:47:49 +00:00
Merge pull request #17186 from trociny/wip-librados_test_stub-zero-snap
test/librados_test_stub: pass snap context to zero op Reviewed-by: Jason Dillaman <dillaman@redhat.com>
This commit is contained in:
commit
9bfc0301ef
@ -920,7 +920,7 @@ void ObjectWriteOperation::writesame(uint64_t off, uint64_t len, const bufferlis
|
||||
|
||||
void ObjectWriteOperation::zero(uint64_t off, uint64_t len) {
|
||||
TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
|
||||
o->ops.push_back(boost::bind(&TestIoCtxImpl::zero, _1, _2, off, len));
|
||||
o->ops.push_back(boost::bind(&TestIoCtxImpl::zero, _1, _2, off, len, _4));
|
||||
}
|
||||
|
||||
Rados::Rados() : client(NULL) {
|
||||
|
@ -158,7 +158,8 @@ public:
|
||||
std::map<std::string, bufferlist>* attrset) = 0;
|
||||
virtual int xattr_set(const std::string& oid, const std::string &name,
|
||||
bufferlist& bl) = 0;
|
||||
virtual int zero(const std::string& oid, uint64_t off, uint64_t len) = 0;
|
||||
virtual int zero(const std::string& oid, uint64_t off, uint64_t len,
|
||||
const SnapContext &snapc) = 0;
|
||||
|
||||
int execute_operation(const std::string& oid,
|
||||
const Operation &operation);
|
||||
|
@ -657,7 +657,8 @@ int TestMemIoCtxImpl::xattr_set(const std::string& oid, const std::string &name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TestMemIoCtxImpl::zero(const std::string& oid, uint64_t off, uint64_t len) {
|
||||
int TestMemIoCtxImpl::zero(const std::string& oid, uint64_t off, uint64_t len,
|
||||
const SnapContext &snapc) {
|
||||
if (m_client->is_blacklisted()) {
|
||||
return -EBLACKLISTED;
|
||||
}
|
||||
@ -666,11 +667,11 @@ int TestMemIoCtxImpl::zero(const std::string& oid, uint64_t off, uint64_t len) {
|
||||
TestMemCluster::SharedFile file;
|
||||
{
|
||||
RWLock::WLocker l(m_pool->file_lock);
|
||||
file = get_file(oid, false, get_snap_context());
|
||||
file = get_file(oid, false, snapc);
|
||||
if (!file) {
|
||||
return 0;
|
||||
}
|
||||
file = get_file(oid, true, get_snap_context());
|
||||
file = get_file(oid, true, snapc);
|
||||
|
||||
RWLock::RLocker l2(file->lock);
|
||||
if (len > 0 && off + len >= file->data.length()) {
|
||||
@ -679,12 +680,12 @@ int TestMemIoCtxImpl::zero(const std::string& oid, uint64_t off, uint64_t len) {
|
||||
}
|
||||
}
|
||||
if (truncate_redirect) {
|
||||
return truncate(oid, off, get_snap_context());
|
||||
return truncate(oid, off, snapc);
|
||||
}
|
||||
|
||||
bufferlist bl;
|
||||
bl.append_zero(len);
|
||||
return write(oid, bl, len, off, get_snap_context());
|
||||
return write(oid, bl, len, off, snapc);
|
||||
}
|
||||
|
||||
void TestMemIoCtxImpl::append_clone(bufferlist& src, bufferlist* dest) {
|
||||
|
@ -68,7 +68,8 @@ public:
|
||||
std::map<std::string, bufferlist>* attrset) override;
|
||||
int xattr_set(const std::string& oid, const std::string &name,
|
||||
bufferlist& bl) override;
|
||||
int zero(const std::string& oid, uint64_t off, uint64_t len) override;
|
||||
int zero(const std::string& oid, uint64_t off, uint64_t len,
|
||||
const SnapContext &snapc) override;
|
||||
|
||||
protected:
|
||||
TestMemCluster::Pool *get_pool() {
|
||||
|
Loading…
Reference in New Issue
Block a user