in channel.c [229:284]
static int send_modifychannel_with_ack(struct vmbus_channel *channel, u32 target_vp)
{
struct vmbus_channel_modifychannel *msg;
struct vmbus_channel_msginfo *info;
unsigned long flags;
int ret;
info = kzalloc(sizeof(struct vmbus_channel_msginfo) +
sizeof(struct vmbus_channel_modifychannel),
GFP_KERNEL);
if (!info)
return -ENOMEM;
init_completion(&info->waitevent);
info->waiting_channel = channel;
msg = (struct vmbus_channel_modifychannel *)info->msg;
msg->header.msgtype = CHANNELMSG_MODIFYCHANNEL;
msg->child_relid = channel->offermsg.child_relid;
msg->target_vp = target_vp;
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_add_tail(&info->msglistentry, &vmbus_connection.chn_msg_list);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
ret = vmbus_post_msg(msg, sizeof(*msg), true);
trace_vmbus_send_modifychannel(msg, ret);
if (ret != 0) {
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&info->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
goto free_info;
}
/*
* Release channel_mutex; otherwise, vmbus_onoffer_rescind() could block on
* the mutex and be unable to signal the completion.
*
* See the caller target_cpu_store() for information about the usage of the
* mutex.
*/
mutex_unlock(&vmbus_connection.channel_mutex);
wait_for_completion(&info->waitevent);
mutex_lock(&vmbus_connection.channel_mutex);
spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
list_del(&info->msglistentry);
spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
if (info->response.modify_response.status)
ret = -EAGAIN;
free_info:
kfree(info);
return ret;
}