Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
/* This file contains the multithreaded driver interface.
|
2011-11-02 17:31:38 +01:00
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* Aug 27, 2011 created (A. Welzel)
|
|
|
|
*
|
|
|
|
* The entry points into this file are:
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_task: the main message loop of the driver
|
|
|
|
* blockdriver_mt_terminate: break out of the main message loop
|
|
|
|
* blockdriver_mt_sleep: put the current thread to sleep
|
|
|
|
* blockdriver_mt_wakeup: wake up a sleeping thread
|
2011-12-07 15:44:28 +01:00
|
|
|
* blockdriver_mt_set_workers:set the number of worker threads
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
#include <minix/blockdriver_mt.h>
|
2011-11-02 17:31:38 +01:00
|
|
|
#include <minix/mthread.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
#include "const.h"
|
2011-11-02 17:31:38 +01:00
|
|
|
#include "driver.h"
|
|
|
|
#include "mq.h"
|
2011-12-07 15:44:28 +01:00
|
|
|
|
|
|
|
/* A thread ID is composed of a device ID and a per-device worker thread ID.
|
|
|
|
* All thread IDs must be in the range 0..(MAX_THREADS-1) inclusive.
|
|
|
|
*/
|
|
|
|
#define MAKE_TID(did, wid) ((did) * MAX_WORKERS + (wid))
|
|
|
|
#define TID_DEVICE(tid) ((tid) / MAX_WORKERS)
|
|
|
|
#define TID_WORKER(tid) ((tid) % MAX_WORKERS)
|
|
|
|
|
|
|
|
typedef int worker_id_t;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
STATE_DEAD,
|
|
|
|
STATE_RUNNING,
|
2011-12-07 15:44:28 +01:00
|
|
|
STATE_BUSY,
|
2011-11-02 17:31:38 +01:00
|
|
|
STATE_EXITED
|
|
|
|
} worker_state;
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Structure with information about a worker thread. */
|
2011-11-02 17:31:38 +01:00
|
|
|
typedef struct {
|
2011-12-07 15:44:28 +01:00
|
|
|
device_id_t device_id;
|
|
|
|
worker_id_t worker_id;
|
2011-11-02 17:31:38 +01:00
|
|
|
worker_state state;
|
|
|
|
mthread_thread_t mthread;
|
2011-12-07 15:44:28 +01:00
|
|
|
mthread_event_t sleep_event;
|
2011-11-02 17:31:38 +01:00
|
|
|
} worker_t;
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Structure with information about a device. */
|
|
|
|
typedef struct {
|
|
|
|
device_id_t id;
|
|
|
|
unsigned int workers;
|
|
|
|
worker_t worker[MAX_WORKERS];
|
|
|
|
mthread_event_t queue_event;
|
|
|
|
mthread_rwlock_t barrier;
|
|
|
|
} device_t;
|
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PRIVATE struct blockdriver *bdtab;
|
|
|
|
PRIVATE int running = FALSE;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
PRIVATE mthread_key_t worker_key;
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE device_t device[MAX_DEVICES];
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE worker_t *exited[MAX_THREADS];
|
2011-11-02 17:31:38 +01:00
|
|
|
PRIVATE int num_exited = 0;
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* enqueue *
|
|
|
|
*===========================================================================*/
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE void enqueue(device_t *dp, const message *m_src, int ipc_status)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Enqueue a message into the device's queue, and signal the event.
|
2011-11-02 17:31:38 +01:00
|
|
|
* Must be called from the master thread.
|
|
|
|
*/
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
if (!mq_enqueue(dp->id, m_src, ipc_status))
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: enqueue failed (message queue full)");
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
mthread_event_fire(&dp->queue_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* try_dequeue *
|
|
|
|
*===========================================================================*/
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE int try_dequeue(device_t *dp, message *m_dst, int *ipc_status)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
2011-12-07 15:44:28 +01:00
|
|
|
/* See if a message can be dequeued from the current worker thread's device
|
|
|
|
* queue. If so, dequeue the message and return TRUE. If not, return FALSE.
|
|
|
|
* Must be called from a worker thread. Does not block.
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
return mq_dequeue(dp->id, m_dst, ipc_status);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* dequeue *
|
|
|
|
*===========================================================================*/
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE int dequeue(device_t *dp, worker_t *wp, message *m_dst,
|
|
|
|
int *ipc_status)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Dequeue a message from the current worker thread's device queue. Block the
|
|
|
|
* current thread if necessary. Must be called from a worker thread. Either
|
|
|
|
* succeeds with a message (TRUE) or indicates that the thread should be
|
|
|
|
* terminated (FALSE).
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
do {
|
|
|
|
mthread_event_wait(&dp->queue_event);
|
|
|
|
|
|
|
|
/* If we were woken up as a result of terminate or set_workers, break
|
|
|
|
* out of the loop and terminate the thread.
|
|
|
|
*/
|
|
|
|
if (!running || wp->worker_id >= dp->workers)
|
|
|
|
return FALSE;
|
|
|
|
} while (!try_dequeue(dp, m_dst, ipc_status));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* is_transfer_req *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE int is_transfer_req(int type)
|
|
|
|
{
|
|
|
|
/* Return whether the given block device request is a transfer request.
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case BDEV_READ:
|
|
|
|
case BDEV_WRITE:
|
|
|
|
case BDEV_GATHER:
|
|
|
|
case BDEV_SCATTER:
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* worker_thread *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void *worker_thread(void *param)
|
|
|
|
{
|
|
|
|
/* The worker thread loop. Set up the thread-specific reference to itself and
|
|
|
|
* start looping. The loop consists of blocking dequeing and handling messages.
|
|
|
|
* After handling a message, the thread might have been stopped, so we check
|
|
|
|
* for this condition and exit if so.
|
|
|
|
*/
|
|
|
|
worker_t *wp;
|
2011-12-07 15:44:28 +01:00
|
|
|
device_t *dp;
|
|
|
|
thread_id_t tid;
|
2011-11-02 17:31:38 +01:00
|
|
|
message m;
|
|
|
|
int ipc_status, r;
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
|
2011-11-02 17:31:38 +01:00
|
|
|
wp = (worker_t *) param;
|
|
|
|
assert(wp != NULL);
|
2011-12-07 15:44:28 +01:00
|
|
|
dp = &device[wp->device_id];
|
|
|
|
tid = MAKE_TID(wp->device_id, wp->worker_id);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
if (mthread_setspecific(worker_key, wp))
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: could not save local thread pointer");
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
while (running && wp->worker_id < dp->workers) {
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* See if a new message is available right away. */
|
|
|
|
if (!try_dequeue(dp, &m, &ipc_status)) {
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* If not, block waiting for a new message or a thread
|
|
|
|
* termination event.
|
|
|
|
*/
|
|
|
|
if (!dequeue(dp, wp, &m, &ipc_status))
|
2011-11-02 17:31:38 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Even if the thread was stopped before, a new message resumes it. */
|
2011-12-07 15:44:28 +01:00
|
|
|
wp->state = STATE_BUSY;
|
|
|
|
|
|
|
|
/* If the request is a transfer request, we acquire the read barrier
|
|
|
|
* lock. Otherwise, we acquire the write lock.
|
|
|
|
*/
|
|
|
|
if (is_transfer_req(m.m_type))
|
|
|
|
mthread_rwlock_rdlock(&dp->barrier);
|
|
|
|
else
|
|
|
|
mthread_rwlock_wrlock(&dp->barrier);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Handle the request and send a reply. */
|
|
|
|
r = blockdriver_handle_request(bdtab, &m, tid);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
blockdriver_reply(&m, ipc_status, r);
|
2011-12-07 15:44:28 +01:00
|
|
|
|
|
|
|
/* Switch the thread back to running state, and unlock the barrier. */
|
|
|
|
wp->state = STATE_RUNNING;
|
|
|
|
mthread_rwlock_unlock(&dp->barrier);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up and terminate this thread. */
|
|
|
|
if (mthread_setspecific(worker_key, NULL))
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: could not delete local thread pointer");
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
wp->state = STATE_EXITED;
|
|
|
|
|
|
|
|
exited[num_exited++] = wp;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* master_create_worker *
|
|
|
|
*===========================================================================*/
|
2011-12-07 15:44:28 +01:00
|
|
|
PRIVATE void master_create_worker(worker_t *wp, worker_id_t worker_id,
|
|
|
|
device_id_t device_id)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* Start a new worker thread.
|
|
|
|
*/
|
|
|
|
int r;
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
wp->device_id = device_id;
|
|
|
|
wp->worker_id = worker_id;
|
2011-11-02 17:31:38 +01:00
|
|
|
wp->state = STATE_RUNNING;
|
|
|
|
|
|
|
|
/* Initialize synchronization primitives. */
|
2011-12-07 15:44:28 +01:00
|
|
|
mthread_event_init(&wp->sleep_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
r = mthread_create(&wp->mthread, NULL /*attr*/, worker_thread, (void *) wp);
|
|
|
|
|
|
|
|
if (r != 0)
|
2011-12-07 15:44:28 +01:00
|
|
|
panic("blockdriver_mt: could not start thread %d (%d)", worker_id, r);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* master_destroy_worker *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void master_destroy_worker(worker_t *wp)
|
|
|
|
{
|
|
|
|
/* Clean up resources used by an exited worker thread.
|
|
|
|
*/
|
|
|
|
|
|
|
|
assert(wp != NULL);
|
|
|
|
assert(wp->state == STATE_EXITED);
|
|
|
|
|
|
|
|
/* Join the thread. */
|
|
|
|
if (mthread_join(wp->mthread, NULL))
|
2011-12-07 15:44:28 +01:00
|
|
|
panic("blockdriver_mt: could not join thread %d", wp->worker_id);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
/* Destroy resources. */
|
2011-12-07 15:44:28 +01:00
|
|
|
mthread_event_destroy(&wp->sleep_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
wp->state = STATE_DEAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* master_handle_exits *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void master_handle_exits(void)
|
|
|
|
{
|
|
|
|
/* Destroy the remains of all exited threads.
|
|
|
|
*/
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_exited; i++)
|
|
|
|
master_destroy_worker(exited[i]);
|
|
|
|
|
|
|
|
num_exited = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* master_handle_request *
|
|
|
|
*===========================================================================*/
|
|
|
|
PRIVATE void master_handle_request(message *m_ptr, int ipc_status)
|
|
|
|
{
|
2011-12-07 15:44:28 +01:00
|
|
|
/* For real request messages, query the device ID, start a thread if none is
|
|
|
|
* free and the maximum number of threads for that device has not yet been
|
|
|
|
* reached, and enqueue the message in the devices's message queue.
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
2011-12-07 15:44:28 +01:00
|
|
|
device_id_t id;
|
2011-11-02 17:31:38 +01:00
|
|
|
worker_t *wp;
|
2011-12-07 15:44:28 +01:00
|
|
|
device_t *dp;
|
|
|
|
int r, wid;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
/* If this is not a block driver request, we cannot get the minor device
|
|
|
|
* associated with it, and thus we can not tell which thread should process
|
|
|
|
* it either. In that case, the master thread has to handle it instead.
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
if (!IS_BDEV_RQ(m_ptr->m_type)) {
|
|
|
|
/* Process as 'other' message. */
|
2011-11-24 14:50:13 +01:00
|
|
|
r = blockdriver_handle_request(bdtab, m_ptr, MAIN_THREAD);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
blockdriver_reply(m_ptr, ipc_status, r);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Query the device ID. Upon failure, send the error code to the caller. */
|
|
|
|
r = (*bdtab->bdr_device)(m_ptr->BDEV_MINOR, &id);
|
2011-11-02 17:31:38 +01:00
|
|
|
if (r != OK) {
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
blockdriver_reply(m_ptr, ipc_status, r);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Look up the device control block. */
|
|
|
|
assert(id >= 0 && id < MAX_DEVICES);
|
|
|
|
dp = &device[id];
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Find the first non-busy worker thread. */
|
|
|
|
for (wid = 0; wid < dp->workers; wid++)
|
|
|
|
if (dp->worker[wid].state != STATE_BUSY)
|
|
|
|
break;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* If the worker thread is dead, start a thread now, unless we have already
|
|
|
|
* reached the maximum number of threads.
|
|
|
|
*/
|
|
|
|
if (wid < dp->workers) {
|
|
|
|
wp = &dp->worker[wid];
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
assert(wp->state != STATE_EXITED);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* If the non-busy thread has not yet been created, create one now. */
|
|
|
|
if (wp->state == STATE_DEAD)
|
|
|
|
master_create_worker(wp, wid, dp->id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enqueue the message at the device queue. */
|
|
|
|
enqueue(dp, m_ptr, ipc_status);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
|
|
|
* master_init *
|
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PRIVATE void master_init(struct blockdriver *bdp)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* Initialize the state of the master thread.
|
|
|
|
*/
|
2011-12-07 15:44:28 +01:00
|
|
|
int i, j;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
assert(bdp != NULL);
|
2011-12-07 15:44:28 +01:00
|
|
|
assert(bdp->bdr_device != NULL);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
mthread_init();
|
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
bdtab = bdp;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Initialize device-specific data structures. */
|
|
|
|
for (i = 0; i < MAX_DEVICES; i++) {
|
|
|
|
device[i].id = i;
|
|
|
|
device[i].workers = 1;
|
|
|
|
mthread_event_init(&device[i].queue_event);
|
|
|
|
mthread_rwlock_init(&device[i].barrier);
|
|
|
|
|
|
|
|
for (j = 0; j < MAX_WORKERS; j++)
|
|
|
|
device[i].worker[j].state = STATE_DEAD;
|
|
|
|
}
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
/* Initialize a per-thread key, where each worker thread stores its own
|
|
|
|
* reference to the worker structure.
|
|
|
|
*/
|
|
|
|
if (mthread_key_create(&worker_key, NULL))
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: error initializing worker key");
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
/*===========================================================================*
|
|
|
|
* blockdriver_mt_get_tid *
|
|
|
|
*===========================================================================*/
|
|
|
|
PUBLIC thread_id_t blockdriver_mt_get_tid(void)
|
|
|
|
{
|
|
|
|
/* Return back the ID of this thread.
|
|
|
|
*/
|
|
|
|
worker_t *wp;
|
|
|
|
|
|
|
|
wp = (worker_t *) mthread_getspecific(worker_key);
|
|
|
|
|
|
|
|
if (wp == NULL)
|
|
|
|
panic("blockdriver_mt: master thread cannot query thread ID\n");
|
|
|
|
|
|
|
|
return MAKE_TID(wp->device_id, wp->worker_id);
|
|
|
|
}
|
|
|
|
|
2011-11-02 17:31:38 +01:00
|
|
|
/*===========================================================================*
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_receive *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PRIVATE void blockdriver_mt_receive(message *m_ptr, int *ipc_status)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* Receive a message.
|
|
|
|
*/
|
|
|
|
int r;
|
|
|
|
|
|
|
|
r = sef_receive_status(ANY, m_ptr, ipc_status);
|
|
|
|
|
|
|
|
if (r != OK)
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: sef_receive_status() returned %d", r);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_task *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PUBLIC void blockdriver_mt_task(struct blockdriver *driver_tab)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* The multithreaded driver task.
|
|
|
|
*/
|
2011-12-07 15:44:28 +01:00
|
|
|
int ipc_status, i;
|
2011-11-02 17:31:38 +01:00
|
|
|
message mess;
|
|
|
|
|
|
|
|
/* Initialize first if necessary. */
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
if (!running) {
|
|
|
|
master_init(driver_tab);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
running = TRUE;
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The main message loop. */
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
while (running) {
|
2011-11-02 17:31:38 +01:00
|
|
|
/* Receive a message. */
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
blockdriver_mt_receive(&mess, &ipc_status);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
|
|
|
/* Dispatch the message. */
|
|
|
|
if (is_ipc_notify(ipc_status))
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
blockdriver_handle_notify(bdtab, &mess);
|
2011-11-02 17:31:38 +01:00
|
|
|
else
|
|
|
|
master_handle_request(&mess, ipc_status);
|
|
|
|
|
|
|
|
/* Let other threads run. */
|
|
|
|
mthread_yield_all();
|
|
|
|
|
|
|
|
/* Clean up any exited threads. */
|
|
|
|
if (num_exited > 0)
|
|
|
|
master_handle_exits();
|
|
|
|
}
|
2011-12-07 15:44:28 +01:00
|
|
|
|
|
|
|
/* Free up resources. */
|
|
|
|
for (i = 0; i < MAX_DEVICES; i++)
|
|
|
|
mthread_event_destroy(&device[i].queue_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_terminate *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PUBLIC void blockdriver_mt_terminate(void)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
/* Instruct libblockdriver to shut down.
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
|
|
|
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
running = FALSE;
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_sleep *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PUBLIC void blockdriver_mt_sleep(void)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* Let the current thread sleep until it gets woken up by the master thread.
|
|
|
|
*/
|
|
|
|
worker_t *wp;
|
|
|
|
|
|
|
|
wp = (worker_t *) mthread_getspecific(worker_key);
|
|
|
|
|
|
|
|
if (wp == NULL)
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
panic("blockdriver_mt: master thread cannot sleep");
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
mthread_event_wait(&wp->sleep_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
* blockdriver_mt_wakeup *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
PUBLIC void blockdriver_mt_wakeup(thread_id_t id)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
|
|
|
/* Wake up a sleeping worker thread from the master thread.
|
|
|
|
*/
|
|
|
|
worker_t *wp;
|
2011-12-07 15:44:28 +01:00
|
|
|
device_id_t device_id;
|
|
|
|
worker_id_t worker_id;
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
device_id = TID_DEVICE(id);
|
|
|
|
worker_id = TID_WORKER(id);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
assert(device_id >= 0 && device_id < MAX_DEVICES);
|
|
|
|
assert(worker_id >= 0 && worker_id < MAX_WORKERS);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
wp = &device[device_id].worker[worker_id];
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
assert(wp->state == STATE_RUNNING || wp->state == STATE_BUSY);
|
|
|
|
|
|
|
|
mthread_event_fire(&wp->sleep_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*
|
2011-12-07 15:44:28 +01:00
|
|
|
* blockdriver_mt_set_workers *
|
2011-11-02 17:31:38 +01:00
|
|
|
*===========================================================================*/
|
2011-12-07 15:44:28 +01:00
|
|
|
PUBLIC void blockdriver_mt_set_workers(device_id_t id, int workers)
|
2011-11-02 17:31:38 +01:00
|
|
|
{
|
2011-12-07 15:44:28 +01:00
|
|
|
/* Set the number of worker threads for the given device.
|
2011-11-02 17:31:38 +01:00
|
|
|
*/
|
2011-12-07 15:44:28 +01:00
|
|
|
device_t *dp;
|
Split block/character protocols and libdriver
This patch separates the character and block driver communication
protocols. The old character protocol remains the same, but a new
block protocol is introduced. The libdriver library is replaced by
two new libraries: libchardriver and libblockdriver. Their exposed
API, and drivers that use them, have been updated accordingly.
Together, libbdev and libblockdriver now completely abstract away
the message format used by the block protocol. As the memory driver
is both a character and a block device driver, it now implements its
own message loop.
The most important semantic change made to the block protocol is that
it is no longer possible to return both partial results and an error
for a single transfer. This simplifies the interaction between the
caller and the driver, as the I/O vector no longer needs to be copied
back. Also, drivers are now no longer supposed to decide based on the
layout of the I/O vector when a transfer should be cut short. Put
simply, transfers are now supposed to either succeed completely, or
result in an error.
After this patch, the state of the various pieces is as follows:
- block protocol: stable
- libbdev API: stable for synchronous communication
- libblockdriver API: needs slight revision (the drvlib/partition API
in particular; the threading API will also change shortly)
- character protocol: needs cleanup
- libchardriver API: needs cleanup accordingly
- driver restarts: largely unsupported until endpoint changes are
reintroduced
As a side effect, this patch eliminates several bugs, hacks, and gcc
-Wall and -W warnings all over the place. It probably introduces a
few new ones, too.
Update warning: this patch changes the protocol between MFS and disk
drivers, so in order to use old/new images, the MFS from the ramdisk
must be used to mount all file systems.
2011-11-22 13:27:53 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
assert(id >= 0 && id < MAX_DEVICES);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
if (workers > MAX_WORKERS)
|
|
|
|
workers = MAX_WORKERS;
|
|
|
|
|
|
|
|
dp = &device[id];
|
|
|
|
|
|
|
|
/* If we are cleaning up, wake up all threads waiting on a queue event. */
|
|
|
|
if (workers == 1 && dp->workers > workers)
|
|
|
|
mthread_event_fire_all(&dp->queue_event);
|
2011-11-02 17:31:38 +01:00
|
|
|
|
2011-12-07 15:44:28 +01:00
|
|
|
dp->workers = workers;
|
2011-11-02 17:31:38 +01:00
|
|
|
}
|