yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
902636
From 7a3c94e10b087c06635ef72aadb1550184dd5c58 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:01:58 +0100
902636
Subject: [PATCH 087/116] virtiofsd: add helper for lo_data cleanup
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-84-dgilbert@redhat.com>
902636
Patchwork-id: 93538
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 083/112] virtiofsd: add helper for lo_data cleanup
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: Liu Bo <bo.liu@linux.alibaba.com>
902636
902636
This offers an helper function for lo_data's cleanup.
902636
902636
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
902636
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit 18a69cbbb6a4caa7c2040c6db4a33b044a32be7e)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/passthrough_ll.c | 37 +++++++++++++++++++++----------------
902636
 1 file changed, 21 insertions(+), 16 deletions(-)
902636
902636
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
902636
index 056ebe8..e8dc5c7 100644
902636
--- a/tools/virtiofsd/passthrough_ll.c
902636
+++ b/tools/virtiofsd/passthrough_ll.c
902636
@@ -2407,6 +2407,26 @@ static gboolean lo_key_equal(gconstpointer a, gconstpointer b)
902636
     return la->ino == lb->ino && la->dev == lb->dev;
902636
 }
902636
 
902636
+static void fuse_lo_data_cleanup(struct lo_data *lo)
902636
+{
902636
+    if (lo->inodes) {
902636
+        g_hash_table_destroy(lo->inodes);
902636
+    }
902636
+    lo_map_destroy(&lo->fd_map);
902636
+    lo_map_destroy(&lo->dirp_map);
902636
+    lo_map_destroy(&lo->ino_map);
902636
+
902636
+    if (lo->proc_self_fd >= 0) {
902636
+        close(lo->proc_self_fd);
902636
+    }
902636
+
902636
+    if (lo->root.fd >= 0) {
902636
+        close(lo->root.fd);
902636
+    }
902636
+
902636
+    free(lo->source);
902636
+}
902636
+
902636
 int main(int argc, char *argv[])
902636
 {
902636
     struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
902636
@@ -2554,22 +2574,7 @@ err_out2:
902636
 err_out1:
902636
     fuse_opt_free_args(&args);
902636
 
902636
-    if (lo.inodes) {
902636
-        g_hash_table_destroy(lo.inodes);
902636
-    }
902636
-    lo_map_destroy(&lo.fd_map);
902636
-    lo_map_destroy(&lo.dirp_map);
902636
-    lo_map_destroy(&lo.ino_map);
902636
-
902636
-    if (lo.proc_self_fd >= 0) {
902636
-        close(lo.proc_self_fd);
902636
-    }
902636
-
902636
-    if (lo.root.fd >= 0) {
902636
-        close(lo.root.fd);
902636
-    }
902636
-
902636
-    free(lo.source);
902636
+    fuse_lo_data_cleanup(&lo);
902636
 
902636
     return ret ? 1 : 0;
902636
 }
902636
-- 
902636
1.8.3.1
902636