Changeset 9cc1f43 in mainline


Ignore:
Timestamp:
2011-08-03T18:49:28Z (13 years ago)
Author:
Oleg Romanenko <romanenko.oleg@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1119e5
Parents:
1940326
Message:

Migrate changes from mainline to exfat_idx.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/exfat/exfat_idx.c

    r1940326 r9cc1f43  
    5858 */
    5959typedef struct {
    60         link_t          link;
    61         devmap_handle_t devmap_handle;
     60        link_t link;
     61        devmap_handle_t devmap_handle;
    6262
    6363        /** Next unassigned index. */
    64         fs_index_t      next;
     64        fs_index_t next;
    6565        /** Number of remaining unassigned indices. */
    66         uint64_t        remaining;
     66        uint64_t remaining;
    6767
    6868        /** Sorted list of intervals of freed indices. */
    69         link_t          freed_head;
     69        link_t freed_list;
    7070} unused_t;
    7171
     
    7474
    7575/** List of unused structures. */
    76 static LIST_INITIALIZE(unused_head);
     76static LIST_INITIALIZE(unused_list);
    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_head);
     84        list_initialize(&u->freed_list);
    8585}
    8686
     
    9292        if (lock)
    9393                fibril_mutex_lock(&unused_lock);
    94         for (l = unused_head.next; l != &unused_head; l = l->next) {
     94        list_foreach(unused_list, l) {
    9595                u = list_get_instance(l, unused_t, link);
    9696                if (u->devmap_handle == devmap_handle)
    9797                        return u;
    9898        }
     99
    99100        if (lock)
    100101                fibril_mutex_unlock(&unused_lock);
     
    249250                return false;   
    250251
    251         if (list_empty(&u->freed_head)) {
     252        if (list_empty(&u->freed_list)) {
    252253                if (u->remaining) {
    253254                        /*
     
    262263        } else {
    263264                /* 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);
    266267                *index = f->first;
    267268                if (f->first++ == f->last) {
     
    320321                link_t *lnk;
    321322                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;
    323324                    lnk = lnk->next) {
    324325                        freed_t *f = list_get_instance(lnk, freed_t, link);
    325326                        if (f->first == index + 1) {
    326327                                f->first--;
    327                                 if (lnk->prev != &u->freed_head)
     328                                if (lnk->prev != &u->freed_list.head)
    328329                                        try_coalesce_intervals(lnk->prev, lnk,
    329330                                            lnk);
     
    333334                        if (f->last == index - 1) {
    334335                                f->last++;
    335                                 if (lnk->next != &u->freed_head)
     336                                if (lnk->next != &u->freed_list.head)
    336337                                        try_coalesce_intervals(lnk, lnk->next,
    337338                                            lnk);
     
    359360                n->first = index;
    360361                n->last = index;
    361                 list_append(&n->link, &u->freed_head);
     362                list_append(&n->link, &u->freed_list);
    362363        }
    363364        fibril_mutex_unlock(&unused_lock);
     
    559560        fibril_mutex_lock(&unused_lock);
    560561        if (!unused_find(devmap_handle, false)) {
    561                 list_append(&u->link, &unused_head);
     562                list_append(&u->link, &unused_list);
    562563        } else {
    563564                free(u);
     
    595596        fibril_mutex_unlock(&unused_lock);
    596597
    597         while (!list_empty(&u->freed_head)) {
     598        while (!list_empty(&u->freed_list)) {
    598599                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);
    600601                list_remove(&f->link);
    601602                free(f);
Note: See TracChangeset for help on using the changeset viewer.