Changeset c9ce6d22 in mainline
- Timestamp:
- 2025-05-15T19:24:51Z (3 weeks ago)
- Children:
- a2281efc
- Parents:
- 9a3eec1
- Location:
- uspace/srv/bd/hr
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/hr.c
r9a3eec1 rc9ce6d22 296 296 errno_t rc = EOK; 297 297 service_id_t svc_id; 298 hr_volume_t *vol;299 298 300 299 svc_id = ipc_get_arg1(icall); 301 300 302 vol = hr_get_volume(svc_id); 303 if (vol == NULL) { 304 async_answer_0(icall, ENOENT); 305 return; 306 } 307 308 rc = hr_remove_volume(vol); 301 rc = hr_remove_volume(svc_id); 309 302 310 303 async_answer_0(icall, rc); … … 319 312 HR_DEBUG("%s()", __func__); 320 313 321 hr_volume_t *vol;314 service_id_t *vol_svcs = NULL; 322 315 errno_t rc = EOK; 323 324 while (true) { 325 fibril_rwlock_write_lock(&hr_volumes_lock); 326 if (list_empty(&hr_volumes)) { 327 fibril_rwlock_write_unlock(&hr_volumes_lock); 328 break; 329 } 330 331 vol = list_pop(&hr_volumes, hr_volume_t, lvolumes); 332 333 fibril_rwlock_write_unlock(&hr_volumes_lock); 334 335 rc = hr_remove_volume(vol); 316 size_t i, vol_cnt; 317 318 rc = hr_get_volume_svcs(&vol_cnt, &vol_svcs); 319 if (rc != EOK) 320 goto fail; 321 322 for (i = 0; i < vol_cnt; i++) { 323 rc = hr_remove_volume(vol_svcs[i]); 336 324 if (rc != EOK) 337 325 break; 338 326 } 339 327 328 fail: 329 if (vol_svcs != NULL) 330 free(vol_svcs); 340 331 async_answer_0(icall, rc); 341 332 } -
uspace/srv/bd/hr/util.c
r9a3eec1 rc9ce6d22 215 215 } 216 216 } 217 218 217 fibril_rwlock_read_unlock(&hr_volumes_lock); 218 219 219 return rvol; 220 220 } 221 221 222 errno_t hr_remove_volume(hr_volume_t *vol) 223 { 224 HR_DEBUG("%s()", __func__); 222 errno_t hr_remove_volume(service_id_t svc_id) 223 { 224 HR_DEBUG("%s()", __func__); 225 226 hr_volume_t *vol = hr_get_volume(svc_id); 227 if (vol == NULL) 228 return ENOENT; 225 229 226 230 fibril_rwlock_write_lock(&hr_volumes_lock); … … 228 232 int open_cnt = atomic_load_explicit(&vol->open_cnt, 229 233 memory_order_relaxed); 234 230 235 /* 231 236 * The atomicity of this if condition (and this whole … … 246 251 /* save metadata, but we don't care about states anymore */ 247 252 (void)vol->meta_ops->save(vol, NO_STATE_CALLBACK); 248 249 service_id_t svc_id = vol->svc_id;250 253 251 254 HR_NOTE("deactivating volume \"%s\"\n", vol->devname); -
uspace/srv/bd/hr/util.h
r9a3eec1 rc9ce6d22 72 72 extern errno_t hr_get_volume_svcs(size_t *, service_id_t **); 73 73 extern hr_volume_t *hr_get_volume(service_id_t); 74 extern errno_t hr_remove_volume( hr_volume_t *);74 extern errno_t hr_remove_volume(service_id_t); 75 75 extern errno_t hr_init_extents_from_cfg(hr_volume_t *, hr_config_t *); 76 76 extern void hr_fini_devs(hr_volume_t *);
Note:
See TracChangeset
for help on using the changeset viewer.