Skip to content

Commit

Permalink
test/d4n: Add D4N filter test program
Browse files Browse the repository at this point in the history
Signed-off-by: Samarah <[email protected]>
  • Loading branch information
Samarah committed Dec 6, 2024
1 parent 7fc5c6a commit 87d110a
Show file tree
Hide file tree
Showing 5 changed files with 2,851 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/rgw/driver/d4n/d4n_policy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ void LFUDAPolicy::cleaning(const DoutPrefixProvider* dpp)
}
rgw::d4n::CacheBlock block;
block.cacheObj.bucketName = c_obj->get_bucket()->get_bucket_id();
std::cout << "bucket name: " << block.cacheObj.bucketName << std::endl;
block.cacheObj.objName = c_obj->get_name();
block.size = 0;
block.blockID = 0;
Expand Down
34 changes: 16 additions & 18 deletions src/rgw/driver/d4n/rgw_sal_d4n.cc
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,12 @@ int D4NFilterObject::copy_object(const ACLOwner& owner,
ldpp_dout(dpp, 20) << "D4NFilterObject::" << __func__ << " size is: " << dest_object->get_size() << dendl;
d4n_dest_object->set_attrs_from_obj_state(dpp, y, baseAttrs, dirty);
} else {
auto o_attrs = baseAttrs;
dest_object->load_obj_state(dpp, y);
baseAttrs = dest_object->get_attrs();
d4n_dest_object->set_attrs_from_obj_state(dpp, y, baseAttrs, dirty);
auto ret = d4n_dest_object->calculate_version(dpp, y, dest_version);
if (ret < 0 || dest_version.empty()) {
d4n_dest_object->calculate_version(dpp, y, dest_version, o_attrs);
if (dest_version.empty()) {
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): version could not be calculated." << dendl;
}
}
Expand Down Expand Up @@ -523,18 +524,15 @@ void D4NFilterObject::set_attrs_from_obj_state(const DoutPrefixProvider* dpp, op
return;
}

