2010-11-26 13:45:10 +00:00
|
|
|
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
|
2011-03-07 10:27:38 +00:00
|
|
|
#ifndef MARS_AIO_H
|
|
|
|
#define MARS_AIO_H
|
2010-11-26 13:45:10 +00:00
|
|
|
|
|
|
|
#include <linux/aio.h>
|
|
|
|
#include <linux/syscalls.h>
|
|
|
|
|
2012-10-15 14:35:36 +00:00
|
|
|
#define AIO_SUBMIT_MAX_LATENCY 1000 // 1 ms
|
|
|
|
#define AIO_IO_R_MAX_LATENCY 50000 // 50 ms
|
|
|
|
#define AIO_IO_W_MAX_LATENCY 150000 // 150 ms
|
|
|
|
#define AIO_SYNC_MAX_LATENCY 150000 // 150 ms
|
|
|
|
|
|
|
|
extern struct threshold aio_submit_threshold;
|
|
|
|
extern struct threshold aio_io_threshold[2];
|
|
|
|
extern struct threshold aio_sync_threshold;
|
|
|
|
|
2011-07-05 07:07:06 +00:00
|
|
|
//#define USE_CLEVER_SYNC // TODO: NYI (should result in better write performance)
|
2011-07-01 14:07:56 +00:00
|
|
|
#ifdef USE_CLEVER_SYNC
|
|
|
|
|
|
|
|
#include "lib_pairing_heap.h"
|
|
|
|
|
|
|
|
_PAIRING_HEAP_TYPEDEF(sync,);
|
|
|
|
|
|
|
|
struct q_sync {
|
|
|
|
struct pairing_heap_sync *heap[MARS_PRIO_NR];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2011-03-07 10:27:38 +00:00
|
|
|
struct aio_mref_aspect {
|
2010-12-15 12:13:18 +00:00
|
|
|
GENERIC_ASPECT(mref);
|
2011-07-01 14:07:56 +00:00
|
|
|
#ifdef USE_CLEVER_SYNC
|
|
|
|
struct pairing_heap_sync heap_head;
|
|
|
|
#endif
|
2010-11-26 13:45:10 +00:00
|
|
|
struct list_head io_head;
|
2012-10-15 14:35:36 +00:00
|
|
|
unsigned long long enqueue_stamp;
|
2011-03-10 11:40:06 +00:00
|
|
|
long long start_jiffies;
|
2010-11-26 13:45:10 +00:00
|
|
|
int resubmit;
|
2011-06-30 13:15:52 +00:00
|
|
|
int alloc_len;
|
2010-12-10 17:40:20 +00:00
|
|
|
bool do_dealloc;
|
2010-11-26 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
2011-03-07 10:27:38 +00:00
|
|
|
struct aio_brick {
|
|
|
|
MARS_BRICK(aio);
|
2011-03-11 13:57:54 +00:00
|
|
|
// parameters
|
|
|
|
int readahead;
|
2012-02-20 09:34:42 +00:00
|
|
|
int linear_cache_size; // in MB
|
|
|
|
int linear_cache_rounds;
|
2011-03-11 13:57:54 +00:00
|
|
|
bool o_direct;
|
|
|
|
bool o_fdsync;
|
2011-04-29 09:36:10 +00:00
|
|
|
bool wait_during_fdsync;
|
2010-11-26 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
2011-03-07 10:27:38 +00:00
|
|
|
struct aio_input {
|
|
|
|
MARS_INPUT(aio);
|
2010-11-26 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct aio_threadinfo {
|
2011-05-19 11:36:00 +00:00
|
|
|
struct list_head mref_list[MARS_PRIO_NR];
|
2011-03-07 10:27:38 +00:00
|
|
|
struct aio_output *output;
|
2010-11-26 13:45:10 +00:00
|
|
|
struct task_struct *thread;
|
|
|
|
wait_queue_head_t event;
|
2012-10-15 14:35:36 +00:00
|
|
|
wait_queue_head_t terminate_event;
|
2010-11-26 13:45:10 +00:00
|
|
|
spinlock_t lock;
|
2012-10-15 14:35:36 +00:00
|
|
|
int queued[MARS_PRIO_NR];
|
2012-12-19 15:19:33 +00:00
|
|
|
atomic_t queued_sum;
|
2011-05-06 10:25:52 +00:00
|
|
|
atomic_t total_enqueue_count;
|
2012-10-15 14:35:36 +00:00
|
|
|
bool terminated;
|
2010-11-26 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
2011-03-07 10:27:38 +00:00
|
|
|
struct aio_output {
|
|
|
|
MARS_OUTPUT(aio);
|
2010-11-26 13:45:10 +00:00
|
|
|
// private
|
|
|
|
struct file *filp;
|
|
|
|
int fd; // FIXME: remove this!
|
2012-02-20 09:34:42 +00:00
|
|
|
int rounds;
|
|
|
|
loff_t min_pos;
|
2010-11-26 13:45:10 +00:00
|
|
|
struct aio_threadinfo tinfo[3];
|
|
|
|
aio_context_t ctxp;
|
2011-04-29 09:36:10 +00:00
|
|
|
wait_queue_head_t fdsync_event;
|
2012-02-01 12:47:35 +00:00
|
|
|
bool fdsync_active;
|
2011-04-12 15:31:08 +00:00
|
|
|
// statistics
|
2012-10-15 14:35:36 +00:00
|
|
|
int index;
|
2011-04-12 15:31:08 +00:00
|
|
|
atomic_t total_read_count;
|
|
|
|
atomic_t total_write_count;
|
|
|
|
atomic_t total_alloc_count;
|
2012-12-20 10:32:47 +00:00
|
|
|
atomic_t total_submit_count;
|
2011-04-29 09:36:10 +00:00
|
|
|
atomic_t total_delay_count;
|
2011-05-06 10:25:52 +00:00
|
|
|
atomic_t total_msleep_count;
|
|
|
|
atomic_t total_fdsync_count;
|
2011-04-29 09:36:10 +00:00
|
|
|
atomic_t total_fdsync_wait_count;
|
2012-02-20 09:34:42 +00:00
|
|
|
atomic_t total_mapfree_count;
|
2011-04-12 15:31:08 +00:00
|
|
|
atomic_t read_count;
|
|
|
|
atomic_t write_count;
|
|
|
|
atomic_t alloc_count;
|
2012-12-18 07:00:27 +00:00
|
|
|
atomic_t submit_count;
|
2010-11-26 13:45:10 +00:00
|
|
|
};
|
|
|
|
|
2011-03-07 10:27:38 +00:00
|
|
|
MARS_TYPES(aio);
|
2010-11-26 13:45:10 +00:00
|
|
|
|
|
|
|
#endif
|