Allow channel mode override in snapshot sessions
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 20 Apr 2016 15:19:58 +0000 (11:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 16 Jun 2016 13:54:21 +0000 (09:54 -0400)
Allow the lttng cmd line and liblttng-ctl users to override the channel
mode in snapshot sessions.

Note that liblttng-ctl users expecting that an "overwrite" mode
explicitly set at the value "0" (discard) for a snapshot session will
now create a channel in discard mode.

The DEFAULT_CHANNEL_OVERWRITE used by liblttng-ctl
lttng_channel_set_default_attr() is changed to "-1".

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/lttng/channel.h
src/bin/lttng-sessiond/channel.c
src/bin/lttng/commands/create.c
src/common/defaults.h

index 622ce85e9f30bbcf01cd15cb1a3abc418813f3de..732074c3ae99d8c137483cd792e62e4dbafd2da4 100644 (file)
@@ -33,7 +33,7 @@ extern "C" {
  */
 #define LTTNG_CHANNEL_ATTR_PADDING1        LTTNG_SYMBOL_NAME_LEN + 12
 struct lttng_channel_attr {
-       int overwrite;                      /* 1: overwrite, 0: discard */
+       int overwrite;                      /* -1: session default, 1: overwrite, 0: discard */
        uint64_t subbuf_size;               /* bytes, power of 2 */
        uint64_t num_subbuf;                /* power of 2 */
        unsigned int switch_timer_interval; /* usec */
index f35410e3ae3fe85c1a7b05e87d3c25e5865795ae..88480c4b4e7b78fd63a2edc744618eadba0c36bc 100644 (file)
@@ -214,9 +214,16 @@ int channel_kernel_create(struct ltt_kernel_session *ksession,
                attr = defattr;
        }
 
+       /*
+        * Set the overwrite mode for this channel based on the session
+        * type unless the client explicitly overrides the channel mode.
+        */
+       if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
+               attr->attr.overwrite = !!ksession->snapshot_mode;
+       }
+
+       /* Enforce mmap output for snapshot sessions. */
        if (ksession->snapshot_mode) {
-               /* Force channel attribute for snapshot mode. */
-               attr->attr.overwrite = 1;
                attr->attr.output = LTTNG_EVENT_MMAP;
        }
 
@@ -318,9 +325,16 @@ int channel_ust_create(struct ltt_ust_session *usess,
                }
        }
 
+       /*
+        * Set the overwrite mode for this channel based on the session
+        * type unless the client explicitly overrides the channel mode.
+        */
+       if (attr->attr.overwrite == DEFAULT_CHANNEL_OVERWRITE) {
+               attr->attr.overwrite = !!usess->snapshot_mode;
+       }
+
+       /* Enforce mmap output for snapshot sessions. */
        if (usess->snapshot_mode) {
-               /* Force channel attribute for snapshot mode. */
-               attr->attr.overwrite = 1;
                attr->attr.output = LTTNG_EVENT_MMAP;
        }
 
index 3379a3b27b8638a3f3455af6cc4b0dca981a90b5..0ae2b10968456adc54d4df7f4985458268c4e8f7 100644 (file)
@@ -439,7 +439,7 @@ static int create_session(void)
                        MSG("Default snapshot output set to: %s", print_str_url);
                }
                MSG("Snapshot mode set. Every channel enabled for that session will "
-                               "be set in overwrite mode and mmap output.");
+                               "be set to mmap output, and default to overwrite mode.");
        }
        if (opt_shm_path) {
                MSG("Session %s set to shm_path: %s.", session_name,
index 59fe8ec46054b9314e2284c87db5d1a0fa6fe5b9..f05030766a77be8dae7452e4fdaae94205378d79 100644 (file)
 #define DEFAULT_PYTHON_EVENT_COMPONENT    "lttng_python"
 #define DEFAULT_PYTHON_EVENT_NAME         DEFAULT_PYTHON_EVENT_COMPONENT ":*"
 
-#define DEFAULT_CHANNEL_OVERWRITE       0
+#define DEFAULT_CHANNEL_OVERWRITE       -1
 #define DEFAULT_CHANNEL_TRACEFILE_SIZE  CONFIG_DEFAULT_CHANNEL_TRACEFILE_SIZE
 #define DEFAULT_CHANNEL_TRACEFILE_COUNT CONFIG_DEFAULT_CHANNEL_TRACEFILE_COUNT
 
This page took 0.029301 seconds and 5 git commands to generate.