1
0
Fork 0

Use io_uring SQ size for ringloop capacity - otherwise get_sqe could return NULL when space_left() was > 0 under load

Raise default io_uring size to 1024 for the same effective capacity as previously
csi-ext4-noatime
Vitaliy Filippov 2023-11-20 03:03:33 +03:00
parent 6b33ae973d
commit b5c020ce0b
12 changed files with 18 additions and 18 deletions

View File

@ -331,7 +331,7 @@ static int run(cli_tool_t *p, json11::Json::object cfg)
{ {
// Create client // Create client
json11::Json cfg_j = cfg; json11::Json cfg_j = cfg;
p->ringloop = new ring_loop_t(512); p->ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
p->epmgr = new epoll_manager_t(p->ringloop); p->epmgr = new epoll_manager_t(p->ringloop);
p->cli = new cluster_client_t(p->ringloop, p->epmgr->tfd, cfg_j); p->cli = new cluster_client_t(p->ringloop, p->epmgr->tfd, cfg_j);
// Smaller timeout by default for more interactiveness // Smaller timeout by default for more interactiveness

View File

@ -245,7 +245,7 @@ int disk_tool_t::resize_copy_data()
{ {
iodepth = 32; iodepth = 32;
} }
ringloop = new ring_loop_t(iodepth < 512 ? 512 : iodepth); ringloop = new ring_loop_t(iodepth < RINGLOOP_DEFAULT_SIZE ? RINGLOOP_DEFAULT_SIZE : iodepth);
dsk.data_fd = open(dsk.data_device.c_str(), O_DIRECT|O_RDWR); dsk.data_fd = open(dsk.data_device.c_str(), O_DIRECT|O_RDWR);
if (dsk.data_fd < 0) if (dsk.data_fd < 0)
{ {

View File

@ -130,7 +130,7 @@ static int bs_init(struct thread_data *td)
config[p.first] = p.second.dump(); config[p.first] = p.second.dump();
} }
} }
bsd->ringloop = new ring_loop_t(512); bsd->ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
bsd->epmgr = new epoll_manager_t(bsd->ringloop); bsd->epmgr = new epoll_manager_t(bsd->ringloop);
bsd->bs = new blockstore_t(config, bsd->ringloop, bsd->epmgr->tfd); bsd->bs = new blockstore_t(config, bsd->ringloop, bsd->epmgr->tfd);
while (1) while (1)

View File

@ -225,7 +225,7 @@ public:
cfg = obj; cfg = obj;
} }
// Create client // Create client
ringloop = new ring_loop_t(512); ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
epmgr = new epoll_manager_t(ringloop); epmgr = new epoll_manager_t(ringloop);
cli = new cluster_client_t(ringloop, epmgr->tfd, cfg); cli = new cluster_client_t(ringloop, epmgr->tfd, cfg);
if (!inode) if (!inode)

View File

@ -124,7 +124,7 @@ void nfs_proxy_t::run(json11::Json cfg)
cfg = obj; cfg = obj;
} }
// Create client // Create client
ringloop = new ring_loop_t(512); ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
epmgr = new epoll_manager_t(ringloop); epmgr = new epoll_manager_t(ringloop);
cli = new cluster_client_t(ringloop, epmgr->tfd, cfg); cli = new cluster_client_t(ringloop, epmgr->tfd, cfg);
cmd = new cli_tool_t(); cmd = new cli_tool_t();

View File

