diff --git a/criu/include/kerndat.h b/criu/include/kerndat.h index c2164fa0a..d93e07813 100644 --- a/criu/include/kerndat.h +++ b/criu/include/kerndat.h @@ -62,7 +62,6 @@ struct kerndat_s { bool has_nsid; bool has_link_nsid; unsigned int sysctl_nr_open; - unsigned long files_stat_max_files; bool x86_has_ptrace_fpu_xsave_bug; bool has_inotify_setnextwd; bool has_kcmp_epoll_tfd; diff --git a/criu/kerndat.c b/criu/kerndat.c index c158d6760..39cacb8fe 100644 --- a/criu/kerndat.c +++ b/criu/kerndat.c @@ -157,19 +157,12 @@ static void kerndat_mmap_min_addr(void) (unsigned long)kdat.mmap_min_addr); } -static int kerndat_files_stat(bool early) +static int kerndat_files_stat(void) { static const uint32_t NR_OPEN_DEFAULT = 1024 * 1024; - static const uint64_t MAX_FILES_DEFAULT = 8192; - uint64_t max_files; uint32_t nr_open; struct sysctl_req req[] = { - { - .name = "fs/file-max", - .arg = &max_files, - .type = CTL_U64, - }, { .name = "fs/nr_open", .arg = &nr_open, @@ -177,50 +170,15 @@ static int kerndat_files_stat(bool early) }, }; - if (!early) { - if (sysctl_op(req, ARRAY_SIZE(req), CTL_READ, 0)) { - pr_warn("Can't fetch file_stat, using kernel defaults\n"); - nr_open = NR_OPEN_DEFAULT; - max_files = MAX_FILES_DEFAULT; - } - } else { - char buf[64]; - int fd1, fd2; - ssize_t ret; - - fd1 = open("/proc/sys/fs/file-max", O_RDONLY); - fd2 = open("/proc/sys/fs/nr_open", O_RDONLY); - + if (sysctl_op(req, ARRAY_SIZE(req), CTL_READ, 0)) { + pr_warn("Can't fetch file_stat, using kernel defaults\n"); nr_open = NR_OPEN_DEFAULT; - max_files = MAX_FILES_DEFAULT; - - if (fd1 < 0 || fd2 < 0) { - pr_warn("Can't fetch file_stat, using kernel defaults\n"); - } else { - ret = read(fd1, buf, sizeof(buf) - 1); - if (ret > 0) { - buf[ret] = '\0'; - max_files = atol(buf); - } - ret = read(fd2, buf, sizeof(buf) - 1); - if (ret > 0) { - buf[ret] = '\0'; - nr_open = atol(buf); - } - } - - if (fd1 >= 0) - close(fd1); - if (fd2 >= 0) - close(fd2); } kdat.sysctl_nr_open = nr_open; - kdat.files_stat_max_files = max_files; - pr_debug("files stat: %s %lu, %s %u\n", - req[0].name, kdat.files_stat_max_files, - req[1].name, kdat.sysctl_nr_open); + pr_debug("files stat: %s %u\n", + req[0].name, kdat.sysctl_nr_open); return 0; } @@ -1088,7 +1046,7 @@ int kerndat_init(void) kerndat_lsm(); kerndat_mmap_min_addr(); - kerndat_files_stat(false); + kerndat_files_stat(); if (!ret) kerndat_save_cache();