@@ -116,59 +116,61 @@ int SSDDriver::initialize(const DoutPrefixProvider* dpp)
116116 partition_info.location += " /" ;
117117 }
118118
119- try {
120- if (efs::exists (partition_info.location )) {
121- if (dpp->get_cct ()->_conf ->rgw_d4n_l1_evict_cache_on_start ) {
122- ldpp_dout (dpp, 5 ) << " initialize: evicting the persistent storage directory on start" << dendl;
123-
124- uid_t uid = dpp->get_cct ()->get_set_uid ();
125- gid_t gid = dpp->get_cct ()->get_set_gid ();
126-
127- ldpp_dout (dpp, 5 ) << " initialize:: uid is " << uid << " and gid is " << gid << dendl;
128- ldpp_dout (dpp, 5 ) << " initialize:: changing permissions for datacache directory." << dendl;
129-
130- if (uid) {
131- if (chown (partition_info.location .c_str (), uid, gid) == -1 ) {
132- ldpp_dout (dpp, 5 ) << " initialize: chown return error: " << strerror (errno) << dendl;
133- }
134-
135- if (chmod (partition_info.location .c_str (), S_IRWXU|S_IRWXG|S_IRWXO) == -1 ) {
136- ldpp_dout (dpp, 5 ) << " initialize: chmod return error: " << strerror (errno) << dendl;
137- }
138- }
139-
140- for (auto & p : efs::directory_iterator (partition_info.location )) {
141- efs::remove_all (p.path ());
142- }
143- }
144- } else {
145- ldpp_dout (dpp, 5 ) << " initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
146- std::error_code ec;
147- if (!efs::create_directories (partition_info.location , ec)) {
148- ldpp_dout (dpp, 0 ) << " initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
149- " ' : " << ec.value () << dendl;
150- } else {
151- uid_t uid = dpp->get_cct ()->get_set_uid ();
152- gid_t gid = dpp->get_cct ()->get_set_gid ();
153-
154- ldpp_dout (dpp, 5 ) << " initialize:: uid is " << uid << " and gid is " << gid << dendl;
155- ldpp_dout (dpp, 5 ) << " initialize:: changing permissions for datacache directory." << dendl;
156-
157- if (uid) {
158- if (chown (partition_info.location .c_str (), uid, gid) == -1 ) {
159- ldpp_dout (dpp, 5 ) << " initialize: chown return error: " << strerror (errno) << dendl;
160- }
161-
162- if (chmod (partition_info.location .c_str (), S_IRWXU|S_IRWXG|S_IRWXO) == -1 ) {
163- ldpp_dout (dpp, 5 ) << " initialize: chmod return error: " << strerror (errno) << dendl;
164- }
165- }
166- }
167- }
168- } catch (const efs::filesystem_error& e) {
169- ldpp_dout (dpp, 0 ) << " initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
170- " ' : " << e.what () << dendl;
171- // return -EINVAL; Should return error from here?
119+ if (!admin) { // Only initialize or evict cache if radosgw-admin is not responsible for call
120+ try {
121+ if (efs::exists (partition_info.location )) {
122+ if (dpp->get_cct ()->_conf ->rgw_d4n_l1_evict_cache_on_start ) {
123+ ldpp_dout (dpp, 5 ) << " initialize: evicting the persistent storage directory on start" << dendl;
124+
125+ uid_t uid = dpp->get_cct ()->get_set_uid ();
126+ gid_t gid = dpp->get_cct ()->get_set_gid ();
127+
128+ ldpp_dout (dpp, 5 ) << " initialize:: uid is " << uid << " and gid is " << gid << dendl;
129+ ldpp_dout (dpp, 5 ) << " initialize:: changing permissions for datacache directory." << dendl;
130+
131+ if (uid) {
132+ if (chown (partition_info.location .c_str (), uid, gid) == -1 ) {
133+ ldpp_dout (dpp, 5 ) << " initialize: chown return error: " << strerror (errno) << dendl;
134+ }
135+
136+ if (chmod (partition_info.location .c_str (), S_IRWXU|S_IRWXG|S_IRWXO) == -1 ) {
137+ ldpp_dout (dpp, 5 ) << " initialize: chmod return error: " << strerror (errno) << dendl;
138+ }
139+ }
140+
141+ for (auto & p : efs::directory_iterator (partition_info.location )) {
142+ efs::remove_all (p.path ());
143+ }
144+ }
145+ } else {
146+ ldpp_dout (dpp, 5 ) << " initialize:: creating the persistent storage directory on start: " << partition_info.location << dendl;
147+ std::error_code ec;
148+ if (!efs::create_directories (partition_info.location , ec)) {
149+ ldpp_dout (dpp, 0 ) << " initialize::: ERROR initializing the cache storage directory: '" << partition_info.location <<
150+ " ' : " << ec.value () << dendl;
151+ } else {
152+ uid_t uid = dpp->get_cct ()->get_set_uid ();
153+ gid_t gid = dpp->get_cct ()->get_set_gid ();
154+
155+ ldpp_dout (dpp, 5 ) << " initialize:: uid is " << uid << " and gid is " << gid << dendl;
156+ ldpp_dout (dpp, 5 ) << " initialize:: changing permissions for datacache directory." << dendl;
157+
158+ if (uid) {
159+ if (chown (partition_info.location .c_str (), uid, gid) == -1 ) {
160+ ldpp_dout (dpp, 5 ) << " initialize: chown return error: " << strerror (errno) << dendl;
161+ }
162+
163+ if (chmod (partition_info.location .c_str (), S_IRWXU|S_IRWXG|S_IRWXO) == -1 ) {
164+ ldpp_dout (dpp, 5 ) << " initialize: chmod return error: " << strerror (errno) << dendl;
165+ }
166+ }
167+ }
168+ }
169+ } catch (const efs::filesystem_error& e) {
170+ ldpp_dout (dpp, 0 ) << " initialize::: ERROR initializing the cache storage directory '" << partition_info.location <<
171+ " ' : " << e.what () << dendl;
172+ // return -EINVAL; Should return error from here?
173+ }
172174 }
173175
174176 #if defined(HAVE_LIBAIO) && defined(__GLIBC__)
0 commit comments