Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dbae2c55 authored by Michael Callahan's avatar Michael Callahan Committed by Jens Axboe
Browse files

block: Define and use STAT_READ and STAT_WRITE



Add defines for STAT_READ and STAT_WRITE for indexing the partition
stat entries. This clarifies some fs/ code which has hardcoded 1 for
STAT_WRITE and will make it easier to extend the stats with additional
fields.

tj: Refreshed on top of v4.17.

Signed-off-by: default avatarMichael Callahan <michaelcallahan@fb.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 59767fbd
Loading
Loading
Loading
Loading
+8 −8
Original line number Original line Diff line number Diff line
@@ -1337,14 +1337,14 @@ static int diskstats_show(struct seq_file *seqf, void *v)
			   "%u %lu %lu %lu %u %u %u %u\n",
			   "%u %lu %lu %lu %u %u %u %u\n",
			   MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
			   MAJOR(part_devt(hd)), MINOR(part_devt(hd)),
			   disk_name(gp, hd->partno, buf),
			   disk_name(gp, hd->partno, buf),
			   part_stat_read(hd, ios[READ]),
			   part_stat_read(hd, ios[STAT_READ]),
			   part_stat_read(hd, merges[READ]),
			   part_stat_read(hd, merges[STAT_READ]),
			   part_stat_read(hd, sectors[READ]),
			   part_stat_read(hd, sectors[STAT_READ]),
			   jiffies_to_msecs(part_stat_read(hd, ticks[READ])),
			   jiffies_to_msecs(part_stat_read(hd, ticks[STAT_READ])),
			   part_stat_read(hd, ios[WRITE]),
			   part_stat_read(hd, ios[STAT_WRITE]),
			   part_stat_read(hd, merges[WRITE]),
			   part_stat_read(hd, merges[STAT_WRITE]),
			   part_stat_read(hd, sectors[WRITE]),
			   part_stat_read(hd, sectors[STAT_WRITE]),
			   jiffies_to_msecs(part_stat_read(hd, ticks[WRITE])),
			   jiffies_to_msecs(part_stat_read(hd, ticks[STAT_WRITE])),
			   inflight[0],
			   inflight[0],
			   jiffies_to_msecs(part_stat_read(hd, io_ticks)),
			   jiffies_to_msecs(part_stat_read(hd, io_ticks)),
			   jiffies_to_msecs(part_stat_read(hd, time_in_queue))
			   jiffies_to_msecs(part_stat_read(hd, time_in_queue))
+8 −8
Original line number Original line Diff line number Diff line
@@ -132,14 +132,14 @@ ssize_t part_stat_show(struct device *dev,
		"%8lu %8lu %8llu %8u "
		"%8lu %8lu %8llu %8u "
		"%8u %8u %8u"
		"%8u %8u %8u"
		"\n",
		"\n",
		part_stat_read(p, ios[READ]),
		part_stat_read(p, ios[STAT_READ]),
		part_stat_read(p, merges[READ]),
		part_stat_read(p, merges[STAT_READ]),
		(unsigned long long)part_stat_read(p, sectors[READ]),
		(unsigned long long)part_stat_read(p, sectors[STAT_READ]),
		jiffies_to_msecs(part_stat_read(p, ticks[READ])),
		jiffies_to_msecs(part_stat_read(p, ticks[STAT_READ])),
		part_stat_read(p, ios[WRITE]),
		part_stat_read(p, ios[STAT_WRITE]),
		part_stat_read(p, merges[WRITE]),
		part_stat_read(p, merges[STAT_WRITE]),
		(unsigned long long)part_stat_read(p, sectors[WRITE]),
		(unsigned long long)part_stat_read(p, sectors[STAT_WRITE]),
		jiffies_to_msecs(part_stat_read(p, ticks[WRITE])),
		jiffies_to_msecs(part_stat_read(p, ticks[STAT_WRITE])),
		inflight[0],
		inflight[0],
		jiffies_to_msecs(part_stat_read(p, io_ticks)),
		jiffies_to_msecs(part_stat_read(p, io_ticks)),
		jiffies_to_msecs(part_stat_read(p, time_in_queue)));
		jiffies_to_msecs(part_stat_read(p, time_in_queue)));
