Changeset add5835 in mainline for uspace/srv/fs/fat/fat_idx.c


Ignore:
Timestamp:
2008-05-17T20:10:54Z (17 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e811bde
Parents:
78a1b7b
Message:

Add locks to FAT index structures, FAT in-core node structures. Add futex to
protect the list of free cached FAT in-core nodes. Make fat_node_get() and
fat_node_put() and some other functions aware of these new locks.

File:
1 edited

Legend:

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

    r78a1b7b radd5835  
    7575static LIST_INITIALIZE(unused_head);
    7676
    77 /** Futex protecting the up_hash and ui_hash.
    78  *
    79  * The locking strategy assumes that there will be at most one fibril for each
    80  * dev_handle.  Therefore it will be sufficient to hold the futex for shorter
    81  * times (i.e. only during hash table operations as opposed to holding it the
    82  * whole time between an unsuccessful find and the following insert). Should the
    83  * assumption break, the locking strategy for this futex will have to be
    84  * reconsidered.
    85  */
     77/** Futex protecting the up_hash and ui_hash. */
    8678static futex_t used_futex = FUTEX_INITIALIZER;
    8779
     
    353345        futex_down(&used_futex);
    354346        l = hash_table_find(&up_hash, pkey);
    355         futex_up(&used_futex);
    356347        if (l) {
    357348                fidx = hash_table_get_instance(l, fat_idx_t, uph_link);
     
    359350                fidx = (fat_idx_t *) malloc(sizeof(fat_idx_t));
    360351                if (!fidx) {
     352                        futex_up(&used_futex);
    361353                        return NULL;
    362354                }
    363355                if (!fat_idx_alloc(dev_handle, &fidx->index)) {
    364356                        free(fidx);
     357                        futex_up(&used_futex);
    365358                        return NULL;
    366359                }
     
    373366                link_initialize(&fidx->uph_link);
    374367                link_initialize(&fidx->uih_link);
     368                futex_initialize(&fidx->lock, 1);
    375369                fidx->dev_handle = dev_handle;
    376370                fidx->pfc = pfc;
     
    378372                fidx->nodep = NULL;
    379373
    380                 futex_down(&used_futex);
    381374                hash_table_insert(&up_hash, pkey, &fidx->uph_link);
    382375                hash_table_insert(&ui_hash, ikey, &fidx->uih_link);
    383                 futex_up(&used_futex);
    384         }
     376        }
     377        futex_down(&fidx->lock);
     378        futex_up(&used_futex);
    385379
    386380        return fidx;
     
    399393        futex_down(&used_futex);
    400394        l = hash_table_find(&ui_hash, ikey);
    401         futex_up(&used_futex);
    402395        if (l) {
    403396                fidx = hash_table_get_instance(l, fat_idx_t, uih_link);
    404         }
     397                futex_down(&fidx->lock);
     398        }
     399        futex_up(&used_futex);
    405400
    406401        return fidx;
Note: See TracChangeset for help on using the changeset viewer.