Changes in uspace/srv/fs/fat/fat_idx.c [9a15176:430de97] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat_idx.c
r9a15176 r430de97 43 43 #include <adt/list.h> 44 44 #include <assert.h> 45 #include <fibril_sync .h>45 #include <fibril_synch.h> 46 46 47 47 /** Each instance of this type describes one interval of freed VFS indices. */ … … 149 149 { 150 150 dev_handle_t dev_handle = (dev_handle_t)key[UPH_DH_KEY]; 151 fat_cluster_t pfc = (fat_cluster_t)key[UPH_PFC_KEY];152 unsigned pdi = (unsigned)key[UPH_PDI_KEY];151 fat_cluster_t pfc; 152 unsigned pdi; 153 153 fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uph_link); 154 154 155 return (dev_handle == fidx->dev_handle) && (pfc == fidx->pfc) && 156 (pdi == fidx->pdi); 155 switch (keys) { 156 case 1: 157 return (dev_handle == fidx->dev_handle); 158 case 3: 159 pfc = (fat_cluster_t) key[UPH_PFC_KEY]; 160 pdi = (unsigned) key[UPH_PDI_KEY]; 161 return (dev_handle == fidx->dev_handle) && (pfc == fidx->pfc) && 162 (pdi == fidx->pdi); 163 default: 164 assert((keys == 1) || (keys == 3)); 165 } 157 166 } 158 167 … … 197 206 { 198 207 dev_handle_t dev_handle = (dev_handle_t)key[UIH_DH_KEY]; 199 fs_index_t index = (fs_index_t)key[UIH_INDEX_KEY];208 fs_index_t index; 200 209 fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link); 201 210 202 return (dev_handle == fidx->dev_handle) && (index == fidx->index); 211 switch (keys) { 212 case 1: 213 return (dev_handle == fidx->dev_handle); 214 case 2: 215 index = (fs_index_t) key[UIH_INDEX_KEY]; 216 return (dev_handle == fidx->dev_handle) && 217 (index == fidx->index); 218 default: 219 assert((keys == 1) || (keys == 2)); 220 } 203 221 } 204 222 205 223 static void idx_remove_callback(link_t *item) 206 224 { 207 /* nothing to do */ 225 fat_idx_t *fidx = list_get_instance(item, fat_idx_t, uih_link); 226 227 free(fidx); 208 228 } 209 229 … … 486 506 [UIH_INDEX_KEY] = idx->index, 487 507 }; 508 dev_handle_t dev_handle = idx->dev_handle; 509 fs_index_t index = idx->index; 488 510 489 511 assert(idx->pfc == FAT_CLST_RES0); … … 498 520 fibril_mutex_unlock(&used_lock); 499 521 /* Release the VFS index. */ 500 fat_index_free(idx->dev_handle, idx->index); 501 /* Deallocate the structure. */ 502 free(idx); 522 fat_index_free(dev_handle, index); 523 /* The index structure itself is freed in idx_remove_callback(). */ 503 524 } 504 525 … … 531 552 unused_initialize(u, dev_handle); 532 553 fibril_mutex_lock(&unused_lock); 533 if (!unused_find(dev_handle, false)) 554 if (!unused_find(dev_handle, false)) { 534 555 list_append(&u->link, &unused_head); 535 else 556 } else { 557 free(u); 536 558 rc = EEXIST; 559 } 537 560 fibril_mutex_unlock(&unused_lock); 538 561 return rc; … … 541 564 void fat_idx_fini_by_dev_handle(dev_handle_t dev_handle) 542 565 { 543 unused_t *u; 544 545 u = unused_find(dev_handle, true); 566 unsigned long ikey[] = { 567 [UIH_DH_KEY] = dev_handle 568 }; 569 unsigned long pkey[] = { 570 [UPH_DH_KEY] = dev_handle 571 }; 572 573 /* 574 * Remove this instance's index structure from up_hash and ui_hash. 575 * Process up_hash first and ui_hash second because the index structure 576 * is actually removed in idx_remove_callback(). 577 */ 578 fibril_mutex_lock(&used_lock); 579 hash_table_remove(&up_hash, pkey, 1); 580 hash_table_remove(&ui_hash, ikey, 1); 581 fibril_mutex_unlock(&used_lock); 582 583 /* 584 * Free the unused and freed structures for this instance. 585 */ 586 unused_t *u = unused_find(dev_handle, true); 546 587 assert(u); 547 588 list_remove(&u->link);
Note:
See TracChangeset
for help on using the changeset viewer.