Changeset d773bea9 in mainline


Ignore:
Timestamp:
2025-01-12T21:53:55Z (5 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
35f2a877
Parents:
dec4150
git-author:
Miroslav Cimerman <mc@…> (2025-01-12 20:12:46)
git-committer:
Miroslav Cimerman <mc@…> (2025-01-12 21:53:55)
Message:

hr: RAID1: handle state edge cases in a rebuild

File:
1 edited

Legend:

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

    rdec4150 rd773bea9  
    675675
    676676                if (i + 1 >= vol->extent_no) {
    677                         HR_ERROR("rebuild on \"%s\" (%lu), failed due to "
    678                             "too many failed extents\n",
    679                             vol->devname, vol->svc_id);
     677                        if (rc != ENOMEM) {
     678                                HR_ERROR("rebuild on \"%s\" (%lu), failed due "
     679                                    "to too many failed extents\n",
     680                                    vol->devname, vol->svc_id);
     681                        }
     682
     683                        /* for now we have to invalidate the rebuild extent */
     684                        if (rc == ENOMEM) {
     685                                HR_ERROR("rebuild on \"%s\" (%lu), failed due "
     686                                    "to too many failed reads, because of not "
     687                                    "enough memory\n",
     688                                    vol->devname, vol->svc_id);
     689                                hr_raid1_ext_state_callback(vol, rebuild_idx,
     690                                    ENOMEM);
     691                        }
    680692
    681693                        return rc;
     
    685697        rc = block_write_direct(rebuild_ext->svc_id, ba, cnt, buf);
    686698        if (rc != EOK) {
    687                 if (rc != ENOMEM)
    688                         hr_raid1_ext_state_callback(vol, rebuild_idx, rc);
     699                /*
     700                 * Here we dont handle ENOMEM, because maybe in the
     701                 * future, there is going to be M_WAITOK, or we are
     702                 * going to wait for more memory, so that we don't
     703                 * have to invalidate it...
     704                 *
     705                 * XXX: for now we do
     706                 */
     707                hr_raid1_ext_state_callback(vol, rebuild_idx, rc);
    689708
    690709                HR_ERROR("rebuild on \"%s\" (%lu), failed due to "
     
    761780
    762781        fibril_rwlock_write_lock(&vol->states_lock);
     782
    763783        hr_update_ext_status(vol, rebuild_idx, HR_EXT_ONLINE);
     784        /*
     785         * We can be optimistic here, if some extents are
     786         * still INVALID, FAULTY or MISSING, the update vol
     787         * function will pick them up, and set the volume
     788         * state accordingly.
     789         */
     790        hr_update_vol_status(vol, HR_VOL_ONLINE);
     791        atomic_store(&vol->state_changed, true);
     792
    764793        fibril_rwlock_write_unlock(&vol->states_lock);
    765794
     
    771800end:
    772801        if (rc != EOK) {
     802                /*
     803                 * We can fail either because:
     804                 * - the rebuild extent failing or invalidation
     805                 * - there is are no ONLINE extents (vol is FAULTY)
     806                 * - we got ENOMEM on all READs (we also invalidate the
     807                 *   rebuild extent here, for now)
     808                 */
    773809                fibril_rwlock_write_lock(&vol->states_lock);
    774810                hr_update_vol_status(vol, HR_VOL_DEGRADED);
     811                atomic_store(&vol->state_changed, true);
    775812                fibril_rwlock_write_unlock(&vol->states_lock);
    776813        }
Note: See TracChangeset for help on using the changeset viewer.