Changeset 9fc1d36d in mainline


Ignore:
Timestamp:
2024-10-28T20:03:53Z (7 months ago)
Author:
Miroslav Cimerman <mc@…>
Children:
1903d77
Parents:
e47a032
Message:

hr: RAID 0 status handling

File:
1 edited

Legend:

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

    re47a032 r9fc1d36d  
    7474};
    7575
     76static errno_t hr_raid0_check_vol_status(hr_volume_t *vol)
     77{
     78        if (vol->status == HR_VOL_ONLINE)
     79                return EOK;
     80        return EINVAL;
     81}
     82
     83/*
     84 * Update vol->status and return EOK if volume
     85 * is usable
     86 */
     87static errno_t hr_raid0_update_vol_status(hr_volume_t *vol)
     88{
     89        for (size_t i = 0; i < vol->dev_no; i++) {
     90                if (vol->extents[i].status != HR_EXT_ONLINE) {
     91                        log_msg(LOG_DEFAULT, LVL_ERROR,
     92                            "RAID 0 needs all disks to be ONLINE, marking "
     93                            "\"%s\" (%lu) as FAULTY",
     94                            vol->devname, vol->svc_id);
     95                        vol->status = HR_VOL_FAULTY;
     96                        return EINVAL;
     97                }
     98        }
     99
     100        vol->status = HR_VOL_ONLINE;
     101        return EOK;
     102}
     103
    76104static errno_t hr_raid0_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    77105{
     
    109137
    110138        fibril_mutex_lock(&vol->lock);
     139
     140        rc = hr_raid0_check_vol_status(vol);
     141        if (rc != EOK) {
     142                fibril_mutex_unlock(&vol->lock);
     143                return EIO;
     144        }
    111145
    112146        left = cnt;
     
    135169                        rc = EINVAL;
    136170                }
    137                 if (rc != EOK)
     171
     172                if (rc == ENOENT) {
     173                        hr_update_ext_status(vol, extent, HR_EXT_MISSING);
     174                        rc = EIO;
    138175                        goto error;
     176                } else if (rc != EOK) {
     177                        hr_update_ext_status(vol, extent, HR_EXT_FAILED);
     178                        rc = EIO;
     179                        goto error;
     180                }
    139181
    140182                left -= cnt;
     
    148190
    149191error:
     192        (void) hr_raid0_update_vol_status(vol);
    150193        fibril_mutex_unlock(&vol->lock);
    151194        return rc;
     
    196239                return EINVAL;
    197240        }
     241
     242        rc = hr_raid0_update_vol_status(new_volume);
     243        if (rc != EOK)
     244                return rc;
    198245
    199246        bd_srvs_init(&new_volume->hr_bds);
Note: See TracChangeset for help on using the changeset viewer.