Changeset dec4150 in mainline


Ignore:
Timestamp:
2025-01-12T21:53:55Z (5 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
d773bea9
Parents:
401b9e42
git-author:
Miroslav Cimerman <mc@…> (2025-01-12 20:11:54)
git-committer:
Miroslav Cimerman <mc@…> (2025-01-12 21:53:55)
Message:

hr: RAID1: fix unsafe access in add_hotspare()

File:
1 edited

Legend:

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

    r401b9e42 rdec4150  
    162162        hr_update_hotspare_status(vol, hs_idx, HR_EXT_HOTSPARE);
    163163
    164         /*
    165          * If the volume is degraded, start rebuild right away.
    166          */
    167         if (vol->status == HR_VOL_DEGRADED) {
    168                 HR_DEBUG("hr_raid1_add_hotspare(): volume in DEGRADED state, "
    169                     "spawning new rebuild fibril\n");
    170                 fid_t fib = fibril_create(hr_raid1_rebuild, vol);
    171                 if (fib == 0) {
    172                         rc = ENOMEM;
    173                         goto error;
    174                 }
    175                 fibril_start(fib);
    176                 fibril_detach(fib);
    177         }
    178 
     164        atomic_store(&vol->state_changed, true);
    179165error:
    180166        fibril_mutex_unlock(&vol->hotspare_lock);
     167
     168        hr_raid1_update_vol_status(vol);
    181169
    182170        return rc;
     
    305293                }
    306294        } else if (healthy < vol->extent_no) {
     295                if (old_state != HR_VOL_REBUILD &&
     296                    old_state != HR_VOL_DEGRADED) {
     297                        fibril_rwlock_write_lock(&vol->states_lock);
     298                        hr_update_vol_status(vol, HR_VOL_DEGRADED);
     299                        fibril_rwlock_write_unlock(&vol->states_lock);
     300                }
     301
    307302                if (old_state != HR_VOL_REBUILD) {
    308                         if (old_state != HR_VOL_DEGRADED) {
    309                                 fibril_rwlock_write_lock(&vol->states_lock);
    310                                 hr_update_vol_status(vol, HR_VOL_DEGRADED);
    311                                 fibril_rwlock_write_unlock(&vol->states_lock);
    312                         }
    313 
    314303                        if (vol->hotspare_no > 0) {
    315304                                fid_t fib = fibril_create(hr_raid1_rebuild,
Note: See TracChangeset for help on using the changeset viewer.