Add osd_memlock option

This commit is contained in:
Vitaliy Filippov
2022-02-02 01:40:22 +03:00
parent 20ee4ed758
commit 73ae578981
3 changed files with 22 additions and 0 deletions
+11
View File
@@ -3,6 +3,7 @@
#include <sys/socket.h>
#include <sys/poll.h>
#include <sys/mman.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
@@ -53,6 +54,16 @@ osd_t::osd_t(const json11::Json & config, ring_loop_t *ringloop)
autosync_writes = max_autosync;
}
if (this->config["osd_memlock"] == "true" || this->config["osd_memlock"] == "1" || this->config["osd_memlock"] == "yes")
{
// Lock all OSD memory if requested
if (mlockall(MCL_CURRENT|MCL_FUTURE|MCL_ONFAULT) != 0)
{
fprintf(stderr, "osd_memlock is set to true, but mlockall() failed: %s\n", strerror(errno));
exit(-1);
}
}
this->tfd->set_timer(print_stats_interval*1000, true, [this](int timer_id)
{
print_stats();