From d28f6a948209434945e785f2ad3b89aaa67897e4 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 3 Dec 2013 14:33:24 -0500 Subject: [PATCH] Fix: remove unused code in session daemon This also removes unused data structure in an unit test. Signed-off-by: David Goulet --- src/bin/lttng-sessiond/jul.c | 21 ----- src/bin/lttng-sessiond/modprobe.c | 21 ----- src/bin/lttng-sessiond/modprobe.h | 1 - src/bin/lttng-sessiond/trace-ust.c | 56 ----------- src/bin/lttng-sessiond/trace-ust.h | 22 ----- src/bin/lttng-sessiond/ust-app.c | 144 ----------------------------- src/bin/lttng-sessiond/ust-app.h | 30 ------ tests/unit/test_ust_data.c | 30 +----- 8 files changed, 1 insertion(+), 324 deletions(-) diff --git a/src/bin/lttng-sessiond/jul.c b/src/bin/lttng-sessiond/jul.c index 183081dc0..59be57f6e 100644 --- a/src/bin/lttng-sessiond/jul.c +++ b/src/bin/lttng-sessiond/jul.c @@ -677,27 +677,6 @@ error: return NULL; } -/* - * Delete JUL event from given domain. Events hash table MUST be initialized. - */ -void jul_delete_event(struct jul_event *event, struct jul_domain *dom) -{ - int ret; - struct lttng_ht_iter iter; - - assert(event); - assert(dom); - assert(dom->events); - - DBG3("JUL deleting event %s from domain", event->name); - - iter.iter.node = &event->node.node; - rcu_read_lock(); - ret = lttng_ht_del(dom->events, &iter); - rcu_read_unlock(); - assert(!ret); -} - /* * Free given JUL event. This event must not be globally visible at this * point (only expected to be used on failure just after event diff --git a/src/bin/lttng-sessiond/modprobe.c b/src/bin/lttng-sessiond/modprobe.c index a010e7cd7..92563b0fa 100644 --- a/src/bin/lttng-sessiond/modprobe.c +++ b/src/bin/lttng-sessiond/modprobe.c @@ -232,24 +232,3 @@ int modprobe_lttng_data(void) error: return ret; } - -/* - * Load all lttng kernel modules. - */ -int modprobe_lttng_all(void) -{ - int ret; - - ret = modprobe_lttng_control(); - if (ret < 0) { - goto error; - } - - ret = modprobe_lttng_data(); - if (ret < 0) { - goto error; - } - -error: - return ret; -} diff --git a/src/bin/lttng-sessiond/modprobe.h b/src/bin/lttng-sessiond/modprobe.h index 8f329fad1..0c6f5f158 100644 --- a/src/bin/lttng-sessiond/modprobe.h +++ b/src/bin/lttng-sessiond/modprobe.h @@ -21,7 +21,6 @@ void modprobe_remove_lttng_all(void); void modprobe_remove_lttng_control(void); void modprobe_remove_lttng_data(void); -int modprobe_lttng_all(void); int modprobe_lttng_control(void); int modprobe_lttng_data(void); diff --git a/src/bin/lttng-sessiond/trace-ust.c b/src/bin/lttng-sessiond/trace-ust.c index 657d6e554..70b3a91a3 100644 --- a/src/bin/lttng-sessiond/trace-ust.c +++ b/src/bin/lttng-sessiond/trace-ust.c @@ -404,48 +404,6 @@ error: return NULL; } -/* - * Allocate and initialize a ust metadata. - * - * Return pointer to structure or NULL. - */ -struct ltt_ust_metadata *trace_ust_create_metadata(char *path) -{ - int ret; - struct ltt_ust_metadata *lum; - - assert(path); - - lum = zmalloc(sizeof(struct ltt_ust_metadata)); - if (lum == NULL) { - PERROR("ust metadata zmalloc"); - goto error; - } - - /* Set default attributes */ - lum->attr.overwrite = DEFAULT_CHANNEL_OVERWRITE; - lum->attr.subbuf_size = default_get_metadata_subbuf_size(); - lum->attr.num_subbuf = DEFAULT_METADATA_SUBBUF_NUM; - lum->attr.switch_timer_interval = DEFAULT_METADATA_SWITCH_TIMER; - lum->attr.read_timer_interval = DEFAULT_METADATA_READ_TIMER; - lum->attr.output = LTTNG_UST_MMAP; - - lum->handle = -1; - /* Set metadata trace path */ - ret = snprintf(lum->pathname, PATH_MAX, "%s/" DEFAULT_METADATA_NAME, path); - if (ret < 0) { - PERROR("asprintf ust metadata"); - goto error_free_metadata; - } - - return lum; - -error_free_metadata: - free(lum); -error: - return NULL; -} - /* * Allocate and initialize an UST context. * @@ -638,20 +596,6 @@ void trace_ust_delete_channel(struct lttng_ht *ht, assert(!ret); } -/* - * Cleanup ust metadata structure. - */ -void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) -{ - assert(metadata); - - if (!metadata->handle) { - return; - } - DBG2("Trace UST destroy metadata %d", metadata->handle); - free(metadata); -} - /* * Iterate over a hash table containing channels and cleanup safely. */ diff --git a/src/bin/lttng-sessiond/trace-ust.h b/src/bin/lttng-sessiond/trace-ust.h index 9f8d182b3..f2f8c7e36 100644 --- a/src/bin/lttng-sessiond/trace-ust.h +++ b/src/bin/lttng-sessiond/trace-ust.h @@ -67,15 +67,6 @@ struct ltt_ust_channel { uint64_t tracefile_count; }; -/* UST Metadata */ -struct ltt_ust_metadata { - int handle; - struct lttng_ust_object_data *obj; - char pathname[PATH_MAX]; /* Trace file path name */ - struct lttng_ust_channel_attr attr; - struct lttng_ust_object_data *stream_obj; -}; - /* UST domain global (LTTNG_DOMAIN_UST) */ struct ltt_ust_domain_global { struct lttng_ht *channels; @@ -170,7 +161,6 @@ struct ltt_ust_channel *trace_ust_create_channel(struct lttng_channel *attr); struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, struct lttng_filter_bytecode *filter, struct lttng_event_exclusion *exclusion); -struct ltt_ust_metadata *trace_ust_create_metadata(char *path); struct ltt_ust_context *trace_ust_create_context( struct lttng_event_context *ctx); void trace_ust_delete_channel(struct lttng_ht *ht, @@ -181,7 +171,6 @@ void trace_ust_delete_channel(struct lttng_ht *ht, * it's applies. */ void trace_ust_destroy_session(struct ltt_ust_session *session); -void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata); void trace_ust_destroy_channel(struct ltt_ust_channel *channel); void trace_ust_destroy_event(struct ltt_ust_event *event); @@ -221,22 +210,11 @@ struct ltt_ust_event *trace_ust_create_event(struct lttng_event *ev, { return NULL; } -static inline -struct ltt_ust_metadata *trace_ust_create_metadata(char *path) -{ - return NULL; -} - static inline void trace_ust_destroy_session(struct ltt_ust_session *session) { } -static inline -void trace_ust_destroy_metadata(struct ltt_ust_metadata *metadata) -{ -} - static inline void trace_ust_destroy_channel(struct ltt_ust_channel *channel) { diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index ab08ac0e4..c7bcc85f5 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -2817,14 +2817,6 @@ error: return ret; } -/* - * Return pointer to traceable apps list. - */ -struct lttng_ht *ust_app_get_ht(void) -{ - return ust_app_ht; -} - /* * Return ust app pointer or NULL if not found. RCU read side lock MUST be * acquired before calling this function. @@ -3087,20 +3079,6 @@ void ust_app_unregister(int sock) return; } -/* - * Return traceable_app_count - */ -unsigned long ust_app_list_count(void) -{ - unsigned long count; - - rcu_read_lock(); - count = lttng_ht_get_count(ust_app_ht); - rcu_read_unlock(); - - return count; -} - /* * Fill events array with all events name of all registered apps. */ @@ -3538,65 +3516,6 @@ int ust_app_disable_event_glb(struct ltt_ust_session *usess, return ret; } -/* - * For a specific UST session and UST channel, the event for all - * registered apps. - */ -int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan) -{ - int ret = 0; - struct lttng_ht_iter iter, uiter; - struct lttng_ht_node_str *ua_chan_node; - struct ust_app *app; - struct ust_app_session *ua_sess; - struct ust_app_channel *ua_chan; - struct ust_app_event *ua_event; - - DBG("UST app disabling all event for all apps in channel " - "%s for session id %" PRIu64, uchan->name, usess->id); - - rcu_read_lock(); - - /* For all registered applications */ - cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) { - if (!app->compatible) { - /* - * TODO: In time, we should notice the caller of this error by - * telling him that this is a version error. - */ - continue; - } - ua_sess = lookup_session_by_app(usess, app); - if (!ua_sess) { - /* The application has problem or is probably dead. */ - continue; - } - - /* Lookup channel in the ust app session */ - lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &uiter); - ua_chan_node = lttng_ht_iter_get_node_str(&uiter); - /* If the channel is not found, there is a code flow error */ - assert(ua_chan_node); - - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); - - /* Disable each events of channel */ - cds_lfht_for_each_entry(ua_chan->events->ht, &uiter.iter, ua_event, - node.node) { - ret = disable_ust_app_event(ua_sess, ua_event, app); - if (ret < 0) { - /* XXX: Report error someday... */ - continue; - } - } - } - - rcu_read_unlock(); - - return ret; -} - /* * For a specific UST session, create the channel for all registered apps. */ @@ -4476,69 +4395,6 @@ end: return ret; } -/* - * Disable event for a channel from a UST session for a specific PID. - */ -int ust_app_disable_event_pid(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, pid_t pid) -{ - int ret = 0; - struct lttng_ht_iter iter; - struct lttng_ht_node_str *ua_chan_node, *ua_event_node; - struct ust_app *app; - struct ust_app_session *ua_sess; - struct ust_app_channel *ua_chan; - struct ust_app_event *ua_event; - - DBG("UST app disabling event %s for PID %d", uevent->attr.name, pid); - - rcu_read_lock(); - - app = ust_app_find_by_pid(pid); - if (app == NULL) { - ERR("UST app disable event per PID %d not found", pid); - ret = -1; - goto error; - } - - if (!app->compatible) { - ret = 0; - goto error; - } - - ua_sess = lookup_session_by_app(usess, app); - if (!ua_sess) { - /* The application has problem or is probably dead. */ - goto error; - } - - /* Lookup channel in the ust app session */ - lttng_ht_lookup(ua_sess->channels, (void *)uchan->name, &iter); - ua_chan_node = lttng_ht_iter_get_node_str(&iter); - if (ua_chan_node == NULL) { - /* Channel does not exist, skip disabling */ - goto error; - } - ua_chan = caa_container_of(ua_chan_node, struct ust_app_channel, node); - - lttng_ht_lookup(ua_chan->events, (void *)uevent->attr.name, &iter); - ua_event_node = lttng_ht_iter_get_node_str(&iter); - if (ua_event_node == NULL) { - /* Event does not exist, skip disabling */ - goto error; - } - ua_event = caa_container_of(ua_event_node, struct ust_app_event, node); - - ret = disable_ust_app_event(ua_sess, ua_event, app); - if (ret < 0) { - goto error; - } - -error: - rcu_read_unlock(); - return ret; -} - /* * Calibrate registered applications. */ diff --git a/src/bin/lttng-sessiond/ust-app.h b/src/bin/lttng-sessiond/ust-app.h index 252255710..fe040ae50 100644 --- a/src/bin/lttng-sessiond/ust-app.h +++ b/src/bin/lttng-sessiond/ust-app.h @@ -282,7 +282,6 @@ int ust_app_register_done(int sock) } int ust_app_version(struct ust_app *app); void ust_app_unregister(int sock); -unsigned long ust_app_list_count(void); int ust_app_start_trace_all(struct ltt_ust_session *usess); int ust_app_stop_trace_all(struct ltt_ust_session *usess); int ust_app_destroy_trace_all(struct ltt_ust_session *usess); @@ -292,9 +291,6 @@ int ust_app_create_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); int ust_app_create_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); -int ust_app_disable_event_pid(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - pid_t pid); int ust_app_enable_event_pid(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, pid_t pid); @@ -304,8 +300,6 @@ int ust_app_enable_channel_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); int ust_app_enable_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent); -int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan); int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan); int ust_app_disable_event_glb(struct ltt_ust_session *usess, @@ -316,7 +310,6 @@ void ust_app_global_update(struct ltt_ust_session *usess, int sock); void ust_app_clean_list(void); void ust_app_ht_alloc(void); -struct lttng_ht *ust_app_get_ht(void); struct ust_app *ust_app_find_by_pid(pid_t pid); int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate); struct ust_app_stream *ust_app_alloc_stream(void); @@ -391,11 +384,6 @@ void ust_app_unregister(int sock) { } static inline -unsigned int ust_app_list_count(void) -{ - return 0; -} -static inline void ust_app_lock_list(void) { } @@ -418,11 +406,6 @@ struct ust_app *ust_app_get_by_pid(pid_t pid) return NULL; } static inline -struct lttng_ht *ust_app_get_ht(void) -{ - return NULL; -} -static inline void ust_app_ht_alloc(void) {} static inline @@ -447,12 +430,6 @@ int ust_app_create_channel_glb(struct ltt_ust_session *usess, return 0; } static inline -int ust_app_disable_all_event_glb(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan) -{ - return 0; -} -static inline int ust_app_enable_all_event_glb(struct ltt_ust_session *usess, struct ltt_ust_channel *uchan) { @@ -490,13 +467,6 @@ int ust_app_enable_event_pid(struct ltt_ust_session *usess, return 0; } static inline -int ust_app_disable_event_pid(struct ltt_ust_session *usess, - struct ltt_ust_channel *uchan, struct ltt_ust_event *uevent, - pid_t pid) -{ - return 0; -} -static inline int ust_app_calibrate_glb(struct lttng_ust_calibrate *calibrate) { return 0; diff --git a/tests/unit/test_ust_data.c b/tests/unit/test_ust_data.c index 2f08b38c0..52b93e9f6 100644 --- a/tests/unit/test_ust_data.c +++ b/tests/unit/test_ust_data.c @@ -39,7 +39,7 @@ #define RANDOM_STRING_LEN 11 /* Number of TAP tests in this file */ -#define NUM_TESTS 12 +#define NUM_TESTS 10 /* For lttngerr.h */ int lttng_opt_quiet = 1; @@ -91,33 +91,6 @@ static void test_create_one_ust_session(void) trace_ust_destroy_session(usess); } -static void test_create_ust_metadata(void) -{ - struct ltt_ust_metadata *metadata; - - assert(usess != NULL); - - metadata = trace_ust_create_metadata(PATH1); - ok(metadata != NULL, "Create UST metadata"); - - ok(metadata->handle == -1 && - strlen(metadata->pathname) && - metadata->attr.overwrite - == DEFAULT_CHANNEL_OVERWRITE && - metadata->attr.subbuf_size - == default_get_metadata_subbuf_size() && - metadata->attr.num_subbuf - == DEFAULT_METADATA_SUBBUF_NUM && - metadata->attr.switch_timer_interval - == DEFAULT_METADATA_SWITCH_TIMER && - metadata->attr.read_timer_interval - == DEFAULT_METADATA_READ_TIMER && - metadata->attr.output == LTTNG_UST_MMAP, - "Validate UST session metadata"); - - trace_ust_destroy_metadata(metadata); -} - static void test_create_ust_channel(void) { struct ltt_ust_channel *uchan; @@ -226,7 +199,6 @@ int main(int argc, char **argv) diag("UST data structures unit test"); test_create_one_ust_session(); - test_create_ust_metadata(); test_create_ust_channel(); test_create_ust_event(); test_create_ust_context(); -- 2.34.1