Allow channel mode override in snapshot sessions
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 13 Apr 2016 22:08:44 +0000 (18:08 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 14 Apr 2016 16:34:06 +0000 (12:34 -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>
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 0119abf6a3a25e0849446de8de726d12d82fe79e..7bb0ff7e9311b4a043154970eae323dfda2a67d7 100644 (file)
@@ -214,9 +214,20 @@ 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) {
+               if (ksession->snapshot_mode) {
+                       attr->attr.overwrite = 1;
+               } else {
+                       attr->attr.overwrite = 0;
+               }
+       }
+
+       /* 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 +329,20 @@ 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) {
+               if (usess->snapshot_mode) {
+                       attr->attr.overwrite = 1;
+               } else {
+                       attr->attr.overwrite = 0;
+               }
+       }
+
+       /* 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 525464aa822d90b556308d830196eb38ed92b898..d8e4da4d8070b58e2e4fa8d76cb0508f757e6577 100644 (file)
@@ -442,7 +442,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 6e343b50c8425b5948abd853ccad9b7c375545db..fc48ff985a0a9bab5f97d8414ca8a2adf5693528 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  0
 #define DEFAULT_CHANNEL_TRACEFILE_COUNT 0
 
This page took 0.029008 seconds and 5 git commands to generate.