[v2,05/14] files: Rename service_fd_rlim_cur to service_fd_base_cur

Submitted by Kirill Tkhai on Dec. 28, 2017, 1:09 p.m.

Details

Message ID 151446657067.28132.11368271465408767799.stgit@localhost.localdomain
State New
Series "Introduce custom per-task service fds placement"
Headers show

Commit Message

Kirill Tkhai Dec. 28, 2017, 1:09 p.m.
Next patches will make service fds numbers not connected
not rlimit. Change the name to better fit its goal.

Also, leave service_fd_rlim_cur variable to have cached
access to rlimit value.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

v2: More comments
---
 criu/include/util.h |    2 ++
 criu/util.c         |   11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/include/util.h b/criu/include/util.h
index c40b0c6f9..722afb77a 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -37,6 +37,8 @@ 
 struct vma_area;
 struct list_head;
 
+extern int service_fd_rlim_cur;
+
 extern void pr_vma(unsigned int loglevel, const struct vma_area *vma_area);
 
 #define pr_info_vma(vma_area)	pr_vma(LOG_INFO, vma_area)
diff --git a/criu/util.c b/criu/util.c
index 386c755a6..c08e13dfb 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -434,7 +434,11 @@  int do_open_proc(pid_t pid, int flags, const char *fmt, ...)
 	return openat(dirfd, path, flags);
 }
 
-static int service_fd_rlim_cur;
+/* Max potentially possible fd to be open by criu process */
+int service_fd_rlim_cur;
+/* Base of current process service fds set */
+static int service_fd_base;
+/* Id of current process in shared fdt */
 static int service_fd_id = 0;
 
 int init_service_fd(void)
@@ -452,14 +456,15 @@  int init_service_fd(void)
 	}
 
 	service_fd_rlim_cur = (int)rlimit.rlim_cur;
-	BUG_ON(service_fd_rlim_cur < SERVICE_FD_MAX);
+	service_fd_base = service_fd_rlim_cur;
+	BUG_ON(service_fd_base < SERVICE_FD_MAX);
 
 	return 0;
 }
 
 static int __get_service_fd(enum sfd_type type, int service_fd_id)
 {
-	return service_fd_rlim_cur - type - SERVICE_FD_MAX * service_fd_id;
+	return service_fd_base - type - SERVICE_FD_MAX * service_fd_id;
 }
 
 int service_fd_min_fd(struct pstree_item *item)