svn commit: r267933 - head/sys/cam/ctl
Alexander Motin
mav at FreeBSD.org
Thu Jun 26 20:06:37 UTC 2014
Author: mav
Date: Thu Jun 26 20:06:37 2014
New Revision: 267933
URL: http://svnweb.freebsd.org/changeset/base/267933
Log:
Simplify statistics calculation.
Instead of trying to guess size of disk I/O operations (it just won't work
that way for newly added commands, and is equal to data move size for old
ones), account data move traffic. If disk I/Os are that interesting, then
backends have to account and provide that information.
Block backend already exports the information about disk I/Os via devstat,
so having it here too is excessive.
MFC after: 2 weeks
Modified:
head/sys/cam/ctl/ctl.c
Modified: head/sys/cam/ctl/ctl.c
==============================================================================
--- head/sys/cam/ctl/ctl.c Thu Jun 26 20:02:29 2014 (r267932)
+++ head/sys/cam/ctl/ctl.c Thu Jun 26 20:06:37 2014 (r267933)
@@ -12900,132 +12900,34 @@ ctl_process_done(union ctl_io *io)
*
* XXX KDM should we also track I/O latency?
*/
- if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS) {
- uint32_t blocksize;
+ if ((io->io_hdr.status & CTL_STATUS_MASK) == CTL_SUCCESS &&
+ io->io_hdr.io_type == CTL_IO_SCSI) {
#ifdef CTL_TIME_IO
struct bintime cur_bt;
#endif
+ int type;
- if ((lun->be_lun != NULL)
- && (lun->be_lun->blocksize != 0))
- blocksize = lun->be_lun->blocksize;
+ if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) ==
+ CTL_FLAG_DATA_IN)
+ type = CTL_STATS_READ;
+ else if ((io->io_hdr.flags & CTL_FLAG_DATA_MASK) ==
+ CTL_FLAG_DATA_OUT)
+ type = CTL_STATS_WRITE;
else
- blocksize = 512;
-
- switch (io->io_hdr.io_type) {
- case CTL_IO_SCSI: {
- int isread;
- struct ctl_lba_len_flags *lbalen;
-
- isread = 0;
- switch (io->scsiio.cdb[0]) {
- case READ_6:
- case READ_10:
- case READ_12:
- case READ_16:
- isread = 1;
- /* FALLTHROUGH */
- case WRITE_6:
- case WRITE_10:
- case WRITE_12:
- case WRITE_16:
- case WRITE_VERIFY_10:
- case WRITE_VERIFY_12:
- case WRITE_VERIFY_16:
- lbalen = (struct ctl_lba_len_flags *)
- &io->io_hdr.ctl_private[CTL_PRIV_LBA_LEN];
-
- if (isread) {
- lun->stats.ports[targ_port].bytes[CTL_STATS_READ] +=
- lbalen->len * blocksize;
- lun->stats.ports[targ_port].operations[CTL_STATS_READ]++;
-
-#ifdef CTL_TIME_IO
- bintime_add(
- &lun->stats.ports[targ_port].dma_time[CTL_STATS_READ],
- &io->io_hdr.dma_bt);
- lun->stats.ports[targ_port].num_dmas[CTL_STATS_READ] +=
- io->io_hdr.num_dmas;
- getbintime(&cur_bt);
- bintime_sub(&cur_bt,
- &io->io_hdr.start_bt);
-
- bintime_add(
- &lun->stats.ports[targ_port].time[CTL_STATS_READ],
- &cur_bt);
-
-#if 0
- cs_prof_gettime(&cur_ticks);
- lun->stats.time[CTL_STATS_READ] +=
- cur_ticks -
- io->io_hdr.start_ticks;
-#endif
-#if 0
- lun->stats.time[CTL_STATS_READ] +=
- jiffies - io->io_hdr.start_time;
-#endif
-#endif /* CTL_TIME_IO */
- } else {
- lun->stats.ports[targ_port].bytes[CTL_STATS_WRITE] +=
- lbalen->len * blocksize;
- lun->stats.ports[targ_port].operations[
- CTL_STATS_WRITE]++;
-
-#ifdef CTL_TIME_IO
- bintime_add(
- &lun->stats.ports[targ_port].dma_time[CTL_STATS_WRITE],
- &io->io_hdr.dma_bt);
- lun->stats.ports[targ_port].num_dmas[CTL_STATS_WRITE] +=
- io->io_hdr.num_dmas;
- getbintime(&cur_bt);
- bintime_sub(&cur_bt,
- &io->io_hdr.start_bt);
-
- bintime_add(
- &lun->stats.ports[targ_port].time[CTL_STATS_WRITE],
- &cur_bt);
-#if 0
- cs_prof_gettime(&cur_ticks);
- lun->stats.ports[targ_port].time[CTL_STATS_WRITE] +=
- cur_ticks -
- io->io_hdr.start_ticks;
- lun->stats.ports[targ_port].time[CTL_STATS_WRITE] +=
- jiffies - io->io_hdr.start_time;
-#endif
-#endif /* CTL_TIME_IO */
- }
- break;
- default:
- lun->stats.ports[targ_port].operations[CTL_STATS_NO_IO]++;
+ type = CTL_STATS_NO_IO;
+ lun->stats.ports[targ_port].bytes[type] +=
+ io->scsiio.kern_total_len;
+ lun->stats.ports[targ_port].operations[type]++;
#ifdef CTL_TIME_IO
- bintime_add(
- &lun->stats.ports[targ_port].dma_time[CTL_STATS_NO_IO],
- &io->io_hdr.dma_bt);
- lun->stats.ports[targ_port].num_dmas[CTL_STATS_NO_IO] +=
- io->io_hdr.num_dmas;
- getbintime(&cur_bt);
- bintime_sub(&cur_bt, &io->io_hdr.start_bt);
-
- bintime_add(&lun->stats.ports[targ_port].time[CTL_STATS_NO_IO],
- &cur_bt);
-
-#if 0
- cs_prof_gettime(&cur_ticks);
- lun->stats.ports[targ_port].time[CTL_STATS_NO_IO] +=
- cur_ticks -
- io->io_hdr.start_ticks;
- lun->stats.ports[targ_port].time[CTL_STATS_NO_IO] +=
- jiffies - io->io_hdr.start_time;
+ bintime_add(&lun->stats.ports[targ_port].dma_time[type],
+ &io->io_hdr.dma_bt);
+ lun->stats.ports[targ_port].num_dmas[type] +=
+ io->io_hdr.num_dmas;
+ getbintime(&cur_bt);
+ bintime_sub(&cur_bt, &io->io_hdr.start_bt);
+ bintime_add(&lun->stats.ports[targ_port].time[type], &cur_bt);
#endif
-#endif /* CTL_TIME_IO */
- break;
- }
- break;
- }
- default:
- break;
- }
}
/*
More information about the svn-src-head
mailing list