[2/2] ext4: change type to same as sectors in disk_stats

Message ID 1543570361-3168-2-git-send-email-huijin.park@samsung.com
State New
Headers show
Series
  • [1/2] genhd: avoid overflow of sectors in disk_stats
Related show

Commit Message

Huijin Park Nov. 30, 2018, 9:32 a.m.
From: "huijin.park" <huijin.park@samsung.com>

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 <huijin.park@samsung.com>
---
 fs/ext4/ext4.h  |    2 +-
 fs/ext4/sysfs.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch

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);