mirror of https://github.com/schoebel/mars
import mars-34.tgz
This commit is contained in:
parent
4a47eac2ff
commit
00c2987c6c
90
brick.h
90
brick.h
|
@ -35,7 +35,7 @@
|
|||
|
||||
struct generic_aspect;
|
||||
|
||||
#define GENERIC_ASPECT_TYPE(BRICK) \
|
||||
#define GENERIC_ASPECT_TYPE(TYPE) \
|
||||
char *aspect_type_name; \
|
||||
const struct generic_object_type *object_type; \
|
||||
int aspect_size; \
|
||||
|
@ -46,7 +46,7 @@ struct generic_aspect_type {
|
|||
GENERIC_ASPECT_TYPE(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_ASPECT_LAYOUT(BRICK) \
|
||||
#define GENERIC_ASPECT_LAYOUT(TYPE) \
|
||||
const struct generic_aspect_type *aspect_type; \
|
||||
void *init_data; \
|
||||
int aspect_offset; \
|
||||
|
@ -55,7 +55,7 @@ struct generic_aspect_layout {
|
|||
GENERIC_ASPECT_LAYOUT(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_OBJECT_TYPE(BRICK) \
|
||||
#define GENERIC_OBJECT_TYPE(TYPE) \
|
||||
char *object_type_name; \
|
||||
int default_size; \
|
||||
int brick_obj_nr; \
|
||||
|
@ -66,7 +66,7 @@ struct generic_object_type {
|
|||
GENERIC_OBJECT_TYPE(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_OBJECT_LAYOUT(BRICK) \
|
||||
#define GENERIC_OBJECT_LAYOUT(TYPE) \
|
||||
struct generic_aspect_layout **aspect_layouts; \
|
||||
const struct generic_object_type *object_type; \
|
||||
void *init_data; \
|
||||
|
@ -84,23 +84,23 @@ struct generic_object_layout {
|
|||
GENERIC_OBJECT_LAYOUT(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_OBJECT(BRICK) \
|
||||
struct BRICK##_object_layout *object_layout; \
|
||||
#define GENERIC_OBJECT(TYPE) \
|
||||
struct TYPE##_object_layout *object_layout; \
|
||||
int object_size; \
|
||||
|
||||
struct generic_object {
|
||||
GENERIC_OBJECT(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_ASPECT(BRICK) \
|
||||
struct BRICK##_object *object; \
|
||||
#define GENERIC_ASPECT(TYPE) \
|
||||
struct TYPE##_object *object; \
|
||||
|
||||
struct generic_aspect {
|
||||
GENERIC_ASPECT(generic);
|
||||
};
|
||||
|
||||
#define GENERIC_CALLBACK(BRICK) \
|
||||
void (*cb_fn)(struct BRICK##_callback *cb); \
|
||||
#define GENERIC_CALLBACK(TYPE) \
|
||||
void (*cb_fn)(struct TYPE##_callback *cb); \
|
||||
void *cb_private; \
|
||||
int cb_error; \
|
||||
struct generic_callback *cb_prev; \
|
||||
|
@ -242,6 +242,15 @@ struct generic_output_type {
|
|||
int generic_register_brick_type(const struct generic_brick_type *new_type);
|
||||
int generic_unregister_brick_type(const struct generic_brick_type *old_type);
|
||||
|
||||
extern inline void _generic_output_init(struct generic_brick *brick, const struct generic_output_type *type, struct generic_output *output, char *output_name)
|
||||
{
|
||||
output->output_name = output_name;
|
||||
output->brick = brick;
|
||||
output->type = type;
|
||||
output->ops = type->master_ops;
|
||||
output->nr_connected = 0;
|
||||
}
|
||||
|
||||
#ifdef _STRATEGY // call this only in strategy bricks, never in ordinary bricks
|
||||
|
||||
// you need this only if you circumvent generic_brick_init_full()
|
||||
|
@ -277,11 +286,7 @@ extern inline int generic_output_init(struct generic_brick *brick, int index, co
|
|||
return -ENOMEM;
|
||||
if (brick->outputs[index])
|
||||
return -EEXIST;
|
||||
output->output_name = output_name;
|
||||
output->brick = brick;
|
||||
output->type = type;
|
||||
output->ops = type->master_ops;
|
||||
output->nr_connected = 0;
|
||||
_generic_output_init(brick, type, output, output_name);
|
||||
brick->outputs[index] = output;
|
||||
brick->nr_outputs++;
|
||||
return 0;
|
||||
|
@ -369,11 +374,20 @@ extern int BRICK##_make_object_layout(struct BRICK##_output *output, struct gene
|
|||
return default_make_object_layout((struct generic_output*)output, object_layout); \
|
||||
} \
|
||||
\
|
||||
_STRATEGY_CODE( \
|
||||
extern const struct BRICK##_brick_type BRICK##_brick_type; \
|
||||
extern const struct BRICK##_input_type BRICK##_input_type; \
|
||||
extern const struct BRICK##_input_type BRICK##_input_type; \
|
||||
extern const struct BRICK##_output_type BRICK##_output_type; \
|
||||
\
|
||||
static inline void _##BRICK##_output_init(struct BRICK##_brick *brick, struct BRICK##_output *output, char *output_name) \
|
||||
{ \
|
||||
_generic_output_init( \
|
||||
(struct generic_brick*)brick, \
|
||||
(const struct generic_output_type*)&BRICK##_output_type, \
|
||||
(struct generic_output*)output, \
|
||||
output_name); \
|
||||
} \
|
||||
\
|
||||
_STRATEGY_CODE( \
|
||||
static inline int BRICK##_brick_init(struct BRICK##_brick *brick, char *brick_name) \
|
||||
{ \
|
||||
return generic_brick_init((const struct generic_brick_type*)&BRICK##_brick_type, (struct generic_brick*)brick, brick_name); \
|
||||
|
@ -389,7 +403,7 @@ static inline int BRICK##_input_init(struct BRICK##_brick *brick, int index, str
|
|||
input_name); \
|
||||
} \
|
||||
\
|
||||
static inline int BRICK##_output_init(struct BRICK##_brick *brick, int index, struct BRICK##_input *output, char *output_name) \
|
||||
static inline int BRICK##_output_init(struct BRICK##_brick *brick, int index, struct BRICK##_output *output, char *output_name) \
|
||||
{ \
|
||||
return generic_output_init( \
|
||||
(struct generic_brick*)brick, \
|
||||
|
@ -408,7 +422,7 @@ static inline int BRICK##_output_init(struct BRICK##_brick *brick, int index, st
|
|||
* (b) these macros generate only definitions, but no additional
|
||||
* code at runtime.
|
||||
*/
|
||||
#define GENERIC_MAKE_CONNECT(INPUT_BRICK,OUTPUT_BRICK) \
|
||||
#define GENERIC_MAKE_CONNECT(INPUT_BRICK,OUTPUT_BRICK) \
|
||||
\
|
||||
_STRATEGY_CODE( \
|
||||
\
|
||||
|
@ -449,20 +463,20 @@ extern inline int BRICK##_init_object_layout(struct BRICK##_output *output, stru
|
|||
return default_init_object_layout((struct generic_output*)output, object_layout, aspect_max, object_type, #BRICK); \
|
||||
} \
|
||||
|
||||
#define GENERIC_ASPECT_LAYOUT_FUNCTIONS(BRICK,PREFIX) \
|
||||
#define GENERIC_ASPECT_LAYOUT_FUNCTIONS(BRICK,TYPE) \
|
||||
\
|
||||
extern inline int BRICK##_##PREFIX##_add_aspect(struct BRICK##_output *output, struct PREFIX##_object_layout *object_layout, const struct generic_aspect_type *aspect_type) \
|
||||
extern inline int BRICK##_##TYPE##_add_aspect(struct BRICK##_output *output, struct TYPE##_object_layout *object_layout, const struct generic_aspect_type *aspect_type) \
|
||||
{ \
|
||||
int res = generic_add_aspect((struct generic_output*)output, (struct generic_object_layout *)object_layout, aspect_type); \
|
||||
BRICK_DBG(#BRICK " " #PREFIX "added aspect_type %p (%s) to object_layout %p (type %s) on output %p (type %s), status=%d\n", aspect_type, aspect_type->aspect_type_name, object_layout, object_layout->object_type->object_type_name, output, output->type->type_name, res); \
|
||||
BRICK_DBG(#BRICK " " #TYPE "added aspect_type %p (%s) to object_layout %p (type %s) on output %p (type %s), status=%d\n", aspect_type, aspect_type->aspect_type_name, object_layout, object_layout->object_type->object_type_name, output, output->type->type_name, res); \
|
||||
return res; \
|
||||
} \
|
||||
|
||||
#define GENERIC_OBJECT_FUNCTIONS(BRICK) \
|
||||
#define GENERIC_OBJECT_FUNCTIONS(TYPE) \
|
||||
\
|
||||
extern inline struct BRICK##_object *BRICK##_construct(void *data, struct BRICK##_object_layout *object_layout) \
|
||||
extern inline struct TYPE##_object *TYPE##_construct(void *data, struct TYPE##_object_layout *object_layout) \
|
||||
{ \
|
||||
struct BRICK##_object *obj = data; \
|
||||
struct TYPE##_object *obj = data; \
|
||||
int i; \
|
||||
\
|
||||
obj->object_layout = object_layout; \
|
||||
|
@ -490,9 +504,9 @@ extern inline struct BRICK##_object *BRICK##_construct(void *data, struct BRICK#
|
|||
return obj; \
|
||||
} \
|
||||
\
|
||||
extern inline void BRICK##_destruct(struct BRICK##_object *obj) \
|
||||
extern inline void TYPE##_destruct(struct TYPE##_object *obj) \
|
||||
{ \
|
||||
struct BRICK##_object_layout *object_layout = obj->object_layout; \
|
||||
struct TYPE##_object_layout *object_layout = obj->object_layout; \
|
||||
int i; \
|
||||
\
|
||||
if (object_layout->object_type->exit_fn) { \
|
||||
|
@ -511,9 +525,9 @@ extern inline void BRICK##_destruct(struct BRICK##_object *obj) \
|
|||
} \
|
||||
} \
|
||||
|
||||
#define GENERIC_ASPECT_FUNCTIONS(BRICK,PREFIX) \
|
||||
#define GENERIC_ASPECT_FUNCTIONS(BRICK,TYPE) \
|
||||
\
|
||||
extern inline struct BRICK##_##PREFIX##_aspect *BRICK##_##PREFIX##_get_aspect(struct BRICK##_output *output, struct PREFIX##_object *obj) \
|
||||
extern inline struct BRICK##_##TYPE##_aspect *BRICK##_##TYPE##_get_aspect(struct BRICK##_output *output, struct TYPE##_object *obj) \
|
||||
{ \
|
||||
struct generic_object_layout *object_layout; \
|
||||
struct generic_aspect_layout *aspect_layout; \
|
||||
|
@ -523,31 +537,31 @@ extern inline struct BRICK##_##PREFIX##_aspect *BRICK##_##PREFIX##_get_aspect(st
|
|||
nr = object_layout->object_type->brick_obj_nr; \
|
||||
aspect_layout = &output->aspect_layouts[nr]; \
|
||||
if (unlikely(!aspect_layout->aspect_type)) { \
|
||||
BRICK_ERR("brick "#BRICK": bad aspect slot on " #PREFIX " pointer %p\n", obj); \
|
||||
BRICK_ERR("brick "#BRICK": bad aspect slot on " #TYPE " pointer %p\n", obj); \
|
||||
return NULL; \
|
||||
} \
|
||||
return (void*)obj + aspect_layout->aspect_offset; \
|
||||
} \
|
||||
\
|
||||
extern inline int BRICK##_##PREFIX##_init_object_layout(struct BRICK##_output *output, struct generic_object_layout *object_layout) \
|
||||
extern inline int BRICK##_##TYPE##_init_object_layout(struct BRICK##_output *output, struct generic_object_layout *object_layout) \
|
||||
{ \
|
||||
return BRICK##_init_object_layout(output, object_layout, 32, &PREFIX##_type); \
|
||||
return BRICK##_init_object_layout(output, object_layout, 32, &TYPE##_type); \
|
||||
} \
|
||||
\
|
||||
extern inline struct PREFIX##_object *BRICK##_alloc_##PREFIX(struct BRICK##_output *output, struct generic_object_layout *object_layout) \
|
||||
extern inline struct TYPE##_object *BRICK##_alloc_##TYPE(struct BRICK##_output *output, struct generic_object_layout *object_layout) \
|
||||
{ \
|
||||
int status = BRICK##_##PREFIX##_init_object_layout(output, object_layout); \
|
||||
int status = BRICK##_##TYPE##_init_object_layout(output, object_layout); \
|
||||
if (status < 0) \
|
||||
return NULL; \
|
||||
return (struct PREFIX##_object*)alloc_generic(object_layout); \
|
||||
return (struct TYPE##_object*)alloc_generic(object_layout); \
|
||||
} \
|
||||
\
|
||||
extern inline struct PREFIX##_object *BRICK##_alloc_##PREFIX##_pure(struct generic_object_layout *object_layout) \
|
||||
extern inline struct TYPE##_object *BRICK##_alloc_##TYPE##_pure(struct generic_object_layout *object_layout) \
|
||||
{ \
|
||||
return (struct PREFIX##_object*)alloc_generic(object_layout); \
|
||||
return (struct TYPE##_object*)alloc_generic(object_layout); \
|
||||
} \
|
||||
\
|
||||
extern inline void BRICK##_free_##PREFIX(struct PREFIX##_object *object) \
|
||||
extern inline void BRICK##_free_##TYPE(struct TYPE##_object *object) \
|
||||
{ \
|
||||
free_generic((struct generic_object*)object); \
|
||||
} \
|
||||
|
|
12
mars_buf.c
12
mars_buf.c
|
@ -374,12 +374,14 @@ static int buf_ref_get(struct buf_output *output, struct mars_ref_object *mref)
|
|||
again:
|
||||
bf = hash_find_insert(brick, ((unsigned int)base_pos) >> brick->backing_order, new);
|
||||
if (bf) {
|
||||
atomic_inc(&brick->hit_count);
|
||||
if (!list_empty(&bf->bf_lru_head)) {
|
||||
traced_lock(&brick->brick_lock, flags);
|
||||
list_del_init(&bf->bf_lru_head);
|
||||
traced_unlock(&brick->brick_lock, flags);
|
||||
}
|
||||
if (new) {
|
||||
if (unlikely(new)) {
|
||||
atomic_inc(&brick->nr_collisions);
|
||||
MARS_DBG("race detected: alias elem appeared in the meantime\n");
|
||||
traced_lock(&brick->brick_lock, flags);
|
||||
|
||||
|
@ -387,14 +389,12 @@ again:
|
|||
|
||||
traced_unlock(&brick->brick_lock, flags);
|
||||
new = NULL;
|
||||
atomic_inc(&brick->nr_collisions);
|
||||
}
|
||||
atomic_inc(&brick->hit_count);
|
||||
} else if (new) {
|
||||
atomic_inc(&brick->miss_count);
|
||||
MARS_DBG("new elem added\n");
|
||||
bf = new;
|
||||
new = NULL;
|
||||
atomic_inc(&brick->miss_count);
|
||||
} else {
|
||||
MARS_DBG("buf_get() hash nothing found\n");
|
||||
|
||||
|
@ -1087,7 +1087,7 @@ static struct buf_output_ops buf_output_ops = {
|
|||
.mars_ref_io = buf_ref_io,
|
||||
};
|
||||
|
||||
static const struct buf_input_type buf_input_type = {
|
||||
const struct buf_input_type buf_input_type = {
|
||||
.type_name = "buf_input",
|
||||
.input_size = sizeof(struct buf_input),
|
||||
};
|
||||
|
@ -1096,7 +1096,7 @@ static const struct buf_input_type *buf_input_types[] = {
|
|||
&buf_input_type,
|
||||
};
|
||||
|
||||
static const struct buf_output_type buf_output_type = {
|
||||
const struct buf_output_type buf_output_type = {
|
||||
.type_name = "buf_output",
|
||||
.output_size = sizeof(struct buf_output),
|
||||
.master_ops = &buf_output_ops,
|
||||
|
|
56
mars_check.c
56
mars_check.c
|
@ -22,17 +22,39 @@
|
|||
|
||||
static void check_buf_endio(struct generic_callback *cb)
|
||||
{
|
||||
struct check_mars_ref_aspect *mref_a = cb->cb_private;
|
||||
struct mars_ref_object *mref = mref_a->object;
|
||||
struct check_output *output = mref_a->output;
|
||||
struct check_input *input = output->brick->inputs[0];
|
||||
struct check_mars_ref_aspect *mref_a;
|
||||
struct mars_ref_object *mref;
|
||||
struct check_output *output;
|
||||
struct check_input *input;
|
||||
struct generic_callback *prev_cb;
|
||||
unsigned long flags;
|
||||
|
||||
if (!mref_a) {
|
||||
mref_a = cb->cb_private;
|
||||
if (unlikely(!mref_a)) {
|
||||
MARS_FAT("cannot get aspect -- hanging up\n");
|
||||
msleep(60000);
|
||||
return;
|
||||
goto fatal;
|
||||
}
|
||||
if (unlikely(&mref_a->cb != cb)) {
|
||||
MARS_FAT("bad callback -- hanging up\n");
|
||||
goto fatal;
|
||||
}
|
||||
|
||||
mref = mref_a->object;
|
||||
if (unlikely(!mref)) {
|
||||
MARS_FAT("bad mref -- hanging up\n");
|
||||
goto fatal;
|
||||
}
|
||||
|
||||
output = mref_a->output;
|
||||
if (unlikely(!output)) {
|
||||
MARS_FAT("bad output -- hanging up\n");
|
||||
goto fatal;
|
||||
}
|
||||
|
||||
input = output->brick->inputs[0];
|
||||
if (unlikely(!input)) {
|
||||
MARS_FAT("bad input -- hanging up\n");
|
||||
goto fatal;
|
||||
}
|
||||
|
||||
if (atomic_dec_and_test(&mref_a->callback_count)) {
|
||||
|
@ -61,6 +83,10 @@ static void check_buf_endio(struct generic_callback *cb)
|
|||
return;
|
||||
}
|
||||
prev_cb->cb_fn(prev_cb);
|
||||
return;
|
||||
fatal:
|
||||
msleep(60000);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CHECK_LOCK
|
||||
|
@ -162,7 +188,6 @@ static void check_ref_io(struct check_output *output, struct mars_ref_object *mr
|
|||
{
|
||||
struct check_input *input = output->brick->inputs[0];
|
||||
struct check_mars_ref_aspect *mref_a = check_mars_ref_get_aspect(output, mref);
|
||||
struct generic_callback *cb = &mref_a->cb;
|
||||
unsigned long flags;
|
||||
|
||||
if (!mref_a) {
|
||||
|
@ -179,22 +204,26 @@ static void check_ref_io(struct check_output *output, struct mars_ref_object *mr
|
|||
|
||||
#ifdef CHECK_LOCK
|
||||
traced_lock(&output->check_lock, flags);
|
||||
|
||||
if (!list_empty(&mref_a->mref_head)) {
|
||||
list_del(&mref_a->mref_head);
|
||||
MARS_ERR("instance %d/%s: list head not empty on %p\n", output->instance_nr, input->connect->type->type_name, mref);
|
||||
list_del(&mref_a->mref_head);
|
||||
}
|
||||
list_add_tail(&mref_a->mref_head, &output->mref_anchor);
|
||||
|
||||
traced_unlock(&output->check_lock, flags);
|
||||
#else
|
||||
(void)flags;
|
||||
#endif
|
||||
|
||||
if (mref->ref_cb != cb) {
|
||||
if (!mref_a->installed) {
|
||||
struct generic_callback *cb = &mref_a->cb;
|
||||
mref_a->installed = true;
|
||||
mref_a->output = output;
|
||||
cb->cb_fn = check_buf_endio;
|
||||
cb->cb_private = mref_a;
|
||||
cb->cb_error = 0;
|
||||
cb->cb_prev = mref->ref_cb;
|
||||
mref_a->output = output;
|
||||
mref->ref_cb = cb;
|
||||
}
|
||||
mref_a->last_jiffies = jiffies;
|
||||
|
@ -215,6 +244,7 @@ static int check_mars_ref_aspect_init_fn(struct generic_aspect *_ini, void *_ini
|
|||
ini->last_jiffies = jiffies;
|
||||
atomic_set(&ini->call_count, 2);
|
||||
atomic_set(&ini->callback_count, 1);
|
||||
ini->installed = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -267,7 +297,7 @@ static struct check_output_ops check_output_ops = {
|
|||
.mars_ref_io = check_ref_io,
|
||||
};
|
||||
|
||||
static const struct check_input_type check_input_type = {
|
||||
const struct check_input_type check_input_type = {
|
||||
.type_name = "check_input",
|
||||
.input_size = sizeof(struct check_input),
|
||||
};
|
||||
|
@ -276,7 +306,7 @@ static const struct check_input_type *check_input_types[] = {
|
|||
&check_input_type,
|
||||
};
|
||||
|
||||
static const struct check_output_type check_output_type = {
|
||||
const struct check_output_type check_output_type = {
|
||||
.type_name = "check_output",
|
||||
.output_size = sizeof(struct check_output),
|
||||
.master_ops = &check_output_ops,
|
||||
|
|
|
@ -14,6 +14,7 @@ struct check_mars_ref_aspect {
|
|||
unsigned long last_jiffies;
|
||||
atomic_t call_count;
|
||||
atomic_t callback_count;
|
||||
bool installed;
|
||||
};
|
||||
|
||||
struct check_brick {
|
||||
|
|
|
@ -488,7 +488,7 @@ static struct device_sio_output_ops device_sio_output_ops = {
|
|||
.mars_get_info = device_sio_get_info,
|
||||
};
|
||||
|
||||
static const struct device_sio_output_type device_sio_output_type = {
|
||||
const struct device_sio_output_type device_sio_output_type = {
|
||||
.type_name = "device_sio_output",
|
||||
.output_size = sizeof(struct device_sio_output),
|
||||
.master_ops = &device_sio_output_ops,
|
||||
|
|
|
@ -88,7 +88,7 @@ static struct dummy_output_ops dummy_output_ops = {
|
|||
.mars_ref_io = dummy_ref_io,
|
||||
};
|
||||
|
||||
static const struct dummy_input_type dummy_input_type = {
|
||||
const struct dummy_input_type dummy_input_type = {
|
||||
.type_name = "dummy_input",
|
||||
.input_size = sizeof(struct dummy_input),
|
||||
};
|
||||
|
@ -97,7 +97,7 @@ static const struct dummy_input_type *dummy_input_types[] = {
|
|||
&dummy_input_type,
|
||||
};
|
||||
|
||||
static const struct dummy_output_type dummy_output_type = {
|
||||
const struct dummy_output_type dummy_output_type = {
|
||||
.type_name = "dummy_output",
|
||||
.output_size = sizeof(struct dummy_output),
|
||||
.master_ops = &dummy_output_ops,
|
||||
|
|
|
@ -55,8 +55,8 @@ static void _if_device_endio(struct generic_callback *cb)
|
|||
*/
|
||||
static int if_device_make_request(struct request_queue *q, struct bio *bio)
|
||||
{
|
||||
struct if_device_input *input = q->queuedata;
|
||||
struct if_device_output *output;
|
||||
struct if_device_input *input;
|
||||
struct if_device_brick *brick;
|
||||
struct mars_ref_object *mref = NULL;
|
||||
struct if_device_mars_ref_aspect *mref_a;
|
||||
struct generic_callback *cb;
|
||||
|
@ -65,26 +65,26 @@ static int if_device_make_request(struct request_queue *q, struct bio *bio)
|
|||
|
||||
MARS_DBG("make_request(%d)\n", bio->bi_size);
|
||||
|
||||
input = q->queuedata;
|
||||
if (unlikely(!input))
|
||||
goto err;
|
||||
|
||||
#if 1 // RPOVIDIONALY TODO: remove
|
||||
{
|
||||
static int first = 0;
|
||||
if (!first++)
|
||||
msleep(1000);
|
||||
}
|
||||
#endif
|
||||
output = input->connect;
|
||||
if (unlikely(!output || !output->ops->mars_ref_io))
|
||||
brick = input->brick;
|
||||
if (unlikely(!brick))
|
||||
goto err;
|
||||
|
||||
/* THIS IS PROVISIONARY
|
||||
*/
|
||||
while (unlikely(!brick->is_active)) {
|
||||
msleep(100);
|
||||
}
|
||||
|
||||
error = -ENOMEM;
|
||||
mref = if_device_alloc_mars_ref(output, &input->mref_object_layout);
|
||||
mref = if_device_alloc_mars_ref(&brick->hidden_output, &input->mref_object_layout);
|
||||
if (unlikely(!mref))
|
||||
goto err;
|
||||
|
||||
mref_a = if_device_mars_ref_get_aspect(output, mref);
|
||||
mref_a = if_device_mars_ref_get_aspect(&brick->hidden_output, mref);
|
||||
if (unlikely(!mref_a))
|
||||
goto err;
|
||||
cb = &mref_a->cb;
|
||||
|
@ -96,9 +96,9 @@ static int if_device_make_request(struct request_queue *q, struct bio *bio)
|
|||
|
||||
mars_ref_attach_bio(mref, bio);
|
||||
|
||||
GENERIC_OUTPUT_CALL(output, mars_ref_io, mref, rw);
|
||||
GENERIC_INPUT_CALL(input, mars_ref_io, mref, rw);
|
||||
|
||||
GENERIC_OUTPUT_CALL(output, mars_ref_put, mref);
|
||||
GENERIC_INPUT_CALL(input, mars_ref_put, mref);
|
||||
|
||||
return 0;
|
||||
|
||||
|
@ -158,6 +158,8 @@ MARS_MAKE_STATICS(if_device);
|
|||
|
||||
static int if_device_brick_construct(struct if_device_brick *brick)
|
||||
{
|
||||
struct if_device_output *hidden = &brick->hidden_output;
|
||||
_if_device_output_init(brick, hidden, "internal");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -243,12 +245,21 @@ static int if_device_input_destruct(struct if_device_input *input)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int if_device_output_construct(struct if_device_output *output)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
///////////////////////// static structs ////////////////////////
|
||||
|
||||
static struct if_device_brick_ops if_device_brick_ops = {
|
||||
};
|
||||
|
||||
static const struct if_device_input_type if_device_input_type = {
|
||||
static struct if_device_output_ops if_device_output_ops = {
|
||||
.make_object_layout = if_device_make_object_layout,
|
||||
};
|
||||
|
||||
const struct if_device_input_type if_device_input_type = {
|
||||
.type_name = "if_device_input",
|
||||
.input_size = sizeof(struct if_device_input),
|
||||
.input_construct = &if_device_input_construct,
|
||||
|
@ -259,6 +270,16 @@ static const struct if_device_input_type *if_device_input_types[] = {
|
|||
&if_device_input_type,
|
||||
};
|
||||
|
||||
const struct if_device_output_type if_device_output_type = {
|
||||
.type_name = "if_device_output",
|
||||
.output_size = sizeof(struct if_device_output),
|
||||
.master_ops = &if_device_output_ops,
|
||||
.output_construct = &if_device_output_construct,
|
||||
.aspect_types = if_device_aspect_types,
|
||||
.layout_code = {
|
||||
[BRICK_OBJ_MARS_REF] = LAYOUT_ALL,
|
||||
}
|
||||
};
|
||||
const struct if_device_brick_type if_device_brick_type = {
|
||||
.type_name = "if_device_brick",
|
||||
.brick_size = sizeof(struct if_device_brick),
|
||||
|
|
|
@ -10,10 +10,6 @@ struct if_device_mars_ref_aspect {
|
|||
struct generic_callback cb;
|
||||
};
|
||||
|
||||
struct if_device_brick {
|
||||
MARS_BRICK(if_device);
|
||||
};
|
||||
|
||||
struct if_device_input {
|
||||
MARS_INPUT(if_device);
|
||||
struct request_queue *q;
|
||||
|
@ -27,6 +23,12 @@ struct if_device_output {
|
|||
MARS_OUTPUT(if_device);
|
||||
};
|
||||
|
||||
struct if_device_brick {
|
||||
MARS_BRICK(if_device);
|
||||
bool is_active;
|
||||
struct if_device_output hidden_output;
|
||||
};
|
||||
|
||||
MARS_TYPES(if_device);
|
||||
|
||||
#endif
|
||||
|
|
15
mars_test.c
15
mars_test.c
|
@ -23,6 +23,7 @@
|
|||
GENERIC_ASPECT_FUNCTIONS(generic,mars_ref);
|
||||
|
||||
static struct generic_brick *if_brick = NULL;
|
||||
static struct if_device_brick *_if_brick = NULL;
|
||||
static struct generic_brick *usebuf_brick = NULL;
|
||||
static struct generic_brick *buf_brick = NULL;
|
||||
static struct buf_brick *_buf_brick = NULL;
|
||||
|
@ -80,7 +81,7 @@ void make_test_instance(void)
|
|||
void connect(struct generic_input *a, struct generic_output *b)
|
||||
{
|
||||
int status;
|
||||
#if 0
|
||||
#if 1
|
||||
struct generic_brick *tmp = brick(&check_brick_type);
|
||||
|
||||
status = generic_connect(a, tmp->outputs[0]);
|
||||
|
@ -120,8 +121,8 @@ void make_test_instance(void)
|
|||
|
||||
buf_brick = brick(&buf_brick_type);
|
||||
_buf_brick = (void*)buf_brick;
|
||||
//_buf_brick->backing_order = 0;
|
||||
_buf_brick->backing_order = 2;
|
||||
_buf_brick->backing_order = 0;
|
||||
//_buf_brick->backing_order = 2;
|
||||
//_buf_brick->backing_order = 4;
|
||||
//_buf_brick->backing_order = 7;
|
||||
_buf_brick->backing_size = PAGE_SIZE << _buf_brick->backing_order;
|
||||
|
@ -167,6 +168,14 @@ void make_test_instance(void)
|
|||
(void)test_endio;
|
||||
connect(last, device_brick->outputs[0]);
|
||||
#endif
|
||||
|
||||
msleep(200);
|
||||
|
||||
MARS_INF("------------- END INIT --------------\n");
|
||||
|
||||
_if_brick = (void*)if_brick;
|
||||
_if_brick->is_active = true;
|
||||
|
||||
msleep(2000);
|
||||
MARS_INF("------------- DONE --------------\n");
|
||||
}
|
||||
|
|
|
@ -44,10 +44,10 @@ static struct trans_logger_mars_ref_aspect *hash_find(struct hash_anchor *table,
|
|||
|
||||
traced_readlock(&start->hash_lock, flags);
|
||||
|
||||
/* Caution: there may be duplicates in the list, some of them
|
||||
* overlapping in many different ways.
|
||||
/* The lists are always sorted according to age.
|
||||
* Caution: there may be duplicates in the list, some of them
|
||||
* overlapping with the search area in many different ways.
|
||||
* Always find the both _newest_ and _lowest_ overlapping element.
|
||||
* The lists are alwaysw sorted according to age.
|
||||
*/
|
||||
for (tmp = start->hash_anchor.next; tmp != &start->hash_anchor; tmp = tmp->next) {
|
||||
#if 1
|
||||
|
@ -220,7 +220,7 @@ static struct trans_logger_output_ops trans_logger_output_ops = {
|
|||
.mars_ref_io = trans_logger_ref_io,
|
||||
};
|
||||
|
||||
static const struct trans_logger_input_type trans_logger_input_type = {
|
||||
const struct trans_logger_input_type trans_logger_input_type = {
|
||||
.type_name = "trans_logger_input",
|
||||
.input_size = sizeof(struct trans_logger_input),
|
||||
};
|
||||
|
@ -231,7 +231,7 @@ static const struct trans_logger_input_type *trans_logger_input_types[] = {
|
|||
&trans_logger_input_type,
|
||||
};
|
||||
|
||||
static const struct trans_logger_output_type trans_logger_output_type = {
|
||||
const struct trans_logger_output_type trans_logger_output_type = {
|
||||
.type_name = "trans_logger_output",
|
||||
.output_size = sizeof(struct trans_logger_output),
|
||||
.master_ops = &trans_logger_output_ops,
|
||||
|
|
|
@ -285,7 +285,6 @@ static void usebuf_ref_io(struct usebuf_output *output, struct mars_ref_object *
|
|||
_usebuf_copy(mref_a, WRITE);
|
||||
} else {
|
||||
// first start initial read, to get the whole buffer UPTODATE
|
||||
MARS_DBG("AHA\n");
|
||||
my_rw = READ;
|
||||
}
|
||||
}
|
||||
|
@ -293,7 +292,7 @@ static void usebuf_ref_io(struct usebuf_output *output, struct mars_ref_object *
|
|||
// grab reference for each sub-IO
|
||||
CHECK_ATOMIC(&origmref_a->subref_count, 1);
|
||||
atomic_inc(&origmref_a->subref_count);
|
||||
|
||||
|
||||
GENERIC_INPUT_CALL(input, mars_ref_io, mref, my_rw);
|
||||
|
||||
put:
|
||||
|
@ -369,7 +368,7 @@ static struct usebuf_output_ops usebuf_output_ops = {
|
|||
.mars_ref_io = usebuf_ref_io,
|
||||
};
|
||||
|
||||
static const struct usebuf_input_type usebuf_input_type = {
|
||||
const struct usebuf_input_type usebuf_input_type = {
|
||||
.type_name = "usebuf_input",
|
||||
.input_size = sizeof(struct usebuf_input),
|
||||
};
|
||||
|
@ -378,7 +377,7 @@ static const struct usebuf_input_type *usebuf_input_types[] = {
|
|||
&usebuf_input_type,
|
||||
};
|
||||
|
||||
static const struct usebuf_output_type usebuf_output_type = {
|
||||
const struct usebuf_output_type usebuf_output_type = {
|
||||
.type_name = "usebuf_output",
|
||||
.output_size = sizeof(struct usebuf_output),
|
||||
.master_ops = &usebuf_output_ops,
|
||||
|
|
Loading…
Reference in New Issue