Move uint8_t[] buffers into any_op_t/any_reply_t
parent
d4fd9d982a
commit
72a89be912
|
@ -160,11 +160,7 @@ static enum fio_q_status sec_queue(struct thread_data *td, struct io_u *io)
|
||||||
}
|
}
|
||||||
|
|
||||||
io->engine_data = bsd;
|
io->engine_data = bsd;
|
||||||
union
|
osd_any_op_t op = { 0 };
|
||||||
{
|
|
||||||
osd_any_op_t op;
|
|
||||||
uint8_t op_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
|
|
||||||
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
||||||
op.hdr.id = n;
|
op.hdr.id = n;
|
||||||
|
@ -208,7 +204,7 @@ static enum fio_q_status sec_queue(struct thread_data *td, struct io_u *io)
|
||||||
bsd->op_n++;
|
bsd->op_n++;
|
||||||
bsd->queue[n] = io;
|
bsd->queue[n] = io;
|
||||||
|
|
||||||
if (write(bsd->connect_fd, op_buf, OSD_PACKET_SIZE) != OSD_PACKET_SIZE)
|
if (write(bsd->connect_fd, op.buf, OSD_PACKET_SIZE) != OSD_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
perror("write");
|
perror("write");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -228,14 +224,10 @@ static int sec_getevents(struct thread_data *td, unsigned int min, unsigned int
|
||||||
{
|
{
|
||||||
sec_data *bsd = (sec_data*)td->io_ops_data;
|
sec_data *bsd = (sec_data*)td->io_ops_data;
|
||||||
// FIXME timeout, at least poll. Now it's the stupidest implementation possible
|
// FIXME timeout, at least poll. Now it's the stupidest implementation possible
|
||||||
union
|
osd_any_reply_t reply;
|
||||||
{
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
uint8_t reply_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
while (bsd->completed.size() < min)
|
while (bsd->completed.size() < min)
|
||||||
{
|
{
|
||||||
read_blocking(bsd->connect_fd, reply_buf, OSD_PACKET_SIZE);
|
read_blocking(bsd->connect_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (reply.hdr.magic != SECONDARY_OSD_REPLY_MAGIC)
|
if (reply.hdr.magic != SECONDARY_OSD_REPLY_MAGIC)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "bad reply: magic = %lx instead of %lx\n", reply.hdr.magic, SECONDARY_OSD_REPLY_MAGIC);
|
fprintf(stderr, "bad reply: magic = %lx instead of %lx\n", reply.hdr.magic, SECONDARY_OSD_REPLY_MAGIC);
|
||||||
|
|
12
osd.h
12
osd.h
|
@ -98,16 +98,8 @@ struct osd_op_t
|
||||||
{
|
{
|
||||||
int op_type;
|
int op_type;
|
||||||
int peer_fd;
|
int peer_fd;
|
||||||
union
|
osd_any_op_t op;
|
||||||
{
|
osd_any_reply_t reply;
|
||||||
osd_any_op_t op;
|
|
||||||
uint8_t op_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
uint8_t reply_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
blockstore_op_t bs_op;
|
blockstore_op_t bs_op;
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
osd_primary_op_data_t* op_data = NULL;
|
osd_primary_op_data_t* op_data = NULL;
|
||||||
|
|
|
@ -9,8 +9,8 @@ void handle_sigint(int sig)
|
||||||
|
|
||||||
int main(int narg, char *args[])
|
int main(int narg, char *args[])
|
||||||
{
|
{
|
||||||
if (sizeof(osd_any_op_t) >= OSD_PACKET_SIZE ||
|
if (sizeof(osd_any_op_t) > OSD_PACKET_SIZE ||
|
||||||
sizeof(osd_any_reply_t) >= OSD_PACKET_SIZE)
|
sizeof(osd_any_reply_t) > OSD_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
perror("BUG: too small packet size");
|
perror("BUG: too small packet size");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -180,6 +180,7 @@ union osd_any_op_t
|
||||||
osd_op_show_config_t show_conf;
|
osd_op_show_config_t show_conf;
|
||||||
osd_op_rw_t rw;
|
osd_op_rw_t rw;
|
||||||
osd_op_sync_t sync;
|
osd_op_sync_t sync;
|
||||||
|
uint8_t buf[OSD_PACKET_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
union osd_any_reply_t
|
union osd_any_reply_t
|
||||||
|
@ -193,4 +194,5 @@ union osd_any_reply_t
|
||||||
osd_reply_show_config_t show_conf;
|
osd_reply_show_config_t show_conf;
|
||||||
osd_reply_rw_t rw;
|
osd_reply_rw_t rw;
|
||||||
osd_reply_sync_t sync;
|
osd_reply_sync_t sync;
|
||||||
|
uint8_t buf[OSD_PACKET_SIZE];
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,7 +23,7 @@ void osd_t::read_requests()
|
||||||
cl.read_op->peer_fd = peer_fd;
|
cl.read_op->peer_fd = peer_fd;
|
||||||
}
|
}
|
||||||
cl.read_op->op_type = OSD_OP_IN;
|
cl.read_op->op_type = OSD_OP_IN;
|
||||||
cl.read_buf = &cl.read_op->op_buf;
|
cl.read_buf = &cl.read_op->op.buf;
|
||||||
cl.read_remaining = OSD_PACKET_SIZE;
|
cl.read_remaining = OSD_PACKET_SIZE;
|
||||||
cl.read_state = CL_READ_OP;
|
cl.read_state = CL_READ_OP;
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ void osd_t::handle_read_reply(osd_client_t *cl)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
osd_op_t *request = req_it->second;
|
osd_op_t *request = req_it->second;
|
||||||
memcpy(request->reply_buf, cur_op->op_buf, OSD_PACKET_SIZE);
|
memcpy(request->reply.buf, cur_op->op.buf, OSD_PACKET_SIZE);
|
||||||
if (request->reply.hdr.opcode == OSD_OP_SECONDARY_READ &&
|
if (request->reply.hdr.opcode == OSD_OP_SECONDARY_READ &&
|
||||||
request->reply.hdr.retval > 0)
|
request->reply.hdr.retval > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,13 +32,13 @@ void osd_t::send_replies()
|
||||||
cl.outbox.pop_front();
|
cl.outbox.pop_front();
|
||||||
if (cl.write_op->op_type == OSD_OP_OUT)
|
if (cl.write_op->op_type == OSD_OP_OUT)
|
||||||
{
|
{
|
||||||
cl.write_buf = &cl.write_op->op_buf;
|
cl.write_buf = &cl.write_op->op.buf;
|
||||||
cl.write_remaining = OSD_PACKET_SIZE;
|
cl.write_remaining = OSD_PACKET_SIZE;
|
||||||
cl.write_state = CL_WRITE_REPLY;
|
cl.write_state = CL_WRITE_REPLY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cl.write_buf = &cl.write_op->reply_buf;
|
cl.write_buf = &cl.write_op->reply.buf;
|
||||||
cl.write_remaining = OSD_PACKET_SIZE;
|
cl.write_remaining = OSD_PACKET_SIZE;
|
||||||
cl.write_state = CL_WRITE_REPLY;
|
cl.write_state = CL_WRITE_REPLY;
|
||||||
}
|
}
|
||||||
|
|
20
stub_osd.cpp
20
stub_osd.cpp
|
@ -112,20 +112,12 @@ int bind_stub(const char *bind_address, int bind_port)
|
||||||
|
|
||||||
void run_stub(int peer_fd)
|
void run_stub(int peer_fd)
|
||||||
{
|
{
|
||||||
union
|
osd_any_op_t op;
|
||||||
{
|
osd_any_reply_t reply;
|
||||||
osd_any_op_t op;
|
|
||||||
uint8_t op_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
uint8_t reply_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
void *buf = NULL;
|
void *buf = NULL;
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
int r = read_blocking(peer_fd, op_buf, OSD_PACKET_SIZE);
|
int r = read_blocking(peer_fd, op.buf, OSD_PACKET_SIZE);
|
||||||
if (r < OSD_PACKET_SIZE)
|
if (r < OSD_PACKET_SIZE)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -142,7 +134,7 @@ void run_stub(int peer_fd)
|
||||||
{
|
{
|
||||||
reply.hdr.retval = op.sec_rw.len;
|
reply.hdr.retval = op.sec_rw.len;
|
||||||
buf = malloc(op.sec_rw.len);
|
buf = malloc(op.sec_rw.len);
|
||||||
r = write_blocking(peer_fd, reply_buf, OSD_PACKET_SIZE);
|
r = write_blocking(peer_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (r == OSD_PACKET_SIZE)
|
if (r == OSD_PACKET_SIZE)
|
||||||
r = write_blocking(peer_fd, &buf, op.sec_rw.len);
|
r = write_blocking(peer_fd, &buf, op.sec_rw.len);
|
||||||
free(buf);
|
free(buf);
|
||||||
|
@ -156,7 +148,7 @@ void run_stub(int peer_fd)
|
||||||
free(buf);
|
free(buf);
|
||||||
reply.hdr.retval = op.sec_rw.len;
|
reply.hdr.retval = op.sec_rw.len;
|
||||||
if (r == op.sec_rw.len)
|
if (r == op.sec_rw.len)
|
||||||
r = write_blocking(peer_fd, reply_buf, OSD_PACKET_SIZE);
|
r = write_blocking(peer_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
else
|
else
|
||||||
r = 0;
|
r = 0;
|
||||||
if (r < OSD_PACKET_SIZE)
|
if (r < OSD_PACKET_SIZE)
|
||||||
|
@ -165,7 +157,7 @@ void run_stub(int peer_fd)
|
||||||
else if (op.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL)
|
else if (op.hdr.opcode == OSD_OP_TEST_SYNC_STAB_ALL)
|
||||||
{
|
{
|
||||||
reply.hdr.retval = 0;
|
reply.hdr.retval = 0;
|
||||||
r = write_blocking(peer_fd, reply_buf, OSD_PACKET_SIZE);
|
r = write_blocking(peer_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (r < OSD_PACKET_SIZE)
|
if (r < OSD_PACKET_SIZE)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
36
test_osd.cpp
36
test_osd.cpp
|
@ -117,16 +117,8 @@ bool check_reply(int r, osd_any_op_t & op, osd_any_reply_t & reply, int expected
|
||||||
|
|
||||||
uint64_t test_write(int connect_fd, uint64_t inode, uint64_t stripe, uint64_t version, uint64_t pattern)
|
uint64_t test_write(int connect_fd, uint64_t inode, uint64_t stripe, uint64_t version, uint64_t pattern)
|
||||||
{
|
{
|
||||||
union
|
osd_any_op_t op;
|
||||||
{
|
osd_any_reply_t reply;
|
||||||
osd_any_op_t op;
|
|
||||||
uint8_t op_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
uint8_t reply_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
||||||
op.hdr.id = 1;
|
op.hdr.id = 1;
|
||||||
op.hdr.opcode = OSD_OP_SECONDARY_WRITE;
|
op.hdr.opcode = OSD_OP_SECONDARY_WRITE;
|
||||||
|
@ -140,9 +132,9 @@ uint64_t test_write(int connect_fd, uint64_t inode, uint64_t stripe, uint64_t ve
|
||||||
void *data = memalign(512, op.sec_rw.len);
|
void *data = memalign(512, op.sec_rw.len);
|
||||||
for (int i = 0; i < (op.sec_rw.len)/sizeof(uint64_t); i++)
|
for (int i = 0; i < (op.sec_rw.len)/sizeof(uint64_t); i++)
|
||||||
((uint64_t*)data)[i] = pattern;
|
((uint64_t*)data)[i] = pattern;
|
||||||
write_blocking(connect_fd, op_buf, OSD_PACKET_SIZE);
|
write_blocking(connect_fd, op.buf, OSD_PACKET_SIZE);
|
||||||
write_blocking(connect_fd, data, op.sec_rw.len);
|
write_blocking(connect_fd, data, op.sec_rw.len);
|
||||||
int r = read_blocking(connect_fd, reply_buf, OSD_PACKET_SIZE);
|
int r = read_blocking(connect_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (!check_reply(r, op, reply, op.sec_rw.len))
|
if (!check_reply(r, op, reply, op.sec_rw.len))
|
||||||
{
|
{
|
||||||
free(data);
|
free(data);
|
||||||
|
@ -151,8 +143,8 @@ uint64_t test_write(int connect_fd, uint64_t inode, uint64_t stripe, uint64_t ve
|
||||||
version = reply.sec_rw.version;
|
version = reply.sec_rw.version;
|
||||||
op.hdr.opcode = OSD_OP_TEST_SYNC_STAB_ALL;
|
op.hdr.opcode = OSD_OP_TEST_SYNC_STAB_ALL;
|
||||||
op.hdr.id = 2;
|
op.hdr.id = 2;
|
||||||
write_blocking(connect_fd, op_buf, OSD_PACKET_SIZE);
|
write_blocking(connect_fd, op.buf, OSD_PACKET_SIZE);
|
||||||
r = read_blocking(connect_fd, reply_buf, OSD_PACKET_SIZE);
|
r = read_blocking(connect_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (!check_reply(r, op, reply, 0))
|
if (!check_reply(r, op, reply, 0))
|
||||||
{
|
{
|
||||||
free(data);
|
free(data);
|
||||||
|
@ -164,16 +156,8 @@ uint64_t test_write(int connect_fd, uint64_t inode, uint64_t stripe, uint64_t ve
|
||||||
|
|
||||||
void* test_primary_read(int connect_fd, uint64_t inode, uint64_t offset, uint64_t len)
|
void* test_primary_read(int connect_fd, uint64_t inode, uint64_t offset, uint64_t len)
|
||||||
{
|
{
|
||||||
union
|
osd_any_op_t op;
|
||||||
{
|
osd_any_reply_t reply;
|
||||||
osd_any_op_t op;
|
|
||||||
uint8_t op_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
union
|
|
||||||
{
|
|
||||||
osd_any_reply_t reply;
|
|
||||||
uint8_t reply_buf[OSD_PACKET_SIZE] = { 0 };
|
|
||||||
};
|
|
||||||
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
||||||
op.hdr.id = 1;
|
op.hdr.id = 1;
|
||||||
op.hdr.opcode = OSD_OP_READ;
|
op.hdr.opcode = OSD_OP_READ;
|
||||||
|
@ -181,8 +165,8 @@ void* test_primary_read(int connect_fd, uint64_t inode, uint64_t offset, uint64_
|
||||||
op.rw.offset = offset;
|
op.rw.offset = offset;
|
||||||
op.rw.len = len;
|
op.rw.len = len;
|
||||||
void *data = memalign(512, len);
|
void *data = memalign(512, len);
|
||||||
write_blocking(connect_fd, op_buf, OSD_PACKET_SIZE);
|
write_blocking(connect_fd, op.buf, OSD_PACKET_SIZE);
|
||||||
int r = read_blocking(connect_fd, reply_buf, OSD_PACKET_SIZE);
|
int r = read_blocking(connect_fd, reply.buf, OSD_PACKET_SIZE);
|
||||||
if (!check_reply(r, op, reply, len))
|
if (!check_reply(r, op, reply, len))
|
||||||
{
|
{
|
||||||
free(data);
|
free(data);
|
||||||
|
|
Loading…
Reference in New Issue