[CRIU] [PATCH 2/4] sfd: Rework install, clone helpers to use fcntl
Cyrill Gorcunov
gorcunov at gmail.com
Tue May 30 15:39:59 PDT 2017
On Wed, May 31, 2017 at 01:14:08AM +0300, Cyrill Gorcunov wrote:
> On Tue, May 30, 2017 at 02:47:55PM -0700, Andrey Vagin wrote:
> > > +
> > > + /*
> > > + * Cloning of service fds happen at early stage
> > > + * where no other files needed are opened, so
> > > + * for simplicity just close the destination.
> >
> > Why should we close the destination? Who could open it?
>
> Our fdt_shared test already does it :( There is a transition
> from service_fd_id = 2 to 0, where 0 already has these
> files opened. If you uncomment SDF_DEBUG on top of this
> patch and run the test you'll see.
To be precise
---
[cyrill at uranus criu] git diff
diff --git a/criu/servicefd.c b/criu/servicefd.c
index 245891b79cbc..3ad969087632 100644
--- a/criu/servicefd.c
+++ b/criu/servicefd.c
@@ -15,7 +15,7 @@
#undef LOG_PREFIX
#define LOG_PREFIX "sfd: "
-// #define SFD_DEBUG
+#define SFD_DEBUG
#ifdef SFD_DEBUG
# define pr_sfd_debug(fmt, ...) pr_debug(fmt, ##__VA_ARGS__)
@@ -168,7 +168,7 @@ int clone_service_fd(int id)
* structure should have own sfd_map and everything
* should be under appropriate shared locking.
*/
- close(new);
+ //close(new);
ret = fcntl(old, F_DUPFD, new);
if (ret < 0 || ret != new) {
if (ret < 0) {
-------------
[root at uranus 1] grep sfd restore.log
(00.000174) sfd: install 0/1048573 (PROC_FD_OFF)
(00.000391) sfd: install 0/1048569 (CR_PROC_FD_OFF)
(00.000394) sfd: install 0/1048572 (PROC_PID_FD_OFF)
(00.000432) sfd: install 0/1048562 (FDSTORE_SK_OFF)
(00.009285) 24: sfd: close 0/1048572 (PROC_PID_FD_OFF)
(00.009312) 24: sfd: install 0/1048564 (TRANSPORT_FD_OFF)
(00.009339) 24: sfd: install 0/1048573 (PROC_FD_OFF)
(00.009340) 24: sfd: close previous 0/1048573 (PROC_FD_OFF)
(00.009344) 24: sfd: close 0/1048573 (PROC_FD_OFF)
(00.009883) 24: sfd: install 0/1048568 (ROOT_FD_OFF)
(00.010066) 24: sfd: install 0/1048564 (TRANSPORT_FD_OFF)
(00.010068) 24: sfd: close previous 0/1048564 (TRANSPORT_FD_OFF)
(00.010073) 24: sfd: close 0/1048564 (TRANSPORT_FD_OFF)
(00.010312) 24: sfd: clone 0/1
(00.010314) 24: sfd: clone 0/1048575 -> 1/1048559 (LOG_FD_OFF)
(00.010318) 24: sfd: clone 0/1048574 -> 1/1048558 (IMG_FD_OFF)
(00.010319) 24: sfd: clone 0/1048573 -> 1/1048557 (PROC_FD_OFF)
(00.010321) 24: sfd: clone 0/1048569 -> 1/1048553 (CR_PROC_FD_OFF)
(00.010326) 24: sfd: clone 0/1048568 -> 1/1048552 (ROOT_FD_OFF)
(00.010328) 24: sfd: clone 0/1048564 -> 1/1048548 (TRANSPORT_FD_OFF)
(00.010329) 24: sfd: clone 0/1048562 -> 1/1048546 (FDSTORE_SK_OFF)
(00.010419) 24: sfd: clone 0/2
(00.010422) 24: sfd: clone 0/1048575 -> 2/1048543 (LOG_FD_OFF)
(00.010426) 24: sfd: clone 0/1048574 -> 2/1048542 (IMG_FD_OFF)
(00.010428) 24: sfd: clone 0/1048573 -> 2/1048541 (PROC_FD_OFF)
(00.010431) 24: sfd: clone 0/1048569 -> 2/1048537 (CR_PROC_FD_OFF)
(00.010433) 24: sfd: clone 0/1048568 -> 2/1048536 (ROOT_FD_OFF)
(00.010435) 24: sfd: clone 0/1048564 -> 2/1048532 (TRANSPORT_FD_OFF)
(00.010437) 24: sfd: clone 0/1048562 -> 2/1048530 (FDSTORE_SK_OFF)
(00.010807) 26: sfd: install 1/1048548 (TRANSPORT_FD_OFF)
(00.010809) 26: sfd: close previous 1/1048548 (TRANSPORT_FD_OFF)
(00.010812) 26: sfd: close 1/1048548 (TRANSPORT_FD_OFF)
(00.010897) 25: sfd: install 2/1048532 (TRANSPORT_FD_OFF)
(00.010899) 25: sfd: close previous 2/1048532 (TRANSPORT_FD_OFF)
(00.010900) 25: sfd: close 2/1048532 (TRANSPORT_FD_OFF)
(00.017537) 25: sfd: clone 2/0
(00.017590) 25: Error (criu/servicefd.c:176): sfd: clone 2/1048543 -> 0/1048575 (LOG_FD_OFF) transition failed: Too many open files
(00.017715) 25: sfd: clone 2/3
(00.017717) 25: sfd: clone 2/1048543 -> 3/1048527 (LOG_FD_OFF)
(00.017721) 25: sfd: clone 2/1048542 -> 3/1048526 (IMG_FD_OFF)
(00.017723) 25: sfd: clone 2/1048541 -> 3/1048525 (PROC_FD_OFF)
(00.017724) 25: sfd: clone 2/1048537 -> 3/1048521 (CR_PROC_FD_OFF)
(00.017726) 25: sfd: clone 2/1048536 -> 3/1048520 (ROOT_FD_OFF)
(00.017727) 25: sfd: clone 2/1048532 -> 3/1048516 (TRANSPORT_FD_OFF)
(00.017729) 25: sfd: clone 2/1048530 -> 3/1048514 (FDSTORE_SK_OFF)
(00.018019) 27: sfd: install 3/1048516 (TRANSPORT_FD_OFF)
(00.018021) 27: sfd: close previous 3/1048516 (TRANSPORT_FD_OFF)
(00.018023) 27: sfd: close 3/1048516 (TRANSPORT_FD_OFF)
More information about the CRIU
mailing list