mars/kernel/mars_aio.h

115 lines
2.8 KiB
C
Raw Normal View History

2014-11-21 10:51:34 +00:00
/*
* MARS Long Distance Replication Software
*
* This file is part of MARS project: http://schoebel.github.io/mars/
*
* Copyright (C) 2010-2014 Thomas Schoebel-Theuer
* Copyright (C) 2011-2014 1&1 Internet AG
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
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>
2014-03-30 06:18:47 +00:00
#include "lib_mapfree.h"
#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;
/* aio_sync_mode:
* 0 = filemap_write_and_wait_range()
* 1 = fdatasync()
* 2 = fsync()
*/
extern int aio_sync_mode;
2011-03-07 10:27:38 +00:00
struct aio_mref_aspect {
2010-12-15 12:13:18 +00:00
GENERIC_ASPECT(mref);
2010-11-26 13:45:10 +00:00
struct list_head io_head;
2014-03-30 06:18:47 +00:00
struct dirty_info di;
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
bool o_creat;
2011-03-11 13:57:54 +00:00
bool o_direct;
bool o_fdsync;
bool is_static_device;
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;
wait_queue_head_t terminate_event;
2010-11-26 13:45:10 +00:00
spinlock_t lock;
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;
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 mapfree_info *mf;
2010-11-26 13:45:10 +00:00
int fd; // FIXME: remove this!
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
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;
2012-12-20 11:02:54 +00:00
atomic_t total_again_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;
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