Skip to contentSkip to conversation

LTTng-core 0.5.108 : relayfs

PATCH In review Mathieu Desnoyers 3 participants 6 messages Sep 14, 2006

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 10/11 LTTng-core 0.5.108 : relayfs

10 - Forward port of RelayFS 2.6.16 API, plus some enhancements. patch-2.6.17-lttng-core-0.5.108-relayfs.diff

OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68 
Documentation/ioctl-number.txt +3 -0
@@ -190,3 +190,6 @@ Code	Seq#	Include File		Comments
 					<mailto:[email protected]>
 0xF3	00-3F	video/sisfb.h		sisfb (in development)
 					<mailto:[email protected]>
+0xF4	00-3F	linux/relayfs_fs.h RelayFS
+					<mailto:[email protected]>
+
include/linux/relay.h +67 -1

138 lines not on this page · raw message

fs/relayfs/Makefile new file +4 -0
@@ -0,0 +1,4 @@
+obj-$(CONFIG_RELAY)	 += relayfs.o
+
+relayfs-y := relay.o inode.o buffers.o
+
fs/relayfs/inode.c new file +591 -0

591 lines not on this page · raw message

fs/relayfs/relay.c new file +560 -0

560 lines not on this page · raw message

fs/relayfs/buffers.c new file +190 -0

190 lines not on this page · raw message

fs/relayfs/buffers.h new file +9 -0
@@ -0,0 +1,9 @@
+#ifndef _BUFFERS_H
+#define _BUFFERS_H
+
+extern int relay_mmap_buf(struct rchan_buf *buf, struct vm_area_struct *vma);
+extern struct rchan_buf *relay_create_buf(struct rchan *chan);
+extern void relay_destroy_buf(struct rchan_buf *buf);
+extern void relay_remove_buf(struct kref *kref);
+
+#endif/* _BUFFERS_H */
fs/relayfs/relay.h new file +12 -0
@@ -0,0 +1,12 @@
+#ifndef _RELAY_H
+#define _RELAY_H
+
+extern int relayfs_remove(struct dentry *dentry);
+extern int relay_buf_empty(struct rchan_buf *buf);
+extern int relay_buf_full(struct rchan_buf *buf);
+extern void relay_destroy_channel(struct kref *kref);
+extern void setup_fileops(struct rchan *chan,
+				   struct file_operations *fops,
+					 struct module *client_module);
+
+#endif /* _RELAY_H */
fs/Makefile +1 -0
@@ -102,3 +102,4 @@ obj-$(CONFIG_HOSTFS)		+= hostfs/
 obj-$(CONFIG_HPPFS)		+= hppfs/
 obj-$(CONFIG_DEBUG_FS)		+= debugfs/
 obj-$(CONFIG_OCFS2_FS)		+= ocfs2/
