[ltt-dev] [PATCH 1/3] Remove old per-type filter

Zhaolei zhaolei at cn.fujitsu.com
Sun Mar 29 04:42:44 EDT 2009


We remove old filter because we'll use new in-kernel filter instead.

Signed-off-by: Zhao Lei <zhaolei at cn.fujitsu.com>
---
 include/linux/ltt-tracer.h |    2 -
 ltt/Kconfig                |    4 -
 ltt/Makefile               |    1 -
 ltt/ltt-filter.c           |   66 ---------
 ltt/probes/ext4-trace.c    |  339 --------------------------------------------
 ltt/probes/jbd2-trace.c    |  168 ----------------------
 6 files changed, 0 insertions(+), 580 deletions(-)
 delete mode 100644 ltt/ltt-filter.c

diff --git a/include/linux/ltt-tracer.h b/include/linux/ltt-tracer.h
index 29ae8cf..f3e91f5 100644
--- a/include/linux/ltt-tracer.h
+++ b/include/linux/ltt-tracer.h
@@ -632,8 +632,6 @@ enum ltt_filter_control_msg {
 extern int ltt_filter_control(enum ltt_filter_control_msg msg,
 		const char *trace_name);
 
-extern struct dentry *get_filter_root(void);
-
 extern void ltt_buffer_destroy(struct ltt_channel_struct *ltt_chan);
 
 void ltt_core_register(int (*function)(u8, void *));
diff --git a/ltt/Kconfig b/ltt/Kconfig
index 7e59a87..3c520f5 100644
--- a/ltt/Kconfig
+++ b/ltt/Kconfig
@@ -28,9 +28,6 @@ menuconfig LTT
 
 if LTT
 
-config LTT_FILTER
-	tristate
-
 config HAVE_LTT_DUMP_TABLES
 	def_bool n
 
@@ -97,7 +94,6 @@ config LTT_TRACEPROBES
 	depends on LTT_FAST_SERIALIZE
 	depends on LTT_SERIALIZE
 	default m
-	select LTT_FILTER
 	help
 	  Compile lttng tracing probes, which connect to the tracepoints when
 	  loaded and format the information collected by the tracepoints with
diff --git a/ltt/Makefile b/ltt/Makefile
index 3f59d70..5ea5cca 100644
--- a/ltt/Makefile
+++ b/ltt/Makefile
@@ -15,7 +15,6 @@ obj-$(CONFIG_LTT_STATEDUMP)		+= ltt-statedump.o
 obj-$(CONFIG_LTT_FAST_SERIALIZE)	+= ltt-type-serializer.o
 obj-$(CONFIG_LTT_TRACE_CONTROL)		+= ltt-trace-control.o
 obj-$(CONFIG_LTT_USERSPACE_EVENT)	+= ltt-userspace-event.o
-obj-$(CONFIG_LTT_FILTER)		+= ltt-filter.o
 obj-$(CONFIG_LTT_KPROBES)		+= ltt-kprobes.o
 obj-$(CONFIG_LTT_TRACEPROBES)		+= probes/
 obj-$(CONFIG_LTT_FTRACE)		+= ltt-ftrace.o
diff --git a/ltt/ltt-filter.c b/ltt/ltt-filter.c
deleted file mode 100644
index 92b062e..0000000
--- a/ltt/ltt-filter.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2008 Mathieu Desnoyers
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <linux/module.h>
-#include <linux/debugfs.h>
-#include <linux/fs.h>
-#include <linux/ltt-tracer.h>
-#include <linux/mutex.h>
-
-#define LTT_FILTER_DIR	"filter"
-
-/*
- * Protects the ltt_filter_dir allocation.
- */
-static DEFINE_MUTEX(ltt_filter_mutex);
-
-static struct dentry *ltt_filter_dir;
-
-struct dentry *get_filter_root(void)
-{
-	struct dentry *ltt_root_dentry;
-
-	mutex_lock(&ltt_filter_mutex);
-	if (!ltt_filter_dir) {
-		ltt_root_dentry = get_ltt_root();
-		if (!ltt_root_dentry)
-			goto err_no_root;
-
-		ltt_filter_dir = debugfs_create_dir(LTT_FILTER_DIR,
-						    ltt_root_dentry);
-		if (!ltt_filter_dir)
-			printk(KERN_ERR
-				"ltt_filter_init: failed to create dir %s\n",
-				LTT_FILTER_DIR);
-	}
-err_no_root:
-	mutex_unlock(&ltt_filter_mutex);
-	return ltt_filter_dir;
-}
-EXPORT_SYMBOL_GPL(get_filter_root);
-
-static void __exit ltt_filter_exit(void)
-{
-	debugfs_remove(ltt_filter_dir);
-}
-
-module_exit(ltt_filter_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Mathieu Desnoyers <mathieu.desnoyers at polymtl.ca>");
-MODULE_DESCRIPTION("Linux Trace Toolkit Filter");
diff --git a/ltt/probes/ext4-trace.c b/ltt/probes/ext4-trace.c
index 671067e..545fdc2 100644
--- a/ltt/probes/ext4-trace.c
+++ b/ltt/probes/ext4-trace.c
@@ -6,68 +6,12 @@
 
 #include <linux/module.h>
 #include <linux/writeback.h>
-#include <linux/ltt-tracer.h>
-#include <linux/debugfs.h>
-#include <linux/mutex.h>
-#include <linux/rcupdate.h>
 #include <trace/ext4.h>
 
 #include "../../fs/ext4/mballoc.h"
 
-static struct dentry *ext4_filter_dentry, *ext4_filter_dev_dentry,
-	*ext4_filter_inode_dentry;
-static DEFINE_MUTEX(ext4_filter_mutex);
-/* Make sure we don't race between module exit and file write */
-static int module_exits;
-
-struct rcu_dev_filter {
-	struct rcu_head rcu;
-	char devname[NAME_MAX];
-};
-
-static struct rcu_dev_filter *dev_filter;
-/* ~0UL inode_filter enables all inodes */
-static unsigned long inode_filter = ~0UL;
-
-/*
- * Probes are executed in rcu_sched read-side critical section.
- */
-
-static int do_dev_filter(const char *dev)
-{
-	struct rcu_dev_filter *ldev_filter = rcu_dereference(dev_filter);
-
-	if (unlikely(ldev_filter))
-		if (unlikely(strcmp(ldev_filter->devname, dev)))
-			return 0;
-	return 1;
-}
-
-static int do_inode_filter(unsigned long ino)
-{
-	if (unlikely(inode_filter != ~0UL))
-		if (unlikely(inode_filter != ino))
-			return 0;
-	return 1;
-}
-
-/*
- * Logical AND between dev and inode filter.
- */
-static int do_filter(const char *dev, unsigned long ino)
-{
-	if (unlikely(!do_dev_filter(dev)))
-		return 0;
-	if (unlikely(!do_inode_filter(ino)))
-		return 0;
-	return 1;
-}
-
-
 void probe_ext4_free_inode(struct inode *inode)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, free_inode, ext4_free_inode,
 		probe_ext4_free_inode,
 		"dev %s ino %lu mode %d uid %lu gid %lu blocks %llu",
@@ -78,8 +22,6 @@ void probe_ext4_free_inode(struct inode *inode)
 
 void probe_ext4_request_inode(struct inode *dir, int mode)
 {
-	if (unlikely(!do_filter(dir->i_sb->s_id, dir->i_ino)))
-		return;
 	trace_mark_tp(ext4, request_inode, ext4_request_inode,
 		probe_ext4_request_inode,
 		"dev %s dir %lu mode %d",
@@ -88,9 +30,6 @@ void probe_ext4_request_inode(struct inode *dir, int mode)
 
 void probe_ext4_allocate_inode(struct inode *inode, struct inode *dir, int mode)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)
-		     && !do_filter(dir->i_sb->s_id, dir->i_ino)))
-		return;
 	trace_mark_tp(ext4, allocate_inode, ext4_allocate_inode,
 		probe_ext4_allocate_inode,
 		"dev %s ino %lu dir %lu mode %d",
@@ -100,8 +39,6 @@ void probe_ext4_allocate_inode(struct inode *inode, struct inode *dir, int mode)
 void probe_ext4_write_begin(struct inode *inode, loff_t pos, unsigned int len,
 			    unsigned int flags)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, write_begin, ext4_write_begin,
 		probe_ext4_write_begin,
 		"dev %s ino %lu pos %llu len %u flags %u",
@@ -112,8 +49,6 @@ void probe_ext4_write_begin(struct inode *inode, loff_t pos, unsigned int len,
 void probe_ext4_ordered_write_end(struct inode *inode, loff_t pos,
 			    unsigned int len, unsigned int copied)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, ordered_write_end, ext4_ordered_write_end,
 		probe_ext4_ordered_write_end,
 		"dev %s ino %lu pos %llu len %u copied %u",
@@ -124,8 +59,6 @@ void probe_ext4_ordered_write_end(struct inode *inode, loff_t pos,
 void probe_ext4_writeback_write_end(struct inode *inode, loff_t pos,
 			    unsigned int len, unsigned int copied)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, writeback_write_end, ext4_writeback_write_end,
 		probe_ext4_writeback_write_end,
 		"dev %s ino %lu pos %llu len %u copied %u",
@@ -136,8 +69,6 @@ void probe_ext4_writeback_write_end(struct inode *inode, loff_t pos,
 void probe_ext4_journalled_write_end(struct inode *inode, loff_t pos,
 			    unsigned int len, unsigned int copied)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, journalled_write_end, ext4_journalled_write_end,
 		probe_ext4_journalled_write_end,
 		"dev %s ino %lu pos %llu len %u copied %u",
@@ -147,8 +78,6 @@ void probe_ext4_journalled_write_end(struct inode *inode, loff_t pos,
 
 void probe_ext4_da_writepage(struct inode *inode, struct page *page)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, da_writepage, ext4_da_writepage,
 		probe_ext4_da_writepage,
 		"dev %s ino %lu page_index %lu",
@@ -162,8 +91,6 @@ void probe_ext4_da_writepage(struct inode *inode, struct page *page)
 void probe_ext4_da_writepages(struct inode *inode,
 			      struct writeback_control *wbc)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, da_writepages, ext4_da_writepages,
 		probe_ext4_da_writepages,
 		"dev %s ino %lu nr_to_write %ld "
@@ -189,8 +116,6 @@ void probe_ext4_da_writepages_result(struct inode *inode,
 				     struct writeback_control *wbc,
 				     int ret, int pages_written)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, da_writepages_result, ext4_da_writepages_result,
 		probe_ext4_da_writepages_result,
 		"dev %s ino %lu ret %d pages_written %d "
@@ -207,8 +132,6 @@ void probe_ext4_da_writepages_result(struct inode *inode,
 void probe_ext4_da_write_begin(struct inode *inode, loff_t pos,
 			    unsigned int len, unsigned int flags)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, da_write_begin, ext4_da_write_begin,
 		probe_ext4_da_write_begin,
 		"dev %s ino %lu pos %llu len %u flags %u",
@@ -219,8 +142,6 @@ void probe_ext4_da_write_begin(struct inode *inode, loff_t pos,
 void probe_ext4_da_write_end(struct inode *inode, loff_t pos,
 			    unsigned int len, unsigned int copied)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, da_write_end, ext4_da_write_end,
 		probe_ext4_da_write_end,
 		"dev %s ino %lu pos %llu len %u copied %u",
@@ -230,8 +151,6 @@ void probe_ext4_da_write_end(struct inode *inode, loff_t pos,
 
 void probe_ext4_normal_writepage(struct inode *inode, struct page *page)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, normal_writepage, ext4_normal_writepage,
 		probe_ext4_normal_writepage,
 		"dev %s ino %lu page_index %lu",
@@ -240,8 +159,6 @@ void probe_ext4_normal_writepage(struct inode *inode, struct page *page)
 
 void probe_ext4_journalled_writepage(struct inode *inode, struct page *page)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, journalled_writepage, ext4_journalled_writepage,
 		probe_ext4_journalled_writepage,
 		"dev %s ino %lu page_index %lu",
@@ -251,8 +168,6 @@ void probe_ext4_journalled_writepage(struct inode *inode, struct page *page)
 void probe_ext4_discard_blocks(struct super_block *sb, unsigned long long blk,
 			       struct ext4_free_data *entry)
 {
-	if (unlikely(!do_dev_filter(sb->s_id)))
-		return;
 	trace_mark_tp(ext4, discard_blocks, ext4_discard_blocks,
 		probe_ext4_discard_blocks,
 		"dev %s blk %llu count %u",
@@ -262,8 +177,6 @@ void probe_ext4_discard_blocks(struct super_block *sb, unsigned long long blk,
 void probe_ext4_mb_new_inode_pa(struct ext4_allocation_context *ac,
 			        struct ext4_prealloc_space *pa)
 {
-	if (unlikely(!do_filter(ac->ac_sb->s_id, ac->ac_inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, mb_new_inode_pa, ext4_mb_new_inode_pa,
 		probe_ext4_mb_new_inode_pa,
 		"dev %s ino %lu pstart %llu len %u lstart %u",
@@ -274,8 +187,6 @@ void probe_ext4_mb_new_inode_pa(struct ext4_allocation_context *ac,
 void probe_ext4_mb_new_group_pa(struct ext4_allocation_context *ac,
 			        struct ext4_prealloc_space *pa)
 {
-	if (unlikely(!do_dev_filter(ac->ac_sb->s_id)))
-		return;
 	trace_mark_tp(ext4, mb_new_group_pa, ext4_mb_new_group_pa,
 		probe_ext4_mb_new_group_pa,
 		"dev %s pstart %llu len %u lstart %u",
@@ -288,8 +199,6 @@ void probe_ext4_mb_release_inode_pa(struct ext4_allocation_context *ac,
 				    unsigned long long block,
 				    unsigned int count)
 {
-	if (unlikely(!do_filter(ac->ac_sb->s_id, ac->ac_inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, mb_release_inode_pa, ext4_mb_release_inode_pa,
 		probe_ext4_mb_release_inode_pa,
 		"dev %s ino %lu block %llu count %u",
@@ -299,8 +208,6 @@ void probe_ext4_mb_release_inode_pa(struct ext4_allocation_context *ac,
 void probe_ext4_mb_release_group_pa(struct ext4_allocation_context *ac,
 				    struct ext4_prealloc_space *pa)
 {
-	if (unlikely(!do_dev_filter(ac->ac_sb->s_id)))
-		return;
 	trace_mark_tp(ext4, mb_release_group_pa, ext4_mb_release_group_pa,
 		probe_ext4_mb_release_group_pa,
 		"dev %s pstart %llu len %d",
@@ -309,8 +216,6 @@ void probe_ext4_mb_release_group_pa(struct ext4_allocation_context *ac,
 
 void probe_ext4_discard_preallocations(struct inode *inode)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, discard_preallocations,
 		ext4_discard_preallocations,
 		probe_ext4_discard_preallocations,
@@ -320,8 +225,6 @@ void probe_ext4_discard_preallocations(struct inode *inode)
 
 void probe_ext4_mb_discard_preallocations(struct super_block *sb, int needed)
 {
-	if (unlikely(!do_dev_filter(sb->s_id)))
-		return;
 	trace_mark_tp(ext4, mb_discard_preallocations,
 		ext4_mb_discard_preallocations,
 		probe_ext4_mb_discard_preallocations,
@@ -331,14 +234,6 @@ void probe_ext4_mb_discard_preallocations(struct super_block *sb, int needed)
 
 void probe_ext4_request_blocks(struct ext4_allocation_request *ar)
 {
-	if (ar->inode) {
-		if (unlikely(!do_filter(ar->inode->i_sb->s_id,
-					ar->inode->i_ino)))
-			return;
-	} else {
-		if (unlikely(!do_dev_filter(ar->inode->i_sb->s_id)))
-			return;
-	}
 	trace_mark_tp(ext4, request_blocks, ext4_request_blocks,
 		probe_ext4_request_blocks,
 		"dev %s flags %u len %u ino %lu "
@@ -357,14 +252,6 @@ void probe_ext4_request_blocks(struct ext4_allocation_request *ar)
 void probe_ext4_allocate_blocks(struct ext4_allocation_request *ar,
 				unsigned long long block)
 {
-	if (ar->inode) {
-		if (unlikely(!do_filter(ar->inode->i_sb->s_id,
-					ar->inode->i_ino)))
-			return;
-	} else {
-		if (unlikely(!do_dev_filter(ar->inode->i_sb->s_id)))
-			return;
-	}
 	trace_mark_tp(ext4, allocate_blocks, ext4_allocate_blocks,
 		probe_ext4_allocate_blocks,
 		"dev %s block %llu flags %u len %u ino %lu "
@@ -383,8 +270,6 @@ void probe_ext4_allocate_blocks(struct ext4_allocation_request *ar,
 void probe_ext4_free_blocks(struct inode *inode, unsigned long block,
 			    unsigned long count, int metadata)
 {
-	if (unlikely(!do_filter(inode->i_sb->s_id, inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, free_blocks, ext4_free_blocks,
 		probe_ext4_free_blocks,
 		"dev %s block %lu count %lu metadata %d ino %lu",
@@ -394,11 +279,6 @@ void probe_ext4_free_blocks(struct inode *inode, unsigned long block,
 void probe_ext4_sync_file(struct file *file, struct dentry *dentry,
 			  int datasync)
 {
-	if (unlikely(!do_dev_filter(dentry->d_inode->i_sb->s_id)))
-		return;
-	if (unlikely(!do_inode_filter(dentry->d_inode->i_ino)
-			&& !do_inode_filter(dentry->d_parent->d_inode->i_ino)))
-		return;
 	trace_mark_tp(ext4, sync_file, ext4_sync_file,
 		probe_ext4_sync_file,
 		"dev %s datasync %d ino %ld parent %ld",
@@ -408,231 +288,12 @@ void probe_ext4_sync_file(struct file *file, struct dentry *dentry,
 
 void probe_ext4_sync_fs(struct super_block *sb, int wait)
 {
-	if (unlikely(!do_dev_filter(sb->s_id)))
-		return;
 	trace_mark_tp(ext4, sync_fs, ext4_sync_fs,
 		probe_ext4_sync_fs,
 		"dev %s wait %d",
 		sb->s_id, wait);
 }
 
-static void free_dev_filter(struct rcu_head *head)
-{
-	kfree(container_of(head, struct rcu_dev_filter, rcu));
-}
-
-static ssize_t dev_filter_op_write(struct file *file,
-	const char __user *user_buf, size_t count, loff_t *ppos)
-{
-	int err = 0;
-	char buf[NAME_MAX];
-	int buf_size;
-	char name[NAME_MAX];
-	struct rcu_dev_filter *new, *old;
-
-	mutex_lock(&ext4_filter_mutex);
-	if (module_exits) {
-		err = -EPERM;
-		goto error;
-	}
-	buf_size = min(count, sizeof(buf) - 1);
-	err = copy_from_user(buf, user_buf, buf_size);
-	if (err)
-		goto error;
-	buf[buf_size] = 0;
-
-	if (sscanf(buf, "%s", name) != 1) {
-		err = -EPERM;
-		goto error;
-	}
-
-	old = dev_filter;
-
-	/* Empty string or * means all active */
-	if (name[0] == '\0' || (name[0] == '*' && name[1] == '\0')) {
-		new = NULL;
-	} else {
-		new = kmalloc(sizeof(*new), GFP_KERNEL);
-		strcpy(new->devname, name);
-	}
-
-	rcu_assign_pointer(dev_filter, new);
-	if (old)
-		call_rcu_sched(&old->rcu, free_dev_filter);
-
-	mutex_unlock(&ext4_filter_mutex);
-	return count;
-
-error:
-	mutex_unlock(&ext4_filter_mutex);
-	return err;
-}
-
-static ssize_t dev_filter_op_read(struct file *filp, char __user *buffer,
-	size_t count, loff_t *ppos)
-{
-	ssize_t bcount;
-	const char *devname;
-
-	mutex_lock(&ext4_filter_mutex);
-	if (!dev_filter)
-		devname = "*";
-	else
-		devname = dev_filter->devname;
-	bcount = simple_read_from_buffer(buffer, count, ppos,
-			devname, strlen(devname));
-	mutex_unlock(&ext4_filter_mutex);
-	return bcount;
-}
-
-static struct file_operations ext4_dev_file_operations = {
-	.write = dev_filter_op_write,
-	.read = dev_filter_op_read,
-};
-
-static ssize_t inode_filter_op_write(struct file *file,
-	const char __user *user_buf, size_t count, loff_t *ppos)
-{
-	int err = 0;
-	char buf[NAME_MAX];
-	int buf_size;
-	char name[NAME_MAX];
-	unsigned long inode_num;
-
-	mutex_lock(&ext4_filter_mutex);
-	if (module_exits) {
-		err = -EPERM;
-		goto error;
-	}
-	buf_size = min(count, sizeof(buf) - 1);
-	err = copy_from_user(buf, user_buf, buf_size);
-	if (err)
-		goto error;
-	buf[buf_size] = 0;
-
-	if (sscanf(buf, "%s", name) != 1) {
-		err = -EPERM;
-		goto error;
-	}
-
-	/* Empty string or * means all active */
-	if (name[0] == '\0' || (name[0] == '*' && name[1] == '\0')) {
-		inode_filter = ~0UL;
-	} else {
-		if (sscanf(buf, "%lu", &inode_num) != 1) {
-			err = -EPERM;
-			goto error;
-		}
-		inode_filter = inode_num;
-	}
-
-	mutex_unlock(&ext4_filter_mutex);
-	return count;
-
-error:
-	mutex_unlock(&ext4_filter_mutex);
-	return err;
-}
-
-static ssize_t inode_filter_op_read(struct file *filp, char __user *buffer,
-	size_t count, loff_t *ppos)
-{
-	ssize_t bcount;
-	char inode_str[NAME_MAX];
-
-	mutex_lock(&ext4_filter_mutex);
-	if (inode_filter == ~0UL)
-		strcpy(inode_str, "*");
-	else {
-		bcount = snprintf(inode_str, sizeof(inode_str), "%lu",
-			       inode_filter);
-		if (bcount == sizeof(inode_str))
-			bcount = -ENOSPC;
-		if (bcount < 0)
-			goto end;
-	}
-	bcount = simple_read_from_buffer(buffer, count, ppos,
-			inode_str, strlen(inode_str));
-end:
-	mutex_unlock(&ext4_filter_mutex);
-	return bcount;
-}
-
-static struct file_operations ext4_inode_file_operations = {
-	.write = inode_filter_op_write,
-	.read = inode_filter_op_read,
-};
-
-static void release_filter_dev(void)
-{
-	struct rcu_dev_filter *old;
-
-	mutex_lock(&ext4_filter_mutex);
-	module_exits = 1;
-	old = dev_filter;
-	rcu_assign_pointer(dev_filter, NULL);
-	if (old)
-		call_rcu_sched(&old->rcu, free_dev_filter);
-	mutex_unlock(&ext4_filter_mutex);
-}
-
-static int __init filter_init(void)
-{
-	struct dentry *filter_root_dentry;
-	int err = 0;
-
-	filter_root_dentry = get_filter_root();
-	if (!filter_root_dentry) {
-		err = -ENOENT;
-		goto end;
-	}
-
-	ext4_filter_dentry = debugfs_create_dir("ext4", filter_root_dentry);
-
-	if (IS_ERR(ext4_filter_dentry) || !ext4_filter_dentry) {
-		printk(KERN_ERR "Failed to create ext4 filter file\n");
-		err = -ENOMEM;
-		goto end;
-	}
-
-	ext4_filter_dev_dentry = debugfs_create_file("dev", S_IWUSR,
-			ext4_filter_dentry, NULL, &ext4_dev_file_operations);
-	if (IS_ERR(ext4_filter_dev_dentry) || !ext4_filter_dev_dentry) {
-		printk(KERN_ERR "Failed to create ext4 dev filter file\n");
-		err = -ENOMEM;
-		goto release_filter_dentry;
-	}
-
-	ext4_filter_inode_dentry = debugfs_create_file("inode", S_IWUSR,
-			ext4_filter_dentry, NULL, &ext4_inode_file_operations);
-	if (IS_ERR(ext4_filter_inode_dentry) || !ext4_filter_inode_dentry) {
-		printk(KERN_ERR "Failed to create ext4 inode filter file\n");
-		err = -ENOMEM;
-		goto release_filter_dev_dentry;
-	}
-
-	goto end;
-
-release_filter_dev_dentry:
-	debugfs_remove(ext4_filter_dev_dentry);
-release_filter_dentry:
-	debugfs_remove(ext4_filter_dentry);
-	release_filter_dev();
-end:
-	return err;
-}
-
-static void __exit filter_exit(void)
-{
-	debugfs_remove(ext4_filter_dev_dentry);
-	debugfs_remove(ext4_filter_inode_dentry);
-	debugfs_remove(ext4_filter_dentry);
-	release_filter_dev();
-}
-
-module_init(filter_init);
-module_exit(filter_exit);
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mathieu Desnoyers");
 MODULE_DESCRIPTION("ext4 Tracepoint Probes");
diff --git a/ltt/probes/jbd2-trace.c b/ltt/probes/jbd2-trace.c
index 22b851e..b5ce5de 100644
--- a/ltt/probes/jbd2-trace.c
+++ b/ltt/probes/jbd2-trace.c
@@ -5,41 +5,10 @@
  */
 
 #include <linux/module.h>
-#include <linux/ltt-tracer.h>
-#include <linux/debugfs.h>
-#include <linux/mutex.h>
-#include <linux/rcupdate.h>
 #include <trace/jbd2.h>
 
-static struct dentry *jbd2_filter_dentry, *jbd2_filter_dev_dentry;
-static DEFINE_MUTEX(jbd2_filter_mutex);
-/* Make sure we don't race between module exit and file write */
-static int module_exits;
-
-struct rcu_dev_filter {
-	struct rcu_head rcu;
-	char devname[NAME_MAX];
-};
-
-static struct rcu_dev_filter *dev_filter;
-
-/*
- * Probes are executed in rcu_sched read-side critical section.
- */
-static int do_filter(const char *dev)
-{
-	struct rcu_dev_filter *ldev_filter = rcu_dereference(dev_filter);
-
-	if (unlikely(ldev_filter))
-		if (unlikely(strcmp(ldev_filter->devname, dev)))
-			return 0;
-	return 1;
-}
-
 void probe_jbd2_checkpoint(journal_t *journal, int result)
 {
-	if (unlikely(!do_filter(journal->j_devname)))
-		return;
 	trace_mark_tp(jbd2, checkpoint, jbd2_checkpoint,
 		probe_jbd2_checkpoint, "dev %s need_checkpoint %d",
 		journal->j_devname, result);
@@ -48,8 +17,6 @@ void probe_jbd2_checkpoint(journal_t *journal, int result)
 void probe_jbd2_start_commit(journal_t *journal,
 			     transaction_t *commit_transaction)
 {
-	if (unlikely(!do_filter(journal->j_devname)))
-		return;
 	trace_mark_tp(jbd2, start_commit, jbd2_start_commit,
 		probe_jbd2_start_commit, "dev %s transaction %d",
 		journal->j_devname, commit_transaction->t_tid);
@@ -58,147 +25,12 @@ void probe_jbd2_start_commit(journal_t *journal,
 void probe_jbd2_end_commit(journal_t *journal,
 			   transaction_t *commit_transaction)
 {
-	if (unlikely(!do_filter(journal->j_devname)))
-		return;
 	trace_mark_tp(jbd2, end_commit, jbd2_end_commit,
 		probe_jbd2_end_commit, "dev %s transaction %d head %d",
 		journal->j_devname, commit_transaction->t_tid,
 		journal->j_tail_sequence);
 }
 
-static void free_dev_filter(struct rcu_head *head)
-{
-	kfree(container_of(head, struct rcu_dev_filter, rcu));
-}
-
-static ssize_t filter_op_write(struct file *file,
-	const char __user *user_buf, size_t count, loff_t *ppos)
-{
-	int err = 0;
-	char buf[NAME_MAX];
-	int buf_size;
-	char name[NAME_MAX];
-	struct rcu_dev_filter *new, *old;
-
-	mutex_lock(&jbd2_filter_mutex);
-	if (module_exits) {
-		err = -EPERM;
-		goto error;
-	}
-	buf_size = min(count, sizeof(buf) - 1);
-	err = copy_from_user(buf, user_buf, buf_size);
-	if (err)
-		goto error;
-	buf[buf_size] = 0;
-
-	if (sscanf(buf, "%s", name) != 1) {
-		err = -EPERM;
-		goto error;
-	}
-
-	old = dev_filter;
-
-	/* Empty string or * means all active */
-	if (name[0] == '\0' || (name[0] == '*' && name[1] == '\0')) {
-		new = NULL;
-	} else {
-		new = kmalloc(sizeof(*new), GFP_KERNEL);
-		strcpy(new->devname, name);
-	}
-
-	rcu_assign_pointer(dev_filter, new);
-	if (old)
-		call_rcu_sched(&old->rcu, free_dev_filter);
-
-	mutex_unlock(&jbd2_filter_mutex);
-	return count;
-
-error:
-	mutex_unlock(&jbd2_filter_mutex);
-	return err;
-}
-
-static ssize_t filter_op_read(struct file *filp, char __user *buffer,
-	size_t count, loff_t *ppos)
-{
-	ssize_t bcount;
-	const char *devname;
-
-	mutex_lock(&jbd2_filter_mutex);
-	if (!dev_filter)
-		devname = "*";
-	else
-		devname = dev_filter->devname;
-	bcount = simple_read_from_buffer(buffer, count, ppos,
-			devname, strlen(devname));
-	mutex_unlock(&jbd2_filter_mutex);
-	return bcount;
-}
-
-static struct file_operations jbd2_file_operations = {
-	.write = filter_op_write,
-	.read = filter_op_read,
-};
-
-static void release_filter_dev(void)
-{
-	struct rcu_dev_filter *old;
-
-	mutex_lock(&jbd2_filter_mutex);
-	module_exits = 1;
-	old = dev_filter;
-	rcu_assign_pointer(dev_filter, NULL);
-	if (old)
-		call_rcu_sched(&old->rcu, free_dev_filter);
-	mutex_unlock(&jbd2_filter_mutex);
-}
-
-static int __init filter_init(void)
-{
-	struct dentry *filter_root_dentry;
-	int err = 0;
-
-	filter_root_dentry = get_filter_root();
-	if (!filter_root_dentry) {
-		err = -ENOENT;
-		goto end;
-	}
-
-	jbd2_filter_dentry = debugfs_create_dir("jbd2", filter_root_dentry);
-
-	if (IS_ERR(jbd2_filter_dentry) || !jbd2_filter_dentry) {
-		printk(KERN_ERR "Failed to create jbd2 filter file\n");
-		err = -ENOMEM;
-		goto end;
-	}
-
-	jbd2_filter_dev_dentry = debugfs_create_file("dev", S_IWUSR,
-			jbd2_filter_dentry, NULL, &jbd2_file_operations);
-	if (IS_ERR(jbd2_filter_dentry) || !jbd2_filter_dentry) {
-		printk(KERN_ERR "Failed to create jbd2 filter file\n");
-		err = -ENOMEM;
-		goto release_filter_dentry;
-	}
-
-	goto end;
-
-release_filter_dentry:
-	debugfs_remove(jbd2_filter_dentry);
-	release_filter_dev();
-end:
-	return err;
-}
-
-static void __exit filter_exit(void)
-{
-	debugfs_remove(jbd2_filter_dev_dentry);
-	debugfs_remove(jbd2_filter_dentry);
-	release_filter_dev();
-}
-
-module_init(filter_init);
-module_exit(filter_exit);
-
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mathieu Desnoyers");
 MODULE_DESCRIPTION("JBD2 Tracepoint Probes");
-- 
1.5.5.3






More information about the lttng-dev mailing list