[v5,14/19] epoll: Save fields of target files in eventpoll_tfd_entry

Submitted by Cyrill Gorcunov on July 4, 2018, 3:51 p.m.

Details

Message ID 20180704155147.29114-15-gorcunov@gmail.com
State Accepted
Series "epoll: Add support for duped targets"
Commit 7400d9d363a3b56e3ac321f3c649d2c8cdeb2d7f
Headers show

Commit Message

Cyrill Gorcunov July 4, 2018, 3:51 p.m.
We will use them to fast lookup of targets files.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
 criu/proc_parse.c      | 20 +++++++++++++++++---
 images/eventpoll.proto |  5 +++++
 2 files changed, 22 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/proc_parse.c b/criu/proc_parse.c
index b431168ff2fa..8c52e5044733 100644
--- a/criu/proc_parse.c
+++ b/criu/proc_parse.c
@@ -1835,9 +1835,23 @@  static int parse_fdinfo_pid_s(int pid, int fd, int type, void *arg)
 
 			eventpoll_tfd_entry__init(e);
 
-			ret = sscanf(str, "tfd: %d events: %x data: %"PRIx64,
-					&e->tfd, &e->events, &e->data);
-			if (ret != 3) {
+			ret = sscanf(str, "tfd: %d events: %x data: %llx"
+				     " pos:%lli ino:%lx sdev:%x",
+					&e->tfd, &e->events, (long long *)&e->data,
+					(long long *)&e->pos, (long *)&e->inode,
+					&e->dev);
+			if (ret < 3 || ret > 6) {
+				eventpoll_tfd_entry__free_unpacked(e, NULL);
+				goto parse_err;
+			} else if (ret == 3) {
+				e->has_dev = false;
+				e->has_inode = false;
+				e->has_pos = false;
+			} else if (ret == 6) {
+				e->has_dev = true;
+				e->has_inode = true;
+				e->has_pos = true;
+			} else if (ret < 6) {
 				eventpoll_tfd_entry__free_unpacked(e, NULL);
 				goto parse_err;
 			}
diff --git a/images/eventpoll.proto b/images/eventpoll.proto
index 8901d807a577..4a8d1b834ef8 100644
--- a/images/eventpoll.proto
+++ b/images/eventpoll.proto
@@ -7,6 +7,11 @@  message eventpoll_tfd_entry {
 	required uint32		tfd	= 2;
 	required uint32		events	= 3;
 	required uint64		data	= 4;
+
+	/* to find dup'ed target files */
+	optional uint32		dev	= 5;
+	optional uint64		inode	= 6;
+	optional uint64		pos	= 7;
 }
 
 message eventpoll_file_entry {