74,15 → 74,7 |
/** List of unused structures. */ |
static LIST_INITIALIZE(unused_head); |
|
/** Futex protecting the up_hash and ui_hash. |
* |
* The locking strategy assumes that there will be at most one fibril for each |
* dev_handle. Therefore it will be sufficient to hold the futex for shorter |
* times (i.e. only during hash table operations as opposed to holding it the |
* whole time between an unsuccessful find and the following insert). Should the |
* assumption break, the locking strategy for this futex will have to be |
* reconsidered. |
*/ |
/** Futex protecting the up_hash and ui_hash. */ |
static futex_t used_futex = FUTEX_INITIALIZER; |
|
/** |
352,16 → 344,17 |
|
futex_down(&used_futex); |
l = hash_table_find(&up_hash, pkey); |
futex_up(&used_futex); |
if (l) { |
fidx = hash_table_get_instance(l, fat_idx_t, uph_link); |
} else { |
fidx = (fat_idx_t *) malloc(sizeof(fat_idx_t)); |
if (!fidx) { |
futex_up(&used_futex); |
return NULL; |
} |
if (!fat_idx_alloc(dev_handle, &fidx->index)) { |
free(fidx); |
futex_up(&used_futex); |
return NULL; |
} |
|
372,16 → 365,17 |
|
link_initialize(&fidx->uph_link); |
link_initialize(&fidx->uih_link); |
futex_initialize(&fidx->lock, 1); |
fidx->dev_handle = dev_handle; |
fidx->pfc = pfc; |
fidx->pdi = pdi; |
fidx->nodep = NULL; |
|
futex_down(&used_futex); |
hash_table_insert(&up_hash, pkey, &fidx->uph_link); |
hash_table_insert(&ui_hash, ikey, &fidx->uih_link); |
futex_up(&used_futex); |
} |
futex_down(&fidx->lock); |
futex_up(&used_futex); |
|
return fidx; |
} |
398,10 → 392,11 |
|
futex_down(&used_futex); |
l = hash_table_find(&ui_hash, ikey); |
futex_up(&used_futex); |
if (l) { |
fidx = hash_table_get_instance(l, fat_idx_t, uih_link); |
futex_down(&fidx->lock); |
} |
futex_up(&used_futex); |
|
return fidx; |
} |