Add a command type argument to cmd_rotate_session().
Change the internal session_close_trace_chunk() API to introduce the
LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION command rather than rely on
a NULL pointer, which facilitates passing of command argument across
cmd_rotate_session.
This introduces the LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE command,
which is required for the clear feature. Its implementation will
follow in a separate commit.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic1d8cbab1f98b93f1f6d27a2c6624ac2780932e2
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
}
ret = cmd_rotate_session(cmd_ctx->session, &rotate_return,
- false);
+ false,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret < 0) {
ret = -ret;
goto error;
* was produced as the session was stopped, so the
* rotation should happen on reception of the command.
*/
- ret = cmd_rotate_session(session, NULL, true);
+ ret = cmd_rotate_session(session, NULL, true,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
if (ret != LTTNG_OK) {
goto error;
}
* Perform a last rotation on destruction if rotations have
* occurred during the session's lifetime.
*/
- ret = cmd_rotate_session(session, NULL, false);
+ ret = cmd_rotate_session(session, NULL, false,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret != LTTNG_OK) {
ERR("Failed to perform an implicit rotation as part of the destruction of session \"%s\": %s",
session->name, lttng_strerror(-ret));
* emitted and no renaming of the current trace chunk takes
* place.
*/
- ret = cmd_rotate_session(session, NULL, true);
+ ret = cmd_rotate_session(session, NULL, true,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION);
if (ret != LTTNG_OK) {
ERR("Failed to perform a quiet rotation as part of the destruction of session \"%s\": %s",
session->name, lttng_strerror(-ret));
}
}
- if (session_close_trace_chunk(
- session, session->current_trace_chunk, NULL, NULL)) {
+ if (session_close_trace_chunk(session, session->current_trace_chunk,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION, NULL)) {
/*
* Don't goto end; make sure the chunk is closed for the session
* to allow future snapshots.
*/
int cmd_rotate_session(struct ltt_session *session,
struct lttng_rotate_session_return *rotate_return,
- bool quiet_rotation)
+ bool quiet_rotation,
+ enum lttng_trace_chunk_command_type command)
{
int ret;
uint64_t ongoing_rotation_chunk_id;
assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
ret = session_close_trace_chunk(session, chunk_being_archived,
- quiet_rotation ?
- NULL :
- &((enum lttng_trace_chunk_command_type){
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED}),
- session->last_chunk_path);
+ command, session->last_chunk_path);
if (ret) {
cmd_ret = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
goto error;
int cmd_rotate_session(struct ltt_session *session,
struct lttng_rotate_session_return *rotate_return,
- bool quiet_rotation);
+ bool quiet_rotation,
+ enum lttng_trace_chunk_command_type command);
int cmd_rotate_get_info(struct ltt_session *session,
struct lttng_rotation_get_info_return *info_return,
uint64_t rotate_id);
DBG("[rotation-thread] Launching scheduled time-based rotation on session \"%s\"",
session->name);
- ret = cmd_rotate_session(session, &rotation_return, false);
+ ret = cmd_rotate_session(session, &rotation_return, false,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret == LTTNG_OK) {
DBG("[rotation-thread] Scheduled time-based rotation successfully launched on session \"%s\"",
session->name);
goto end_unlock;
}
- ret = cmd_rotate_session(session, NULL, false);
+ ret = cmd_rotate_session(session, NULL, false,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED);
if (ret == -LTTNG_ERR_ROTATION_PENDING) {
DBG("Rotate already pending, subscribe to the next threshold value");
} else if (ret != LTTNG_OK) {
goto end;
}
-int session_close_trace_chunk(const struct ltt_session *session,
+int session_close_trace_chunk(struct ltt_session *session,
struct lttng_trace_chunk *trace_chunk,
- const enum lttng_trace_chunk_command_type *close_command,
+ enum lttng_trace_chunk_command_type close_command,
char *closed_trace_chunk_path)
{
int ret = 0;
enum lttng_trace_chunk_status chunk_status;
const time_t chunk_close_timestamp = time(NULL);
- if (close_command) {
- chunk_status = lttng_trace_chunk_set_close_command(
- trace_chunk, *close_command);
- if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
- ret = -1;
- goto end;
- }
+ chunk_status = lttng_trace_chunk_set_close_command(
+ trace_chunk, close_command);
+ if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
+ ret = -1;
+ goto end;
}
if (chunk_close_timestamp == (time_t) -1) {
* Close a chunk on the remote peers of a session. Has no effect on the
* ltt_session itself.
*/
-int session_close_trace_chunk(const struct ltt_session *session,
+int session_close_trace_chunk(struct ltt_session *session,
struct lttng_trace_chunk *trace_chunk,
- const enum lttng_trace_chunk_command_type *close_command,
+ enum lttng_trace_chunk_command_type close_command,
char *path);
bool session_output_supports_trace_chunks(const struct ltt_session *session);
char *close_command_names[] = {
[LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED] =
"move to completed chunk folder",
+ [LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION] =
+ "no operation",
+ [LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE] =
+ "delete",
};
static const
DBG("Setting trace chunk close command to \"%s\"",
close_command_names[close_command]);
}
- LTTNG_OPTIONAL_SET(&chunk->close_command, close_command);
+ /*
+ * Unset close command for no-op for backward compatibility with relayd
+ * 2.11.
+ */
+ if (close_command != LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION) {
+ LTTNG_OPTIONAL_SET(&chunk->close_command, close_command);
+ } else {
+ LTTNG_OPTIONAL_UNSET(&chunk->close_command);
+ }
pthread_mutex_unlock(&chunk->lock);
end:
return status;
switch (command) {
case LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED:
return "move to completed trace chunk folder";
+ case LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION:
+ return "no operation";
+ case LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE:
+ return "delete";
default:
abort();
}
enum lttng_trace_chunk_command_type {
LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED = 0,
- LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_NO_OPERATION = 1,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_DELETE = 2,
+ LTTNG_TRACE_CHUNK_COMMAND_TYPE_MAX,
};
LTTNG_HIDDEN