From: David Goulet Date: Fri, 12 Jul 2013 14:53:59 +0000 (-0400) Subject: Add the number of snapshot taken to the output path X-Git-Tag: v2.3.0-rc1~37 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1bfe73287bb3776cdba5a76d5a812ef79820bf10;p=lttng-tools.git Add the number of snapshot taken to the output path This number of snapshots is per session. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 636450782..f55c772c1 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2584,7 +2584,7 @@ int cmd_snapshot_record(struct ltt_session *session, int ret = LTTNG_OK; unsigned int use_tmp_output = 0; struct snapshot_output tmp_output; - unsigned int nb_streams; + unsigned int nb_streams, snapshot_success = 0; assert(session); @@ -2618,6 +2618,8 @@ int cmd_snapshot_record(struct ltt_session *session, } goto error; } + /* Use the global session count for the temporary snapshot. */ + tmp_output.nb_snapshot = session->snapshot.nb_snapshot; use_tmp_output = 1; } @@ -2636,6 +2638,7 @@ int cmd_snapshot_record(struct ltt_session *session, if (ret < 0) { goto error; } + snapshot_success = 1; } else { struct snapshot_output *sout; struct lttng_ht_iter iter; @@ -2661,12 +2664,15 @@ int cmd_snapshot_record(struct ltt_session *session, sizeof(tmp_output.name)); } + tmp_output.nb_snapshot = session->snapshot.nb_snapshot; + ret = record_kernel_snapshot(ksess, &tmp_output, session, wait, nb_streams); if (ret < 0) { rcu_read_unlock(); goto error; } + snapshot_success = 1; } rcu_read_unlock(); } @@ -2681,6 +2687,7 @@ int cmd_snapshot_record(struct ltt_session *session, if (ret < 0) { goto error; } + snapshot_success = 1; } else { struct snapshot_output *sout; struct lttng_ht_iter iter; @@ -2708,17 +2715,24 @@ int cmd_snapshot_record(struct ltt_session *session, sizeof(tmp_output.name)); } + tmp_output.nb_snapshot = session->snapshot.nb_snapshot; + ret = record_ust_snapshot(usess, &tmp_output, session, wait, nb_streams); if (ret < 0) { rcu_read_unlock(); goto error; } + snapshot_success = 1; } rcu_read_unlock(); } } + if (snapshot_success) { + session->snapshot.nb_snapshot++; + } + error: return ret; } diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index 66fecd617..79fdbf1c8 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -1232,8 +1232,9 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, msg.u.snapshot_channel.relayd_id = output->consumer->net_seq_index; msg.u.snapshot_channel.use_relayd = 1; ret = snprintf(msg.u.snapshot_channel.pathname, - sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->subdir, output->name, output->datetime, + sizeof(msg.u.snapshot_channel.pathname), + "%s/%s-%s-%" PRIu64 "%s", output->consumer->subdir, + output->name, output->datetime, output->nb_snapshot, session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; @@ -1241,9 +1242,10 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, } } else { ret = snprintf(msg.u.snapshot_channel.pathname, - sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s", - output->consumer->dst.trace_path, output->name, - output->datetime, session_path); + sizeof(msg.u.snapshot_channel.pathname), + "%s/%s-%s-%" PRIu64 "%s", output->consumer->dst.trace_path, + output->name, output->datetime, output->nb_snapshot, + session_path); if (ret < 0) { ret = -LTTNG_ERR_NOMEM; goto error; diff --git a/src/bin/lttng-sessiond/snapshot.h b/src/bin/lttng-sessiond/snapshot.h index a505128a6..bdf057036 100644 --- a/src/bin/lttng-sessiond/snapshot.h +++ b/src/bin/lttng-sessiond/snapshot.h @@ -32,6 +32,8 @@ struct consumer_output; struct snapshot_output { uint32_t id; uint64_t max_size; + /* Number of snapshot taken with that output. */ + uint64_t nb_snapshot; char name[NAME_MAX]; struct consumer_output *consumer; int kernel_sockets_copied; @@ -50,6 +52,11 @@ struct snapshot_output { struct snapshot { unsigned long next_output_id; size_t nb_output; + /* + * Number of snapshot taken for that object. This value is used with a + * temporary output of a snapshot record. + */ + uint64_t nb_snapshot; struct lttng_ht *output_ht; };