Changeset d9e9caf in mainline
- Timestamp:
- 2008-04-15T02:45:48Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 80e8482
- Parents:
- e13d1feb
- Location:
- uspace/srv/fs/fat
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/fat/fat.h
re13d1feb rd9e9caf 148 148 /** FAT in-core node. */ 149 149 typedef struct { 150 /** Protects an instance of this type. */ 151 futex_t lock; 150 152 fat_node_type_t type; 151 153 /** VFS index is the node's first allocated cluster. */ -
uspace/srv/fs/fat/fat_ops.c
re13d1feb rd9e9caf 47 47 #include <libadt/list.h> 48 48 #include <assert.h> 49 #include <futex.h> 49 50 50 51 #define BS_BLOCK 0 … … 52 53 #define FIN_KEY_DEV_HANDLE 0 53 54 #define FIN_KEY_INDEX 1 55 56 /** Futex protecting both fin_hash and ffn_head. */ 57 futex_t fin_futex = FUTEX_INITIALIZER; 54 58 55 59 /** Hash table of FAT in-core nodes. */ … … 119 123 static void fat_node_initialize(fat_node_t *node) 120 124 { 125 futex_initialize(&node->lock, 1); 121 126 node->type = 0; 122 127 node->index = 0; … … 201 206 }; 202 207 208 futex_down(&fin_futex); 203 209 lnk = hash_table_find(&fin_hash, key); 204 210 if (lnk) { … … 209 215 if (!node->refcnt++) 210 216 list_remove(&node->ffn_link); 217 futex_up(&fin_futex); 218 219 /* Make sure that the node is fully instantiated. */ 220 futex_down(&node->lock); 221 futex_up(&node->lock); 222 211 223 return (void *) node; 212 224 } … … 242 254 node->index = index; 243 255 node->pindex = pindex; 256 key[FIN_KEY_DEV_HANDLE] = node->dev_handle; 257 key[FIN_KEY_INDEX] = node->index; 258 hash_table_insert(&fin_hash, key, &node->fin_link); 259 260 /* 261 * We have already put the node back to fin_hash. 262 * The node is not yet fully instantiated so we lock it prior to 263 * unlocking fin_hash. 264 */ 265 futex_down(&node->lock); 266 futex_up(&fin_futex); 244 267 245 268 /* … … 269 292 node->size = uint32_t_le2host(d->size); 270 293 block_put(b); 271 272 key[FIN_KEY_DEV_HANDLE] = node->dev_handle; 273 key[FIN_KEY_INDEX] = node->index; 274 hash_table_insert(&fin_hash, key, &node->fin_link); 275 294 295 futex_up(&node->lock); 276 296 return node; 277 297 } … … 281 301 fat_node_t *nodep = (fat_node_t *)node; 282 302 283 if (nodep->refcnt-- == 1) 303 futex_down(&fin_futex); 304 if (!--nodep->refcnt) 284 305 list_append(&nodep->ffn_link, &ffn_head); 306 futex_up(&fin_futex); 285 307 } 286 308
Note:
See TracChangeset
for help on using the changeset viewer.