Changeset e0695ce in mainline for uspace/srv/bd/hr/raid1.c


Ignore:
Timestamp:
2025-06-23T16:50:43Z (5 weeks ago)
Author:
Miroslav Cimerman <mc@…>
Children:
6a8c1569
Parents:
f18e36e
git-author:
Miroslav Cimerman <mc@…> (2025-06-23 16:47:52)
git-committer:
Miroslav Cimerman <mc@…> (2025-06-23 16:50:43)
Message:

hr: save REBUILD position

File:
1 edited

Legend:

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

    rf18e36e re0695ce  
    153153
    154154        vol->meta_ops->inc_counter(vol);
    155         (void)vol->meta_ops->save(vol, WITH_STATE_CALLBACK);
     155        vol->meta_ops->save(vol, WITH_STATE_CALLBACK);
    156156
    157157        hr_raid1_vol_state_eval_forced(vol);
     
    194194        size_t invalid_no = hr_count_extents(vol, HR_EXT_INVALID);
    195195
     196        size_t rebuild_no = hr_count_extents(vol, HR_EXT_REBUILD);
     197
    196198        fibril_mutex_lock(&vol->hotspare_lock);
    197199        size_t hs_no = vol->hotspare_no;
     
    216218
    217219                if (old_state != HR_VOL_REBUILD) {
    218                         if (hs_no > 0 || invalid_no > 0) {
     220                        if (hs_no > 0 || invalid_no > 0 || rebuild_no > 0) {
    219221                                fid_t fib = fibril_create(hr_raid1_rebuild,
    220222                                    vol);
     
    443445}
    444446
    445 /*
    446  * Put the last HOTSPARE extent in place
    447  * of first that != ONLINE, and start the rebuild.
    448  */
    449447static errno_t hr_raid1_rebuild(void *arg)
    450448{
     
    463461        rebuild_ext = &vol->extents[rebuild_idx];
    464462
    465         size_t left = vol->data_blkno;
     463        size_t left = vol->data_blkno - vol->rebuild_blk;
    466464        size_t max_blks = DATA_XFER_LIMIT / vol->bsize;
    467465        buf = hr_malloc_waitok(max_blks * vol->bsize);
    468466
    469467        size_t cnt;
    470         uint64_t ba = 0;
     468        uint64_t ba = vol->rebuild_blk;
    471469        hr_add_data_offset(vol, &ba);
    472470
     
    487485        hr_range_lock_t *rl = NULL;
    488486
     487        HR_NOTE("\"%s\": REBUILD started on extent no. %zu at block %lu.\n",
     488            vol->devname, rebuild_idx, ba);
     489
     490        uint64_t written = 0;
    489491        unsigned int percent, old_percent = 100;
    490492        while (left != 0) {
     
    517519                }
    518520
     521                if (written * vol->bsize > HR_REBUILD_SAVE_BYTES) {
     522                        vol->meta_ops->save(vol, WITH_STATE_CALLBACK);
     523                        written = 0;
     524                }
     525
    519526                hr_range_lock_release(rl);
    520527
     528                written += cnt;
    521529                ba += cnt;
    522530                left -= cnt;
     
    531539        hr_update_ext_state(vol, rebuild_idx, HR_EXT_ONLINE);
    532540
     541        atomic_store_explicit(&vol->rebuild_blk, 0, memory_order_relaxed);
     542
    533543        hr_mark_vol_state_dirty(vol);
    534544
    535545        fibril_rwlock_write_unlock(&vol->states_lock);
    536 
    537         /* (void)vol->meta_ops->save(vol, WITH_STATE_CALLBACK); */
    538 
    539546end:
    540547        fibril_rwlock_read_unlock(&vol->extents_lock);
     
    542549        hr_raid1_vol_state_eval(vol);
    543550
    544         if (buf != NULL)
    545                 free(buf);
     551        free(buf);
    546552
    547553        return rc;
Note: See TracChangeset for help on using the changeset viewer.