[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 075/104] virtiofsd: Clean up inodes on destroy
From: |
Dr. David Alan Gilbert (git) |
Subject: |
[PATCH 075/104] virtiofsd: Clean up inodes on destroy |
Date: |
Thu, 12 Dec 2019 16:38:35 +0000 |
From: "Dr. David Alan Gilbert" <address@hidden>
Clear out our inodes and fd's on a 'destroy' - so we get rid
of them if we reboot the guest.
Signed-off-by: Dr. David Alan Gilbert <address@hidden>
---
tools/virtiofsd/passthrough_ll.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index bbc5f0981e..c526d6f4f6 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -1201,6 +1201,25 @@ static void unref_inode_lolocked(struct lo_data *lo,
struct lo_inode *inode,
}
}
+static int unref_all_inodes_cb(gpointer key, gpointer value, gpointer
user_data)
+{
+ struct lo_inode *inode = value;
+ struct lo_data *lo = user_data;
+
+ inode->refcount = 0;
+ lo_map_remove(&lo->ino_map, inode->fuse_ino);
+ close(inode->fd);
+
+ return TRUE;
+}
+
+static void unref_all_inodes(struct lo_data *lo)
+{
+ pthread_mutex_lock(&lo->mutex);
+ g_hash_table_foreach_remove(lo->inodes, unref_all_inodes_cb, lo);
+ pthread_mutex_unlock(&lo->mutex);
+}
+
static void lo_forget_one(fuse_req_t req, fuse_ino_t ino, uint64_t nlookup)
{
struct lo_data *lo = lo_data(req);
@@ -2066,6 +2085,12 @@ static void lo_lseek(fuse_req_t req, fuse_ino_t ino,
off_t off, int whence,
}
}
+static void lo_destroy(void *userdata)
+{
+ struct lo_data *lo = (struct lo_data *)userdata;
+ unref_all_inodes(lo);
+}
+
static struct fuse_lowlevel_ops lo_oper = {
.init = lo_init,
.lookup = lo_lookup,
@@ -2104,6 +2129,7 @@ static struct fuse_lowlevel_ops lo_oper = {
.copy_file_range = lo_copy_file_range,
#endif
.lseek = lo_lseek,
+ .destroy = lo_destroy,
};
/* Print vhost-user.json backend program capabilities */
--
2.23.0
- [PATCH 065/104] contrib/libvhost-user: Protect slave fd with mutex, (continued)
- [PATCH 065/104] contrib/libvhost-user: Protect slave fd with mutex, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 066/104] virtiofsd: passthrough_ll: add renameat2 support, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 067/104] virtiofsd: passthrough_ll: disable readdirplus on cache=never, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 068/104] virtiofsd: passthrough_ll: control readdirplus, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 069/104] virtiofsd: rename unref_inode() to unref_inode_lolocked(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 070/104] virtiofsd: fail when parent inode isn't known in lo_do_lookup(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 072/104] virtiofsd: passthrough_ll: fix refcounting on remove/rename, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 071/104] virtiofsd: extract root inode init into setup_root(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 073/104] virtiofsd: passthrough_ll: clean up cache related options, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 074/104] virtiofsd: passthrough_ll: use hashtable, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 075/104] virtiofsd: Clean up inodes on destroy,
Dr. David Alan Gilbert (git) <=
- [PATCH 076/104] virtiofsd: support nanosecond resolution for file timestamp, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 077/104] virtiofsd: fix error handling in main(), Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 078/104] virtiofsd: cleanup allocated resource in se, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 079/104] virtiofsd: fix memory leak on lo.source, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 080/104] virtiofsd: add helper for lo_data cleanup, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 081/104] virtiofsd: Prevent multiply running with same vhost_user_socket, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 082/104] virtiofsd: enable PARALLEL_DIROPS during INIT, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 084/104] Virtiofsd: fix memory leak on fuse queueinfo, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 083/104] virtiofsd: fix incorrect error handling in lo_do_lookup, Dr. David Alan Gilbert (git), 2019/12/12
- [PATCH 086/104] virtiofsd: use fuse_lowlevel_is_virtio() in fuse_session_destroy(), Dr. David Alan Gilbert (git), 2019/12/12