From 31674331f3cc7f58f81fb85cfa48f4cf81be0d9b Mon Sep 17 00:00:00 2001 From: Samarah Date: Mon, 19 Jun 2023 11:58:36 -0400 Subject: [PATCH] RGW: Fix rgw crash issue Signed-off-by: Samarah --- src/rgw/driver/d4n/d4n_policy.cc | 14 ++++++++------ src/rgw/driver/d4n/rgw_sal_d4n.cc | 1 - 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/rgw/driver/d4n/d4n_policy.cc b/src/rgw/driver/d4n/d4n_policy.cc index f648519ab50..0e75692fcc6 100644 --- a/src/rgw/driver/d4n/d4n_policy.cc +++ b/src/rgw/driver/d4n/d4n_policy.cc @@ -248,7 +248,7 @@ CacheBlock LFUDAPolicy::find_victim(const DoutPrefixProvider* dpp, rgw::cache::C } int LFUDAPolicy::get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw::cache::CacheDriver* cacheNode) { -/* std::string key = "rgw-object:" + block->cacheObj.objName + ":directory"; + std::string key = "rgw-object:" + block->cacheObj.objName + ":directory"; std::string localWeightStr = cacheNode->get_attr(dpp, block->cacheObj.objName, "localWeight"); // change to block name eventually -Sam int localWeight = -1; @@ -267,13 +267,13 @@ int LFUDAPolicy::get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw int age = get_age(); - if (cacheNode->key_exists(dpp, block->cacheObj.objName)) { + if (cacheNode->key_exists(dpp, block->cacheObj.objName)) { /* Local copy */ localWeight += age; } else { std::string hosts; uint64_t freeSpace = cacheNode->get_free_space(dpp); - while (freeSpace < block->size) + while (freeSpace < block->size) /* Not enough space in local cache */ freeSpace += eviction(dpp, cacheNode); if (exist_key(key)) { @@ -293,19 +293,21 @@ int LFUDAPolicy::get_block(const DoutPrefixProvider* dpp, CacheBlock* block, rgw } // should not hold local cache IP if in this else statement -Sam - if (hosts.length() > 0) { + if (hosts.length() > 0) { /* Remote copy */ int globalWeight = get_global_weight(key); globalWeight += age; if (set_global_weight(key, globalWeight)) return -1; - } else { + } else { /* No remote copy */ // do I need to add the block to the local cache here? -Sam // update hosts list for block as well? check read workflow -Sam localWeight += age; return cacheNode->set_attr(dpp, block->cacheObj.objName, "localWeight", std::to_string(localWeight)); } - }*/ + } + + return 0; } uint64_t LFUDAPolicy::eviction(const DoutPrefixProvider* dpp, rgw::cache::CacheDriver* cacheNode) { diff --git a/src/rgw/driver/d4n/rgw_sal_d4n.cc b/src/rgw/driver/d4n/rgw_sal_d4n.cc index e5fdffc41b0..9e5474ed472 100644 --- a/src/rgw/driver/d4n/rgw_sal_d4n.cc +++ b/src/rgw/driver/d4n/rgw_sal_d4n.cc @@ -412,7 +412,6 @@ int D4NFilterObject::D4NFilterReadOp::iterate(const DoutPrefixProvider* dpp, int /* Local cache check */ if (source->driver->get_policy_driver()->cacheDriver->key_exists(dpp, oid)) { // Entire object for now -Sam ret = source->driver->get_policy_driver()->cacheDriver->get(dpp, source->get_key().get_oid(), ofs, len, bl, source->get_attrs()); - dout(0) << "Sam: correct" << dendl; cb->handle_data(bl, ofs, len); } else { /* Block directory check */ -- 2.39.5