Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2535 → Rev 2536

/trunk/uspace/srv/fs/fat/fat.c
41,7 → 41,7
#include <async.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>>
#include <stdio.h>
#include "../../vfs/vfs.h"
 
#define dprintf(...) printf(__VA_ARGS__)
62,18 → 62,46
}
};
 
/*
* This fibril processes request from the VFS server.
/**
* This connection fibril processes VFS requests from VFS.
*
* In order to support simultaneous VFS requests, our design is as follows.
* The connection fibril accepts VFS requests from VFS. If there is only one
* instance of the fibril, VFS will need to serialize all VFS requests it sends
* to FAT. To overcome this bottleneck, VFS can send FAT the IPC_M_CONNECT_ME_TO
* call. In that case, a new connection fibril will be created, which in turn
* will accept the call. Thus, a new phone will be opened for VFS.
*
* There are few issues with this arrangement. First, VFS can run out of
* available phones. In that case, VFS can close some other phones or use one
* phone for more serialized requests. Similarly, FAT can refuse to duplicate
* the connection. VFS should then just make use of already existing phones and
* route its requests through them. To avoid paying the fibril creation price
* upon each request, FAT might want to keep the connections open after the
* request has been completed.
*/
void fat_connection(ipc_callid_t iid, ipc_call_t *icall)
static void fat_connection(ipc_callid_t iid, ipc_call_t *icall)
{
dprintf("Callback connection established.\n");
if (iid) {
/*
* This only happens for connections opened by
* IPC_M_CONNECT_ME_TO calls as opposed to callback connections
* created by IPC_M_CONNECT_TO_ME.
*/
ipc_answer_fast(iid, EOK, 0, 0);
}
dprintf("VFS-FAT connection established.\n");
while (1) {
ipc_callid_t callid;
ipc_call_t call;
callid = async_get_call(&call);
ipc_answer_fast(callid, ENOTSUP, 0, 0);
switch (IPC_GET_METHOD(call)) {
default:
ipc_answer_fast(callid, ENOTSUP, 0, 0);
break;
}
}
}
 
112,7 → 140,16
ipcarg_t phonehash;
ipc_connect_to_me(vfs_phone, 0, 0, &phonehash);
 
/*
* Create a connection fibril to handle the callback connection.
*/
async_new_connection(phonehash, 0, NULL, fat_connection);
/*
* Tell the async framework that other connections are to be handled by
* the same connection fibril as well.
*/
async_set_client_connection(fat_connection);
 
/*
* Pick up the answer for the request to the VFS_REQUEST call.
120,10 → 157,12
async_wait_for(req, NULL);
dprintf("FAT filesystem registered.\n");
 
async_create_manager();
 
/*
* TODO: Interestingly, if we merely return, the only thread dies.
* If the only thread dies, the whole task is destroyed.
* Prevent the thread from exiting when there are active fibrils.
* If the only thread dies, the whole task is destroyed.
* Prevent the thread from exiting when there are active fibrils.
*/
fibril_schedule_next_adv(FIBRIL_FROM_DEAD);
/* not reached */