Changeset 137f7cf5 in mainline


Ignore:
Timestamp:
2025-06-17T22:29:10Z (4 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
3c518fc
Parents:
a3486f2
git-author:
Miroslav Cimerman <mc@…> (2025-06-17 22:04:20)
git-committer:
Miroslav Cimerman <mc@…> (2025-06-17 22:29:10)
Message:

hr: add common hr_sync_extents() fcn

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

Legend:

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

    ra3486f2 r137f7cf5  
    354354        }
    355355
    356         hr_extent_t *ext = &vol->extents[extent_idx_to_fail];
    357 
    358356        fibril_rwlock_read_lock(&vol->extents_lock);
    359357        fibril_rwlock_write_lock(&vol->states_lock);
     358
     359        hr_extent_t *ext = &vol->extents[extent_idx_to_fail];
    360360
    361361        switch (ext->state) {
  • uspace/srv/bd/hr/raid0.c

    ra3486f2 r137f7cf5  
    208208static errno_t hr_raid0_bd_sync_cache(bd_srv_t *bd, aoff64_t ba, size_t cnt)
    209209{
    210         return hr_raid0_bd_op(HR_BD_SYNC, bd, ba, cnt, NULL, NULL, 0);
     210        hr_volume_t *vol = bd->srvs->sarg;
     211
     212        return hr_sync_extents(vol);
    211213}
    212214
  • uspace/srv/bd/hr/raid1.c

    ra3486f2 r137f7cf5  
    263263static errno_t hr_raid1_bd_sync_cache(bd_srv_t *bd, aoff64_t ba, size_t cnt)
    264264{
    265         return hr_raid1_bd_op(HR_BD_SYNC, bd, ba, cnt, NULL, NULL, 0);
     265        hr_volume_t *vol = bd->srvs->sarg;
     266
     267        return hr_sync_extents(vol);
    266268}
    267269
     
    310312
    311313        return count;
    312 
    313314}
    314315
  • uspace/srv/bd/hr/raid5.c

    ra3486f2 r137f7cf5  
    219219static errno_t hr_raid5_bd_sync_cache(bd_srv_t *bd, aoff64_t ba, size_t cnt)
    220220{
    221         /* XXX */
    222         return EOK;
     221        hr_volume_t *vol = bd->srvs->sarg;
     222
     223        return hr_sync_extents(vol);
    223224}
    224225
  • uspace/srv/bd/hr/util.c

    ra3486f2 r137f7cf5  
    11001100}
    11011101
     1102errno_t hr_sync_extents(hr_volume_t *vol)
     1103{
     1104        errno_t rc = EOK;
     1105
     1106        fibril_rwlock_read_lock(&vol->extents_lock);
     1107        for (size_t e = 0; e < vol->extent_no; e++) {
     1108                fibril_rwlock_read_lock(&vol->states_lock);
     1109                hr_ext_state_t s = vol->extents[e].state;
     1110                fibril_rwlock_read_unlock(&vol->states_lock);
     1111
     1112                service_id_t svc_id = vol->extents[e].svc_id;
     1113
     1114                if (s == HR_EXT_ONLINE || s == HR_EXT_REBUILD) {
     1115                        errno_t rc = hr_sync_cache(svc_id, 0, 0);
     1116                        if (rc != EOK && rc != ENOTSUP)
     1117                                vol->hr_ops.ext_state_cb(vol, e, rc);
     1118                }
     1119        }
     1120        fibril_rwlock_read_unlock(&vol->extents_lock);
     1121
     1122        vol->hr_ops.vol_state_eval(vol);
     1123
     1124        fibril_rwlock_read_lock(&vol->states_lock);
     1125        hr_vol_state_t s = vol->state;
     1126        fibril_rwlock_read_unlock(&vol->states_lock);
     1127
     1128        if (s == HR_VOL_FAULTY)
     1129                rc = EIO;
     1130
     1131        return rc;
     1132}
     1133
    11021134/** @}
    11031135 */
  • uspace/srv/bd/hr/util.h

    ra3486f2 r137f7cf5  
    111111extern errno_t hr_util_add_hotspare(hr_volume_t *, service_id_t);
    112112extern void hr_raid5_xor(void *, const void *, size_t);
     113extern errno_t hr_sync_extents(hr_volume_t *);
    113114
    114115#endif
Note: See TracChangeset for help on using the changeset viewer.