[CRIU] [PATCH 2/2] fsnotify: Warn a user if queued data present

Cyrill Gorcunov gorcunov at openvz.org
Wed Feb 26 01:36:41 PST 2014


At the moment we can't restore fsnotify queued data,
so inform a user that some events are lost during
c/r procedure.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 fsnotify.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/fsnotify.c b/fsnotify.c
index a81c2420bd34..08ada24324b2 100644
--- a/fsnotify.c
+++ b/fsnotify.c
@@ -9,6 +9,7 @@
 #include <utime.h>
 #include <dirent.h>
 #include <limits.h>
+#include <poll.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/inotify.h>
@@ -97,6 +98,19 @@ static void decode_handle(fh_t *handle, FhEntry *img)
 				sizeof(handle->__handle)));
 }
 
+static bool has_queued_events(int lfd)
+{
+	struct pollfd pfd = {lfd, POLLIN, 0};
+	int ret;
+
+	ret = poll(&pfd, 1, 0);
+	if (ret < 0)
+		pr_perror("Poll request failed");
+	else if (ret == 1)
+		pr_warn("Has queued events to read\n");
+	return ret != 0;
+}
+
 static int open_handle(unsigned int s_dev, unsigned long i_ino,
 		FhEntry *f_handle)
 {
@@ -204,6 +218,10 @@ static int dump_one_inotify(int lfd, u32 id, const struct fd_parms *p)
 	ie.fown = (FownEntry *)&p->fown;
 
 	pr_info("id 0x%08x flags 0x%08x\n", ie.id, ie.flags);
+
+	if (has_queued_events(lfd) < 0)
+		return -1;
+
 	if (pb_write_one(fdset_fd(glob_fdset, CR_FD_INOTIFY_FILE), &ie, PB_INOTIFY_FILE))
 		return -1;
 
@@ -288,6 +306,9 @@ static int dump_one_fanotify(int lfd, u32 id, const struct fd_parms *p)
 
 	pr_info("id 0x%08x flags 0x%08x\n", fe.id, fe.flags);
 
+	if (has_queued_events(lfd) < 0)
+		return -1;
+
 	fe.faflags = fsn_params.faflags;
 	fe.evflags = fsn_params.evflags;
 
-- 
1.8.3.1



More information about the CRIU mailing list