@@ -75,6 +75,11 @@ shared< hs_index_table_t > HomeBlocksImpl::recover_index_table(homestore::superb
75
75
// cause crash;
76
76
//
77
77
VolumeManager::NullAsyncResult HomeBlocksImpl::create_volume (VolumeInfo&& vol_info) {
78
+ if (is_restricted ()) {
79
+ LOGE (" Can't serve volume create, System is in restricted mode." );
80
+ return folly::makeUnexpected (VolumeError::UNSUPPORTED_OP);
81
+ }
82
+
78
83
inc_ref ();
79
84
auto id = vol_info.id ;
80
85
@@ -115,6 +120,20 @@ VolumeManager::NullAsyncResult HomeBlocksImpl::create_volume(VolumeInfo&& vol_in
115
120
// vol in destroying state already indicates an outstanding volume which consumed in no_outstanding_vols() API;
116
121
//
117
122
VolumeManager::NullAsyncResult HomeBlocksImpl::remove_volume (const volume_id_t & id) {
123
+ if (is_restricted ()) {
124
+ LOGE (" Can't serve volume remove, System is in restricted mode." );
125
+ return folly::makeUnexpected (VolumeError::UNSUPPORTED_OP);
126
+ }
127
+
128
+ auto vol = lookup_volume (id);
129
+ if (vol == nullptr ) {
130
+ LOGE (" Volume with id {} not found, cannot remove" , boost::uuids::to_string (id));
131
+ return folly::makeUnexpected (VolumeError::INVALID_ARG);
132
+ } else if (vol->is_offline ()) {
133
+ LOGE (" Volume {} is offline, cannot remove" , vol->id_str ());
134
+ return folly::makeUnexpected (VolumeError::VOLUME_OFFLINE);
135
+ }
136
+
118
137
LOGINFO (" remove_volume with input id: {}" , boost::uuids::to_string (id));
119
138
iomanager.run_on_forget (iomgr::reactor_regex::random_worker, [this , id]() {
120
139
// 1. get the volume ptr from the map;
@@ -208,6 +227,14 @@ void HomeBlocksImpl::get_volume_ids(std::vector< volume_id_t >& vol_ids) const {
208
227
}
209
228
210
229
VolumeManager::NullAsyncResult HomeBlocksImpl::write (const VolumePtr& vol, const vol_interface_req_ptr& req) {
230
+ if (is_restricted ()) {
231
+ LOGE (" Can't serve write, System is in restricted mode." );
232
+ return folly::makeUnexpected (VolumeError::UNSUPPORTED_OP);
233
+ } else if (vol->is_offline ()) {
234
+ LOGE (" Can't serve write, Volume {} is offline." , vol->id_str ());
235
+ return folly::makeUnexpected (VolumeError::VOLUME_OFFLINE);
236
+ }
237
+
211
238
if (vol->is_destroying () || is_shutting_down ()) {
212
239
LOGE (
213
240
" Can't serve write, Volume {} is_destroying: {} is either in destroying state or System is shutting down. " ,
@@ -226,6 +253,14 @@ VolumeManager::NullAsyncResult HomeBlocksImpl::write(const VolumePtr& vol, const
226
253
}
227
254
228
255
VolumeManager::NullAsyncResult HomeBlocksImpl::read (const VolumePtr& vol, const vol_interface_req_ptr& req) {
256
+ if (is_restricted ()) {
257
+ LOGE (" Can't serve read, System is in restricted mode." );
258
+ return folly::makeUnexpected (VolumeError::UNSUPPORTED_OP);
259
+ } else if (vol->is_offline ()) {
260
+ LOGE (" Can't serve read, Volume {} is offline." , vol->id_str ());
261
+ return folly::makeUnexpected (VolumeError::VOLUME_OFFLINE);
262
+ }
263
+
229
264
if (vol->is_destroying () || is_shutting_down ()) {
230
265
LOGE (" Can't serve read, Volume {} is_destroying: {} is either in destroying state or System is shutting down. " ,
231
266
vol->id_str (), vol->is_destroying ());
@@ -245,6 +280,14 @@ VolumeManager::NullAsyncResult HomeBlocksImpl::read(const VolumePtr& vol, const
245
280
VolumeManager::NullAsyncResult HomeBlocksImpl::unmap (const VolumePtr& vol, const vol_interface_req_ptr& req) {
246
281
LOGWARN (" Unmap to vol: {} not implemented" , vol->id_str ());
247
282
283
+ if (is_restricted ()) {
284
+ LOGE (" Can't serve unmap, System is in restricted mode." );
285
+ return folly::makeUnexpected (VolumeError::UNSUPPORTED_OP);
286
+ } else if (vol->is_offline ()) {
287
+ LOGE (" Can't serve unmap, Volume {} is offline." , vol->id_str ());
288
+ return folly::makeUnexpected (VolumeError::VOLUME_OFFLINE);
289
+ }
290
+
248
291
if (vol->is_destroying () || is_shutting_down ()) {
249
292
LOGE (
250
293
" Can't serve unmap, Volume {} is_destroying: {} is either in destroying state or System is shutting down. " ,
0 commit comments