diff --git a/sys/cam/ctl/ctl.c b/sys/cam/ctl/ctl.c --- a/sys/cam/ctl/ctl.c +++ b/sys/cam/ctl/ctl.c @@ -68,6 +68,7 @@ #include #include #include +#include #include #include @@ -12819,6 +12820,16 @@ } } +#ifdef __i386__ +_Static_assert(sizeof(time_t) == 4, "time_t has unexpected size on this arch"); +#define atomic_add_time_t atomic_add_32 +#define atomic_load_time_t atomic_load_32 +#else +_Static_assert(sizeof(time_t) == 8, "time_t has unexpected size on this arch"); +#define atomic_add_time_t atomic_add_64 +#define atomic_load_time_t atomic_load_64 +#endif + static void ctl_process_done(union ctl_io *io) { @@ -12832,20 +12843,40 @@ fe_done = port->fe_done; #ifdef CTL_TIME_IO - if ((time_uptime - io->io_hdr.start_time) > ctl_time_io_secs) { - char str[256]; - char path_str[64]; - struct sbuf sb; - - ctl_scsi_path_string(io, path_str, sizeof(path_str)); - sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); - - ctl_io_sbuf(io, &sb); - sbuf_cat(&sb, path_str); - sbuf_printf(&sb, "ctl_process_done: %jd seconds\n", - (intmax_t)time_uptime - io->io_hdr.start_time); - sbuf_finish(&sb); - printf("%s", sbuf_data(&sb)); + static volatile time_t last_warn_time = 0; + time_t now, io_time, llwt; + static volatile int suppressed_warnings = 0; + int lsw; + + now = time_uptime; + io_time = now - io->io_hdr.start_time; + if (io_time > ctl_time_io_secs) { + llwt = atomic_load_time_t(&last_warn_time); + if (now - llwt > 1) { + char str[256]; + char path_str[64]; + struct sbuf sb; + + ctl_scsi_path_string(io, path_str, sizeof(path_str)); + sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); + + ctl_io_sbuf(io, &sb); + sbuf_cat(&sb, path_str); + sbuf_printf(&sb, "ctl_process_done: %jd seconds", + (intmax_t)io_time); + lsw = atomic_swap_int(&suppressed_warnings, 0); + if (lsw > 0) { + sbuf_printf(&sb, + " (suppressed %d similar warnings)", + lsw); + } + sbuf_putc(&sb, '\n'); + sbuf_finish(&sb); + printf("%s", sbuf_data(&sb)); + atomic_add_time_t(&last_warn_time, now - llwt); + } else { + atomic_add_int(&suppressed_warnings, 1); + } } #endif /* CTL_TIME_IO */