+3 −2
Original line number Original line Diff line number Diff line
@@ -3514,7 +3514,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
	sbi->s_sb_block = sb_block;
	sbi->s_sb_block = sb_block;
	if (sb->s_bdev->bd_part)
	if (sb->s_bdev->bd_part)
		sbi->s_sectors_written_start =
		sbi->s_sectors_written_start =
			part_stat_read(sb->s_bdev->bd_part, sectors[1]);
			part_stat_read(sb->s_bdev->bd_part, sectors[STAT_WRITE]);


	/* Cleanup superblock name */
	/* Cleanup superblock name */
	strreplace(sb->s_id, '/', '!');
	strreplace(sb->s_id, '/', '!');
@@ -4824,7 +4824,8 @@ static int ext4_commit_super(struct super_block *sb, int sync)
	if (sb->s_bdev->bd_part)
	if (sb->s_bdev->bd_part)
		es->s_kbytes_written =
		es->s_kbytes_written =
			cpu_to_le64(EXT4_SB(sb)->s_kbytes_written +
			cpu_to_le64(EXT4_SB(sb)->s_kbytes_written +
			    ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
			    ((part_stat_read(sb->s_bdev->bd_part,
					     sectors[STAT_WRITE]) -
			      EXT4_SB(sb)->s_sectors_written_start) >> 1));
			      EXT4_SB(sb)->s_sectors_written_start) >> 1));
	else
	else
		es->s_kbytes_written =
		es->s_kbytes_written =
+4 −2
Original line number Original line Diff line number Diff line
@@ -56,7 +56,8 @@ static ssize_t session_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
	if (!sb->s_bdev->bd_part)
	if (!sb->s_bdev->bd_part)
		return snprintf(buf, PAGE_SIZE, "0\n");
		return snprintf(buf, PAGE_SIZE, "0\n");
	return snprintf(buf, PAGE_SIZE, "%lu\n",
	return snprintf(buf, PAGE_SIZE, "%lu\n",
			(part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
			(part_stat_read(sb->s_bdev->bd_part,
					sectors[STAT_WRITE]) -
			 sbi->s_sectors_written_start) >> 1);
			 sbi->s_sectors_written_start) >> 1);
}
}


@@ -68,7 +69,8 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
		return snprintf(buf, PAGE_SIZE, "0\n");
		return snprintf(buf, PAGE_SIZE, "0\n");
	return snprintf(buf, PAGE_SIZE, "%llu\n",
	return snprintf(buf, PAGE_SIZE, "%llu\n",
			(unsigned long long)(sbi->s_kbytes_written +
			(unsigned long long)(sbi->s_kbytes_written +
			((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
			((part_stat_read(sb->s_bdev->bd_part,
					 sectors[STAT_WRITE]) -
			  EXT4_SB(sb)->s_sectors_written_start) >> 1)));
			  EXT4_SB(sb)->s_sectors_written_start) >> 1)));
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -1304,7 +1304,7 @@ static inline bool time_to_inject(struct f2fs_sb_info *sbi, int type)
 * and the return value is in kbytes. s is of struct f2fs_sb_info.
 * and the return value is in kbytes. s is of struct f2fs_sb_info.
 */
 */
#define BD_PART_WRITTEN(s)						 \
#define BD_PART_WRITTEN(s)						 \
(((u64)part_stat_read((s)->sb->s_bdev->bd_part, sectors[1]) -		 \
(((u64)part_stat_read((s)->sb->s_bdev->bd_part, sectors[STAT_WRITE]) -   \
		(s)->sectors_written_start) >> 1)
		(s)->sectors_written_start) >> 1)


static inline void f2fs_update_time(struct f2fs_sb_info *sbi, int type)
static inline void f2fs_update_time(struct f2fs_sb_info *sbi, int type)
Loading