aio: fix portability to changed kernels / kthread implementation

In the long term, mars_aio will be replaced anyway because it
uses userspace concepts like ioctx.

Don't use the internal kthread_stop_nowait() anymore.
It is too cumbersome to catch up with upstream development.
This commit is contained in:
Thomas Schoebel-Theuer 2015-03-20 11:01:54 +01:00
parent 77714f374e
commit 7d66938666
2 changed files with 8 additions and 5 deletions

View File

@ -461,6 +461,7 @@ int aio_start_thread(
spin_lock_init(&tinfo->lock); spin_lock_init(&tinfo->lock);
init_waitqueue_head(&tinfo->event); init_waitqueue_head(&tinfo->event);
init_waitqueue_head(&tinfo->terminate_event); init_waitqueue_head(&tinfo->terminate_event);
tinfo->should_terminate = false;
tinfo->terminated = false; tinfo->terminated = false;
tinfo->thread = brick_thread_create(fn, tinfo, "mars_aio_%c%d", class, output->index); tinfo->thread = brick_thread_create(fn, tinfo, "mars_aio_%c%d", class, output->index);
if (unlikely(!tinfo->thread)) { if (unlikely(!tinfo->thread)) {
@ -474,10 +475,11 @@ static
void aio_stop_thread(struct aio_output *output, int i, bool do_submit_dummy) void aio_stop_thread(struct aio_output *output, int i, bool do_submit_dummy)
{ {
struct aio_threadinfo *tinfo = &output->tinfo[i]; struct aio_threadinfo *tinfo = &output->tinfo[i];
struct task_struct *thread = tinfo->thread;
if (tinfo->thread) { if (thread) {
MARS_DBG("stopping thread %d ...\n", i); MARS_DBG("stopping thread %d ...\n", i);
brick_thread_stop_nowait(tinfo->thread); tinfo->should_terminate = true;
// workaround for waking up the receiver thread. TODO: check whether signal handlong could do better. // workaround for waking up the receiver thread. TODO: check whether signal handlong could do better.
if (do_submit_dummy) { if (do_submit_dummy) {
@ -569,7 +571,7 @@ int aio_sync_thread(void *data)
MARS_DBG("sync thread has started on '%s'.\n", output->brick->brick_path); MARS_DBG("sync thread has started on '%s'.\n", output->brick->brick_path);
//set_user_nice(current, -20); //set_user_nice(current, -20);
while (!brick_thread_should_stop() || atomic_read(&tinfo->queued_sum) > 0) { while (!tinfo->should_terminate || atomic_read(&tinfo->queued_sum) > 0) {
LIST_HEAD(tmp_list); LIST_HEAD(tmp_list);
unsigned long flags; unsigned long flags;
int i; int i;
@ -627,7 +629,7 @@ static int aio_event_thread(void *data)
if (unlikely(err < 0)) if (unlikely(err < 0))
goto err; goto err;
while (!brick_thread_should_stop() || atomic_read(&tinfo->queued_sum) > 0) { while (!tinfo->should_terminate || atomic_read(&tinfo->queued_sum) > 0) {
mm_segment_t oldfs; mm_segment_t oldfs;
int count; int count;
int i; int i;
@ -842,7 +844,7 @@ static int aio_submit_thread(void *data)
use_fake_mm(); use_fake_mm();
while (!brick_thread_should_stop() || atomic_read(&output->read_count) + atomic_read(&output->write_count) + atomic_read(&tinfo->queued_sum) > 0) { while (!tinfo->should_terminate || atomic_read(&output->read_count) + atomic_read(&output->write_count) + atomic_read(&tinfo->queued_sum) > 0) {
struct aio_mref_aspect *mref_a; struct aio_mref_aspect *mref_a;
struct mref_object *mref; struct mref_object *mref;
int sleeptime; int sleeptime;

View File

@ -79,6 +79,7 @@ struct aio_threadinfo {
int queued[MARS_PRIO_NR]; int queued[MARS_PRIO_NR];
atomic_t queued_sum; atomic_t queued_sum;
atomic_t total_enqueue_count; atomic_t total_enqueue_count;
bool should_terminate;
bool terminated; bool terminated;
}; };