From: Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Linux Trace Devel <linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 6/8] trace-cmd output: Set file_state of output handle after copy of headers
Date: Tue, 2 Mar 2021 16:51:56 +0200 [thread overview]
Message-ID: <CAPpZLN6v9swL2osRXG6nV_2J3zxvcSA1m9-LOA-30-pg3Z65Qw@mail.gmail.com> (raw)
In-Reply-To: <20210302091949.263d02c8@gandalf.local.home>
On Tue, Mar 2, 2021 at 4:19 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Tue, 2 Mar 2021 10:10:24 +0200
> Tzvetomir Stoyanov <tz.stoyanov@gmail.com> wrote:
>
> > On Mon, Mar 1, 2021 at 4:38 PM Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> > >
> > > Now that the input and output handles know the state they are at in reading
> > > or writing, the tracecmd_copy() has to set the state of the output handle it
> > > creates.
> > >
> > > Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> > > ---
> > > lib/trace-cmd/trace-output.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
> > > index 6d504cbaf133..1156899a85d3 100644
> > > --- a/lib/trace-cmd/trace-output.c
> > > +++ b/lib/trace-cmd/trace-output.c
> > > @@ -1656,6 +1656,8 @@ struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle,
> > > if (tracecmd_copy_headers(ihandle, handle->fd) < 0)
> > > goto out_free;
> > >
> > > + handle->file_state = TRACECMD_FILE_CMD_LINES;
> >
> > Why is the state overwritten here, isn't it more logical to be set in
> > tracecmd_copy_headers(), by each function that copies a header to set
>
> That's because the handle is not passed into tracecmd_copy_headers.
>
> And because the handle is a struct tracecmd_output, the
> tracecmd_copy_headers() which is in trace-input.c doesn't have access to
> this structure, and I prefer to keep it that way.
>
> That said, we could modify tracecmd_copy_header() to return the state that
> it copied up to, or negative on error.
>
> state = tracecmd_copy_headers(ihandle, handle->fd);
> if (state < 0)
> goto out_free;
>
> handle->file_state = state;
The output handle should have the same state as the input handle,
so we can just have:
handle->file_state = tracecmd_get_file_state(ihandle);
There is exactly the same use case in tracecmd_get_output_handle_fd(),
where the out handle is built on a partially written file.
>
> That would be more robust!
>
> -- Steve
>
>
> > the relevant state. The last call in tracecmd_copy_headers()
> > is copy_command_lines(), which should set state to
> > TRACECMD_FILE_CMD_LINES in case of success.
> > The state is already TRACECMD_FILE_CMD_LINES
> > in tracecmd_copy_headers(), but right before its exit it
> > is overwritten to the old file state. And here again it is
> > overwritten back to TRACECMD_FILE_CMD_LINES.
> > May be I miss something here, cannot understand the logic.
> >
> > > +
> > > /* The file is all ready to have cpu data attached */
> > > return handle;
> > >
> > > --
> > > 2.30.0
> > >
> > >
> >
> >
>
--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center
next prev parent reply other threads:[~2021-03-03 0:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-01 14:37 [PATCH 0/8] trace-cmd: Fixes for trace-cmd restore Steven Rostedt
2021-03-01 14:37 ` [PATCH 1/8] trace-cmd restore: Fix to add saved cmdlines after calling tracecmd_create_init_file_override() Steven Rostedt
2021-03-01 14:37 ` [PATCH 2/8] trace-cmd: Create API tracecmd_read_pre_headers() Steven Rostedt
2021-03-02 4:49 ` Tzvetomir Stoyanov
2021-03-02 14:13 ` Steven Rostedt
2021-03-01 14:37 ` [PATCH 3/8] trace-cmd: Move tracecmd_write_cmdlines() out of tracecmd_append_cpu_data() Steven Rostedt
2021-03-01 14:37 ` [PATCH 4/8] trace-cmd: Move the output state updates into the functions that change the state Steven Rostedt
2021-03-01 14:37 ` [PATCH 5/8] trace-cmd: Move the input " Steven Rostedt
2021-03-01 14:37 ` [PATCH 6/8] trace-cmd output: Set file_state of output handle after copy of headers Steven Rostedt
2021-03-02 8:10 ` Tzvetomir Stoyanov
2021-03-02 14:19 ` Steven Rostedt
2021-03-02 14:51 ` Tzvetomir Stoyanov [this message]
2021-03-02 15:48 ` Steven Rostedt
2021-03-02 17:35 ` Tzvetomir Stoyanov
2021-03-02 19:59 ` Steven Rostedt
2021-03-02 14:22 ` Steven Rostedt
2021-03-01 14:37 ` [PATCH 7/8] trace-cmd input: Validate the input handle when copying from it Steven Rostedt
2021-03-01 14:37 ` [PATCH 8/8] trace-cmd input: Add validation updates to the copy of a handle Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPpZLN6v9swL2osRXG6nV_2J3zxvcSA1m9-LOA-30-pg3Z65Qw@mail.gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).