[CRIU] [PATCH 07/16] file: Find descs by ID only

Pavel Emelyanov xemul at virtuozzo.com
Thu Jul 6 19:16:28 MSK 2017


Actually all file-s we dump have unique IDs, regardless of
their types. This fact will be used to reduce complexity
of the SCM code -- instead of keeping TYPE:ID pair it'll
save only the ID.

Siad that -- we will need the way to lookup desc by ID only.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/files.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index f5ec405..ccd4042 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -100,9 +100,13 @@ struct file_desc *find_file_desc_raw(int type, u32 id)
 	struct hlist_head *chain;
 
 	chain = &file_desc_hash[id % FDESC_HASH_SIZE];
-	hlist_for_each_entry(d, chain, hash)
-		if (d->ops->type == type && d->id == id)
+	hlist_for_each_entry(d, chain, hash) {
+		if (d->id == id) {
+			/* All descs actually have unique ID */
+			BUG_ON(type != FD_TYPES__UND && type != d->ops->type);
 			return d;
+		}
+	}
 
 	return NULL;
 }
-- 
2.1.4



More information about the CRIU mailing list