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


Ignore:
Timestamp:
2025-06-09T20:01:03Z (6 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
e2a8fd2
Parents:
431b513
Message:

hr: move state printing to hrctl

One IPC call is for short volume states printing
and other one for specific volume detailed info
printing.

File:
1 edited

Legend:

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

    r431b513 re0bbecb  
    5959static void hr_stop_all_srv(ipc_call_t *);
    6060static void hr_add_hotspare_srv(ipc_call_t *);
    61 static void hr_print_state_srv(ipc_call_t *);
     61static void hr_get_vol_states_srv(ipc_call_t *);
    6262static void hr_ctl_conn(ipc_call_t *);
    6363static void hr_client_conn(ipc_call_t *, void *);
     
    416416}
    417417
    418 /** Volume state printing (server).
    419  *
    420  * Prints info about all active volumes.
    421  */
    422 static void hr_print_state_srv(ipc_call_t *icall)
     418/** Send volume states.
     419 *
     420 * Sends the client pairs of (volume service_id, state).
     421 */
     422static void hr_get_vol_states_srv(ipc_call_t *icall)
    423423{
    424424        HR_DEBUG("%s()", __func__);
     
    426426        errno_t rc;
    427427        size_t vol_cnt = 0;
    428         hr_vol_info_t info;
     428        hr_pair_vol_state_t pair;
    429429        ipc_call_t call;
    430430        size_t size;
     
    439439        }
    440440
    441         if (size != sizeof(size_t)) {
     441        if (size != sizeof(vol_cnt)) {
    442442                rc = EINVAL;
    443443                goto error;
     
    449449
    450450        list_foreach(hr_volumes, lvolumes, hr_volume_t, vol) {
    451                 memcpy(info.extents, vol->extents,
    452                     sizeof(hr_extent_t) * HR_MAX_EXTENTS);
    453                 memcpy(info.hotspares, vol->hotspares,
    454                     sizeof(hr_extent_t) * HR_MAX_HOTSPARES);
    455                 info.svc_id = vol->svc_id;
    456                 info.extent_no = vol->extent_no;
    457                 info.hotspare_no = vol->hotspare_no;
    458                 info.level = vol->level;
    459                 /* print usable number of blocks */
    460                 /* TODO: change to data_blkno */
    461                 info.nblocks = vol->data_blkno;
    462                 info.strip_size = vol->strip_size;
    463                 info.bsize = vol->bsize;
    464                 info.state = vol->state;
    465                 info.layout = vol->layout;
     451                pair.svc_id = vol->svc_id;
     452                pair.state = vol->state;
    466453
    467454                if (!async_data_read_receive(&call, &size)) {
     
    470457                }
    471458
    472                 if (size != sizeof(hr_vol_info_t)) {
     459                if (size != sizeof(pair)) {
    473460                        rc = EINVAL;
    474461                        goto error;
    475462                }
    476463
    477                 rc = async_data_read_finalize(&call, &info, size);
     464                rc = async_data_read_finalize(&call, &pair, size);
    478465                if (rc != EOK)
    479466                        goto error;
     
    489476}
    490477
     478/** Send volume info.
     479 *
     480 * Sends the client volume info.
     481 */
     482static void hr_get_vol_info_srv(ipc_call_t *icall)
     483{
     484        HR_DEBUG("%s()", __func__);
     485
     486        errno_t rc;
     487        size_t size;
     488        ipc_call_t call;
     489        service_id_t svc_id;
     490        hr_vol_info_t info;
     491        hr_volume_t *vol;
     492
     493        if (!async_data_write_receive(&call, &size)) {
     494                rc = EREFUSED;
     495                goto error;
     496        }
     497
     498        if (size != sizeof(service_id_t)) {
     499                rc = EINVAL;
     500                goto error;
     501        }
     502
     503        rc = async_data_write_finalize(&call, &svc_id, size);
     504        if (rc != EOK)
     505                goto error;
     506
     507        vol = hr_get_volume(svc_id);
     508        if (vol == NULL) {
     509                rc = ENOENT;
     510                goto error;
     511        }
     512
     513        memcpy(info.extents, vol->extents,
     514            sizeof(hr_extent_t) * HR_MAX_EXTENTS);
     515        memcpy(info.hotspares, vol->hotspares,
     516            sizeof(hr_extent_t) * HR_MAX_HOTSPARES);
     517        info.svc_id = vol->svc_id;
     518        info.extent_no = vol->extent_no;
     519        info.hotspare_no = vol->hotspare_no;
     520        info.level = vol->level;
     521        info.data_blkno = vol->data_blkno;
     522        info.strip_size = vol->strip_size;
     523        info.bsize = vol->bsize;
     524        info.state = vol->state;
     525        info.layout = vol->layout;
     526        info.meta_type = vol->meta_ops->get_type();
     527        memcpy(info.devname, vol->devname, HR_DEVNAME_LEN);
     528
     529        if (!async_data_read_receive(&call, &size)) {
     530                rc = EREFUSED;
     531                goto error;
     532        }
     533
     534        if (size != sizeof(info)) {
     535                rc = EINVAL;
     536                goto error;
     537        }
     538
     539        rc = async_data_read_finalize(&call, &info, size);
     540        if (rc != EOK)
     541                goto error;
     542
     543        async_answer_0(icall, EOK);
     544        return;
     545error:
     546        async_answer_0(&call, rc);
     547        async_answer_0(icall, rc);
     548}
     549
    491550/**  HelenRAID server control IPC methods crossroad.
    492551 */
     
    529588                        hr_add_hotspare_srv(&call);
    530589                        break;
    531                 case HR_STATUS:
    532                         hr_print_state_srv(&call);
     590                case HR_GET_VOL_STATES:
     591                        hr_get_vol_states_srv(&call);
     592                        break;
     593                case HR_GET_VOL_INFO:
     594                        hr_get_vol_info_srv(&call);
    533595                        break;
    534596                default:
Note: See TracChangeset for help on using the changeset viewer.