Changeset edc89bd8 in mainline


Ignore:
Timestamp:
2025-01-12T21:53:55Z (5 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
e2b417f
Parents:
36661772
git-author:
Miroslav Cimerman <mc@…> (2025-01-12 17:19:43)
git-committer:
Miroslav Cimerman <mc@…> (2025-01-12 21:53:55)
Message:

hr: util: add hr_update_{ext,hotspare}_svc_id()

Provides easy way to assert write-ownership of needed
locks.

Location:
uspace/srv/bd/hr
Files:
2 edited

Legend:

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

    r36661772 redc89bd8  
    240240}
    241241
    242 void hr_update_vol_status(hr_volume_t *vol, hr_vol_status_t s)
     242void hr_update_vol_status(hr_volume_t *vol, hr_vol_status_t new)
    243243{
    244244        assert(fibril_rwlock_is_write_locked(&vol->states_lock));
    245245
    246246        HR_WARN("\"%s\": changing volume state: %s -> %s\n", vol->devname,
    247             hr_get_vol_status_msg(vol->status), hr_get_vol_status_msg(s));
    248         vol->status = s;
     247            hr_get_vol_status_msg(vol->status), hr_get_vol_status_msg(new));
     248        vol->status = new;
     249}
     250
     251void hr_update_ext_svc_id(hr_volume_t *vol, size_t extent, service_id_t new)
     252{
     253        if (vol->level != HR_LVL_0)
     254                assert(fibril_rwlock_is_write_locked(&vol->extents_lock));
     255
     256        assert(extent < vol->extent_no);
     257
     258        service_id_t old = vol->extents[extent].svc_id;
     259        HR_WARN("\"%s\": changing extent no. %lu svc_id: (%lu) -> (%lu)\n",
     260            vol->devname, extent, old, new);
     261        vol->extents[extent].svc_id = new;
     262}
     263
     264void hr_update_hotspare_svc_id(hr_volume_t *vol, size_t hs, service_id_t new)
     265{
     266        assert(fibril_mutex_is_locked(&vol->hotspare_lock));
     267
     268        assert(hs < vol->hotspare_no);
     269
     270        service_id_t old = vol->hotspares[hs].svc_id;
     271        HR_WARN("\"%s\": changing hotspare no. %lu svc_id: (%lu) -> (%lu)\n",
     272            vol->devname, hs, old, new);
     273        vol->hotspares[hs].svc_id = new;
    249274}
    250275
  • uspace/srv/bd/hr/util.h

    r36661772 redc89bd8  
    6060extern void hr_update_hotspare_status(hr_volume_t *, size_t, hr_ext_status_t);
    6161extern void hr_update_vol_status(hr_volume_t *, hr_vol_status_t);
     62extern void hr_update_ext_svc_id(hr_volume_t *, size_t, service_id_t);
     63extern void hr_update_hotspare_svc_id(hr_volume_t *, size_t, service_id_t);
    6264extern void hr_sync_all_extents(hr_volume_t *);
    6365extern size_t hr_count_extents(hr_volume_t *, hr_ext_status_t);
Note: See TracChangeset for help on using the changeset viewer.