Changeset 401b9e42 in mainline


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

hr: state_changed and peding_invalidation atomic flags

These flags are used to check whether there was a state
change, or if there is a pending invalidation, so that
we can avoid the slow code paths in a lockless fashion.

Location:
uspace/srv/bd/hr
Files:
3 edited

Legend:

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

    re2b417f r401b9e42  
    264264
    265265        atomic_init(&new_volume->rebuild_blk, 0);
     266        atomic_init(&new_volume->state_changed, false);
     267        atomic_init(&new_volume->pending_invalidation, false);
    266268
    267269        rc = new_volume->hr_ops.create(new_volume);
     
    320322                fibril_rwlock_write_lock(&vol->states_lock);
    321323                fibril_rwlock_read_lock(&vol->extents_lock);
     324
     325                /* TODO: maybe expose extent state callbacks */
    322326                hr_update_ext_status(vol, fail_extent, HR_EXT_FAILED);
     327                atomic_store(&vol->state_changed, true);
     328
    323329                fibril_rwlock_read_unlock(&vol->extents_lock);
    324330                fibril_rwlock_write_unlock(&vol->states_lock);
  • uspace/srv/bd/hr/raid1.c

    re2b417f r401b9e42  
    103103        new_volume->hr_bds.sarg = new_volume;
    104104
     105        /* force volume state update */
     106        atomic_store(&new_volume->state_changed, true);
    105107        hr_raid1_update_vol_status(new_volume);
    106108        if (new_volume->status == HR_VOL_FAULTY)
     
    275277static void hr_raid1_update_vol_status(hr_volume_t *vol)
    276278{
    277         fibril_mutex_lock(&vol->deferred_list_lock);
    278 
    279         if (list_count(&vol->deferred_invalidations_list) > 0)
     279        bool exp = true;
     280
     281        if (!atomic_compare_exchange_strong(&vol->state_changed, &exp, false))
     282                return;
     283
     284        if (atomic_compare_exchange_strong(&vol->pending_invalidation, &exp,
     285            false)) {
     286                fibril_mutex_lock(&vol->deferred_list_lock);
    280287                process_deferred_invalidations(vol);
    281 
    282         fibril_mutex_unlock(&vol->deferred_list_lock);
     288                fibril_mutex_unlock(&vol->deferred_list_lock);
     289        }
    283290
    284291        fibril_rwlock_read_lock(&vol->extents_lock);
     
    344351                                assert(vol->extents[extent].status ==
    345352                                    HR_EXT_INVALID);
    346                                 goto done;
     353                                goto deferring_end;
    347354                        }
    348355                }
     
    358365                list_append(&vol->deferred_inval[i].link,
    359366                    &vol->deferred_invalidations_list);
    360         done:
     367
     368                atomic_store(&vol->pending_invalidation, true);
     369        deferring_end:
     370
    361371                fibril_mutex_unlock(&vol->deferred_list_lock);
    362372                break;
     
    367377                hr_update_ext_status(vol, extent, HR_EXT_FAILED);
    368378        }
     379
     380        atomic_store(&vol->state_changed, true);
    369381
    370382        fibril_rwlock_write_unlock(&vol->states_lock);
  • uspace/srv/bd/hr/var.h

    re2b417f r401b9e42  
    117117         * are harvested later when we are able to.
    118118         */
     119        _Atomic bool pending_invalidation;
    119120        fibril_mutex_t deferred_list_lock;
    120121        list_t deferred_invalidations_list;
    121122        hr_deferred_invalidation_t deferred_inval[HR_MAX_EXTENTS];
    122123
     124        _Atomic bool state_changed;
    123125        _Atomic uint64_t rebuild_blk;
    124126        uint64_t counter; /* metadata syncing */
Note: See TracChangeset for help on using the changeset viewer.