forked from vitalif/vitastor
...and make it work :)
parent
a406c62a71
commit
df66a76ce2
|
@ -287,10 +287,14 @@ void osd_t::handle_primary_subop(osd_op_t *cur_op, int ok, uint64_t version)
|
|||
{
|
||||
continue_primary_read(cur_op);
|
||||
}
|
||||
else
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_WRITE)
|
||||
{
|
||||
continue_primary_write(cur_op);
|
||||
}
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_SYNC)
|
||||
{
|
||||
continue_primary_sync(cur_op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,7 +451,6 @@ resume_2:
|
|||
.oid = it->first.oid,
|
||||
.version = it->second,
|
||||
};
|
||||
last_start++;
|
||||
last_end++;
|
||||
}
|
||||
if (last_osd != 0)
|
||||
|
|
|
@ -106,14 +106,19 @@ void osd_t::handle_op_hdr(osd_client_t *cl)
|
|||
cur_op->buf = memalign(512, cur_op->req.sec_rw.len);
|
||||
cl->read_remaining = 0;
|
||||
}
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK)
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_WRITE)
|
||||
{
|
||||
if (cur_op->req.sec_rw.len > 0)
|
||||
cur_op->buf = memalign(512, cur_op->req.sec_rw.len);
|
||||
cl->read_remaining = cur_op->req.sec_rw.len;
|
||||
}
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_SECONDARY_STABILIZE ||
|
||||
cur_op->req.hdr.opcode == OSD_OP_SECONDARY_ROLLBACK)
|
||||
{
|
||||
if (cur_op->req.sec_stab.len > 0)
|
||||
cur_op->buf = memalign(512, cur_op->req.sec_stab.len);
|
||||
cl->read_remaining = cur_op->req.sec_stab.len;
|
||||
}
|
||||
else if (cur_op->req.hdr.opcode == OSD_OP_READ)
|
||||
{
|
||||
if (cur_op->req.rw.len > 0)
|
||||
|
@ -148,6 +153,7 @@ void osd_t::handle_reply_hdr(osd_client_t *cl)
|
|||
if (req_it == cl->sent_ops.end())
|
||||
{
|
||||
// Command out of sync. Drop connection
|
||||
printf("Client %d command out of sync: id %lu\n", cl->peer_fd, cur_op->req.hdr.id);
|
||||
stop_client(cl->peer_fd);
|
||||
return;
|
||||
}
|
||||
|
|
28
osd_test.cpp
28
osd_test.cpp
|
@ -25,6 +25,8 @@ void* test_primary_read(int connect_fd, uint64_t inode, uint64_t offset, uint64_
|
|||
|
||||
void test_primary_write(int connect_fd, uint64_t inode, uint64_t offset, uint64_t len, uint64_t pattern);
|
||||
|
||||
void test_primary_sync(int connect_fd);
|
||||
|
||||
void test_sync_stab_all(int connect_fd);
|
||||
|
||||
int main0(int narg, char *args[])
|
||||
|
@ -68,7 +70,7 @@ int main1(int narg, char *args[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main(int narg, char *args[])
|
||||
int main2(int narg, char *args[])
|
||||
{
|
||||
int connect_fd;
|
||||
// Cluster write (sync not implemented yet)
|
||||
|
@ -92,6 +94,18 @@ int main(int narg, char *args[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
int main(int narg, char *args[])
|
||||
{
|
||||
int connect_fd;
|
||||
// Cluster write (sync not implemented yet)
|
||||
connect_fd = connect_osd("127.0.0.1", 11203);
|
||||
test_primary_write(connect_fd, 2, 0, 128*1024, PATTERN0);
|
||||
test_primary_write(connect_fd, 2, 128*1024, 128*1024, PATTERN1);
|
||||
test_primary_sync(connect_fd);
|
||||
close(connect_fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int connect_osd(const char *osd_address, int osd_port)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
|
@ -228,6 +242,18 @@ void test_primary_write(int connect_fd, uint64_t inode, uint64_t offset, uint64_
|
|||
assert(check_reply(r, op, reply, len));
|
||||
}
|
||||
|
||||
void test_primary_sync(int connect_fd)
|
||||
{
|
||||
osd_any_op_t op;
|
||||
osd_any_reply_t reply;
|
||||
op.hdr.magic = SECONDARY_OSD_OP_MAGIC;
|
||||
op.hdr.id = 1;
|
||||
op.hdr.opcode = OSD_OP_SYNC;
|
||||
write_blocking(connect_fd, op.buf, OSD_PACKET_SIZE);
|
||||
int r = read_blocking(connect_fd, reply.buf, OSD_PACKET_SIZE);
|
||||
assert(check_reply(r, op, reply, 0));
|
||||
}
|
||||
|
||||
void test_sync_stab_all(int connect_fd)
|
||||
{
|
||||
osd_any_op_t op;
|
||||
|
|
Loading…
Reference in New Issue