Changeset 6ebe721 in mainline for uspace/srv/fs/fat/fat_idx.c
- Timestamp:
- 2009-06-17T22:07:42Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4e1b57d
- Parents:
- 34ca870
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_idx.c
r34ca870 r6ebe721 43 43 #include <adt/list.h> 44 44 #include <assert.h> 45 #include <f utex.h>45 #include <fibril_sync.h> 46 46 47 47 /** Each instance of this type describes one interval of freed VFS indices. */ … … 69 69 } unused_t; 70 70 71 /** Futex protecting the list of unused structures. */72 static futex_t unused_futex = FUTEX_INITIALIZER;71 /** Mutex protecting the list of unused structures. */ 72 static FIBRIL_MUTEX_INITIALIZE(unused_lock); 73 73 74 74 /** List of unused structures. */ … … 90 90 91 91 if (lock) 92 f utex_down(&unused_futex);92 fibril_mutex_lock(&unused_lock); 93 93 for (l = unused_head.next; l != &unused_head; l = l->next) { 94 94 u = list_get_instance(l, unused_t, link); … … 97 97 } 98 98 if (lock) 99 f utex_up(&unused_futex);99 fibril_mutex_unlock(&unused_lock); 100 100 return NULL; 101 101 } 102 102 103 /** Futex protecting the up_hash and ui_hash. */104 static futex_t used_futex = FUTEX_INITIALIZER;103 /** Mutex protecting the up_hash and ui_hash. */ 104 static FIBRIL_MUTEX_INITIALIZE(used_lock); 105 105 106 106 /** … … 232 232 *index = u->next++; 233 233 --u->remaining; 234 f utex_up(&unused_futex);234 fibril_mutex_unlock(&unused_lock); 235 235 return true; 236 236 } … … 245 245 free(f); 246 246 } 247 f utex_up(&unused_futex);247 fibril_mutex_unlock(&unused_lock); 248 248 return true; 249 249 } … … 253 253 * too many zero-sized nodes). 254 254 */ 255 f utex_up(&unused_futex);255 fibril_mutex_unlock(&unused_lock); 256 256 return false; 257 257 } … … 303 303 try_coalesce_intervals(lnk->prev, lnk, 304 304 lnk); 305 f utex_up(&unused_futex);305 fibril_mutex_unlock(&unused_lock); 306 306 return; 307 307 } … … 311 311 try_coalesce_intervals(lnk, lnk->next, 312 312 lnk); 313 f utex_up(&unused_futex);313 fibril_mutex_unlock(&unused_lock); 314 314 return; 315 315 } … … 322 322 n->last = index; 323 323 list_insert_before(&n->link, lnk); 324 f utex_up(&unused_futex);324 fibril_mutex_unlock(&unused_lock); 325 325 return; 326 326 } … … 336 336 list_append(&n->link, &u->freed_head); 337 337 } 338 f utex_up(&unused_futex);338 fibril_mutex_unlock(&unused_lock); 339 339 } 340 340 … … 353 353 link_initialize(&fidx->uph_link); 354 354 link_initialize(&fidx->uih_link); 355 f utex_initialize(&fidx->lock, 1);355 fibril_mutex_initialize(&fidx->lock); 356 356 fidx->dev_handle = dev_handle; 357 357 fidx->pfc = FAT_CLST_RES0; /* no parent yet */ … … 366 366 fat_idx_t *fidx; 367 367 368 f utex_down(&used_futex);368 fibril_mutex_lock(&used_lock); 369 369 fidx = fat_idx_create(dev_handle); 370 370 if (!fidx) { 371 f utex_up(&used_futex);371 fibril_mutex_unlock(&used_lock); 372 372 return NULL; 373 373 } … … 379 379 380 380 hash_table_insert(&ui_hash, ikey, &fidx->uih_link); 381 f utex_down(&fidx->lock);382 f utex_up(&used_futex);381 fibril_mutex_lock(&fidx->lock); 382 fibril_mutex_unlock(&used_lock); 383 383 384 384 return fidx; … … 396 396 }; 397 397 398 f utex_down(&used_futex);398 fibril_mutex_lock(&used_lock); 399 399 l = hash_table_find(&up_hash, pkey); 400 400 if (l) { … … 403 403 fidx = fat_idx_create(dev_handle); 404 404 if (!fidx) { 405 f utex_up(&used_futex);405 fibril_mutex_unlock(&used_lock); 406 406 return NULL; 407 407 } … … 418 418 hash_table_insert(&ui_hash, ikey, &fidx->uih_link); 419 419 } 420 f utex_down(&fidx->lock);421 f utex_up(&used_futex);420 fibril_mutex_lock(&fidx->lock); 421 fibril_mutex_unlock(&used_lock); 422 422 423 423 return fidx; … … 432 432 }; 433 433 434 f utex_down(&used_futex);434 fibril_mutex_lock(&used_lock); 435 435 hash_table_insert(&up_hash, pkey, &idx->uph_link); 436 f utex_up(&used_futex);436 fibril_mutex_unlock(&used_lock); 437 437 } 438 438 … … 445 445 }; 446 446 447 f utex_down(&used_futex);447 fibril_mutex_lock(&used_lock); 448 448 hash_table_remove(&up_hash, pkey, 3); 449 f utex_up(&used_futex);449 fibril_mutex_unlock(&used_lock); 450 450 } 451 451 … … 460 460 }; 461 461 462 f utex_down(&used_futex);462 fibril_mutex_lock(&used_lock); 463 463 l = hash_table_find(&ui_hash, ikey); 464 464 if (l) { … … 466 466 futex_down(&fidx->lock); 467 467 } 468 f utex_up(&used_futex);468 fibril_mutex_unlock(&used_lock); 469 469 470 470 return fidx; … … 484 484 assert(idx->pfc == FAT_CLST_RES0); 485 485 486 f utex_down(&used_futex);486 fibril_mutex_lock(&used_lock); 487 487 /* 488 488 * Since we can only free unlinked nodes, the index structure is not … … 491 491 */ 492 492 hash_table_remove(&ui_hash, ikey, 2); 493 f utex_up(&used_futex);493 fibril_mutex_unlock(&used_lock); 494 494 /* Release the VFS index. */ 495 495 fat_index_free(idx->dev_handle, idx->index); … … 525 525 return ENOMEM; 526 526 unused_initialize(u, dev_handle); 527 f utex_down(&unused_futex);527 fibril_mutex_lock(&unused_lock); 528 528 if (!unused_find(dev_handle, false)) 529 529 list_append(&u->link, &unused_head); 530 530 else 531 531 rc = EEXIST; 532 f utex_up(&unused_futex);532 fibril_mutex_unlock(&unused_lock); 533 533 return rc; 534 534 } … … 541 541 assert(u); 542 542 list_remove(&u->link); 543 f utex_up(&unused_futex);543 fibril_mutex_unlock(&unused_lock); 544 544 545 545 while (!list_empty(&u->freed_head)) {
Note:
See TracChangeset
for help on using the changeset viewer.