From: Tom Zanussi <zanussi@us.ibm.com>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, karim@opersys.com
Subject: [PATCH 9/12] relayfs: add support for global relay buffers
Date: Fri, 11 Nov 2005 10:52:16 -0600 [thread overview]
Message-ID: <17268.52288.86985.30978@tut.ibm.com> (raw)
In-Reply-To: <17268.51814.215178.281986@tut.ibm.com>
This patch adds the optional is_global outparam to the
create_buf_file() callback. This 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.
Signed-off-by: Tom Zanussi <zanussi@us.ibm.com>
---
fs/relayfs/relay.c | 35 +++++++++++++++++++++++++----------
include/linux/relayfs_fs.h | 8 +++++++-
2 files changed, 32 insertions(+), 11 deletions(-)
diff --git a/fs/relayfs/relay.c b/fs/relayfs/relay.c
--- a/fs/relayfs/relay.c
+++ b/fs/relayfs/relay.c
@@ -86,7 +86,8 @@ static void buf_unmapped_default_callbac
static struct dentry *create_buf_file_default_callback(const char *filename,
struct dentry *parent,
int mode,
- struct rchan_buf *buf)
+ struct rchan_buf *buf,
+ int *is_global)
{
return relayfs_create_file(filename, parent, mode,
&relayfs_file_operations, buf);
@@ -170,14 +171,16 @@ static inline void __relay_reset(struct
void relay_reset(struct rchan *chan)
{
unsigned int i;
+ struct rchan_buf *prev = NULL;
if (!chan)
return;
for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i])
- continue;
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
__relay_reset(chan->buf[i], 0);
+ prev = chan->buf[i];
}
}
@@ -188,18 +191,22 @@ void relay_reset(struct rchan *chan)
*/
static struct rchan_buf *relay_open_buf(struct rchan *chan,
const char *filename,
- struct dentry *parent)
+ struct dentry *parent,
+ int *is_global)
{
struct rchan_buf *buf;
struct dentry *dentry;
+ if (*is_global)
+ return chan->buf[0];
+
buf = relay_create_buf(chan);
if (!buf)
return NULL;
/* Create file in fs */
dentry = chan->cb->create_buf_file(filename, parent, S_IRUSR,
- buf);
+ buf, is_global);
if (!dentry) {
relay_destroy_buf(buf);
return NULL;
@@ -273,6 +280,7 @@ struct rchan *relay_open(const char *bas
unsigned int i;
struct rchan *chan;
char *tmpname;
+ int is_global = 0;
if (!base_filename)
return NULL;
@@ -297,7 +305,8 @@ struct rchan *relay_open(const char *bas
for_each_online_cpu(i) {
sprintf(tmpname, "%s%d", base_filename, i);
- chan->buf[i] = relay_open_buf(chan, tmpname, parent);
+ chan->buf[i] = relay_open_buf(chan, tmpname, parent,
+ &is_global);
chan->buf[i]->cpu = i;
if (!chan->buf[i])
goto free_bufs;
@@ -311,6 +320,8 @@ free_bufs:
if (!chan->buf[i])
break;
relay_close_buf(chan->buf[i]);
+ if (is_global)
+ break;
}
kfree(tmpname);
@@ -421,14 +432,16 @@ void relay_destroy_channel(struct kref *
void relay_close(struct rchan *chan)
{
unsigned int i;
+ struct rchan_buf *prev = NULL;
if (!chan)
return;
for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i])
- continue;
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
relay_close_buf(chan->buf[i]);
+ prev = chan->buf[i];
}
kref_put(&chan->kref, relay_destroy_channel);
@@ -443,14 +456,16 @@ void relay_close(struct rchan *chan)
void relay_flush(struct rchan *chan)
{
unsigned int i;
+ struct rchan_buf *prev = NULL;
if (!chan)
return;
for (i = 0; i < NR_CPUS; i++) {
- if (!chan->buf[i])
- continue;
+ if (!chan->buf[i] || chan->buf[i] == prev)
+ break;
relay_switch_subbuf(chan->buf[i], 0);
+ prev = chan->buf[i];
}
}
diff --git a/include/linux/relayfs_fs.h b/include/linux/relayfs_fs.h
--- a/include/linux/relayfs_fs.h
+++ b/include/linux/relayfs_fs.h
@@ -115,6 +115,7 @@ struct rchan_callbacks
* @parent: the parent of the file to create
* @mode: the mode of the file to create
* @buf: the channel buffer
+ * @is_global: outparam - set non-zero if the buffer should be global
*
* Called during relay_open(), once for each per-cpu buffer,
* to allow the client to create a file to be used to
@@ -125,12 +126,17 @@ struct rchan_callbacks
* The callback should return the dentry of the file created
* to represent the relay buffer.
*
+ * Setting the is_global outparam to a non-zero value will
+ * cause relay_open() to create a single global buffer rather
+ * than the default set of per-cpu buffers.
+ *
* See Documentation/filesystems/relayfs.txt for more info.
*/
struct dentry *(*create_buf_file)(const char *filename,
struct dentry *parent,
int mode,
- struct rchan_buf *buf);
+ struct rchan_buf *buf,
+ int *is_global);
/*
* remove_buf_file - remove file representing a relayfs channel buffer
next prev parent reply other threads:[~2005-11-11 16:52 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-11 16:44 [PATCH 0/12] relayfs: API additions and fixes Tom Zanussi
2005-11-11 16:46 ` [PATCH 1/12] relayfs: decouple buffer creation from inode creation Tom Zanussi
2005-11-11 16:47 ` [PATCH 2/12] relayfs: export relayfs_create_file() with fileops param Tom Zanussi
2005-11-11 19:37 ` Christoph Hellwig
2005-11-11 19:49 ` Tom Zanussi
2005-12-06 17:29 ` Christoph Hellwig
2005-12-06 19:51 ` Tom Zanussi
2005-11-12 2:10 ` Baruch Even
2005-11-11 16:47 ` [PATCH 3/12] relayfs: add relayfs_remove_file() Tom Zanussi
2005-11-11 16:48 ` [PATCH 4/12] relayfs: use generic_ip for private data Tom Zanussi
2005-11-11 16:49 ` [PATCH 5/12] relayfs: remove unused alloc/destroy_inode() Tom Zanussi
2005-11-11 16:50 ` [PATCH 6/12] relayfs: add Documention for non-relay files Tom Zanussi
2005-11-11 16:51 ` [PATCH 7/12] relayfs: add support for relay files in other filesystems Tom Zanussi
2005-11-11 16:51 ` [PATCH 8/12] relayfs: add Documentation on " Tom Zanussi
2005-11-11 16:52 ` Tom Zanussi [this message]
2005-11-11 16:52 ` [PATCH 10/12] relayfs: add Documentation on global relay buffers Tom Zanussi
2005-11-11 16:53 ` [PATCH 11/12] relayfs: cleanup, change relayfs_file_* to relay_file_* Tom Zanussi
2005-11-11 16:54 ` [PATCH 12/12] relayfs: Documentation cleanup, remove obsolete info Tom Zanussi
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=17268.52288.86985.30978@tut.ibm.com \
--to=zanussi@us.ibm.com \
--cc=akpm@osdl.org \
--cc=karim@opersys.com \
--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
all inboxes | Powered by JetHome®