|
|
1d442b |
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
|
|
|
1d442b |
Date: Mon, 27 Jan 2020 19:01:53 +0000
|
|
|
1d442b |
Subject: [PATCH] virtiofsd: Clean up inodes on destroy
|
|
|
1d442b |
MIME-Version: 1.0
|
|
|
1d442b |
Content-Type: text/plain; charset=UTF-8
|
|
|
1d442b |
Content-Transfer-Encoding: 8bit
|
|
|
1d442b |
|
|
|
1d442b |
Clear out our inodes and fd's on a 'destroy' - so we get rid
|
|
|
1d442b |
of them if we reboot the guest.
|
|
|
1d442b |
|
|
|
1d442b |
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.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 771b01eb76ff480fee984bd1d21727147cc3e702)
|
|
|
1d442b |
---
|
|
|
1d442b |
tools/virtiofsd/passthrough_ll.c | 26 ++++++++++++++++++++++++++
|
|
|
1d442b |
1 file changed, 26 insertions(+)
|
|
|
1d442b |
|
|
|
1d442b |
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
index b176a314d6..9ed77a17fd 100644
|
|
|
1d442b |
--- a/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
+++ b/tools/virtiofsd/passthrough_ll.c
|
|
|
1d442b |
@@ -1169,6 +1169,25 @@ static void unref_inode_lolocked(struct lo_data *lo, struct lo_inode *inode,
|
|
|
1d442b |
}
|
|
|
1d442b |
}
|
|
|
1d442b |
|
|
|
1d442b |
+static int unref_all_inodes_cb(gpointer key, gpointer value, gpointer user_data)
|
|
|
1d442b |
+{
|
|
|
1d442b |
+ struct lo_inode *inode = value;
|
|
|
1d442b |
+ struct lo_data *lo = user_data;
|
|
|
1d442b |
+
|
|
|
1d442b |
+ inode->refcount = 0;
|
|
|
1d442b |
+ lo_map_remove(&lo->ino_map, inode->fuse_ino);
|
|
|
1d442b |
+ close(inode->fd);
|
|
|
1d442b |
+
|
|
|
1d442b |
+ return TRUE;
|
|
|
1d442b |
+}
|
|
|
1d442b |
+
|
|
|
1d442b |
+static void unref_all_inodes(struct lo_data *lo)
|
|
|
1d442b |
+{
|
|
|
1d442b |
+ pthread_mutex_lock(&lo->mutex);
|
|
|
1d442b |
+ g_hash_table_foreach_remove(lo->inodes, unref_all_inodes_cb, lo);
|
|
|
1d442b |
+ pthread_mutex_unlock(&lo->mutex);
|
|
|
1d442b |
+}
|
|
|
1d442b |
+
|
|
|
1d442b |
static void lo_forget_one(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup)
|
|
|
1d442b |
{
|
|
|
1d442b |
struct lo_data *lo = lo_data(req);
|
|
|
1d442b |
@@ -2035,6 +2054,12 @@ static void lo_lseek(fuse_req_t req, fuse_ino_t ino, off_t off, int whence,
|
|
|
1d442b |
}
|
|
|
1d442b |
}
|
|
|
1d442b |
|
|
|
1d442b |
+static void lo_destroy(void *userdata)
|
|
|
1d442b |
+{
|
|
|
1d442b |
+ struct lo_data *lo = (struct lo_data *)userdata;
|
|
|
1d442b |
+ unref_all_inodes(lo);
|
|
|
1d442b |
+}
|
|
|
1d442b |
+
|
|
|
1d442b |
static struct fuse_lowlevel_ops lo_oper = {
|
|
|
1d442b |
.init = lo_init,
|
|
|
1d442b |
.lookup = lo_lookup,
|
|
|
1d442b |
@@ -2073,6 +2098,7 @@ static struct fuse_lowlevel_ops lo_oper = {
|
|
|
1d442b |
.copy_file_range = lo_copy_file_range,
|
|
|
1d442b |
#endif
|
|
|
1d442b |
.lseek = lo_lseek,
|
|
|
1d442b |
+ .destroy = lo_destroy,
|
|
|
1d442b |
};
|
|
|
1d442b |
|
|
|
1d442b |
/* Print vhost-user.json backend program capabilities */
|