+obj-$(CONFIG_RELAY)		+= relayfs/
block/blktrace.c +1 -1
@@ -330,7 +330,7 @@ static int blk_trace_setup(request_queue
 	if (!bt->dropped_file)
 		goto err;
 
-	bt->rchan = relay_open("trace", dir, buts.buf_size, buts.buf_nr, &blk_relay_callbacks);
+	bt->rchan = relay_open("trace", dir, buts.buf_size, buts.buf_nr, 0, THIS_MODULE, &blk_relay_callbacks, NULL, NULL, NULL);
 	if (!bt->rchan)
 		goto err;
 	bt->rchan->private_data = bt;
maintainer
#1 lore raw
Quoted 2 lines · Mathieu Desnoyers

10 - Forward port of RelayFS 2.6.16 API, plus some enhancements. patch-2.6.17-lttng-core-0.5.108-relayfs.diff

One big question - why?!

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 6 lines · * Jens Axboe ([email protected]) wrote:
Quoted 2 lines · Mathieu Desnoyers

10 - Forward port of RelayFS 2.6.16 API, plus some enhancements. patch-2.6.17-lttng-core-0.5.108-relayfs.diff

One big question - why?!

(repeated)
It's a temporary solution only used because relayfs has been such a moving target lately that I decided to wait for things to settle down before switching. I plan to switch to the new relay.o and use DebugFS for filesystem. I just haven't done the change yet.

Mathieu

Quoted 3 lines
Signature · 1 line
Jens Axboe
OpenPGP public key:              http://krystal.dyndns.org:8080/key/compudj.gpg
Key fingerprint:     8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68 
maintainer
#3 lore raw
Quoted 5 lines · Mathieu Desnoyers
Quoted 4 lines · * Jens Axboe ([email protected]) wrote:
Quoted 2 lines · Mathieu Desnoyers

10 - Forward port of RelayFS 2.6.16 API, plus some enhancements. patch-2.6.17-lttng-core-0.5.108-relayfs.diff

Quoted 7 lines
Quoted 2 lines

One big question - why?!

(repeated)
It's a temporary solution only used because relayfs has been such a moving target lately that I decided to wait for things to settle down before switching. I plan to switch to the new relay.o and use DebugFS for filesystem. I just haven't done the change yet.

Since going into the kernel, it's only changed once and that was 6 (something like that) months ago. So I'd say that your statement there is hugely exaggerated. Just get it fixed up, if you are serious in any way with posting your patches.

Signature · 1 line
Jens Axboe
#4 lore raw
In reply to Mathieu Desnoyers

Documentation/ioctl-number.txt Code Seq# Include File Comments · line 195

Quoted 9 lines · Mathieu Desnoyers
Documentation/ioctl-number.txt +3 -0
@@ -190,3 +190,6 @@ Code	Seq#	Include File		Comments
 					<mailto:[email protected]>
 0xF3	00-3F	video/sisfb.h		sisfb (in development)
 					<mailto:[email protected]>
+0xF4	00-3F	linux/relayfs_fs.h RelayFS
+					<mailto:[email protected]>
+

Even if you were to add the file system back in for some nonsensical reason, the header is still wrong.

Quoted 114 lines
include/linux/relay.h +49 -0
@@ -1,6 +1,7 @@
 /*
  * linux/include/linux/relay.h
  *
+ * Copyright (C) 2005, Mathieu Desnoyers ([email protected])
  * Copyright (C) 2002, 2003 - Tom Zanussi ([email protected]), IBM Corp
  * Copyright (C) 1999, 2000, 2001, 2002 - Karim Yaghmour ([email protected])
  *
@@ -37,11 +38,13 @@ struct rchan_buf
 	size_t offset;			/* current offset into sub-buffer */
 	size_t subbufs_produced;	/* count of sub-buffers produced */
 	size_t subbufs_consumed;	/* count of sub-buffers consumed */
+	atomic_t full;		/* buffer is in full state */
 	struct rchan *chan;		/* associated channel */
 	wait_queue_head_t read_wait;	/* reader wait queue */
 	struct work_struct wake_readers; /* reader wake-up work struct */
 	struct dentry *dentry;		/* channel file dentry */
 	struct kref kref;		/* channel buffer refcount */
+	atomic_t open_count;			/* file open count */
 	struct page **page_array;	/* array of current buffer pages */
 	unsigned int page_count;	/* number of current buffer pages */
 	unsigned int finalized;		/* buffer has been finalized */
@@ -60,11 +63,18 @@ struct rchan
 	size_t subbuf_size;		/* sub-buffer size */
 	size_t n_subbufs;		/* number of sub-buffers per buffer */
 	size_t alloc_size;		/* total buffer size allocated */
+	int overwrite;			/* overwrite buffer when full? */
 	struct rchan_callbacks *cb;	/* client callbacks */
+	struct file_operations *fops; 	/* file operations */
+	void *client_data; 		/* client data associated with the
+					   client callbacks */
+	void (*free_client_data_cb)(void*); /* Callback function to free the
+					       client data */
 	struct kref kref;		/* channel refcount */
 	void *private_data;		/* for user-defined data */
 	size_t last_toobig;		/* tried to log event > subbuf size */
 	struct rchan_buf *buf[NR_CPUS]; /* per-cpu channel buffers */
+	struct module *client_module;	/* Client module */
 };
 
 /*
@@ -76,6 +86,7 @@ struct rchan_callbacks
 	 * subbuf_start - called on buffer-switch to a new sub-buffer
 	 * @buf: the channel buffer containing the new sub-buffer
 	 * @subbuf: the start of the new sub-buffer
+	 * @prev_subbuf_idx: the previous sub-buffer's index
 	 * @prev_subbuf: the start of the previous sub-buffer
 	 * @prev_padding: unused space at the end of previous sub-buffer
 	 *
@@ -95,6 +106,18 @@ struct rchan_callbacks
 			     size_t prev_padding);
 
 	/*
+	 * deliver - deliver a guaranteed full sub-buffer to client
+	 * @buf: the channel buffer containing the sub-buffer
+	 * @subbuf_idx: the sub-buffer's index
+	 * @subbuf: the start of the new sub-buffer
+	 *
+	 * Only works if relay_commit is also used
+	 */
+	void (*deliver) (struct rchan_buf *buf,
+			 unsigned subbuf_idx,
+			 void *subbuf);
+
+	/*
 	 * buf_mapped - relay buffer mmap notification
 	 * @buf: the channel buffer
 	 * @filp: relay file pointer
@@ -113,6 +136,7 @@ struct rchan_callbacks
 	 */
         void (*buf_unmapped)(struct rchan_buf *buf,
 			     struct file *filp);
