Skip to contentSkip to conversation

Generic Trace Setup and Control (GTSC) kernel API (3/3)

RFC New David Wilder 1 participant 1 message Jun 18, 2007 Block layer

lore
Share & tools
lore
#0 lore raw

RFC 1/1 Generic Trace Setup and Control (GTSC) kernel API (3/3)

Patches to convert blktrace to the new GTSC API.
Two patches are included, the first is to the kernel portion of blktrace. Apply the second patch is to the blktrace user code.

Signature · 4 lines
David Wilder
IBM Linux Technology Center
Beaverton, Oregon, USA [email protected]
(503)578-3789

This patch converts the blktrace facility to use the Generic Trace Setup and Control (GTSC) API. (kernel patch)

block/Kconfig +1 -1
index a50f481..9ae9a8c 100644
@@ -30,7 +30,7 @@ config LBD
 config BLK_DEV_IO_TRACE
 	bool "Support for tracing block io actions"
 	depends on SYSFS
-	select RELAY
+	select GTSC
 	select DEBUG_FS
 	help
 	  Say Y here, if you want to be able to trace the block layer actions
block/blktrace.c +24 -164

285 lines not on this page · raw message

include/linux/blktrace_api.h +15 -15
index 3680ff9..9ccb72f 100644
@@ -2,7 +2,7 @@
 #define BLKTRACE_H
 
 #include <linux/blkdev.h>
-#include <linux/relay.h>
+#include <linux/gtsc.h>
 
 /*
  * Trace categories
@@ -109,34 +109,34 @@ struct blk_io_trace_remap {
 	__be64 sector;
 };
 
-enum {
-	Blktrace_setup = 1,
-	Blktrace_running,
-	Blktrace_stopped,
-};
-
 struct blk_trace {
-	int trace_state;
-	struct rchan *rchan;
+	struct gtsc_trace *gtsc;
 	unsigned long *sequence;
 	u16 act_mask;
 	u64 start_lba;
 	u64 end_lba;
 	u32 pid;
 	u32 dev;
-	struct dentry *dir;
-	struct dentry *dropped_file;
-	atomic_t dropped;
+};
+
+/*
+ * User setup structure
+ */
+struct gtsc_trace_setup 
+{
+	char root[GTSC_TRACE_ROOT_NAME_SIZE];
+	char name[GTSC_TRACE_NAME_SIZE];
+	u32 buf_size;
+	u32 buf_nr;
+	u32 flags;
 };
 
 /*
  * User setup structure passed with BLKTRACESTART
  */
 struct blk_user_trace_setup {
-	char name[BDEVNAME_SIZE];	/* output */
+	struct gtsc_trace_setup gts;	/* input */
 	u16 act_mask;			/* input */
-	u32 buf_size;			/* input */
-	u32 buf_nr;			/* input */
 	u64 start_lba;
 	u64 end_lba;
 	u32 pid;

This patch converts the blktrace facility to use the Generic Trace Setup and Control (GTSC) API. (patch to blktrace user code)

blktrace.c +3 -3
index 2ad940d..486fdc3 100644
@@ -395,8 +395,8 @@ static int start_trace(struct device_information *dip)
 	struct blk_user_trace_setup buts;
 
 	memset(&buts, 0, sizeof(buts));
-	buts.buf_size = dip->buf_size;
-	buts.buf_nr = dip->buf_nr;
+	buts.gts.buf_size = dip->buf_size;
+	buts.gts.buf_nr = dip->buf_nr;
 	buts.act_mask = act_mask;
 
 	if (ioctl(dip->fd, BLKTRACESETUP, &buts) < 0) {
@@ -409,7 +409,7 @@ static int start_trace(struct device_information *dip)
 		return 1;
 	}
 
-	memcpy(dip->buts_name, buts.name, sizeof(dip->buts_name));
+	memcpy(dip->buts_name, buts.gts.name, sizeof(dip->buts_name));
 	dip_set_tracing(dip, 1);
 	return 0;
 }
blktrace_api.h +17 -3
index 61b405a..3ff0905 100644
@@ -107,14 +107,28 @@ struct blk_io_trace_remap {
 	__u64 sector;
 };
 
+#define GTSC_TRACE_ROOT_NAME_SIZE	64	/* Max root dir identifier */
+#define GTSC_TRACE_NAME_SIZE		64	/* Max trace identifier */
+
+/*
+ * User setup structure
+ */
+struct gtsc_trace_setup 
+{
+	char root[GTSC_TRACE_ROOT_NAME_SIZE];
+	char name[GTSC_TRACE_NAME_SIZE];
+	__u32 buf_size;
+	__u32 buf_nr;
+	__u32 flags;
+};
+
+
 /*
  * User setup structure passed with BLKSTARTTRACE
  */
 struct blk_user_trace_setup {
-	char name[32];			/* output */
+	struct gtsc_trace_setup gts;	/* input */
 	__u16 act_mask;			/* input */
-	__u32 buf_size;			/* input */
-	__u32 buf_nr;			/* input */
 	__u64 start_lba;
 	__u64 end_lba;
 	__u32 pid;