]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: target: Fix LUN/device R/W and total command stats
authorMike Christie <michael.christie@oracle.com>
Wed, 17 Sep 2025 22:12:53 +0000 (17:12 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Mon, 3 Nov 2025 03:06:11 +0000 (22:06 -0500)
In commit 9cf2317b795d ("scsi: target: Move I/O path stats to per CPU")
I saw we sometimes use %u and also misread the spec. As a result I
thought all the stats were supposed to be 32-bit only. However, for the
majority of cases we support currently, the spec specifies u64 bit
stats. This patch converts the stats changed in the commit above to u64.

Fixes: 9cf2317b795d ("scsi: target: Move I/O path stats to per CPU")
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Link: https://patch.msgid.link/20250917221338.14813-2-michael.christie@oracle.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_stat.c
include/target/target_core_base.h

index 6bdf2d8bd6942269df376a4c188d174bf89b8d27..4fdc307ea38bc888d23078d3c07c8b6300fa7f42 100644 (file)
@@ -282,7 +282,7 @@ static ssize_t target_stat_lu_num_cmds_show(struct config_item *item,
        struct se_device *dev = to_stat_lu_dev(item);
        struct se_dev_io_stats *stats;
        unsigned int cpu;
-       u32 cmds = 0;
+       u64 cmds = 0;
 
        for_each_possible_cpu(cpu) {
                stats = per_cpu_ptr(dev->stats, cpu);
@@ -290,7 +290,7 @@ static ssize_t target_stat_lu_num_cmds_show(struct config_item *item,
        }
 
        /* scsiLuNumCommands */
-       return snprintf(page, PAGE_SIZE, "%u\n", cmds);
+       return snprintf(page, PAGE_SIZE, "%llu\n", cmds);
 }
 
 static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item,
@@ -299,7 +299,7 @@ static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item,
        struct se_device *dev = to_stat_lu_dev(item);
        struct se_dev_io_stats *stats;
        unsigned int cpu;
-       u32 bytes = 0;
+       u64 bytes = 0;
 
        for_each_possible_cpu(cpu) {
                stats = per_cpu_ptr(dev->stats, cpu);
@@ -307,7 +307,7 @@ static ssize_t target_stat_lu_read_mbytes_show(struct config_item *item,
        }
 
        /* scsiLuReadMegaBytes */
-       return snprintf(page, PAGE_SIZE, "%u\n", bytes >> 20);
+       return snprintf(page, PAGE_SIZE, "%llu\n", bytes >> 20);
 }
 
 static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item,
@@ -316,7 +316,7 @@ static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item,
        struct se_device *dev = to_stat_lu_dev(item);
        struct se_dev_io_stats *stats;
        unsigned int cpu;
-       u32 bytes = 0;
+       u64 bytes = 0;
 
        for_each_possible_cpu(cpu) {
                stats = per_cpu_ptr(dev->stats, cpu);
@@ -324,7 +324,7 @@ static ssize_t target_stat_lu_write_mbytes_show(struct config_item *item,
        }
 
        /* scsiLuWrittenMegaBytes */
-       return snprintf(page, PAGE_SIZE, "%u\n", bytes >> 20);
+       return snprintf(page, PAGE_SIZE, "%llu\n", bytes >> 20);
 }
 
 static ssize_t target_stat_lu_resets_show(struct config_item *item, char *page)
@@ -1044,7 +1044,7 @@ static ssize_t target_stat_auth_num_cmds_show(struct config_item *item,
        struct se_dev_entry *deve;
        unsigned int cpu;
        ssize_t ret;
-       u32 cmds = 0;
+       u64 cmds = 0;
 
        rcu_read_lock();
        deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
@@ -1059,7 +1059,7 @@ static ssize_t target_stat_auth_num_cmds_show(struct config_item *item,
        }
 
        /* scsiAuthIntrOutCommands */
-       ret = snprintf(page, PAGE_SIZE, "%u\n", cmds);
+       ret = snprintf(page, PAGE_SIZE, "%llu\n", cmds);
        rcu_read_unlock();
        return ret;
 }
@@ -1073,7 +1073,7 @@ static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item,
        struct se_dev_entry *deve;
        unsigned int cpu;
        ssize_t ret;
-       u32 bytes = 0;
+       u64 bytes = 0;
 
        rcu_read_lock();
        deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
@@ -1088,7 +1088,7 @@ static ssize_t target_stat_auth_read_mbytes_show(struct config_item *item,
        }
 
        /* scsiAuthIntrReadMegaBytes */
-       ret = snprintf(page, PAGE_SIZE, "%u\n", bytes >> 20);
+       ret = snprintf(page, PAGE_SIZE, "%llu\n", bytes >> 20);
        rcu_read_unlock();
        return ret;
 }
@@ -1102,7 +1102,7 @@ static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item,
        struct se_dev_entry *deve;
        unsigned int cpu;
        ssize_t ret;
-       u32 bytes = 0;
+       u64 bytes = 0;
 
        rcu_read_lock();
        deve = target_nacl_find_deve(nacl, lacl->mapped_lun);
@@ -1117,7 +1117,7 @@ static ssize_t target_stat_auth_write_mbytes_show(struct config_item *item,
        }
 
        /* scsiAuthIntrWrittenMegaBytes */
-       ret = snprintf(page, PAGE_SIZE, "%u\n", bytes >> 20);
+       ret = snprintf(page, PAGE_SIZE, "%llu\n", bytes >> 20);
        rcu_read_unlock();
        return ret;
 }
index c4d9116904aa0f577bb1f4b2194152d99c33507b..27e1f9d5f0c6cdebd3a9fbfd8447fd50ef24c02e 100644 (file)
@@ -671,9 +671,9 @@ struct se_lun_acl {
 };
 
 struct se_dev_entry_io_stats {
-       u32                     total_cmds;
-       u32                     read_bytes;
-       u32                     write_bytes;
+       u64                     total_cmds;
+       u64                     read_bytes;
+       u64                     write_bytes;
 };
 
 struct se_dev_entry {
@@ -806,9 +806,9 @@ struct se_device_queue {
 };
 
 struct se_dev_io_stats {
-       u32                     total_cmds;
-       u32                     read_bytes;
-       u32                     write_bytes;
+       u64                     total_cmds;
+       u64                     read_bytes;
+       u64                     write_bytes;
 };
 
 struct se_device {