+
 	/*
 	 * create_buf_file - create file to represent a relay channel buffer
 	 * @filename: the name of the file to create
@@ -153,6 +177,31 @@ struct rchan_callbacks
 	 * The callback should return 0 if successful, negative if not.
 	 */
 	int (*remove_buf_file)(struct dentry *dentry);
+
+	/*
+	 * buf_full - relayfs buffer full notification
+	 * @buf: the channel channel buffer
+	 * @subbuf_idx: the current sub-buffer's index
+	 * @subbuf: the start of the current sub-buffer
+	 *
+	 * Called when a relayfs buffer becomes full
+	 */
+	void (*buf_full)(struct rchan_buf *buf,
+			unsigned subbuf_idx,
+			void *subbuf);
+
+	/*
+	 * buf_unfull - relayfs buffer unfull notification
+	 * @buf: the channel channel buffer
+	 * @subbuf_idx: the current sub-buffer's index
+	 * @subbuf: the start of the current sub-buffer
+	 *
+	 * Called when a relayfs buffer passes from full to not full
+	 */
+	void (*buf_unfull)(struct rchan_buf *buf,
+			unsigned subbuf_idx,
+			void *subbuf);
+
 };
 
 /*
@@ -163,7 +212,12 @@ struct rchan *relay_open(const char *bas
 			 struct dentry *parent,
 			 size_t subbuf_size,
 			 size_t n_subbufs,

include/linux/relay.h struct rchan *relay_open(const char *bas · line 223

Quoted 10 lines
include/linux/relay.h +6 -1
-			 struct rchan_callbacks *cb);
+			 int overwrite,
+			 struct module *client_module,
+			 struct rchan_callbacks *cb,
+			 struct file_operations *fops,
+			 void *client_data,
+			 void (*free_client_data_cb)(void*));
 extern void relay_close(struct rchan *chan);
 extern void relay_flush(struct rchan *chan);
 extern void relay_subbufs_consumed(struct rchan *chan,

These should be split out with the corresponding kernel/relay.c updates and posted separately. fops as an argument looks very suspect.

Quoted 19 lines
include/linux/relay.h +11 -0
@@ -175,6 +229,17 @@ extern int relay_buf_full(struct rchan_b
 extern size_t relay_switch_subbuf(struct rchan_buf *buf,
 				  size_t length);
 
+extern struct dentry *relayfs_create_dir(const char *name,
+					 struct dentry *parent);
+extern int relayfs_remove_dir(struct dentry *dentry);
+extern struct dentry *relayfs_create_file(const char *name,
+					  struct dentry *parent,
+					  int mode,
+					  struct file_operations *fops,
+					  void *data);
+extern int relayfs_remove_file(struct dentry *dentry);
+
+
 /**
  *	relay_write - write data into the channel
  *	@chan: relay channel

include/linux/relay.h static inline void *relay_reserve(struct · line 322

Quoted 7 lines
include/linux/relay.h +1 -0
@@ -251,6 +316,7 @@ static inline void *relay_reserve(struct
 		if (!length)
 			return NULL;
 	}
+
 	reserved = buf->data + buf->offset;
 	buf->offset += length;
 

None of this matters, use debugfs, it already does it for you.