Skip to content

Commit

Permalink
vdev: log waiting of the first GET_FEATURES request
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitrii Iakunin <[email protected]>
  • Loading branch information
zeil committed Feb 3, 2025
1 parent ac74e30 commit fb2e7d5
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,10 @@ static void arm_msg_handling_timer(struct vhd_vdev *vdev, int secs)
timerfd_settime(vdev->timerfd, 0, &itimer, NULL);
}

/* Every so many seconds report if the message is still being handled */
/* Report every so many seconds if we haven't received GET_FEATURES request */
#define MSG_GET_FEATURES_WAITING_LOG_INTERVAL 30

/* Report every so many seconds if the message is still being handled */
#define MSG_HANDLING_LOG_INTERVAL 30

#ifdef VHD_DEBUG
Expand All @@ -591,9 +594,15 @@ static void arm_msg_handling_timer(struct vhd_vdev *vdev, int secs)
#define MSG_ELAPSED_NSEC_LOG_THRESHOLD (500 * NSEC_PER_MSEC)
#endif


static void vdev_handle_start(struct vhd_vdev *vdev, uint32_t req,
bool ack_pending)
{
/* we need to detach timer_handler only before very first GET_FEATURES request */
if (vdev->supported_features == 0) {
vhd_detach_io_handler(vdev->timer_handler);
}

/* do not accept further messages until this one is fully handled */
vhd_detach_io_handler(vdev->conn_handler);

Expand Down Expand Up @@ -1978,9 +1987,13 @@ static int timer_read(void *opaque)

elapsed_time(vdev, &elapsed);

VHD_OBJ_WARN(vdev, "long processing %s (%u): elapsed %jd.%03lds",
vhost_req_name(vdev->req), vdev->req,
(intmax_t)elapsed.tv_sec, elapsed.tv_nsec / NSEC_PER_MSEC);
if (vdev->supported_features) {
VHD_OBJ_WARN(vdev, "long processing %s (%u): elapsed %jd.%03lds",
vhost_req_name(vdev->req), vdev->req,
(intmax_t)elapsed.tv_sec, elapsed.tv_nsec / NSEC_PER_MSEC);
} else {
VHD_OBJ_WARN(vdev, "Still waiting for GET_FEATURES request...");
}

return 0;
}
Expand Down Expand Up @@ -2018,18 +2031,22 @@ static int server_read(void *opaque)
if (!timer_handler) {
goto close_timer;
}
/* it only needs to be attached during message handling */
vhd_detach_io_handler(timer_handler);

vhd_detach_io_handler(vdev->listen_handler);

vdev->connfd = connfd;
vdev->conn_handler = conn_handler;
vdev->timerfd = timerfd;
vdev->timer_handler = timer_handler;
vdev->negotiated_features = 0;
vdev->supported_protocol_features = 0;
vdev->negotiated_protocol_features = 0;
/* supported_features is being set on handling first GET_FEATURES request */
vdev->supported_features = 0;
vdev->negotiated_features = 0;
VHD_OBJ_INFO(vdev, "Connection established, sock = %d", connfd);

arm_msg_handling_timer(vdev, MSG_GET_FEATURES_WAITING_LOG_INTERVAL);

return 0;

close_timer:
Expand Down

0 comments on commit fb2e7d5

Please sign in to comment.