Message ID | 20221114135043.2958100-2-j.granados@samsung.com |
---|---|
State | New |
Headers | show |
Series | Add OCP extended log to nvme QEMU | expand |
On Nov 14 14:50, Joel Granados wrote: > In order to return the units_{read/written} required by the SMART log we > need to shift the number of bytes value by BDRV_SECTORS_BITS and multiply > by 1000. This is a prep patch that moves this adjustment to where the SMART > log is calculated in order to use the stats struct for calculating OCP > extended smart log values. > > Signed-off-by: Joel Granados <j.granados@samsung.com> > --- > hw/nvme/ctrl.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c > index 87aeba0564..220683201a 100644 > --- a/hw/nvme/ctrl.c > +++ b/hw/nvme/ctrl.c > @@ -4449,8 +4449,8 @@ static void nvme_set_blk_stats(NvmeNamespace *ns, struct nvme_stats *stats) > { > BlockAcctStats *s = blk_get_stats(ns->blkconf.blk); > > - stats->units_read += s->nr_bytes[BLOCK_ACCT_READ] >> BDRV_SECTOR_BITS; > - stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE] >> BDRV_SECTOR_BITS; > + stats->units_read += s->nr_bytes[BLOCK_ACCT_READ]; > + stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE]; > stats->read_commands += s->nr_ops[BLOCK_ACCT_READ]; > stats->write_commands += s->nr_ops[BLOCK_ACCT_WRITE]; > } > @@ -4490,10 +4490,12 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_t rae, uint32_t buf_len, > trans_len = MIN(sizeof(smart) - off, buf_len); > smart.critical_warning = n->smart_critical_warning; > > - smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_read, > - 1000)); > - smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_written, > - 1000)); > + smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP( > + stats.units_read >> BDRV_SECTOR_BITS, > + 1000)); > + smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP( > + stats.units_written >> BDRV_SECTOR_BITS, > + 1000)); > smart.host_read_commands[0] = cpu_to_le64(stats.read_commands); > smart.host_write_commands[0] = cpu_to_le64(stats.write_commands); > Reviewed-by: Klaus Jensen <k.jensen@samsung.com>
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 87aeba0564..220683201a 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4449,8 +4449,8 @@ static void nvme_set_blk_stats(NvmeNamespace *ns, struct nvme_stats *stats) { BlockAcctStats *s = blk_get_stats(ns->blkconf.blk); - stats->units_read += s->nr_bytes[BLOCK_ACCT_READ] >> BDRV_SECTOR_BITS; - stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE] >> BDRV_SECTOR_BITS; + stats->units_read += s->nr_bytes[BLOCK_ACCT_READ]; + stats->units_written += s->nr_bytes[BLOCK_ACCT_WRITE]; stats->read_commands += s->nr_ops[BLOCK_ACCT_READ]; stats->write_commands += s->nr_ops[BLOCK_ACCT_WRITE]; } @@ -4490,10 +4490,12 @@ static uint16_t nvme_smart_info(NvmeCtrl *n, uint8_t rae, uint32_t buf_len, trans_len = MIN(sizeof(smart) - off, buf_len); smart.critical_warning = n->smart_critical_warning; - smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_read, - 1000)); - smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP(stats.units_written, - 1000)); + smart.data_units_read[0] = cpu_to_le64(DIV_ROUND_UP( + stats.units_read >> BDRV_SECTOR_BITS, + 1000)); + smart.data_units_written[0] = cpu_to_le64(DIV_ROUND_UP( + stats.units_written >> BDRV_SECTOR_BITS, + 1000)); smart.host_read_commands[0] = cpu_to_le64(stats.read_commands); smart.host_write_commands[0] = cpu_to_le64(stats.write_commands);
In order to return the units_{read/written} required by the SMART log we need to shift the number of bytes value by BDRV_SECTORS_BITS and multiply by 1000. This is a prep patch that moves this adjustment to where the SMART log is calculated in order to use the stats struct for calculating OCP extended smart log values. Signed-off-by: Joel Granados <j.granados@samsung.com> --- hw/nvme/ctrl.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)