From 351f4fba843db3303a92897b21a3d4dff4b6c717 Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Wed, 7 Jan 2015 14:09:48 -0800 Subject: f2fs: add f2fs_destroy_trace_ios to free radix tree This patch removes radix tree after finishing tracing IOs. Signed-off-by: Jaegeuk Kim --- fs/f2fs/trace.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'fs/f2fs/trace.c') diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c index 92fa38a47e63..b3570dcca945 100644 --- a/fs/f2fs/trace.c +++ b/fs/f2fs/trace.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "f2fs.h" #include "trace.h" @@ -120,3 +121,39 @@ void f2fs_build_trace_ios(void) { spin_lock_init(&pids_lock); } + +#define PIDVEC_SIZE 128 +static unsigned int gang_lookup_pids(pid_t *results, unsigned long first_index, + unsigned int max_items) +{ + struct radix_tree_iter iter; + void **slot; + unsigned int ret = 0; + + if (unlikely(!max_items)) + return 0; + + radix_tree_for_each_slot(slot, &pids, &iter, first_index) { + results[ret] = iter.index; + if (++ret == PIDVEC_SIZE) + break; + } + return ret; +} + +void f2fs_destroy_trace_ios(void) +{ + pid_t pid[PIDVEC_SIZE]; + pid_t next_pid = 0; + unsigned int found; + + spin_lock(&pids_lock); + while ((found = gang_lookup_pids(pid, next_pid, PIDVEC_SIZE))) { + unsigned idx; + + next_pid = pid[found - 1] + 1; + for (idx = 0; idx < found; idx++) + radix_tree_delete(&pids, pid[idx]); + } + spin_unlock(&pids_lock); +} -- cgit v1.2.3-58-ga151