2019-12-15 01:11:51 +03:00
|
|
|
#include "osd.h"
|
|
|
|
|
2020-01-15 23:20:07 +03:00
|
|
|
#include <signal.h>
|
|
|
|
|
2020-04-24 16:46:02 +03:00
|
|
|
static osd_t *osd = NULL;
|
2020-04-26 01:33:50 +03:00
|
|
|
static bool force_stopping = false;
|
2020-04-24 16:46:02 +03:00
|
|
|
|
|
|
|
static void handle_sigint(int sig)
|
2020-01-15 23:20:07 +03:00
|
|
|
{
|
2020-04-26 01:33:50 +03:00
|
|
|
if (osd && !force_stopping)
|
2020-04-24 16:46:02 +03:00
|
|
|
{
|
2020-04-26 01:33:50 +03:00
|
|
|
force_stopping = true;
|
2020-04-27 14:32:59 +03:00
|
|
|
osd->force_stop(0);
|
2020-04-24 16:46:02 +03:00
|
|
|
return;
|
|
|
|
}
|
2020-01-15 23:20:07 +03:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
2019-12-15 01:11:51 +03:00
|
|
|
int main(int narg, char *args[])
|
|
|
|
{
|
2020-02-23 18:57:20 +03:00
|
|
|
if (sizeof(osd_any_op_t) > OSD_PACKET_SIZE ||
|
|
|
|
sizeof(osd_any_reply_t) > OSD_PACKET_SIZE)
|
2019-12-15 01:11:51 +03:00
|
|
|
{
|
|
|
|
perror("BUG: too small packet size");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
blockstore_config_t config;
|
2020-01-15 23:20:07 +03:00
|
|
|
for (int i = 1; i < narg; i++)
|
|
|
|
{
|
|
|
|
if (args[i][0] == '-' && args[i][1] == '-' && i < narg-1)
|
|
|
|
{
|
|
|
|
char *opt = args[i]+2;
|
|
|
|
config[opt] = args[++i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
signal(SIGINT, handle_sigint);
|
2020-04-24 16:46:02 +03:00
|
|
|
signal(SIGTERM, handle_sigint);
|
2019-12-15 01:11:51 +03:00
|
|
|
ring_loop_t *ringloop = new ring_loop_t(512);
|
2020-04-20 17:44:03 +03:00
|
|
|
// FIXME: Create Blockstore from on-disk superblock config and check it against the OSD cluster config
|
2019-12-15 14:49:10 +03:00
|
|
|
blockstore_t *bs = new blockstore_t(config, ringloop);
|
2020-04-24 16:46:02 +03:00
|
|
|
osd = new osd_t(config, bs, ringloop);
|
2019-12-15 01:11:51 +03:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
ringloop->loop();
|
|
|
|
ringloop->wait();
|
|
|
|
}
|
|
|
|
delete osd;
|
|
|
|
delete bs;
|
|
|
|
delete ringloop;
|
|
|
|
return 0;
|
|
|
|
}
|