bio: separate response thread data

This commit is contained in:
Thomas Schoebel-Theuer 2017-02-25 09:36:01 +01:00 committed by Thomas Schoebel-Theuer
parent 84ff94faec
commit 3066473a31
2 changed files with 20 additions and 14 deletions

View File

@ -121,11 +121,11 @@ void bio_callback(struct bio *bio, int code)
spin_lock_irqsave(&brick->lock, flags);
list_del(&mref_a->io_head);
list_add_tail(&mref_a->io_head, &brick->completed_list);
list_add_tail(&mref_a->io_head, &brick->rsp[0].completed_list);
atomic_inc(&brick->completed_count);
spin_unlock_irqrestore(&brick->lock, flags);
wake_up_interruptible(&brick->response_event);
wake_up_interruptible(&brick->rsp[0].response_event);
return;
err:
@ -559,7 +559,7 @@ int bio_response_thread(void *data)
MARS_IO("%d sleeping %d...\n", round, sleeptime);
#endif
wait_event_interruptible_timeout(
brick->response_event,
brick->rsp[0].response_event,
atomic_read(&brick->completed_count) > 0 ||
(brick_thread_should_stop() &&
atomic_read(&brick->fly_count[0]) +
@ -581,7 +581,7 @@ int bio_response_thread(void *data)
}
#endif
spin_lock_irqsave(&brick->lock, flags);
list_replace_init(&brick->completed_list, &tmp_list);
list_replace_init(&brick->rsp[0].completed_list, &tmp_list);
spin_unlock_irqrestore(&brick->lock, flags);
count = 0;
@ -814,10 +814,10 @@ static int bio_switch(struct bio_brick *brick)
MARS_INF("'%s' size=%lld bvec_max=%d\n",
path, brick->total_size, brick->bvec_max);
brick->response_thread = brick_thread_create(bio_response_thread, brick, "mars_bio_r%d", index);
brick->rsp[0].response_thread = brick_thread_create(bio_response_thread, brick, "mars_bio_r%d", index);
brick->submit_thread = brick_thread_create(bio_submit_thread, brick, "mars_bio_s%d", index);
status = -ENOMEM;
if (likely(brick->submit_thread && brick->response_thread)) {
if (likely(brick->submit_thread && brick->rsp[0].response_thread)) {
brick->bdev = inode->i_bdev;
brick->mode_ptr = &brick->mf->mf_mode;
index++;
@ -834,9 +834,9 @@ static int bio_switch(struct bio_brick *brick)
brick_thread_stop(brick->submit_thread);
brick->submit_thread = NULL;
}
if (brick->response_thread) {
brick_thread_stop(brick->response_thread);
brick->response_thread = NULL;
if (brick->rsp[0].response_thread) {
brick_thread_stop(brick->rsp[0].response_thread);
brick->rsp[0].response_thread = NULL;
}
if (brick->mf) {
mapfree_put(brick->mf);
@ -928,9 +928,9 @@ static int bio_brick_construct(struct bio_brick *brick)
INIT_LIST_HEAD(&brick->queue_list[2]);
INIT_LIST_HEAD(&brick->submitted_list[0]);
INIT_LIST_HEAD(&brick->submitted_list[1]);
INIT_LIST_HEAD(&brick->completed_list);
INIT_LIST_HEAD(&brick->rsp[0].completed_list);
init_waitqueue_head(&brick->submit_event);
init_waitqueue_head(&brick->response_event);
init_waitqueue_head(&brick->rsp[0].response_event);
return 0;
}

View File

@ -24,6 +24,8 @@
#ifndef MARS_BIO_H
#define MARS_BIO_H
#define BIO_RESPONSE_THREADS 1
#define BIO_SUBMIT_MAX_LATENCY 250 // 250 us
#define BIO_IO_R_MAX_LATENCY 40000 // 40 ms
#define BIO_IO_W_MAX_LATENCY 100000 // 100 ms
@ -46,6 +48,12 @@ struct bio_mref_aspect {
bool do_dealloc;
};
struct bio_response {
struct list_head completed_list;
wait_queue_head_t response_event;
brick_thread_t *response_thread;
};
struct bio_brick {
MARS_BRICK(bio);
// tunables
@ -65,13 +73,11 @@ struct bio_brick {
spinlock_t lock;
struct list_head queue_list[MARS_PRIO_NR];
struct list_head submitted_list[2];
struct list_head completed_list;
wait_queue_head_t submit_event;
wait_queue_head_t response_event;
struct mapfree_info *mf;
struct block_device *bdev;
brick_thread_t *submit_thread;
brick_thread_t *response_thread;
struct bio_response rsp[BIO_RESPONSE_THREADS];
int bvec_max;
bool submitted;
};