[stgt] [PATCH 1/2] Add infrastructure for statistics on SCSI device level

Alexander Nezhinsky nezhinsky at gmail.com
Thu Jun 28 09:58:44 CEST 2012

On Wed, Jun 27, 2012 at 4:14 PM, FUJITA Tomonori
<fujita.tomonori at lab.ntt.co.jp> wrote:
> On Wed, 20 Jun 2012 19:01:42 +0300
> Alexander Nezhinsky <alexandern at mellanox.com> wrote:
> > To introduce statistics on SCSI device level we need to accumulate them
> > for each ITL (initiator-target-lun) nexus.
> >
> > For example in case of iscsi, this is a granularity which is finer than
> > a session (IT nexus), as it represents access to a specific lun within
> > the session.
> >
> > Statistics counters are added to the ITL object, "struct it_nexus_lu_info".
> > They need to be shown later in various scopes (connection, device, target etc.)
> > requiring two-way access, both from a device (lun to all its ITLs) and
> > from an IT nexus (IT nexus to all its ITLs).

> You guys really need this fine granularity. I feel that it's too
> much. Linux kernel doesn't provide such?


I think it gives maximum flexibility at no price.
Every command is accounted for only once, while finding the right
ITL-nexus struct
to update the counters costs just as much as reaching any other struct,
and still all possible combinations of statistics "splits" are possible.

The proposed change in data structures also makes them more versatile and ready
for other potential usage cases where ITL level is relevant.

> @@ -201,6 +201,20 @@ int scsi_cmd_perform(int host_no, struct scsi_cmd *cmd)
>       unsigned char op = cmd->scb[0];
>       struct it_nexus_lu_info *itn_lu;
> +     if (scsi_get_data_dir(cmd) == DATA_WRITE) {
> +             cmd->itn_lu_info->stat.wr_subm_sect += scsi_get_out_length(cmd) / 512;

> The sector size is always expected to be 512?

Of course not. 512 was chosen as a minimal data unit. For example we
can count in KB
but then we mis-represent some cmds accessing odd multiples of 512.
We can divide by the actual LUN's logical sector size but then the
statistics can look quite
misleading and when compared across LUNs.
Thus 512 was chosen as a minimal unit, as the simplest alternative to
just counting bytes.
Counting bytes also makes the numbers grow very fast and counters flip
to zero quite often.
What do you think?

To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

More information about the stgt mailing list