Changeset c9ce6d22 in mainline for uspace/srv/bd/hr/hr.c


Ignore:
Timestamp:
2025-05-15T19:24:51Z (3 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
a2281efc
Parents:
9a3eec1
Message:

hr: refactor volume removal

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/hr/hr.c

    r9a3eec1 rc9ce6d22  
    296296        errno_t rc = EOK;
    297297        service_id_t svc_id;
    298         hr_volume_t *vol;
    299298
    300299        svc_id = ipc_get_arg1(icall);
    301300
    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);
    309302
    310303        async_answer_0(icall, rc);
     
    319312        HR_DEBUG("%s()", __func__);
    320313
    321         hr_volume_t *vol;
     314        service_id_t *vol_svcs = NULL;
    322315        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]);
    336324                if (rc != EOK)
    337325                        break;
    338326        }
    339327
     328fail:
     329        if (vol_svcs != NULL)
     330                free(vol_svcs);
    340331        async_answer_0(icall, rc);
    341332}
Note: See TracChangeset for help on using the changeset viewer.