From: Mike Christie <mchristi@redhat.com>
To: target-devel@vger.kernel.org
Subject: Re: tcmu: Reporting of errors detected by handler_read() before it returns
Date: Fri, 02 Aug 2019 16:27:01 +0000 [thread overview]
Message-ID: <5D446455.4080100@redhat.com> (raw)
In-Reply-To: <9f2e4a82-a16f-80bb-2c5d-847ec2d24c5f@gmail.com>
On 08/02/2019 11:20 AM, David Butterfield wrote:
> On 8/1/19 10:18 AM, Mike Christie wrote:
>> Update your tcmu-runner git repo :)
>>
>> A little bit ago, the comments in tcmu-runner.h were updated to make it
>> clear what type of handler can do what, and also support for not having
>> to call cmd->done in handlers like file_example was added.
>
> I've pulled the latest master and the comment has been revised, but part
> of my question still remains:
>
> If the handler successfully completes execution of the block I/O command
> in the callout function, what TCMU_STS code should it return from the
> callout function?
>
> It can't be TCMU_STS_OK, right? Because that would leave tcmu-runner
> expecting a call to cmd->done() later.
>
> And it can't be a TCMU_STS error, because the I/O was successful.
>
> So what does the handler return to indicate both success and completion?
What is says on line 128.
You must return a TCMU_STS code. It can TMCU_STS_OK or a TCMU_STS error
value like TCMU_STS_WR_ERR.
For handlers like file_example that operate like described on line 128,
tcmu-runner core will do cmd->done for it.
>
> 125 /*
> 126 * Below callouts are only executed by generic_handle_cmd.
> 127 *
> 128 * Handlers that completely execute cmds from the callout's calling
> 129 * context must return a TCMU_STS code from the callout.
> 130 *
> 131 * Async handlers that queue a command from the callout and complete
> 132 * it from their own async context return:
> 133 * - TCMU_STS_OK if the handler has queued the command.
> 134 * - TCMU_STS_NO_RESOURCE if the handler was not able to allocate
> 135 * resources to queue the command.
> 136 *
> 137 * If TCMU_STS_OK is returned from the callout the handler must call
> 138 * tcmur_cmd_complete with a TCMU_STS return code to complete the
> 139 * command.
> 140 */
> 141 int (*read)(struct tcmu_device *dev, struct tcmur_cmd *cmd,
> 142 struct iovec *iovec, size_t iov_cnt, size_t len, off_t off);
> 143 int (*write)(struct tcmu_device *dev, struct tcmur_cmd *cmd,
> 144 struct iovec *iovec, size_t iov_cnt, size_t len, off_t off);
> 145 int (*flush)(struct tcmu_device *dev, struct tcmur_cmd *cmd);
>
>
>>> However, the code in file_example.c does not do either of those things, and directly
>>> violates the comment in tcmu-runner.h -- this excerpt is from file_read():
file_example operates like described in line 128.
>>>
>>> while (remaining) {
>>> ret = preadv(state->fd, iov, iov_cnt, offset);
>>> if (ret < 0) {
>>> tcmu_err("read failed: %m\n");
>>> ret = TCMU_STS_RD_ERR;
>>> goto done;
>>> }
>>> ...
>>> }
>>> ret = TCMU_STS_OK;
>>> done:
>>> return ret;
>>>
>>> The file_read() function operates synchronously, and never issues a call to cmd->done()
>>> for successful reads returning TCMU_STS_OK, contradicting the comment in tcmu-runner.h.
>
next prev parent reply other threads:[~2019-08-02 16:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-02 16:20 tcmu: Reporting of errors detected by handler_read() before it returns David Butterfield
2019-08-02 16:27 ` Mike Christie [this message]
2019-08-08 5:50 ` David Butterfield
2019-08-08 18:02 ` Michael Christie
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=5D446455.4080100@redhat.com \
--to=mchristi@redhat.com \
--cc=target-devel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.