Skip to contentSkip to conversation

relayfs: make exported relay fileops useful

PATCH In review Tom Zanussi 1 participant 1 message Nov 9, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 3/4 relayfs: make exported relay fileops useful

Hi,

The relayfs relay_file_operations have always been exported, the intent being to make it possible to create relay files in other filesystems such as debugfs. The problem, though, is that currently the file operations are too tightly coupled to relayfs to actually be used for this purpose. This patch fixes that by adding a couple of callback functions that allow a client to hook into relay_open()/close() and supply the files that will be used to represent the channel buffers; the default implementation if no callbacks are defined is to create the files in relayfs. It also removes relayfs-specific code in the file operations themselves and renames some functions to better reflect their purpose.

The file creation callback also supplies an optional param, is_global, that can be used by clients to create a single global relayfs buffer instead of the default per-cpu buffers. This was suggested as being useful for certain debugging applications where it's more convenient to be able to get all the data from a single channel without having to go to the bother of dealing with per-cpu files.

There are a couple of new examples that demonstrate both usages in the examples/exported-relayfile directory of the relay-apps tarball:

http://prdownloads.sourceforge.net/relayfs/relay-apps-0.9.tar.gz?download

This patch depends on [PATCH 1/4] relayfs: add support for non-relay files.

---

 fs/relayfs/buffers.c       |    3 
 fs/relayfs/inode.c         |  201 ++++++++++++---------------------------------
 fs/relayfs/relay.c         |   69 ++++++++++++---
 fs/relayfs/relay.h         |    4 
 include/linux/relayfs_fs.h |   56 +++++++++---
 5 files changed, 159 insertions(+), 174 deletions(-)
fs/relayfs/buffers.c +2 -1
@@ -185,5 +185,6 @@ void relay_destroy_buf(struct rchan_buf 
 void relay_remove_buf(struct kref *kref)
 {
 	struct rchan_buf *buf = container_of(kref, struct rchan_buf, kref);
-	relayfs_remove(buf->dentry);
+	buf->chan->cb->remove_buf_file(buf->dentry);
+	relay_destroy_buf(buf);
 }
fs/relayfs/inode.c +58 -143

401 lines not on this page · raw message

fs/relayfs/relay.c +58 -11

154 lines not on this page · raw message

fs/relayfs/relay.h +0 -4
@@ -1,10 +1,6 @@
 #ifndef _RELAY_H
 #define _RELAY_H
 
-struct dentry *relayfs_create_relay_file(const char *name,
-					 struct dentry *parent,
-					 int mode,
-					 struct rchan *chan);
 extern int relayfs_remove(struct dentry *dentry);
 extern int relay_buf_empty(struct rchan_buf *buf);
 extern void relay_destroy_channel(struct kref *kref);
include/linux/relayfs_fs.h +41 -15

74 lines not on this page · raw message