@ -58,7 +58,7 @@ int main(int narg, char *args[])
} }
signal(SIGINT, handle_sigint); signal(SIGINT, handle_sigint);
signal(SIGTERM, handle_sigint); signal(SIGTERM, handle_sigint);
ring_loop_t *ringloop = new ring_loop_t(512); ring_loop_t *ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
osd = new osd_t(config, ringloop); osd = new osd_t(config, ringloop);
while (1) while (1)
{ {

View File

@ -17,7 +17,7 @@ ring_loop_t::ring_loop_t(int qd)
{ {
throw std::runtime_error(std::string("io_uring_queue_init: ") + strerror(-ret)); throw std::runtime_error(std::string("io_uring_queue_init: ") + strerror(-ret));
} }
free_ring_data_ptr = *ring.cq.kring_entries; free_ring_data_ptr = *ring.sq.kring_entries;
ring_datas = (struct ring_data_t*)calloc(free_ring_data_ptr, sizeof(ring_data_t)); ring_datas = (struct ring_data_t*)calloc(free_ring_data_ptr, sizeof(ring_data_t));
free_ring_data = (int*)malloc(sizeof(int) * free_ring_data_ptr); free_ring_data = (int*)malloc(sizeof(int) * free_ring_data_ptr);
if (!ring_datas || !free_ring_data) if (!ring_datas || !free_ring_data)

View File

@ -15,6 +15,8 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
#define RINGLOOP_DEFAULT_SIZE 1024
static inline void my_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd, const void *addr, unsigned len, off_t offset) static inline void my_uring_prep_rw(int op, struct io_uring_sqe *sqe, int fd, const void *addr, unsigned len, off_t offset)
{ {
// Prepare a read/write operation without clearing user_data // Prepare a read/write operation without clearing user_data
@ -139,11 +141,9 @@ public:
if (free_ring_data_ptr == 0) if (free_ring_data_ptr == 0)
return NULL; return NULL;
struct io_uring_sqe* sqe = io_uring_get_sqe(&ring); struct io_uring_sqe* sqe = io_uring_get_sqe(&ring);
if (sqe) assert(sqe);
{ *sqe = { 0 };
*sqe = { 0 }; io_uring_sqe_set_data(sqe, ring_datas + free_ring_data[--free_ring_data_ptr]);
io_uring_sqe_set_data(sqe, ring_datas + free_ring_data[--free_ring_data_ptr]);
}
return sqe; return sqe;
} }
inline void set_immediate(const std::function<void()> cb) inline void set_immediate(const std::function<void()> cb)

View File

@ -30,7 +30,7 @@ void stub_exec_op(osd_messenger_t *msgr, osd_op_t *op);
int main(int narg, char *args[]) int main(int narg, char *args[])
{ {
ring_consumer_t looper; ring_consumer_t looper;
ring_loop_t *ringloop = new ring_loop_t(512); ring_loop_t *ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
epoll_manager_t *epmgr = new epoll_manager_t(ringloop); epoll_manager_t *epmgr = new epoll_manager_t(ringloop);
osd_messenger_t *msgr = new osd_messenger_t(); osd_messenger_t *msgr = new osd_messenger_t();
msgr->osd_num = 1351; msgr->osd_num = 1351;

View File

@ -11,7 +11,7 @@ int main(int narg, char *args[])
config["meta_device"] = "./test_meta.bin"; config["meta_device"] = "./test_meta.bin";
config["journal_device"] = "./test_journal.bin"; config["journal_device"] = "./test_journal.bin";
config["data_device"] = "./test_data.bin"; config["data_device"] = "./test_data.bin";
ring_loop_t *ringloop = new ring_loop_t(512); ring_loop_t *ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
epoll_manager_t *epmgr = new epoll_manager_t(ringloop); epoll_manager_t *epmgr = new epoll_manager_t(ringloop);
blockstore_t *bs = new blockstore_t(config, ringloop, epmgr->tfd); blockstore_t *bs = new blockstore_t(config, ringloop, epmgr->tfd);

View File

@ -68,7 +68,7 @@ int main(int narg, char *args[])
| cfg["inode_id"].uint64_value(); | cfg["inode_id"].uint64_value();
uint64_t base_ver = 0; uint64_t base_ver = 0;
// Create client // Create client
auto ringloop = new ring_loop_t(512); auto ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
auto epmgr = new epoll_manager_t(ringloop); auto epmgr = new epoll_manager_t(ringloop);
auto cli = new cluster_client_t(ringloop, epmgr->tfd, cfg); auto cli = new cluster_client_t(ringloop, epmgr->tfd, cfg);
cli->on_ready([&]() cli->on_ready([&]()

View File

@ -114,7 +114,7 @@ vitastor_c *vitastor_c_create_qemu_uring(QEMUSetFDHandler *aio_set_fd_handler, v
ring_loop_t *ringloop = NULL; ring_loop_t *ringloop = NULL;
try try
{ {
ringloop = new ring_loop_t(512); ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
} }
catch (std::exception & e) catch (std::exception & e)
{ {
@ -136,7 +136,7 @@ vitastor_c *vitastor_c_create_uring(const char *config_path, const char *etcd_ho
ring_loop_t *ringloop = NULL; ring_loop_t *ringloop = NULL;
try try
{ {
ringloop = new ring_loop_t(512); ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
} }
catch (std::exception & e) catch (std::exception & e)
{ {
@ -167,7 +167,7 @@ vitastor_c *vitastor_c_create_uring_json(const char **options, int options_len)
ring_loop_t *ringloop = NULL; ring_loop_t *ringloop = NULL;
try try
{ {
ringloop = new ring_loop_t(512); ringloop = new ring_loop_t(RINGLOOP_DEFAULT_SIZE);
} }
catch (std::exception & e) catch (std::exception & e)
{ {