Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_idx.c

    rb72efe8 rc7bbf029  
    6767
    6868        /** Sorted list of intervals of freed indices. */
    69         list_t          freed_list;
     69        link_t          freed_head;
    7070} unused_t;
    7171
     
    7474
    7575/** List of unused structures. */
    76 static LIST_INITIALIZE(unused_list);
     76static LIST_INITIALIZE(unused_head);
    7777
    7878static void unused_initialize(unused_t *u, devmap_handle_t devmap_handle)
     
    8282        u->next = 0;
    8383        u->remaining = ((uint64_t)((fs_index_t)-1)) + 1;
    84         list_initialize(&u->freed_list);
     84        list_initialize(&u->freed_head);
    8585}
    8686
     
    8888{
    8989        unused_t *u;
     90        link_t *l;
    9091
    9192        if (lock)
    9293                fibril_mutex_lock(&unused_lock);
    93 
    94         list_foreach(unused_list, l) {
     94        for (l = unused_head.next; l != &unused_head; l = l->next) {
    9595                u = list_get_instance(l, unused_t, link);
    9696                if (u->devmap_handle == devmap_handle)
    9797                        return u;
    9898        }
    99 
    10099        if (lock)
    101100                fibril_mutex_unlock(&unused_lock);
     
    250249                return false;   
    251250
    252         if (list_empty(&u->freed_list)) {
     251        if (list_empty(&u->freed_head)) {
    253252                if (u->remaining) {
    254253                        /*
     
    263262        } else {
    264263                /* 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);
    267266                *index = f->first;
    268267                if (f->first++ == f->last) {
     
    321320                link_t *lnk;
    322321                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;
    324323                    lnk = lnk->next) {
    325324                        freed_t *f = list_get_instance(lnk, freed_t, link);
    326325                        if (f->first == index + 1) {
    327326                                f->first--;
    328                                 if (lnk->prev != &u->freed_list.head)
     327                                if (lnk->prev != &u->freed_head)
    329328                                        try_coalesce_intervals(lnk->prev, lnk,
    330329                                            lnk);
     
    334333                        if (f->last == index - 1) {
    335334                                f->last++;
    336                                 if (lnk->next != &u->freed_list.head)
     335                                if (lnk->next != &u->freed_head)
    337336                                        try_coalesce_intervals(lnk, lnk->next,
    338337                                            lnk);
     
    360359                n->first = index;
    361360                n->last = index;
    362                 list_append(&n->link, &u->freed_list);
     361                list_append(&n->link, &u->freed_head);
    363362        }
    364363        fibril_mutex_unlock(&unused_lock);
     
    559558        fibril_mutex_lock(&unused_lock);
    560559        if (!unused_find(devmap_handle, false)) {
    561                 list_append(&u->link, &unused_list);
     560                list_append(&u->link, &unused_head);
    562561        } else {
    563562                free(u);
     
    595594        fibril_mutex_unlock(&unused_lock);
    596595
    597         while (!list_empty(&u->freed_list)) {
     596        while (!list_empty(&u->freed_head)) {
    598597                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);
    600599                list_remove(&f->link);
    601600                free(f);
Note: See TracChangeset for help on using the changeset viewer.