int D4NFilterObject::calculate_version(const DoutPrefixProvider* dpp, optional_yield y, std::string& version)
int D4NFilterObject::calculate_version(const DoutPrefixProvider* dpp, optional_yield y, std::string& version, rgw::sal::Attrs& attrs)
{
//versioned objects have instance set to versionId, and get_oid() returns oid containing instance, hence using id tag as version for non versioned objects only
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): object name: " << this->get_name() << " instance: " << this->have_instance() << dendl;
if (! this->have_instance() && version.empty()) {
bufferlist bl;
if (this->get_attr(RGW_ATTR_ID_TAG, bl)) {
version = bl.c_str();
bufferlist bl = attrs[RGW_ATTR_ID_TAG];
version = bl.to_str();
if (!version.empty()) {
ldpp_dout(dpp, 20) << __func__ << " id tag version is: " << version << dendl;
} else {
ldpp_dout(dpp, 0) << __func__ << " Failed to find id tag" << dendl;
return -ENOENT;
}
}
if (this->have_instance()) {
Expand Down Expand Up @@ -996,8 +994,8 @@ int D4NFilterObject::get_obj_attrs(optional_yield y, const DoutPrefixProvider* d
attrs = this->get_attrs();
this->set_attrs_from_obj_state(dpp, y, attrs);

ret = calculate_version(dpp, y, version);
if (ret < 0 || version.empty()) {
calculate_version(dpp, y, version, attrs);
if (version.empty()) {
ldpp_dout(dpp, 0) << "D4NFilterObject::" << __func__ << "(): version could not be calculated." << dendl;
}
std::string objName = this->get_name();
Expand Down Expand Up @@ -1173,8 +1171,8 @@ int D4NFilterObject::D4NFilterReadOp::prepare(optional_yield y, const DoutPrefix
this->source->load_obj_state(dpp, y);
attrs = source->get_attrs();
source->set_attrs_from_obj_state(dpp, y, attrs);
ret = source->calculate_version(dpp, y, version);
if (ret < 0 || version.empty()) {
source->calculate_version(dpp, y, version, attrs);
if (version.empty()) {
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): version could not be calculated." << dendl;
}

Expand Down Expand Up @@ -2284,7 +2282,7 @@ int D4NFilterWriter::prepare(optional_yield y)
d4n_writecache = g_conf()->d4n_writecache_enabled;

if (d4n_writecache == false) {
ldpp_dout(dpp, 0) << "D4NFilterWriter::" << __func__ << "(): calling next process" << dendl;
ldpp_dout(dpp, 0) << "D4NFilterWriter::" << __func__ << "(): calling next->prepare" << dendl;
return next->prepare(y);
} else {
//for non-versioned buckets or version suspended buckets, we need to delete the older dirty blocks of the object from the cache as dirty blocks do not get evicted
Expand Down Expand Up @@ -2474,8 +2472,8 @@ int D4NFilterWriter::complete(size_t accounted_size, const std::string& etag,
object->set_attrs_from_obj_state(dpp, y, attrs, dirty);

std::string version;
ret = object->calculate_version(dpp, y, version);
if (ret < 0 || version.empty()) {
object->calculate_version(dpp, y, version, attrs);
if (version.empty()) {
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): version could not be calculated." << dendl;
}
}
Expand Down Expand Up @@ -2554,8 +2552,8 @@ int D4NFilterMultipartUpload::complete(const DoutPrefixProvider *dpp,
attrs[RGW_CACHE_ATTR_MULTIPART] = std::move(bl_val);

std::string version;
ret = d4n_target_obj->calculate_version(dpp, y, version);
if (ret < 0 || version.empty()) {
d4n_target_obj->calculate_version(dpp, y, version, attrs);
if (version.empty()) {
ldpp_dout(dpp, 10) << "D4NFilterObject::" << __func__ << "(): version could not be calculated." << dendl;
}

Expand Down
2 changes: 1 addition & 1 deletion src/rgw/driver/d4n/rgw_sal_d4n.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class D4NFilterObject : public FilterObject {
const std::string get_prefix() { return this->prefix; }
int get_obj_attrs_from_cache(const DoutPrefixProvider* dpp, optional_yield y);
void set_attrs_from_obj_state(const DoutPrefixProvider* dpp, optional_yield y, rgw::sal::Attrs& attrs, bool dirty = false);
int calculate_version(const DoutPrefixProvider* dpp, optional_yield y, std::string& version);
int calculate_version(const DoutPrefixProvider* dpp, optional_yield y, std::string& version, rgw::sal::Attrs& attrs);
int set_head_obj_dir_entry(const DoutPrefixProvider* dpp, std::vector<std::string>* exec_responses, optional_yield y, bool is_latest_version = true, bool dirty = false);
int set_data_block_dir_entries(const DoutPrefixProvider* dpp, optional_yield y, std::string& version, bool dirty = false);
int delete_data_block_cache_entries(const DoutPrefixProvider* dpp, optional_yield y, std::string& version, bool dirty = false);
Expand Down
15 changes: 15 additions & 0 deletions src/test/rgw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,21 @@ if(WITH_JAEGER)
endif()

if(WITH_RADOSGW_D4N)
add_executable(ceph_test_rgw_d4n_filter
test_d4n_filter.cc
)
target_include_directories(ceph_test_rgw_d4n_filter
SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw/driver/d4n")
target_link_libraries(ceph_test_rgw_d4n_filter PRIVATE
rgw_common
librados
ceph-common
${rgw_libs}
${UNITTEST_LIBS}
${EXTRALIBS}
)
install(TARGETS ceph_test_rgw_d4n_filter DESTINATION ${CMAKE_INSTALL_BINDIR})

add_executable(ceph_test_rgw_d4n_directory
test_d4n_directory.cc
)
Expand Down
Loading

0 comments on commit 87d110a

Please sign in to comment.