Changeset a0c3080 in mainline for uspace/srv/bd/hr/raid1.c
- Timestamp:
- 2024-11-28T17:09:52Z (15 months ago)
- Children:
- 586b39d
- Parents:
- 65706f1
- File:
-
- 1 edited
-
uspace/srv/bd/hr/raid1.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/raid1.c
r65706f1 ra0c3080 147 147 148 148 vol->hotspares[vol->hotspare_no].svc_id = hotspare; 149 vol->hotspares[vol->hotspare_no].status = HR_EXT_HOTSPARE; 149 hr_update_hotspare_status(vol, vol->hotspare_no, HR_EXT_HOTSPARE); 150 150 151 vol->hotspare_no++; 151 152 … … 158 159 fid_t fib = fibril_create(hr_raid1_rebuild, vol); 159 160 if (fib == 0) 160 return E INVAL;161 return ENOMEM; 161 162 fibril_start(fib); 162 163 fibril_detach(fib); … … 219 220 vol->status == HR_VOL_REBUILD) 220 221 return EOK; 221 return EI NVAL;222 return EIO; 222 223 } 223 224 … … 232 233 233 234 if (healthy == 0) { 234 if (old_state != HR_VOL_FAULTY) { 235 HR_WARN("RAID 1 needs at least 1 extent to be" 236 "ONLINE, marking \"%s\" (%lu) volume as FAULTY", 237 vol->devname, vol->svc_id); 238 vol->status = HR_VOL_FAULTY; 239 } 240 return EINVAL; 235 if (old_state != HR_VOL_FAULTY) 236 hr_update_vol_status(vol, HR_VOL_FAULTY); 237 return EIO; 241 238 } else if (healthy < vol->extent_no) { 242 239 if (old_state != HR_VOL_DEGRADED && 243 240 old_state != HR_VOL_REBUILD) { 244 HR_WARN("RAID 1 array \"%s\" (%lu) has some " 245 "unusable extent(s), marking volume as DEGRADED", 246 vol->devname, vol->svc_id); 247 vol->status = HR_VOL_DEGRADED; 241 242 hr_update_vol_status(vol, HR_VOL_DEGRADED); 243 248 244 if (vol->hotspare_no > 0) { 249 245 fid_t fib = fibril_create(hr_raid1_rebuild, 250 246 vol); 251 if (fib == 0) { 252 return EINVAL; 253 } 247 if (fib == 0) 248 return ENOMEM; 254 249 fibril_start(fib); 255 250 fibril_detach(fib); … … 258 253 return EOK; 259 254 } else { 260 if (old_state != HR_VOL_ONLINE) { 261 HR_WARN("RAID 1 array \"%s\" (%lu) has all extents " 262 "active, marking volume as ONLINE", 263 vol->devname, vol->svc_id); 264 vol->status = HR_VOL_ONLINE; 265 } 255 if (old_state != HR_VOL_ONLINE) 256 hr_update_vol_status(vol, HR_VOL_ONLINE); 266 257 return EOK; 267 258 } … … 297 288 298 289 rc = hr_raid1_check_vol_status(vol); 299 if (rc != EOK) { 300 fibril_mutex_unlock(&vol->lock); 301 return EIO; 302 } 290 if (rc != EOK) 291 goto end; 303 292 304 293 size_t successful = 0; … … 352 341 default: 353 342 rc = EINVAL; 343 goto end; 354 344 } 355 345 … … 359 349 rc = EIO; 360 350 351 end: 361 352 (void)hr_raid1_update_vol_status(vol); 362 353 fibril_mutex_unlock(&vol->lock); … … 400 391 } 401 392 393 size_t hotspare_idx = vol->hotspare_no - 1; 394 395 hr_ext_status_t hs_state = vol->hotspares[hotspare_idx].status; 396 if (hs_state != HR_EXT_HOTSPARE) { 397 HR_ERROR("hr_raid1_rebuild(): invalid hotspare state \"%s\", " 398 "aborting rebuild\n", hr_get_ext_status_msg(hs_state)); 399 rc = EINVAL; 400 goto end; 401 } 402 403 HR_DEBUG("hr_raid1_rebuild(): swapping in hotspare\n"); 404 402 405 block_fini(vol->extents[bad].svc_id); 403 406 404 size_t hotspare_idx = vol->hotspare_no - 1;405 406 vol->rebuild_blk = 0;407 407 vol->extents[bad].svc_id = vol->hotspares[hotspare_idx].svc_id; 408 hr_update_ext_status(vol, bad, HR_EXT_ REBUILD);408 hr_update_ext_status(vol, bad, HR_EXT_HOTSPARE); 409 409 410 410 vol->hotspares[hotspare_idx].svc_id = 0; 411 vol->hotspares[hotspare_idx].status = HR_EXT_MISSING; 411 hr_update_hotspare_status(vol, hotspare_idx, HR_EXT_MISSING); 412 412 413 vol->hotspare_no--; 413 414 414 HR_WARN("hr_raid1_rebuild(): changing volume \"%s\" (%lu) state " 415 "from %s to %s\n", vol->devname, vol->svc_id, 416 hr_get_vol_status_msg(vol->status), 417 hr_get_vol_status_msg(HR_VOL_REBUILD)); 418 vol->status = HR_VOL_REBUILD; 419 420 hr_extent_t *hotspare = &vol->extents[bad]; 421 422 HR_DEBUG("hr_raid1_rebuild(): initing (%lu)\n", hotspare->svc_id); 423 424 rc = block_init(hotspare->svc_id); 415 hr_extent_t *rebuild_ext = &vol->extents[bad]; 416 417 rc = block_init(rebuild_ext->svc_id); 425 418 if (rc != EOK) { 426 419 HR_ERROR("hr_raid1_rebuild(): initing (%lu) failed, " 427 "aborting rebuild\n", hotspare->svc_id);420 "aborting rebuild\n", rebuild_ext->svc_id); 428 421 goto end; 429 422 } 423 424 HR_DEBUG("hr_raid1_rebuild(): starting rebuild on (%lu)\n", 425 rebuild_ext->svc_id); 426 427 hr_update_ext_status(vol, bad, HR_EXT_REBUILD); 428 hr_update_vol_status(vol, HR_VOL_REBUILD); 430 429 431 430 size_t left = vol->data_blkno; … … 435 434 hr_extent_t *ext; 436 435 436 vol->rebuild_blk = 0; 437 437 438 size_t cnt; 438 439 uint64_t ba = 0; 439 440 hr_add_ba_offset(vol, &ba); 441 440 442 while (left != 0) { 441 443 vol->rebuild_blk = ba; … … 462 464 } 463 465 464 rc = block_write_direct( hotspare->svc_id, ba, cnt, buf);466 rc = block_write_direct(rebuild_ext->svc_id, ba, cnt, buf); 465 467 if (rc != EOK) { 466 468 hr_raid1_handle_extent_error(vol, bad, rc);
Note:
See TracChangeset
for help on using the changeset viewer.
