All of lore.kernel.org
 help / color / mirror / Atom feed
From: Huijin Park <huijin.park@samsung.com>
To: Andreas Dilger <adilger.kernel@dilger.ca>,
	Michael Callahan <michaelcallahan@fb.com>
Cc: Omar Sandoval <osandov@fb.com>,
	js07.lee@samsung.com, Huijin Park <huijin.park@samsung.com>,
	Huijin Park <bbanghj.park@gmail.com>,
	linux-block@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH,2/2] ext4: change type to same as sectors in disk_stats
Date: Fri, 30 Nov 2018 04:32:41 -0500	[thread overview]
Message-ID: <1543570361-3168-2-git-send-email-huijin.park@samsung.com> (raw)
In-Reply-To: <1543570361-3168-1-git-send-email-huijin.park@samsung.com>

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

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


  parent reply	other threads:[~2018-11-30  9:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20181130093318eucas1p24feb8e649c8f244ce149a7f87e43c828@eucas1p2.samsung.com>
2018-11-30  9:32 ` [PATCH,1/2] genhd: avoid overflow of sectors in disk_stats Huijin Park
     [not found]   ` <CGME20181130093322eucas1p2aab6a9716469d9d2a9de1ffa91dd42f0@eucas1p2.samsung.com>
2018-11-30  9:32     ` Huijin Park [this message]
2018-11-30 19:56   ` Omar Sandoval
2018-12-09 14:44     ` Huijin Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1543570361-3168-2-git-send-email-huijin.park@samsung.com \
    --to=huijin.park@samsung.com \
    --cc=adilger.kernel@dilger.ca \
    --cc=bbanghj.park@gmail.com \
    --cc=js07.lee@samsung.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michaelcallahan@fb.com \
    --cc=osandov@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.