Changeset e4f8c77 in mainline for uspace/lib/block/libblock.c


Ignore:
Timestamp:
2011-07-13T22:39:18Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e6910c8
Parents:
5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/block/libblock.c

    r5974661 re4f8c77  
    6060static FIBRIL_MUTEX_INITIALIZE(dcl_lock);
    6161/** Device connection list head. */
    62 static LIST_INITIALIZE(dcl_head);
     62static LIST_INITIALIZE(dcl);
    6363
    6464#define CACHE_BUCKETS_LOG2  10
     
    7272        unsigned blocks_cached;   /**< Number of cached blocks. */
    7373        hash_table_t block_hash;
    74         link_t free_head;
     74        list_t free_list;
    7575        enum cache_mode mode;
    7676} cache_t;
     
    9797static devcon_t *devcon_search(devmap_handle_t devmap_handle)
    9898{
    99         link_t *cur;
    100        
    10199        fibril_mutex_lock(&dcl_lock);
    102100       
    103         for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
     101        list_foreach(dcl, cur) {
    104102                devcon_t *devcon = list_get_instance(cur, devcon_t, link);
    105103                if (devcon->devmap_handle == devmap_handle) {
     
    116114    size_t bsize, void *comm_area, size_t comm_size)
    117115{
    118         link_t *cur;
    119116        devcon_t *devcon;
    120117       
     
    138135       
    139136        fibril_mutex_lock(&dcl_lock);
    140         for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) {
     137        list_foreach(dcl, cur) {
    141138                devcon_t *d = list_get_instance(cur, devcon_t, link);
    142139                if (d->devmap_handle == devmap_handle) {
     
    146143                }
    147144        }
    148         list_append(&devcon->link, &dcl_head);
     145        list_append(&devcon->link, &dcl);
    149146        fibril_mutex_unlock(&dcl_lock);
    150147        return EOK;
     
    294291       
    295292        fibril_mutex_initialize(&cache->lock);
    296         list_initialize(&cache->free_head);
     293        list_initialize(&cache->free_list);
    297294        cache->lblock_size = size;
    298295        cache->block_count = blocks;
     
    335332         * bother with the cache and block locks because we are single-threaded.
    336333         */
    337         while (!list_empty(&cache->free_head)) {
    338                 block_t *b = list_get_instance(cache->free_head.next,
     334        while (!list_empty(&cache->free_list)) {
     335                block_t *b = list_get_instance(list_first(&cache->free_list),
    339336                    block_t, free_link);
    340337
     
    367364        if (cache->blocks_cached < CACHE_LO_WATERMARK)
    368365                return true;
    369         if (!list_empty(&cache->free_head))
     366        if (!list_empty(&cache->free_list))
    370367                return false;
    371368        return true;
     
    456453                        unsigned long temp_key;
    457454recycle:
    458                         if (list_empty(&cache->free_head)) {
     455                        if (list_empty(&cache->free_list)) {
    459456                                fibril_mutex_unlock(&cache->lock);
    460457                                rc = ENOMEM;
    461458                                goto out;
    462459                        }
    463                         l = cache->free_head.next;
     460                        l = list_first(&cache->free_list);
    464461                        b = list_get_instance(l, block_t, free_link);
    465462
     
    476473                                 */
    477474                                list_remove(&b->free_link);
    478                                 list_append(&b->free_link, &cache->free_head);
     475                                list_append(&b->free_link, &cache->free_list);
    479476                                fibril_mutex_unlock(&cache->lock);
    480477                                fibril_mutex_lock(&devcon->comm_area_lock);
     
    668665                        goto retry;
    669666                }
    670                 list_append(&block->free_link, &cache->free_head);
     667                list_append(&block->free_link, &cache->free_list);
    671668        }
    672669        fibril_mutex_unlock(&block->lock);
Note: See TracChangeset for help on using the changeset viewer.