mirror of https://github.com/schoebel/mars
import mars-42.tgz
This commit is contained in:
parent
cdb92986c6
commit
fe0908b5e8
8
mars.h
8
mars.h
|
@ -194,7 +194,7 @@ static const struct generic_aspect_type *BRICK##_aspect_types[BRICK_OBJ_NR] = {
|
|||
int test = atomic_read(atom); \
|
||||
if (test OP (minval)) { \
|
||||
atomic_set(atom, minval); \
|
||||
MARS_ERR("line %d atomic " #atom " " #OP " " #minval "\n", __LINE__); \
|
||||
MARS_ERR("%d: atomic " #atom " " #OP " " #minval "\n", __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -219,19 +219,19 @@ static inline void mars_ref_attach_bio(struct mars_ref_object *mref, struct bio
|
|||
#define CHECK_HEAD_EMPTY(head) \
|
||||
if (unlikely(!list_empty(head))) { \
|
||||
INIT_LIST_HEAD(head); \
|
||||
MARS_ERR("list_head " #head " (%p) not empty\n", head); \
|
||||
MARS_ERR("%d: list_head " #head " (%p) not empty\n", __LINE__, head); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
|
||||
#define CHECK_PTR(ptr,label) \
|
||||
if (unlikely(!(ptr))) { \
|
||||
MARS_FAT("ptr " #ptr " is NULL\n"); \
|
||||
MARS_FAT("%d: ptr " #ptr " is NULL\n", __LINE__); \
|
||||
goto label; \
|
||||
}
|
||||
|
||||
#define _CHECK(ptr,label) \
|
||||
if (unlikely(!(ptr))) { \
|
||||
MARS_FAT("condition " #ptr " is VIOLATED\n"); \
|
||||
MARS_FAT("%d: condition " #ptr " is VIOLATED\n", __LINE__); \
|
||||
goto label; \
|
||||
}
|
||||
|
|
18
mars_buf.c
18
mars_buf.c
|
@ -226,16 +226,30 @@ static int make_bio(struct buf_brick *brick, struct bio **_bio, void *data, loff
|
|||
struct bio *bio = NULL;
|
||||
struct block_device *bdev;
|
||||
|
||||
status = -EINVAL;
|
||||
CHECK_PTR(brick, out);
|
||||
if (unlikely(!brick->got_info)) {
|
||||
struct request_queue *q;
|
||||
status = get_info(brick);
|
||||
if (status < 0)
|
||||
goto out;
|
||||
status = -EINVAL;
|
||||
CHECK_PTR(brick->base_info.backing_file, out);
|
||||
CHECK_PTR(brick->base_info.backing_file->f_mapping, out);
|
||||
CHECK_PTR(brick->base_info.backing_file->f_mapping->host, out);
|
||||
CHECK_PTR(brick->base_info.backing_file->f_mapping->host->i_sb, out);
|
||||
bdev = brick->base_info.backing_file->f_mapping->host->i_sb->s_bdev;
|
||||
if (!bdev && S_ISBLK(brick->base_info.backing_file->f_mapping->host->i_mode)) {
|
||||
bdev = brick->base_info.backing_file->f_mapping->host->i_bdev;
|
||||
}
|
||||
CHECK_PTR(bdev, out);
|
||||
brick->bdev = bdev;
|
||||
q = bdev_get_queue(bdev);
|
||||
CHECK_PTR(q, out);
|
||||
brick->bvec_max = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
|
||||
} else {
|
||||
bdev = brick->base_info.backing_file->f_mapping->host->i_sb->s_bdev;
|
||||
bdev = brick->bdev;
|
||||
CHECK_PTR(bdev, out);
|
||||
}
|
||||
|
||||
if (unlikely(ilen <= 0)) {
|
||||
|
@ -281,6 +295,8 @@ static int make_bio(struct buf_brick *brick, struct bio **_bio, void *data, loff
|
|||
mylen = myrest;
|
||||
|
||||
page = virt_to_page(data);
|
||||
if (!page)
|
||||
goto out;
|
||||
|
||||
bio->bi_io_vec[i].bv_page = page;
|
||||
bio->bi_io_vec[i].bv_len = mylen;
|
||||
|
|
|
@ -46,6 +46,7 @@ struct buf_brick {
|
|||
struct mars_info base_info;
|
||||
int got_info;
|
||||
int bvec_max;
|
||||
struct block_device *bdev;
|
||||
|
||||
// statistics
|
||||
unsigned long last_jiffies;
|
||||
|
|
11
mars_test.c
11
mars_test.c
|
@ -189,6 +189,7 @@ void make_test_instance(void)
|
|||
connect(last, trans_brick->outputs[0]);
|
||||
#else
|
||||
(void)trans_brick;
|
||||
(void)_trans_brick;
|
||||
(void)tbuf_brick;
|
||||
(void)_tbuf_brick;
|
||||
(void)tdevice_brick;
|
||||
|
@ -233,7 +234,15 @@ void make_test_instance(void)
|
|||
MARS_INF("------------- END INIT --------------\n");
|
||||
|
||||
_if_brick = (void*)if_brick;
|
||||
_if_brick->ops->brick_switch(if_brick, true);
|
||||
{
|
||||
struct mars_info info = {};
|
||||
int status = GENERIC_INPUT_CALL(_if_brick->inputs[0], mars_get_info, &info);
|
||||
MARS_INF("INFO status=%d size=%lld transfer_order=%d transfer_size=%d %p\n", status, info.current_size, info.transfer_order, info.transfer_size, info.backing_file);
|
||||
}
|
||||
|
||||
MARS_INF("------------- START GATE --------------\n");
|
||||
|
||||
_if_brick->ops->brick_switch(_if_brick, true);
|
||||
//_if_brick->is_active = true;
|
||||
|
||||
msleep(2000);
|
||||
|
|
Loading…
Reference in New Issue