diff options
Diffstat (limited to 'runtime/transport')
-rw-r--r-- | runtime/transport/ChangeLog | 21 | ||||
-rw-r--r-- | runtime/transport/procfs.c | 48 | ||||
-rw-r--r-- | runtime/transport/relayfs.c | 162 | ||||
-rw-r--r-- | runtime/transport/relayfs.h | 12 | ||||
-rw-r--r-- | runtime/transport/transport.c | 13 |
5 files changed, 112 insertions, 144 deletions
diff --git a/runtime/transport/ChangeLog b/runtime/transport/ChangeLog index 81618d7b..969f6fb0 100644 --- a/runtime/transport/ChangeLog +++ b/runtime/transport/ChangeLog @@ -1,3 +1,24 @@ +2006-09-19 Tom Zanussi <zanussi@us.ibm.com> + + * procfs.c (_stp_get_proc_root): Removed. + (_stp_force_dir_creation): Removed. + (_stp_register_procfs): Remove unneeded procfs dentry code. * + relayfs.c (_stp_create_buf_file): Remove code to create relay + files in procfs, add code to create in debugfs. + (_stp_remove_buf_file): Remove code to delete relay files in + procfs, add code to delete from debugfs. + (_stp_create_relay_dir): New. + (_stp_remove_relay_dir): New. + (_stp_get_relay_root): New. + (_stp_relayfs_close): Use new functions. + (_stp_relayfs_open): Consolidate alternative versions and remove + extraneous version. * relayfs.h: Remove extraneous + _stp_relayfs_open prototype. + * transport.c (_stp_transport_open): Remove extraneous call to + _stp_relayfs_open() and remove call to _stp_unregister_procfs() on + failure - since it's called from cmd write, cmd can't be removed; + it's removed in normal shutdown anyway. + 2006-09-18 Martin Hunt <hunt@redhat.com> * transport_msgs.h (struct transport_info): Add merge field. diff --git a/runtime/transport/procfs.c b/runtime/transport/procfs.c index d61beba2..857a36c7 100644 --- a/runtime/transport/procfs.c +++ b/runtime/transport/procfs.c @@ -267,38 +267,6 @@ err: return _stp_current_buffers; } -#if defined (STP_RELAYFS) && defined(CONFIG_RELAY) -struct dentry *module_dir_dentry; - -static inline struct dentry *_stp_get_proc_root(void) -{ - struct file_system_type *procfs_type; - struct super_block *procfs_sb; - - procfs_type = get_fs_type("proc"); - if (!procfs_type || list_empty(&procfs_type->fs_supers)) - return NULL; - procfs_sb = list_entry(procfs_type->fs_supers.next, - struct super_block, s_instances); - return procfs_sb->s_root; -} - -static inline struct dentry *_stp_force_dir_creation(const char *dirname, struct dentry *parent) -{ - struct dentry *dir_dentry; - - mutex_lock(&parent->d_inode->i_mutex); - dir_dentry = lookup_one_len(dirname, parent, strlen(dirname)); - mutex_unlock(&parent->d_inode->i_mutex); - if (IS_ERR(dir_dentry)) { - dir_dentry = NULL; - remove_proc_entry(dirname, NULL); - } - - return dir_dentry; -} -#endif /* STP_RELAYFS && CONFIG_RELAY */ - static int _stp_register_procfs (void) { int i; @@ -307,10 +275,6 @@ static int _stp_register_procfs (void) int j; char buf[8]; #endif -#if defined (CONFIG_RELAY) - struct dentry *proc_root_dentry; - struct dentry *systemtap_dir_dentry; -#endif /* CONFIG_RELAY */ struct proc_dir_entry *de; struct list_head *p, *tmp; @@ -342,23 +306,11 @@ static int _stp_register_procfs (void) goto err0; } -#if defined (STP_RELAYFS) && defined (CONFIG_RELAY) - proc_root_dentry = _stp_get_proc_root(); - systemtap_dir_dentry = _stp_force_dir_creation(dirname, proc_root_dentry); - if (!systemtap_dir_dentry) - goto err0; -#endif /* STP_RELAYFS && CONFIG_RELAY */ /* now create /proc/systemtap/module_name */ _stp_proc_mod = proc_mkdir (THIS_MODULE->name, _stp_proc_root); if (_stp_proc_mod == NULL) goto err0; -#if defined (STP_RELAYFS) && defined (CONFIG_RELAY) - module_dir_dentry = _stp_force_dir_creation(THIS_MODULE->name, systemtap_dir_dentry); - if (!module_dir_dentry) - goto err0; -#endif /* STP_RELAYFS && CONFIG_RELAY */ - #ifdef STP_RELAYFS /* now for each cpu "n", create /proc/systemtap/module_name/n */ for_each_cpu(i) { diff --git a/runtime/transport/relayfs.c b/runtime/transport/relayfs.c index 3672c453..defe0087 100644 --- a/runtime/transport/relayfs.c +++ b/runtime/transport/relayfs.c @@ -78,35 +78,15 @@ static struct dentry *_stp_create_buf_file(const char *filename, struct rchan_buf *buf, int *is_global) { - struct proc_dir_entry *pde; - struct dentry *dentry; - struct proc_dir_entry *parent_pde = NULL; - - if (parent) - parent_pde = PDE(parent->d_inode); - pde = create_proc_entry(filename, S_IFREG|S_IRUSR, parent_pde); - if (unlikely(!pde)) - return NULL; - pde->proc_fops = &relay_file_operations; - - mutex_lock(&parent->d_inode->i_mutex); - dentry = lookup_one_len(filename, parent, strlen(filename)); - mutex_unlock(&parent->d_inode->i_mutex); - if (IS_ERR(dentry)) - remove_proc_entry(filename, parent_pde); - - dentry->d_inode->u.generic_ip = buf; - - return dentry; + return debugfs_create_file(filename, mode, parent, buf, + &relay_file_operations); } static int _stp_remove_buf_file(struct dentry *dentry) { - struct proc_dir_entry *pde = PDE(dentry->d_inode); - - remove_proc_entry(pde->name, pde->parent); + debugfs_remove(dentry); - return 0; + return 0; } #endif /* CONFIG_RELAY */ @@ -128,34 +108,85 @@ static struct rchan_callbacks stp_rchan_callbacks = }; #endif /* CONFIG_RELAY */ -/** - * _stp_relayfs_close - destroys relayfs channel - * @chan: the relayfs channel - * @dir: the directory containing the relayfs files - */ +static struct dentry *_stp_create_relay_dir(const char *dirname, struct dentry *parent) +{ + struct dentry *dir; + #if defined (CONFIG_RELAY) -void _stp_relayfs_close(struct rchan *chan, struct dentry *dir) + dir = debugfs_create_dir(dirname, parent); + if (IS_ERR(dir)) { + printk("STP: Couldn't create directory %s - debugfs not configured in.\n", dirname); + dir = NULL; + } +#else + dir = relayfs_create_dir(dirname, parent); +#endif + + return dir; +} + +static void _stp_remove_relay_dir(struct dentry *dir) { - if (!chan) + if (dir == NULL) return; - - relay_close(chan); - if (dir) { - struct proc_dir_entry *pde = PDE(dir->d_inode); - remove_proc_entry(pde->name, pde->parent); - } + +#if defined (CONFIG_RELAY) + debugfs_remove(dir); +#else + relayfs_remove_dir(dir); +#endif } + +static struct dentry *_stp_get_relay_root(void) +{ + struct file_system_type *fs; + struct super_block *sb; + struct dentry *root; + char *dirname = "systemtap"; + + root = _stp_create_relay_dir(dirname, NULL); + if (root) + return root; + +#if defined (CONFIG_RELAY) + fs = get_fs_type("debugfs"); #else + fs = get_fs_type("relayfs"); +#endif + if (!fs) + return NULL; + + sb = list_entry(fs->fs_supers.next, struct super_block, s_instances); + mutex_lock(&sb->s_root->d_inode->i_mutex); + root = lookup_one_len(dirname, sb->s_root, strlen(dirname)); + mutex_unlock(&sb->s_root->d_inode->i_mutex); + if (!IS_ERR(root)) + dput(root); + + return root; +} + +static void _stp_put_relay_root(struct dentry *root) +{ + if (root) + _stp_remove_relay_dir(root); +} + +static struct dentry *_relay_root; + +/** + * _stp_relayfs_close - destroys relayfs channel + * @chan: the relayfs channel + * @dir: the directory containing the relayfs files + */ void _stp_relayfs_close(struct rchan *chan, struct dentry *dir) { if (!chan) return; - relay_close(chan); - if (dir) - relayfs_remove_dir(dir); + _stp_remove_relay_dir(dir); + _stp_put_relay_root(_relay_root); } -#endif /* CONFIG_RELAY */ /** * _stp_relayfs_open - create relayfs channel @@ -163,56 +194,35 @@ void _stp_relayfs_close(struct rchan *chan, struct dentry *dir) * @subbuf_size: size of relayfs sub-buffers * @pid: daemon pid * @outdir: receives directory dentry - * @parentdir: parent directory dentry * * Returns relay channel, NULL on failure * * Creates relayfs files as /systemtap/pid/cpuX in relayfs root */ -#if defined (CONFIG_RELAY) -extern struct dentry *module_dentry; struct rchan *_stp_relayfs_open(unsigned n_subbufs, unsigned subbuf_size, int pid, - struct dentry **outdir, - struct dentry *parent_dir) + struct dentry **outdir) { char dirname[16]; struct rchan *chan; - struct dentry* dir = NULL; + struct dentry* root, *dir; sprintf(dirname, "%d", pid); - /* TODO: need to create systemtap dir */ - chan = relay_open("cpu", parent_dir, subbuf_size, - n_subbufs, &stp_rchan_callbacks); - if (!chan) { - printk("STP: couldn't create relayfs channel.\n"); - if (dir) - remove_proc_entry(dirname, NULL); + root = _stp_get_relay_root(); + if (!root) { + printk("STP: couldn't get relay root dir.\n"); + return NULL; } - *outdir = dir; - return chan; -} -#else -struct rchan *_stp_relayfs_open(unsigned n_subbufs, - unsigned subbuf_size, - int pid, - struct dentry **outdir) -{ - char dirname[16]; - struct rchan *chan; - struct dentry* dir = NULL; - sprintf(dirname, "%d", pid); - - /* TODO: need to create systemtap dir */ - dir = relayfs_create_dir(dirname, NULL); + dir = _stp_create_relay_dir(dirname, root); if (!dir) { - printk("STP: couldn't create relayfs dir %s.\n", dirname); + printk("STP: couldn't create relay dir %s.\n", dirname); + _stp_put_relay_root(root); return NULL; } - + #if (RELAYFS_CHANNEL_VERSION >= 4) chan = relay_open("cpu", dir, subbuf_size, n_subbufs, &stp_rchan_callbacks); @@ -222,15 +232,15 @@ struct rchan *_stp_relayfs_open(unsigned n_subbufs, #endif /* RELAYFS_CHANNEL_VERSION >= 4 */ if (!chan) { - printk("STP: couldn't create relayfs channel.\n"); - if (dir) - relayfs_remove_dir(dir); + printk("STP: couldn't create relay channel.\n"); + _stp_remove_relay_dir(dir); + _stp_put_relay_root(root); } + _relay_root = root; *outdir = dir; return chan; } -#endif /* CONFIG_RELAY */ #endif /* _TRANSPORT_RELAYFS_C_ */ diff --git a/runtime/transport/relayfs.h b/runtime/transport/relayfs.h index c871db31..c47f4b98 100644 --- a/runtime/transport/relayfs.h +++ b/runtime/transport/relayfs.h @@ -9,23 +9,17 @@ # include <linux/relayfs_fs.h> #elif defined (CONFIG_RELAY) # include <linux/relay.h> -# include <linux/namei.h> +# include <linux/debugfs.h> #else # undef STP_RELAYFS #endif -#if defined (CONFIG_RELAY) -struct rchan *_stp_relayfs_open(unsigned n_subbufs, - unsigned subbuf_size, - int pid, - struct dentry **outdir, - struct dentry *parent_dir); -#else +# include <linux/namei.h> + struct rchan *_stp_relayfs_open(unsigned n_subbufs, unsigned subbuf_size, int pid, struct dentry **outdir); -#endif void _stp_relayfs_close(struct rchan *chan, struct dentry *dir); diff --git a/runtime/transport/transport.c b/runtime/transport/transport.c index c9be3311..8cc624a9 100644 --- a/runtime/transport/transport.c +++ b/runtime/transport/transport.c @@ -204,10 +204,6 @@ void _stp_transport_close() kbug("---- CLOSED ----\n"); } -#if defined (STP_RELAYFS) && defined (CONFIG_RELAY) -extern struct dentry *module_dir_dentry; -#endif /* STP_RELAYFS && CONFIG_RELAY */ - /** * _stp_transport_open - open proc and relayfs channels * with proper parameters @@ -247,15 +243,10 @@ int _stp_transport_open(struct transport_info *info) info->merge = 1; #endif -#if defined (CONFIG_RELAY) - _stp_chan = _stp_relayfs_open(n_subbufs, subbuf_size, _stp_pid, &_stp_dir, module_dir_dentry); -#else _stp_chan = _stp_relayfs_open(n_subbufs, subbuf_size, _stp_pid, &_stp_dir); -#endif /* CONFIG_RELAY */ - if (!_stp_chan) { - _stp_unregister_procfs(); + + if (!_stp_chan) return -ENOMEM; - } kbug ("stp_transport_open: %u Mb buffers, subbuf_size=%u, n_subbufs=%u\n", info->buf_size, subbuf_size, n_subbufs); } else |