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


Ignore:
Timestamp:
2025-03-28T23:37:16Z (4 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
0437dd5
Parents:
7bfe468
git-author:
Miroslav Cimerman <mc@…> (2025-03-28 23:25:57)
git-committer:
Miroslav Cimerman <mc@…> (2025-03-28 23:37:16)
Message:

hr: auto assembly, refactor

Added automatic assembly (with hrctl -A). All disks or their partitions
are scanned for HelenRAID metadata and assembly is attempted.

Main volume list is now locked with RW lock. The volume list
manipulation functions are moved into util.c.

hr_{create,destroy}_vol_struct() are implemented for better reusability
and modularity.

Volume destroy/stop (hrctl -D) now returns EBUSY if someone has still
the volume open()-ed.

File:
1 edited

Legend:

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

    r7bfe468 r8b51009  
    115115}
    116116
     117errno_t hr_auto_assemble(size_t *rassembled_cnt)
     118{
     119        hr_t *hr;
     120        errno_t rc;
     121        size_t assembled_cnt;
     122
     123        rc = hr_sess_init(&hr);
     124        if (rc != EOK)
     125                return rc;
     126
     127        async_exch_t *exch = async_exchange_begin(hr->sess);
     128        if (exch == NULL) {
     129                rc = EINVAL;
     130                goto error;
     131        }
     132
     133        aid_t req = async_send_0(exch, HR_AUTO_ASSEMBLE, NULL);
     134
     135        rc = async_data_read_start(exch, &assembled_cnt, sizeof(size_t));
     136        if (rc != EOK) {
     137                async_exchange_end(exch);
     138                async_forget(req);
     139                return rc;
     140        }
     141
     142        async_exchange_end(exch);
     143        async_wait_for(req, &rc);
     144
     145        if (rassembled_cnt != NULL)
     146                *rassembled_cnt = assembled_cnt;
     147error:
     148        hr_sess_destroy(hr);
     149        return rc;
     150}
     151
    117152static errno_t print_vol_info(size_t index, hr_vol_info_t *vol_info)
    118153{
     
    218253        rc = async_req_2_0(exch, HR_STOP, svc_id, extent);
    219254        async_exchange_end(exch);
    220 
    221         if (rc != EOK)
    222                 goto error;
    223255error:
    224256        hr_sess_destroy(hr);
Note: See TracChangeset for help on using the changeset viewer.