Changeset 7b47fa2 in mainline
- Timestamp:
- 2009-06-25T21:30:25Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9593bc8
- Parents:
- d4b9d28
- Location:
- uspace/srv/vfs
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs.c
rd4b9d28 r7b47fa2 44 44 #include <string.h> 45 45 #include <as.h> 46 #include <adt/list.h>47 46 #include <atomic.h> 48 #include <assert.h>49 47 #include "vfs.h" 50 48 … … 142 140 143 141 /* 144 * Initialize the list of registered file systems.145 */146 list_initialize(&fs_head);147 148 /*149 142 * Initialize VFS node hash table. 150 143 */ … … 157 150 * Allocate and initialize the Path Lookup Buffer. 158 151 */ 159 list_initialize(&plb_head);160 152 plb = as_get_mappable_page(PLB_SIZE); 161 153 if (!plb) { … … 177 169 178 170 /* 179 * Add a fibril for handling pending mounts.180 */181 fid_t fid = fibril_create(vfs_process_pending_mount, NULL);182 assert(fid);183 fibril_add_ready(fid);184 185 /*186 171 * Register at the naming service. 187 172 */ -
uspace/srv/vfs/vfs.h
rd4b9d28 r7b47fa2 147 147 extern fibril_mutex_t nodes_mutex; 148 148 149 extern fibril_condvar_t fs_head_cv; 150 extern fibril_mutex_t fs_head_lock; 149 151 extern link_t fs_head; /**< List of registered file systems. */ 150 152 … … 170 172 extern void vfs_release_phone(int); 171 173 172 extern fibril_mutex_t fs_head_lock;173 extern bool pending_new_fs;174 extern fibril_condvar_t pending_cv;175 176 174 extern fs_handle_t fs_name_to_handle(char *, bool); 177 175 … … 197 195 extern void vfs_node_delref(vfs_node_t *); 198 196 199 extern void vfs_process_pending_mount(void);200 197 extern void vfs_register(ipc_callid_t, ipc_call_t *); 201 198 extern void vfs_mount(ipc_callid_t, ipc_call_t *); -
uspace/srv/vfs/vfs_lookup.c
rd4b9d28 r7b47fa2 50 50 51 51 FIBRIL_MUTEX_INITIALIZE(plb_mutex); 52 link_t plb_head;/**< PLB entry ring buffer. */52 LIST_INITIALIZE(plb_head); /**< PLB entry ring buffer. */ 53 53 uint8_t *plb = NULL; 54 54 -
uspace/srv/vfs/vfs_ops.c
rd4b9d28 r7b47fa2 54 54 /* Forward declarations of static functions. */ 55 55 static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t); 56 57 /** Pending mount structure. */58 typedef struct {59 link_t link;60 char *fs_name; /**< File system name */61 char *mp; /**< Mount point */62 char *opts; /**< Mount options. */63 ipc_callid_t callid; /**< Call ID waiting for the mount */64 ipc_callid_t rid; /**< Request ID */65 dev_handle_t dev_handle; /**< Device handle */66 } pending_req_t;67 68 FIBRIL_CONDVAR_INITIALIZE(pending_cv);69 bool pending_new_fs = false; /**< True if a new file system was mounted. */70 LIST_INITIALIZE(pending_req);71 56 72 57 /** … … 261 246 } 262 247 263 /** Process pending mount requests */264 void vfs_process_pending_mount(void)265 {266 link_t *cur;267 268 while (true) {269 fibril_mutex_lock(&fs_head_lock);270 while (!pending_new_fs)271 fibril_condvar_wait(&pending_cv, &fs_head_lock);272 rescan:273 for (cur = pending_req.next; cur != &pending_req;274 cur = cur->next) {275 pending_req_t *pr = list_get_instance(cur,276 pending_req_t, link);277 fs_handle_t fs_handle = fs_name_to_handle(pr->fs_name,278 false);279 if (!fs_handle)280 continue;281 282 /* Acknowledge that we know fs_name. */283 ipc_answer_0(pr->callid, EOK);284 285 list_remove(cur);286 fibril_mutex_unlock(&fs_head_lock);287 288 /* Do the mount */289 vfs_mount_internal(pr->rid, pr->dev_handle, fs_handle,290 pr->mp, pr->opts);291 292 free(pr->fs_name);293 free(pr->mp);294 free(pr->opts);295 free(pr);296 297 fibril_mutex_lock(&fs_head_lock);298 goto rescan;299 }300 pending_new_fs = false;301 fibril_mutex_unlock(&fs_head_lock);302 }303 }304 305 248 void vfs_mount(ipc_callid_t rid, ipc_call_t *request) 306 249 { … … 457 400 */ 458 401 fibril_mutex_lock(&fs_head_lock); 459 fs_handle_t fs_handle = fs_name_to_handle(fs_name, false); 402 fs_handle_t fs_handle; 403 recheck: 404 fs_handle = fs_name_to_handle(fs_name, false); 460 405 if (!fs_handle) { 461 406 if (flags & IPC_FLAG_BLOCKING) { 462 pending_req_t *pr; 463 464 /* Blocking mount, add to pending list */ 465 pr = (pending_req_t *) malloc(sizeof(pending_req_t)); 466 if (!pr) { 467 fibril_mutex_unlock(&fs_head_lock); 468 ipc_answer_0(callid, ENOMEM); 469 ipc_answer_0(rid, ENOMEM); 470 free(mp); 471 free(fs_name); 472 free(opts); 473 return; 474 } 475 476 pr->fs_name = fs_name; 477 pr->mp = mp; 478 pr->opts = opts; 479 pr->callid = callid; 480 pr->rid = rid; 481 pr->dev_handle = dev_handle; 482 link_initialize(&pr->link); 483 list_append(&pr->link, &pending_req); 484 fibril_mutex_unlock(&fs_head_lock); 485 return; 407 fibril_condvar_wait(&fs_head_cv, &fs_head_lock); 408 goto recheck; 486 409 } 487 410 -
uspace/srv/vfs/vfs_register.c
rd4b9d28 r7b47fa2 53 53 #include "vfs.h" 54 54 55 FIBRIL_CONDVAR_INITIALIZE(fs_head_cv); 55 56 FIBRIL_MUTEX_INITIALIZE(fs_head_lock); 56 link_t fs_head;57 LIST_INITIALIZE(fs_head); 57 58 58 59 atomic_t fs_handle_next = { … … 269 270 ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle); 270 271 271 pending_new_fs = true; 272 fibril_condvar_signal(&pending_cv); 272 fibril_condvar_signal(&fs_head_cv); 273 273 fibril_mutex_unlock(&fs_head_lock); 274 274
Note:
See TracChangeset
for help on using the changeset viewer.