From: "huijin.park" <[email protected]>

This patch changes the 's_sectors_written_start' type to u64
same as the 'sectors' type in disk_stats.
Because if the 'sectors' has more than about 2TiB,
the 's_sectors_written_start' will overflow in 32 bit system.
And it makes invalid statistics([session|lifetime]_write_kbytes).

Signed-off-by: huijin.park <[email protected]>
---
 fs/ext4/ext4.h  |    2 +-
 fs/ext4/sysfs.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 3f89d0a..d3a08b2 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1457,7 +1457,7 @@ struct ext4_sb_info {
        struct ext4_locality_group __percpu *s_locality_groups;
 
        /* for write statistics */
-       unsigned long s_sectors_written_start;
+       u64 s_sectors_written_start;
        u64 s_kbytes_written;
 
        /* the size of zero-out chunk */
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index 9212a02..59ac5cf 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -57,7 +57,7 @@ static ssize_t session_write_kbytes_show(struct ext4_sb_info 
*sbi, char *buf)
 
        if (!sb->s_bdev->bd_part)
                return snprintf(buf, PAGE_SIZE, "0\n");
-       return snprintf(buf, PAGE_SIZE, "%lu\n",
+       return snprintf(buf, PAGE_SIZE, "%llu\n",
                        (part_stat_read(sb->s_bdev->bd_part,
                                        sectors[STAT_WRITE]) -
                         sbi->s_sectors_written_start) >> 1);
-- 
1.7.9.5

Reply via email to