Changeset 234212a in mainline
- Timestamp:
- 2025-06-17T13:22:46Z (5 days ago)
- Children:
- f0950d2
- Parents:
- a62079d
- Location:
- uspace/srv/bd/hr
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/bd/hr/raid1.c
ra62079d r234212a 162 162 } 163 163 164 void hr_raid1_ext_state_cb(hr_volume_t *vol, size_t extent, 165 errno_t rc) 166 { 167 HR_DEBUG("%s()", __func__); 164 void 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)); 168 169 169 170 if (rc == EOK) 170 171 return; 171 172 assert(fibril_rwlock_is_locked(&vol->extents_lock));173 172 174 173 fibril_rwlock_write_lock(&vol->states_lock); … … 219 218 if (old_state != HR_VOL_REBUILD) { 220 219 /* 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) { 222 224 fid_t fib = fibril_create(hr_raid1_rebuild, 223 225 vol); … … 322 324 uint64_t rebuild_blk; 323 325 326 if (size < cnt * vol->bsize) 327 return EINVAL; 328 324 329 fibril_rwlock_read_lock(&vol->states_lock); 325 330 hr_vol_state_t vol_state = vol->state; … … 332 337 bool exp = false; 333 338 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)) { 335 340 vol->meta_ops->inc_counter(vol); 336 341 vol->meta_ops->save(vol, WITH_STATE_CALLBACK); 337 342 } 338 339 if (type == HR_BD_READ || type == HR_BD_WRITE)340 if (size < cnt * vol->bsize)341 return EINVAL;342 343 343 344 rc = hr_check_ba_range(vol, cnt, ba); … … 346 347 347 348 /* 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); 350 351 351 352 /* … … 491 492 size_t cnt; 492 493 uint64_t ba = 0; 493 hr_add_ ba_offset(vol, &ba);494 hr_add_data_offset(vol, &ba); 494 495 495 496 /* … … 501 502 /* increment metadata counter only on first write */ 502 503 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)) { 504 505 vol->meta_ops->inc_counter(vol); 505 506 vol->meta_ops->save(vol, WITH_STATE_CALLBACK); -
uspace/srv/bd/hr/util.c
ra62079d r234212a 152 152 153 153 atomic_init(&vol->state_dirty, false); 154 atomic_init(&vol-> data_dirty, false);154 atomic_init(&vol->first_write, false); 155 155 atomic_init(&vol->rebuild_blk, 0); 156 156 atomic_init(&vol->open_cnt, 0); … … 397 397 } 398 398 399 void hr_add_ ba_offset(hr_volume_t *vol, uint64_t *ba)399 void hr_add_data_offset(hr_volume_t *vol, uint64_t *ba) 400 400 { 401 401 *ba = *ba + vol->data_offset; 402 } 403 404 void hr_sub_data_offset(hr_volume_t *vol, uint64_t *ba) 405 { 406 *ba = *ba - vol->data_offset; 402 407 } 403 408 -
uspace/srv/bd/hr/util.h
ra62079d r234212a 87 87 extern errno_t hr_register_volume(hr_volume_t *); 88 88 extern 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 *); 89 extern void hr_add_data_offset(hr_volume_t *, uint64_t *); 90 extern void hr_sub_data_offset(hr_volume_t *, uint64_t *); 90 91 extern void hr_update_ext_state(hr_volume_t *, size_t, hr_ext_state_t); 91 92 extern void hr_update_hotspare_state(hr_volume_t *, size_t, hr_ext_state_t); -
uspace/srv/bd/hr/var.h
ra62079d r234212a 105 105 * allowing non-destructive read-only access 106 106 */ 107 _Atomic bool data_dirty;107 _Atomic bool first_write; 108 108 109 /* XXX: atomic_uint_least64_t? */110 109 _Atomic uint64_t rebuild_blk; /* rebuild position */ 111 110 _Atomic int open_cnt; /* open/close() counter */
Note:
See TracChangeset
for help on using the changeset viewer.