/* drbd_send_state() - Sends the drbd state to the peer @mdev: DRBD device.  */
int drbd_send_state(struct drbd_conf *mdev)
/* drbd_send_state() - Sends the drbd state to the peer @mdev: DRBD device.  */
int drbd_send_state(struct drbd_conf *mdev)
{
	struct socket *sock;
	struct p_state p;
	int ok = 0;
	drbd_state_lock(mdev);
	mutex_lock(&mdev->data.mutex);
	p.state = cpu_to_be32(mdev->state.i);
	sock = mdev->data.socket;
	if (likely(sock != NULL)) {
		ok = _drbd_send_cmd(mdev, sock, P_STATE,
				    (struct p_header *)&p, sizeof(p), 0);
	}
	mutex_unlock(&mdev->data.mutex);
	drbd_state_unlock(mdev);
	return ok;
}