mars/mars_copy.h

87 lines
1.8 KiB
C
Raw Normal View History

2011-02-23 20:48:06 +00:00
// (c) 2010 Thomas Schoebel-Theuer / 1&1 Internet AG
#ifndef MARS_COPY_H
#define MARS_COPY_H
#include <linux/wait.h>
#include <linux/semaphore.h>
#define INPUT_A_IO 0
#define INPUT_A_COPY 1
#define INPUT_B_IO 2
#define INPUT_B_COPY 3
2011-03-22 14:36:26 +00:00
//#define COPY_CHUNK (64 * 1024)
2011-06-10 13:57:52 +00:00
#define COPY_CHUNK (PAGE_SIZE)
2012-08-06 13:30:40 +00:00
#define MAX_COPY_PARA (32 * 1024 * 1024 / COPY_CHUNK)
2011-02-23 20:48:06 +00:00
enum {
2011-06-17 11:32:38 +00:00
COPY_STATE_START = 0,
2012-08-02 08:16:55 +00:00
COPY_STATE_READ1,
COPY_STATE_READ2,
COPY_STATE_READ3,
COPY_STATE_WRITE,
COPY_STATE_WRITTEN,
COPY_STATE_CLEANUP,
COPY_STATE_FINISHED,
2011-06-10 13:57:52 +00:00
};
struct copy_state {
struct mref_object *table[2];
2011-06-17 11:32:38 +00:00
bool active[2];
2011-06-10 13:57:52 +00:00
char state;
bool writeout;
2011-06-10 13:57:52 +00:00
short prev;
short len;
short error;
2011-02-23 20:48:06 +00:00
};
struct copy_mref_aspect {
GENERIC_ASPECT(mref);
struct copy_brick *brick;
int queue;
};
struct copy_brick {
MARS_BRICK(copy);
// parameters
2012-02-01 12:47:35 +00:00
loff_t copy_start;
loff_t copy_end; // stop working if == 0
2011-05-26 14:32:32 +00:00
int io_prio;
int append_mode; // 1 = passively, 2 = actively
bool verify_mode; // 0 = copy, 1 = checksum+compare
2012-08-02 08:16:55 +00:00
bool repair_mode; // whether to repair in case of verify errors
bool recheck_mode; // whether to re-check after repairs (costs performance)
2011-05-26 14:32:32 +00:00
bool utilize_mode; // utilize already copied data
bool abort_mode; // abort on IO error (default is retry forever)
2011-05-26 14:32:32 +00:00
// readonly from outside
2011-06-17 11:32:38 +00:00
loff_t copy_last; // current working position
int copy_error;
2012-08-22 12:37:34 +00:00
int copy_error_count;
2012-08-02 08:16:55 +00:00
int verify_ok_count;
int verify_error_count;
2011-02-23 20:48:06 +00:00
bool low_dirty;
bool is_aborting;
2011-02-23 20:48:06 +00:00
// internal
2012-02-01 12:47:35 +00:00
bool trigger;
unsigned long clash;
2011-02-23 20:48:06 +00:00
atomic_t io_flight;
atomic_t copy_flight;
2011-03-07 05:55:10 +00:00
long long last_jiffies;
2011-02-23 20:48:06 +00:00
wait_queue_head_t event;
struct semaphore mutex;
struct task_struct *thread;
2011-06-10 13:57:52 +00:00
struct copy_state st[MAX_COPY_PARA];
2011-02-23 20:48:06 +00:00
};
struct copy_input {
MARS_INPUT(copy);
};
struct copy_output {
MARS_OUTPUT(copy);
};
MARS_TYPES(copy);
#endif