]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nvmet: fix data units read and written counters in SMART log
authorTom Wu <tomwu@mellanox.com>
Thu, 8 Aug 2019 02:22:36 +0000 (02:22 +0000)
committerSagi Grimberg <sagi@grimberg.me>
Thu, 29 Aug 2019 19:55:01 +0000 (12:55 -0700)
In nvme spec 1.3 there is a definition for data write/read counters
from SMART log, (See section 5.14.1.2):
This value is reported in thousands (i.e., a value of 1
corresponds to 1000 units of 512 bytes read) and is rounded up.

However, in nvme target where value is reported with actual units,
but not thousands of units as the spec requires.

Signed-off-by: Tom Wu <tomwu@mellanox.com>
Reviewed-by: Israel Rukshin <israelr@mellanox.com>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
drivers/nvme/target/admin-cmd.c

index 4dc12ea52f23cbdd970428daf36b66ed694adfd3..51800a9ce9a912d7a22eb6a25f7a29990e9f5bb9 100644 (file)
@@ -81,9 +81,11 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
                goto out;
 
        host_reads = part_stat_read(ns->bdev->bd_part, ios[READ]);
-       data_units_read = part_stat_read(ns->bdev->bd_part, sectors[READ]);
+       data_units_read = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+               sectors[READ]), 1000);
        host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
-       data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
+       data_units_written = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+               sectors[WRITE]), 1000);
 
        put_unaligned_le64(host_reads, &slog->host_reads[0]);
        put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
@@ -111,11 +113,11 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
                if (!ns->bdev)
                        continue;
                host_reads += part_stat_read(ns->bdev->bd_part, ios[READ]);
-               data_units_read +=
-                       part_stat_read(ns->bdev->bd_part, sectors[READ]);
+               data_units_read += DIV_ROUND_UP(
+                       part_stat_read(ns->bdev->bd_part, sectors[READ]), 1000);
                host_writes += part_stat_read(ns->bdev->bd_part, ios[WRITE]);
-               data_units_written +=
-                       part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
+               data_units_written += DIV_ROUND_UP(
+                       part_stat_read(ns->bdev->bd_part, sectors[WRITE]), 1000);
 
        }
        rcu_read_unlock();