Changeset 234212a in mainline


Ignore:
Timestamp:
2025-06-17T13:22:46Z (5 days ago)
Author:
Miroslav Cimerman <mc@…>
Children:
f0950d2
Parents:
a62079d
Message:

hr: rename data_dirty to first_write

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

Legend:

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

    ra62079d r234212a  
    162162}
    163163
    164 void hr_raid1_ext_state_cb(hr_volume_t *vol, size_t extent,
    165     errno_t rc)
    166 {
    167         HR_DEBUG("%s()", __func__);
     164void hr_raid1_ext_state_cb(hr_volume_t *vol, size_t extent, errno_t rc)
     165{
     166        HR_DEBUG("%s()", __func__);
     167
     168        assert(fibril_rwlock_is_locked(&vol->extents_lock));
    168169
    169170        if (rc == EOK)
    170171                return;
    171 
    172         assert(fibril_rwlock_is_locked(&vol->extents_lock));
    173172
    174173        fibril_rwlock_write_lock(&vol->states_lock);
     
    219218                if (old_state != HR_VOL_REBUILD) {
    220219                        /* XXX: allow REBUILD on INVALID extents */
    221                         if (vol->hotspare_no > 0) {
     220                        fibril_mutex_lock(&vol->hotspare_lock);
     221                        size_t hs_no = vol->hotspare_no;
     222                        fibril_mutex_unlock(&vol->hotspare_lock);
     223                        if (hs_no > 0) {
    222224                                fid_t fib = fibril_create(hr_raid1_rebuild,
    223225                                    vol);
     
    322324        uint64_t rebuild_blk;
    323325
     326        if (size < cnt * vol->bsize)
     327                return EINVAL;
     328
    324329        fibril_rwlock_read_lock(&vol->states_lock);
    325330        hr_vol_state_t vol_state = vol->state;
     
    332337        bool exp = false;
    333338        if (type == HR_BD_WRITE &&
    334             atomic_compare_exchange_strong(&vol->data_dirty, &exp, true)) {
     339            atomic_compare_exchange_strong(&vol->first_write, &exp, true)) {
    335340                vol->meta_ops->inc_counter(vol);
    336341                vol->meta_ops->save(vol, WITH_STATE_CALLBACK);
    337342        }
    338 
    339         if (type == HR_BD_READ || type == HR_BD_WRITE)
    340                 if (size < cnt * vol->bsize)
    341                         return EINVAL;
    342343
    343344        rc = hr_check_ba_range(vol, cnt, ba);
     
    346347
    347348        /* allow full dev sync */
    348         if (type != HR_BD_SYNC || ba != 0)
    349                 hr_add_ba_offset(vol, &ba);
     349        if (!(type == HR_BD_SYNC && ba == 0 && cnt == 0))
     350                hr_add_data_offset(vol, &ba);
    350351
    351352        /*
     
    491492        size_t cnt;
    492493        uint64_t ba = 0;
    493         hr_add_ba_offset(vol, &ba);
     494        hr_add_data_offset(vol, &ba);
    494495
    495496        /*
     
    501502        /* increment metadata counter only on first write */
    502503        bool exp = false;
    503         if (atomic_compare_exchange_strong(&vol->data_dirty, &exp, true)) {
     504        if (atomic_compare_exchange_strong(&vol->first_write, &exp, true)) {
    504505                vol->meta_ops->inc_counter(vol);
    505506                vol->meta_ops->save(vol, WITH_STATE_CALLBACK);
  • uspace/srv/bd/hr/util.c

    ra62079d r234212a  
    152152
    153153        atomic_init(&vol->state_dirty, false);
    154         atomic_init(&vol->data_dirty, false);
     154        atomic_init(&vol->first_write, false);
    155155        atomic_init(&vol->rebuild_blk, 0);
    156156        atomic_init(&vol->open_cnt, 0);
     
    397397}
    398398
    399 void hr_add_ba_offset(hr_volume_t *vol, uint64_t *ba)
     399void hr_add_data_offset(hr_volume_t *vol, uint64_t *ba)
    400400{
    401401        *ba = *ba + vol->data_offset;
     402}
     403
     404void hr_sub_data_offset(hr_volume_t *vol, uint64_t *ba)
     405{
     406        *ba = *ba - vol->data_offset;
    402407}
    403408
  • uspace/srv/bd/hr/util.h

    ra62079d r234212a  
    8787extern errno_t hr_register_volume(hr_volume_t *);
    8888extern errno_t hr_check_ba_range(hr_volume_t *, size_t, uint64_t);
    89 extern void hr_add_ba_offset(hr_volume_t *, uint64_t *);
     89extern void hr_add_data_offset(hr_volume_t *, uint64_t *);
     90extern void hr_sub_data_offset(hr_volume_t *, uint64_t *);
    9091extern void hr_update_ext_state(hr_volume_t *, size_t, hr_ext_state_t);
    9192extern void hr_update_hotspare_state(hr_volume_t *, size_t, hr_ext_state_t);
  • uspace/srv/bd/hr/var.h

    ra62079d r234212a  
    105105         * allowing non-destructive read-only access
    106106         */
    107         _Atomic bool data_dirty;
     107        _Atomic bool first_write;
    108108
    109         /* XXX: atomic_uint_least64_t? */
    110109        _Atomic uint64_t rebuild_blk; /* rebuild position */
    111110        _Atomic int open_cnt; /* open/close() counter */
Note: See TracChangeset for help on using the changeset viewer.