Blob Blame History Raw
From 951f8bc4db77ed71a7929c8a0a6c754a5dbb8919 Mon Sep 17 00:00:00 2001
From: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Date: Tue, 27 Apr 2021 19:08:57 -0400
Subject: [PATCH 007/120] criu/files: Don't cache fd ids for device files

Restore operation fails when we perform CR operation of multiple
independent proceses that have device files  because criu caches
the ids for the device files with same mnt_ids, inode pair. This
change ensures that even in case of a cached id found for a device, a
unique subid is generated and returned which is used for dumping.

Suggested-by: Andrei Vagin <avagin@gmail.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
---
 criu/file-ids.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/criu/file-ids.c b/criu/file-ids.c
index 1b9d68888..772bd92cf 100644
--- a/criu/file-ids.c
+++ b/criu/file-ids.c
@@ -77,8 +77,14 @@ int fd_id_generate_special(struct fd_parms *p, u32 *id)
 
 		fi = fd_id_cache_lookup(p);
 		if (fi) {
-			*id = fi->id;
-			return 0;
+			if (p->stat.st_mode & (S_IFCHR | S_IFBLK)) {
+				/* Don't cache the id for mapped devices */
+				*id = fd_tree.subid++;
+				return 1;
+			} else {
+				*id = fi->id;
+				return 0;
+			}
 		}
 	}
 
-- 
2.34.1