Create stream files relative to a stream's current trace chunk
Create stream (and metadata) files relative to a session's current
trace chunk using the lttng_trace_chunk_open/unlink[...] functions
in the consumer daemons.
Four new commands are added to the sessiond <-> consumerd protocol:
- CREATE_TRACE_CHUNK
Command parameters:
- relayd_id: uint64_t
Unique ìd of the session's associated relay daemon connection
- override_name: optional char[]
Overriden chunk name. This field is not used by the consumer
daemon; it is forwarded to the relay daemon in order to set the
name of a trace chunk's directory when it should not follow the
`<ts begin>-<ts end>-<index>` form used by trace archives (i.e. as
produced by session rotations). This is used to preserve the
existing format of snapshot output directory names.
- sessiond_id: uint64_t
Unique id of the session (from the sessiond's perspective) to
which this trace chunk belongs.
- chunk_id: uint64_t
Unique id the the session's trace chunk.
- credentials: pair of uint32_t uid/gid
Credentials the consumer daemon should use in order to create
files within the trace chunk.
The session daemon maintains the current lttng_trace_chunk of an
ltt_session. When a session that has an output (`output_traces` == 1),
an lttng_trace_chunk is created.
In local tracing modes, the current trace chunk of a session, on the
session daemon's end, holds the ownership of the chunk's output
directory.
The CREATE_TRACE_CHUNK command is used to replicate the session
daemon's current trace chunk in the consumer daemon. This
representation of the current trace chunk has a different role. It
is created in "user" mode. Essentialy, the trace chunk's location
is opaque to the consumer daemon; it receives a directory file
descriptor from which a number of stream files will be created.
The trace chunk registry, as used by the consumer daemon, implicitly
owns the trace chunks on behalf of the session daemon. This is only
needed in the consumer since the consumer has no notion of a session
beyond session IDs being used to identify other objects.
When a channel is created, its session_id and initial chunk_id are
provided. This allows the consumer daemon to retrieve the session's
current trace chunk and associate it with the newly-created
channel. The channel holds a reference to its current trace chunk.
Streams created from a channel also hold a reference to their current
trace chunk, as retrived from their "parent" channel.
The life time of trace chunks in the consumer daemon is cooperatively
managed with the session daemon. This means
session daemon through the LTTNG_CONSUMER_CREATE_TRACE_CHUNK and
LTTNG_CONSUMER_CLOSE_TRACE_CHUNK commands.
- CLOSE_TRACE_CHUNK
[... TODO ...]
This command is used to release the global reference to a
given trace chunk in the consumer daemon. Relasing the consumer
daemon's global reference to the trace chunk leaves only the streams
to hold references until the moment when they are either closed or
they switch-over to another chunk in the event of a session rotation.
- TRACE_CHUNK_EXISTS
[... TODO ...]
- ADD_TRACE_CHUNK_CLOSE_COMMAND
[... TODO ...]
This commit changes a lot of code since it essentialy changes how
files and directories are created.
A number of commands no longer need to specify a `trace_archive_id`
since the CREATE_TRACE_CHUNK and CLOSE_TRACE_CHUNK allow the consumer
daemon to keep track of the current trace chunk of a channel at any
given time.
Creation and ownership of channel sub-directories
---
The path expressed in consumer channel objects is now relative to
the current trace chunk rather than being absolute. For example,
the `pathname` of a consumer channel is now of the form
`ust/1000/64-bit` rather than containing the full output path
`/home/me/lttng-traces/session-[...]/ust/1000/64-bit/`.
The subdirectory of a channel (relative to a trace chunk, e.g.
`ust/1000/64-bit`) is lazily created when a stream's output files are
created.
To do so, the `lttng_consumer_channel` now has a
`most_recent_chunk_id` attribute. When a stream creates its output files
(i.e. at the beginning of a session, or during a session rotation),
the stream's current trace chunk `id` is compared to the channel's
`most_recent_chunk_id`. If it is determined that the channel is
entering a new trace chunk, its channel subdirectory is created
relative to the stream's chunk.
Since this new state is within the `lttng_consumer_channel`, the
channel lock must be held on code paths that may result in the
creation of a new set of output files for a given stream.
Note that as of this commit, there is now a clear ownership boundary
between directories, owned by the session daemon through its trace
chunk, and files, owned by the consumer daemon.
Down-scoping of channel credentials
---
Since files are now created relative to their stream's current trace
chunk (which has credentials set), the fewer sites need access to the
channel's credentials. The only reason credentials are kept as part
of the consumer channel structure is the need to open and unlink UST
shared memory mappings. Since the credentials must only be used for
this purpose, they are now stored as an `LTTNG_OPTIONAL` field,
buffer_credentials, that is only set for UST channels.
Stream files should never need those credentials to be created.
The following commands sessiond <-> consumerd commands have been
removed:
- LTTNG_CONSUMER_ROTATE_RENAME
- LTTNG_CONSUMER_CHECK_ROTATION_PENDING_LOCAL
- LTTNG_CONSUMER_CHECK_ROTATION_PENDING_RELAY
- LTTNG_CONSUMER_MKDIR
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
38 files changed:
This page took 0.030694 seconds and 4 git commands to generate.