return dynamic_cast<FilterObject*>(t)->get_next();
}
-D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context) : FilterDriver(_next),
- io_context(io_context),
- y(null_yield)
+D4NFilterDriver::D4NFilterDriver(Driver* _next, boost::asio::io_context& io_context, bool admin) : FilterDriver(_next),
+ io_context(io_context),
+ y(null_yield)
{
rgw::cache::Partition partition_info;
partition_info.location = g_conf()->rgw_d4n_l1_datacache_persistent_path;
partition_info.name = "d4n";
partition_info.type = "read-cache";
partition_info.size = g_conf()->rgw_d4n_l1_datacache_size;
- cacheDriver = std::make_unique<rgw::cache::SSDDriver>(partition_info);
+ cacheDriver = std::make_unique<rgw::cache::SSDDriver>(partition_info, admin);
}
D4NFilterDriver::~D4NFilterDriver() = default;
extern "C" {
-rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, void* io_context)
+rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, void* io_context, bool admin)
{
- rgw::sal::D4NFilterDriver* driver = new rgw::sal::D4NFilterDriver(next, *static_cast<boost::asio::io_context*>(io_context));
+ rgw::sal::D4NFilterDriver* driver = new rgw::sal::D4NFilterDriver(next, *static_cast<boost::asio::io_context*>(io_context), admin);
return driver;
}
#endif
extern rgw::sal::Driver* newBaseFilter(rgw::sal::Driver* next);
#ifdef WITH_RADOSGW_D4N
-extern rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, boost::asio::io_context& io_context);
+extern rgw::sal::Driver* newD4NFilter(rgw::sal::Driver* next, boost::asio::io_context& io_context, bool admin);
#endif
}
bool use_cache,
bool use_gc,
bool background_tasks,
- optional_yield y, rgw::sal::ConfigStore* cfgstore)
+ optional_yield y, rgw::sal::ConfigStore* cfgstore, bool admin)
{
rgw::sal::Driver* driver{nullptr};
#ifdef WITH_RADOSGW_D4N
else if (cfg.filter_name.compare("d4n") == 0) {
rgw::sal::Driver* next = driver;
- driver = newD4NFilter(next, io_context);
+ driver = newD4NFilter(next, io_context, admin);
if (driver->initialize(cct, dpp) < 0) {
delete driver;
optional_yield y,
rgw::sal::ConfigStore* cfgstore,
bool use_cache = true,
- bool use_gc = true) {
+ bool use_gc = true,
+ bool admin = false) {
rgw::sal::Driver* driver = init_storage_provider(dpp, cct, cfg, io_context,
site_config,
use_gc_thread,
run_reshard_thread,
run_notification_thread,
use_cache, use_gc,
- background_tasks, y, cfgstore);
+ background_tasks, y, cfgstore, admin);
return driver;
}
/** Get a stripped down driver by service name */
bool run_notification_thread,
bool use_metadata_cache,
bool use_gc, bool background_tasks,
- optional_yield y, rgw::sal::ConfigStore* cfgstore);
+ optional_yield y, rgw::sal::ConfigStore* cfgstore, bool admin);
/** Initialize a new raw Driver */
static rgw::sal::Driver* init_raw_storage_provider(const DoutPrefixProvider* dpp,
CephContext* cct,
partition_info.location += "/";
}
- try {
- if (efs::exists(partition_info.location)) {
- if (dpp->get_cct()->_conf->rgw_d4n_l1_evict_cache_on_start) {
- ldpp_dout(dpp, 5) << "initialize: evicting the persistent storage directory on start" << dendl;
-
- uid_t uid = dpp->get_cct()->get_set_uid();
- gid_t gid = dpp->get_cct()->get_set_gid();
-
- ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
- ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
-
- if (uid) {
- if (chown(partition_info.location.c_str(), uid, gid) == -1) {
- ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
- }
-
- if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
- ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
- }
- }
-
- for (auto& p : efs::directory_iterator(partition_info.location)) {
- efs::remove_all(p.path());
- }
- }
- } else {
- ldpp_dout(dpp, 5) << "initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
- std::error_code ec;
- if (!efs::create_directories(partition_info.location, ec)) {
- ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
- "' : " << ec.value() << dendl;
- } else {
- uid_t uid = dpp->get_cct()->get_set_uid();
- gid_t gid = dpp->get_cct()->get_set_gid();
-
- ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
- ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
-
- if (uid) {
- if (chown(partition_info.location.c_str(), uid, gid) == -1) {
- ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
- }
-
- if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
- ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
- }
- }
- }
- }
- } catch (const efs::filesystem_error& e) {
- ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
- "' : " << e.what() << dendl;
- //return -EINVAL; Should return error from here?
+ if (!admin) { // Only initialize or evict cache if radosgw-admin is not responsible for call
+ try {
+ if (efs::exists(partition_info.location)) {
+ if (dpp->get_cct()->_conf->rgw_d4n_l1_evict_cache_on_start) {
+ ldpp_dout(dpp, 5) << "initialize: evicting the persistent storage directory on start" << dendl;
+
+ uid_t uid = dpp->get_cct()->get_set_uid();
+ gid_t gid = dpp->get_cct()->get_set_gid();
+
+ ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
+ ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
+
+ if (uid) {
+ if (chown(partition_info.location.c_str(), uid, gid) == -1) {
+ ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
+ }
+
+ if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
+ ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
+ }
+ }
+
+ for (auto& p : efs::directory_iterator(partition_info.location)) {
+ efs::remove_all(p.path());
+ }
+ }
+ } else {
+ ldpp_dout(dpp, 5) << "initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
+ std::error_code ec;
+ if (!efs::create_directories(partition_info.location, ec)) {
+ ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
+ "' : " << ec.value() << dendl;
+ } else {
+ uid_t uid = dpp->get_cct()->get_set_uid();
+ gid_t gid = dpp->get_cct()->get_set_gid();
+
+ ldpp_dout(dpp, 5) << "initialize:: uid is " << uid << " and gid is " << gid << dendl;
+ ldpp_dout(dpp, 5) << "initialize:: changing permissions for datacache directory." << dendl;
+
+ if (uid) {
+ if (chown(partition_info.location.c_str(), uid, gid) == -1) {
+ ldpp_dout(dpp, 5) << "initialize: chown return error: " << strerror(errno) << dendl;
+ }
+
+ if (chmod(partition_info.location.c_str(), S_IRWXU|S_IRWXG|S_IRWXO) == -1) {
+ ldpp_dout(dpp, 5) << "initialize: chmod return error: " << strerror(errno) << dendl;
+ }
+ }
+ }
+ }
+ } catch (const efs::filesystem_error& e) {
+ ldpp_dout(dpp, 0) << "initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
+ "' : " << e.what() << dendl;
+ //return -EINVAL; Should return error from here?
+ }
}
#if defined(HAVE_LIBAIO) && defined(__GLIBC__)