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

Submitted by Pavel Emelianov on July 6, 2017, 4:16 p.m.

Details

Message ID be07f21a-ecec-acfe-6e59-7869d49f0c70@virtuozzo.com
State New
Series "Support descriptors sent over unix sockets"
Headers show

Commit Message

Pavel Emelianov July 6, 2017, 4:16 p.m.
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@virtuozzo.com>
---
 criu/files.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

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;
 }