linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 6/6] f2fs: add f2fs_destroy_trace_ios to free radix tree
Date: Thu,  8 Jan 2015 10:11:01 -0800	[thread overview]
Message-ID: <1420740661-72288-6-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1420740661-72288-1-git-send-email-jaegeuk@kernel.org>

This patch removes radix tree after finishing tracing IOs.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/super.c |  1 +
 fs/f2fs/trace.c | 37 +++++++++++++++++++++++++++++++++++++
 fs/f2fs/trace.h |  2 ++
 3 files changed, 40 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index e6f035c..0e97974 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1272,6 +1272,7 @@ static void __exit exit_f2fs_fs(void)
 	destroy_node_manager_caches();
 	destroy_inodecache();
 	kset_unregister(f2fs_kset);
+	f2fs_destroy_trace_ios();
 }
 
 module_init(init_f2fs_fs)
diff --git a/fs/f2fs/trace.c b/fs/f2fs/trace.c
index 92fa38a..b3570dc 100644
--- a/fs/f2fs/trace.c
+++ b/fs/f2fs/trace.c
@@ -11,6 +11,7 @@
 #include <linux/fs.h>
 #include <linux/f2fs_fs.h>
 #include <linux/sched.h>
+#include <linux/radix-tree.h>
 
 #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);
+}
diff --git a/fs/f2fs/trace.h b/fs/f2fs/trace.h
index eb39fa0..1041dbe 100644
--- a/fs/f2fs/trace.h
+++ b/fs/f2fs/trace.h
@@ -35,10 +35,12 @@ struct last_io_info {
 extern void f2fs_trace_pid(struct page *);
 extern void f2fs_trace_ios(struct page *, struct f2fs_io_info *, int);
 extern void f2fs_build_trace_ios(void);
+extern void f2fs_destroy_trace_ios(void);
 #else
 #define f2fs_trace_pid(p)
 #define f2fs_trace_ios(p, i, n)
 #define f2fs_build_trace_ios()
+#define f2fs_destroy_trace_ios()
 
 #endif
 #endif /* __F2FS_TRACE_H__ */
-- 
2.1.1

      parent reply	other threads:[~2015-01-08 18:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-08 18:10 [PATCH 1/6] f2fs: fix wrong unlock_page call Jaegeuk Kim
2015-01-08 18:10 ` [PATCH 2/6] f2fs: support goingdown for fs shutdown Jaegeuk Kim
2015-01-08 19:54   ` Eric Sandeen
2015-01-08 20:18     ` Jaegeuk Kim
2015-01-08 20:33       ` Eric Sandeen
2015-01-08 20:54         ` Dave Chinner
2015-01-08 21:21           ` Jaegeuk Kim
2015-01-08 22:04             ` Dave Chinner
2015-01-08 22:16               ` Jaegeuk Kim
2015-01-09  1:40                 ` [PATCH 2/6 v2] " Jaegeuk Kim
2015-01-09  2:24                   ` [f2fs-dev] " Dave Chinner
2015-01-09  1:41                 ` [PATCH] xfs: use generic FS_IOC_GOINGDOWN for ioctl Jaegeuk Kim
2015-01-09  1:48                   ` [PATCH v2] " Jaegeuk Kim
2015-01-09  2:17                     ` Dave Chinner
2015-01-08 18:10 ` [PATCH 3/6] f2fs: free radix_tree_nodes used by nat_set entries Jaegeuk Kim
2015-01-08 18:10 ` [PATCH 4/6] f2fs: add nat/sit entries into status Jaegeuk Kim
2015-01-08 18:11 ` [PATCH 5/6] f2fs: add spin_lock to cover radix operations in IO tracer Jaegeuk Kim
2015-01-08 18:11 ` Jaegeuk Kim [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1420740661-72288-6-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).