Changeset d1d355f in mainline for uspace/lib/device/src/hr.c


Ignore:
Timestamp:
2025-05-06T21:30:30Z (5 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
c2f0160
Parents:
40f56a4
Message:

hr: refactor hrctl and some hr IPC methods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/device/src/hr.c

    r40f56a4 rd1d355f  
    109109        async_exchange_end(exch);
    110110        async_wait_for(req, &retval);
    111         if (retval != EOK)
    112                 return retval;
    113 
    114         return EOK;
     111        return retval;
    115112}
    116113
     
    269266}
    270267
    271 errno_t hr_stop(const char *devname, long extent)
     268errno_t hr_stop(const char *devname)
    272269{
    273270        hr_t *hr;
     
    289286                goto error;
    290287        }
    291         rc = async_req_2_0(exch, HR_STOP, svc_id, extent);
     288
     289        rc = async_req_1_0(exch, HR_STOP, svc_id);
    292290        async_exchange_end(exch);
    293291error:
     
    296294}
    297295
    298 errno_t hr_add_hotspare(service_id_t vol_svc_id, service_id_t hs_svc_id)
     296errno_t hr_stop_all(void)
    299297{
    300298        hr_t *hr;
    301         errno_t rc;
    302         async_exch_t *exch;
     299        async_exch_t *exch;
     300        errno_t rc;
     301
     302        rc = hr_sess_init(&hr);
     303        if (rc != EOK)
     304                return rc;
     305
     306        exch = async_exchange_begin(hr->sess);
     307        if (exch == NULL) {
     308                rc = EINVAL;
     309                goto error;
     310        }
     311
     312        rc = async_req_0_0(exch, HR_STOP_ALL);
     313        async_exchange_end(exch);
     314error:
     315        hr_sess_destroy(hr);
     316        return rc;
     317}
     318
     319errno_t hr_fail_extent(const char *volume_name, unsigned long extent)
     320{
     321        hr_t *hr;
     322        errno_t rc;
     323        async_exch_t *exch;
     324        service_id_t vol_svc_id;
     325
     326        rc = loc_service_get_id(volume_name, &vol_svc_id, 0);
     327        if (rc != EOK)
     328                return rc;
     329
     330        rc = hr_sess_init(&hr);
     331        if (rc != EOK)
     332                return rc;
     333
     334        exch = async_exchange_begin(hr->sess);
     335        if (exch == NULL) {
     336                rc = EINVAL;
     337                goto error;
     338        }
     339
     340        rc = async_req_2_0(exch, HR_FAIL_EXTENT, vol_svc_id, extent);
     341        async_exchange_end(exch);
     342error:
     343        hr_sess_destroy(hr);
     344        return rc;
     345}
     346
     347errno_t hr_add_hotspare(const char *volume_name, const char *hotspare)
     348{
     349        hr_t *hr;
     350        errno_t rc;
     351        async_exch_t *exch;
     352        service_id_t vol_svc_id, hs_svc_id;
     353
     354        rc = loc_service_get_id(volume_name, &vol_svc_id, 0);
     355        if (rc != EOK)
     356                return rc;
     357
     358        rc = loc_service_get_id(hotspare, &hs_svc_id, 0);
     359        if (rc != EOK)
     360                return rc;
    303361
    304362        rc = hr_sess_init(&hr);
Note: See TracChangeset for help on using the changeset viewer.