Changeset 9cc1f43 in mainline
- Timestamp:
- 2011-08-03T18:49:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1119e5
- Parents:
- 1940326
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/srv/fs/exfat/exfat_idx.c ¶
r1940326 r9cc1f43 58 58 */ 59 59 typedef struct { 60 link_t 61 devmap_handle_t 60 link_t link; 61 devmap_handle_t devmap_handle; 62 62 63 63 /** Next unassigned index. */ 64 fs_index_t 64 fs_index_t next; 65 65 /** Number of remaining unassigned indices. */ 66 uint64_t 66 uint64_t remaining; 67 67 68 68 /** Sorted list of intervals of freed indices. */ 69 link_t freed_head;69 link_t freed_list; 70 70 } unused_t; 71 71 … … 74 74 75 75 /** List of unused structures. */ 76 static LIST_INITIALIZE(unused_ head);76 static LIST_INITIALIZE(unused_list); 77 77 78 78 static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle) … … 82 82 u->next = 0; 83 83 u->remaining = ((uint64_t)((fs_index_t)-1)) + 1; 84 list_initialize(&u->freed_ head);84 list_initialize(&u->freed_list); 85 85 } 86 86 … … 92 92 if (lock) 93 93 fibril_mutex_lock(&unused_lock); 94 for (l = unused_head.next; l != &unused_head; l = l->next) {94 list_foreach(unused_list, l) { 95 95 u = list_get_instance(l, unused_t, link); 96 96 if (u->devmap_handle == devmap_handle) 97 97 return u; 98 98 } 99 99 100 if (lock) 100 101 fibril_mutex_unlock(&unused_lock); … … 249 250 return false; 250 251 251 if (list_empty(&u->freed_ head)) {252 if (list_empty(&u->freed_list)) { 252 253 if (u->remaining) { 253 254 /* … … 262 263 } else { 263 264 /* There are some freed indices which we can reuse. */ 264 freed_t *f = list_get_instance( u->freed_head.next, freed_t,265 link);265 freed_t *f = list_get_instance(list_first(&u->freed_list), 266 freed_t, link); 266 267 *index = f->first; 267 268 if (f->first++ == f->last) { … … 320 321 link_t *lnk; 321 322 freed_t *n; 322 for (lnk = u->freed_ head.next; lnk != &u->freed_head;323 for (lnk = u->freed_list.head.next; lnk != &u->freed_list.head; 323 324 lnk = lnk->next) { 324 325 freed_t *f = list_get_instance(lnk, freed_t, link); 325 326 if (f->first == index + 1) { 326 327 f->first--; 327 if (lnk->prev != &u->freed_ head)328 if (lnk->prev != &u->freed_list.head) 328 329 try_coalesce_intervals(lnk->prev, lnk, 329 330 lnk); … … 333 334 if (f->last == index - 1) { 334 335 f->last++; 335 if (lnk->next != &u->freed_ head)336 if (lnk->next != &u->freed_list.head) 336 337 try_coalesce_intervals(lnk, lnk->next, 337 338 lnk); … … 359 360 n->first = index; 360 361 n->last = index; 361 list_append(&n->link, &u->freed_ head);362 list_append(&n->link, &u->freed_list); 362 363 } 363 364 fibril_mutex_unlock(&unused_lock); … … 559 560 fibril_mutex_lock(&unused_lock); 560 561 if (!unused_find(devmap_handle, false)) { 561 list_append(&u->link, &unused_ head);562 list_append(&u->link, &unused_list); 562 563 } else { 563 564 free(u); … … 595 596 fibril_mutex_unlock(&unused_lock); 596 597 597 while (!list_empty(&u->freed_ head)) {598 while (!list_empty(&u->freed_list)) { 598 599 freed_t *f; 599 f = list_get_instance( u->freed_head.next, freed_t, link);600 f = list_get_instance(list_first(&u->freed_list), freed_t, link); 600 601 list_remove(&f->link); 601 602 free(f);
Note:
See TracChangeset
for help on using the changeset viewer.