Changes in uspace/srv/fs/fat/fat_idx.c [a9d85df:c7bbf029] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_idx.c
ra9d85df rc7bbf029 59 59 typedef struct { 60 60 link_t link; 61 devmap_handle_t 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 li st_t freed_list;69 link_t freed_head; 70 70 } unused_t; 71 71 … … 74 74 75 75 /** List of unused structures. */ 76 static LIST_INITIALIZE(unused_ list);76 static LIST_INITIALIZE(unused_head); 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_ list);84 list_initialize(&u->freed_head); 85 85 } 86 86 … … 88 88 { 89 89 unused_t *u; 90 link_t *l; 90 91 91 92 if (lock) 92 93 fibril_mutex_lock(&unused_lock); 93 94 list_foreach(unused_list, l) { 94 for (l = unused_head.next; l != &unused_head; l = l->next) { 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 100 99 if (lock) 101 100 fibril_mutex_unlock(&unused_lock); … … 250 249 return false; 251 250 252 if (list_empty(&u->freed_ list)) {251 if (list_empty(&u->freed_head)) { 253 252 if (u->remaining) { 254 253 /* … … 263 262 } else { 264 263 /* There are some freed indices which we can reuse. */ 265 freed_t *f = list_get_instance( list_first(&u->freed_list),266 freed_t,link);264 freed_t *f = list_get_instance(u->freed_head.next, freed_t, 265 link); 267 266 *index = f->first; 268 267 if (f->first++ == f->last) { … … 321 320 link_t *lnk; 322 321 freed_t *n; 323 for (lnk = u->freed_ list.head.next; lnk != &u->freed_list.head;322 for (lnk = u->freed_head.next; lnk != &u->freed_head; 324 323 lnk = lnk->next) { 325 324 freed_t *f = list_get_instance(lnk, freed_t, link); 326 325 if (f->first == index + 1) { 327 326 f->first--; 328 if (lnk->prev != &u->freed_ list.head)327 if (lnk->prev != &u->freed_head) 329 328 try_coalesce_intervals(lnk->prev, lnk, 330 329 lnk); … … 334 333 if (f->last == index - 1) { 335 334 f->last++; 336 if (lnk->next != &u->freed_ list.head)335 if (lnk->next != &u->freed_head) 337 336 try_coalesce_intervals(lnk, lnk->next, 338 337 lnk); … … 360 359 n->first = index; 361 360 n->last = index; 362 list_append(&n->link, &u->freed_ list);361 list_append(&n->link, &u->freed_head); 363 362 } 364 363 fibril_mutex_unlock(&unused_lock); … … 559 558 fibril_mutex_lock(&unused_lock); 560 559 if (!unused_find(devmap_handle, false)) { 561 list_append(&u->link, &unused_ list);560 list_append(&u->link, &unused_head); 562 561 } else { 563 562 free(u); … … 595 594 fibril_mutex_unlock(&unused_lock); 596 595 597 while (!list_empty(&u->freed_ list)) {596 while (!list_empty(&u->freed_head)) { 598 597 freed_t *f; 599 f = list_get_instance( list_first(&u->freed_list), freed_t, link);598 f = list_get_instance(u->freed_head.next, freed_t, link); 600 599 list_remove(&f->link); 601 600 free(f);
Note:
See TracChangeset
for help on using the changeset viewer.