On 7/18/19 9:22 AM, Eric Blake wrote:
On 6/29/19 8:28 AM, Eric Blake wrote:
>
> We also want the client to be aware of any issued/in-flight commands
> that failed because they were stranded when the state machine moved to
> CLOSED or DEAD. Previously, nbd_aio_command_completed() would never
> locate such stranded commands, but adding a common point to fire the
> notifier for such commands makes it also possible to move those
> commands to the completion queue.
>
> +++ b/generator/states.c
> @@ -111,6 +111,31 @@ send_from_wbuf (struct nbd_handle *h)
> return 0; /* move to next state */
> }
>
> +/* Forcefully fail any remaining in-flight commands in list */
> +void abort_commands (struct nbd_handle *h,
> + struct command_in_flight **list)
> +{
> + struct command_in_flight *prev_cmd, *cmd;
> +
> + for (cmd = *list, prev_cmd = NULL;
> + cmd != NULL;
> + prev_cmd = cmd, cmd = cmd->next) {
> + if (cmd->cb.notify && cmd->type != NBD_CMD_DISC) {
> + int error = cmd->error ? cmd->error : ENOTCONN;
> +
> + if (cmd->cb.notify (cmd->cb.opaque, cmd->handle, &error) == -1
&& error)
> + cmd->error = error;
> + }
> + if (cmd->error == 0)
> + cmd->error = ENOTCONN;
> + }
> + if (prev_cmd) {
> + prev_cmd->next = h->cmds_done;
> + h->cmds_done = *list;
> + *list = NULL;
> + }
This inserts the list to the head of cmds_done, which breaks its use as
a FIFO queue for clients using nbd_aio_peek_command_completed to process
messages in server order. I'll post a fix that keeps things in order.
It also failed to keep in_flight up-to-date.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization:
qemu.org |
libvirt.org