import mars-42.tgz

This commit is contained in:
Thomas Schoebel-Theuer 2010-08-27 08:20:26 +01:00
parent cdb92986c6
commit fe0908b5e8
4 changed files with 32 additions and 6 deletions

8
mars.h
View File

@ -194,7 +194,7 @@ static const struct generic_aspect_type *BRICK##_aspect_types[BRICK_OBJ_NR] = {
int test = atomic_read(atom); \ int test = atomic_read(atom); \
if (test OP (minval)) { \ if (test OP (minval)) { \
atomic_set(atom, 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) } 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) \ #define CHECK_HEAD_EMPTY(head) \
if (unlikely(!list_empty(head))) { \ if (unlikely(!list_empty(head))) { \
INIT_LIST_HEAD(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 #endif
#define CHECK_PTR(ptr,label) \ #define CHECK_PTR(ptr,label) \
if (unlikely(!(ptr))) { \ if (unlikely(!(ptr))) { \
MARS_FAT("ptr " #ptr " is NULL\n"); \ MARS_FAT("%d: ptr " #ptr " is NULL\n", __LINE__); \
goto label; \ goto label; \
} }
#define _CHECK(ptr,label) \ #define _CHECK(ptr,label) \
if (unlikely(!(ptr))) { \ if (unlikely(!(ptr))) { \
MARS_FAT("condition " #ptr " is VIOLATED\n"); \ MARS_FAT("%d: condition " #ptr " is VIOLATED\n", __LINE__); \
goto label; \ goto label; \
} }

View File

@ -226,16 +226,30 @@ static int make_bio(struct buf_brick *brick, struct bio **_bio, void *data, loff
struct bio *bio = NULL; struct bio *bio = NULL;
struct block_device *bdev; struct block_device *bdev;
status = -EINVAL;
CHECK_PTR(brick, out);
if (unlikely(!brick->got_info)) { if (unlikely(!brick->got_info)) {
struct request_queue *q; struct request_queue *q;
status = get_info(brick); status = get_info(brick);
if (status < 0) if (status < 0)
goto out; 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; 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); q = bdev_get_queue(bdev);
CHECK_PTR(q, out);
brick->bvec_max = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9); brick->bvec_max = queue_max_hw_sectors(q) >> (PAGE_SHIFT - 9);
} else { } 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)) { if (unlikely(ilen <= 0)) {
@ -281,6 +295,8 @@ static int make_bio(struct buf_brick *brick, struct bio **_bio, void *data, loff
mylen = myrest; mylen = myrest;
page = virt_to_page(data); page = virt_to_page(data);
if (!page)
goto out;
bio->bi_io_vec[i].bv_page = page; bio->bi_io_vec[i].bv_page = page;
bio->bi_io_vec[i].bv_len = mylen; bio->bi_io_vec[i].bv_len = mylen;

View File

@ -46,6 +46,7 @@ struct buf_brick {
struct mars_info base_info; struct mars_info base_info;
int got_info; int got_info;
int bvec_max; int bvec_max;
struct block_device *bdev;
// statistics // statistics
unsigned long last_jiffies; unsigned long last_jiffies;

View File

@ -189,6 +189,7 @@ void make_test_instance(void)
connect(last, trans_brick->outputs[0]); connect(last, trans_brick->outputs[0]);
#else #else
(void)trans_brick; (void)trans_brick;
(void)_trans_brick;
(void)tbuf_brick; (void)tbuf_brick;
(void)_tbuf_brick; (void)_tbuf_brick;
(void)tdevice_brick; (void)tdevice_brick;
@ -233,7 +234,15 @@ void make_test_instance(void)
MARS_INF("------------- END INIT --------------\n"); MARS_INF("------------- END INIT --------------\n");
_if_brick = (void*)if_brick; _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; //_if_brick->is_active = true;
msleep(2000); msleep(2000);