Blame 0089-virtiofsd-add-helper-for-lo_data-cleanup.patch

1d442b
From: Liu Bo <bo.liu@linux.alibaba.com>
1d442b
Date: Mon, 27 Jan 2020 19:01:58 +0000
1d442b
Subject: [PATCH] virtiofsd: add helper for lo_data cleanup
1d442b
MIME-Version: 1.0
1d442b
Content-Type: text/plain; charset=UTF-8
1d442b
Content-Transfer-Encoding: 8bit
1d442b
1d442b
This offers an helper function for lo_data's cleanup.
1d442b
1d442b
Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
1d442b
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit 18a69cbbb6a4caa7c2040c6db4a33b044a32be7e)
1d442b
---
1d442b
 tools/virtiofsd/passthrough_ll.c | 37 ++++++++++++++++++--------------
1d442b
 1 file changed, 21 insertions(+), 16 deletions(-)
1d442b
1d442b
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
1d442b
index 056ebe8556..e8dc5c7320 100644
1d442b
--- a/tools/virtiofsd/passthrough_ll.c
1d442b
+++ b/tools/virtiofsd/passthrough_ll.c
1d442b
@@ -2407,6 +2407,26 @@ static gboolean lo_key_equal(gconstpointer a, gconstpointer b)
1d442b
     return la->ino == lb->ino && la->dev == lb->dev;
1d442b
 }
1d442b
 
1d442b
+static void fuse_lo_data_cleanup(struct lo_data *lo)
1d442b
+{
1d442b
+    if (lo->inodes) {
1d442b
+        g_hash_table_destroy(lo->inodes);
1d442b
+    }
1d442b
+    lo_map_destroy(&lo->fd_map);
1d442b
+    lo_map_destroy(&lo->dirp_map);
1d442b
+    lo_map_destroy(&lo->ino_map);
1d442b
+
1d442b
+    if (lo->proc_self_fd >= 0) {
1d442b
+        close(lo->proc_self_fd);
1d442b
+    }
1d442b
+
1d442b
+    if (lo->root.fd >= 0) {
1d442b
+        close(lo->root.fd);
1d442b
+    }
1d442b
+
1d442b
+    free(lo->source);
1d442b
+}
1d442b
+
1d442b
 int main(int argc, char *argv[])
1d442b
 {
1d442b
     struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
1d442b
@@ -2554,22 +2574,7 @@ err_out2:
1d442b
 err_out1:
1d442b
     fuse_opt_free_args(&args);
1d442b
 
1d442b
-    if (lo.inodes) {
1d442b
-        g_hash_table_destroy(lo.inodes);
1d442b
-    }
1d442b
-    lo_map_destroy(&lo.fd_map);
1d442b
-    lo_map_destroy(&lo.dirp_map);
1d442b
-    lo_map_destroy(&lo.ino_map);
1d442b
-
1d442b
-    if (lo.proc_self_fd >= 0) {
1d442b
-        close(lo.proc_self_fd);
1d442b
-    }
1d442b
-
1d442b
-    if (lo.root.fd >= 0) {
1d442b
-        close(lo.root.fd);
1d442b
-    }
1d442b
-
1d442b
-    free(lo.source);
1d442b
+    fuse_lo_data_cleanup(&lo);
1d442b
 
1d442b
     return ret ? 1 : 0;
1d442b
 }