From 546d8ab2bd809bd56543bff2c14d0503032c2526 Mon Sep 17 00:00:00 2001 From: Changpeng Liu Date: Tue, 28 Aug 2018 00:46:21 -0400 Subject: [PATCH] blobfs: cleanup file based resources when unload blobfs Change-Id: Iea3067d62cd0955c385ce6112f83ef7c793edfb2 Signed-off-by: Changpeng Liu Reviewed-on: https://review.gerrithub.io/423607 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- lib/blobfs/blobfs.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/blobfs/blobfs.c b/lib/blobfs/blobfs.c index 869c23ee0..7e1c42c45 100644 --- a/lib/blobfs/blobfs.c +++ b/lib/blobfs/blobfs.c @@ -739,6 +739,15 @@ unload_cb(void *ctx, int bserrno) struct spdk_fs_request *req = ctx; struct spdk_fs_cb_args *args = &req->args; struct spdk_filesystem *fs = args->fs; + struct spdk_file *file, *tmp; + + TAILQ_FOREACH_SAFE(file, &fs->files, tailq, tmp) { + TAILQ_REMOVE(&fs->files, file, tailq); + cache_free_buffers(file); + free(file->name); + free(file->tree); + free(file); + } pthread_mutex_lock(&g_cache_init_lock); g_fs_count--;