From patchwork Thu Nov 10 10:34:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 124851 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D2E961007D1 for ; Thu, 10 Nov 2011 21:34:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932307Ab1KJKeI (ORCPT ); Thu, 10 Nov 2011 05:34:08 -0500 Received: from mail-gx0-f174.google.com ([209.85.161.174]:41237 "EHLO mail-gx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756562Ab1KJKeG (ORCPT ); Thu, 10 Nov 2011 05:34:06 -0500 Received: by mail-gx0-f174.google.com with SMTP id b2so2783078ggn.19 for ; Thu, 10 Nov 2011 02:34:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=LiYFTlD3RchIVtszoz5/MdoOVX3dc/31eNrvcB2ASac=; b=O3PJlohz1ySEzCDEdyzleBkeqpBP19hx2t2L0hlhdOF96wfOWZv3zlYlYEhwhpAeeN EH5RhsgbhoLLms4uzpRJza+s65l9t4pzMYIlBgC9y+fBGimSnGt2OQvJLyxjMYvh+bcz 1mBqufqXNdApUOLihDoPbhl2zx179nLGLuQCQ= Received: by 10.50.216.167 with SMTP id or7mr7008314igc.22.1320921245725; Thu, 10 Nov 2011 02:34:05 -0800 (PST) Received: from localhost.localdomain ([182.92.247.2]) by mx.google.com with ESMTPS id fu10sm6077720igc.6.2011.11.10.02.34.03 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 02:34:05 -0800 (PST) From: Zheng Liu To: linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: Zheng Liu , Wang Shaoyan Subject: [PATCH v2 8/8] ext4: Show the result of io types statistic in sysfs Date: Thu, 10 Nov 2011 18:34:54 +0800 Message-Id: <1320921294-30321-9-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1320921294-30321-1-git-send-email-wenqing.lz@taobao.com> References: <1320921294-30321-1-git-send-email-wenqing.lz@taobao.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu io_stats file is created to show the result in sysfs. Signed-off-by: Zheng Liu Signed-off-by: Wang Shaoyan --- fs/ext4/super.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 8e27b9c..bc1476d 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2532,6 +2532,52 @@ static ssize_t inode_readahead_blks_store(struct ext4_attr *a, return count; } +static inline unsigned long ext4_get_ios_counter(int rw, int flag); +static ssize_t io_stats_show(struct ext4_attr *a, + struct ext4_sb_info *sbi, char *buf) +{ + int i; + unsigned long ios_counters[EXT4_IOS_TYPE_END][2] = {{0,},}; + + for (i = 0; i < EXT4_IOS_TYPE_END; i++) { + ios_counters[i][READ] = ext4_get_ios_counter(READ, i); + ios_counters[i][WRITE] = ext4_get_ios_counter(WRITE, i); + } + + return snprintf(buf, PAGE_SIZE, + "TYPE READ WRITE\n" + "super block %8lu %8lu\n" + "group descriptor %8lu %8lu\n" + "inode bitmap %8lu %8lu\n" + "block bitmap %8lu %8lu\n" + "inode table %8lu %8lu\n" + "extent block %8lu %8lu\n" + "indirect block %8lu %8lu\n" + "dir entry %8lu %8lu\n" + "extended attribute %8lu %8lu\n" + "regular data %8lu %8lu\n", + ios_counters[EXT4_IOS_SUPER_BLOCK][READ], + ios_counters[EXT4_IOS_SUPER_BLOCK][WRITE], + ios_counters[EXT4_IOS_GROUP_DESC][READ], + ios_counters[EXT4_IOS_GROUP_DESC][WRITE], + ios_counters[EXT4_IOS_INODE_BITMAP][READ], + ios_counters[EXT4_IOS_INODE_BITMAP][WRITE], + ios_counters[EXT4_IOS_BLOCK_BITMAP][READ], + ios_counters[EXT4_IOS_BLOCK_BITMAP][WRITE], + ios_counters[EXT4_IOS_INODE_TABLE][READ], + ios_counters[EXT4_IOS_INODE_TABLE][WRITE], + ios_counters[EXT4_IOS_EXTENT_BLOCK][READ], + ios_counters[EXT4_IOS_EXTENT_BLOCK][WRITE], + ios_counters[EXT4_IOS_INDIRECT_BLOCK][READ], + ios_counters[EXT4_IOS_INDIRECT_BLOCK][WRITE], + ios_counters[EXT4_IOS_DIR_ENTRY][READ], + ios_counters[EXT4_IOS_DIR_ENTRY][WRITE], + ios_counters[EXT4_IOS_EXTENDED_ATTR][READ], + ios_counters[EXT4_IOS_EXTENDED_ATTR][WRITE], + ios_counters[EXT4_IOS_REGULAR_DATA][READ], + ios_counters[EXT4_IOS_REGULAR_DATA][WRITE]); +} + static ssize_t sbi_ui_show(struct ext4_attr *a, struct ext4_sb_info *sbi, char *buf) { @@ -2575,6 +2621,7 @@ EXT4_RO_ATTR(session_write_kbytes); EXT4_RO_ATTR(lifetime_write_kbytes); EXT4_RO_ATTR(extent_cache_hits); EXT4_RO_ATTR(extent_cache_misses); +EXT4_RO_ATTR(io_stats); EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, inode_readahead_blks_store, s_inode_readahead_blks); EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal); @@ -2601,6 +2648,7 @@ static struct attribute *ext4_attrs[] = { ATTR_LIST(mb_stream_req), ATTR_LIST(mb_group_prealloc), ATTR_LIST(max_writeback_mb_bump), + ATTR_LIST(io_stats), NULL, };