linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Track lifetime disk writes
Date: Mon, 23 Mar 2009 21:20:24 +0530	[thread overview]
Message-ID: <20090323155024.GA27876@skywalker> (raw)
In-Reply-To: <E1LdHKi-0000Zm-Mv@closure.thunk.org>

On Sat, Feb 28, 2009 at 12:01:52AM -0500, Theodore Ts'o wrote:
> 
> Add a new superblock value which tracks the lifetime amount of writes
> to the filesystem.  This is useful in estimating the amount of wear on
> solid state drives (SSD's) caused by writes to the filesystem.
> 
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
>  fs/ext4/ext4.h    |    3 ++-
>  fs/ext4/ext4_sb.h |    4 ++++
>  fs/ext4/super.c   |    7 +++++++
>  3 files changed, 13 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 8599e37..f9a3bc3 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -685,7 +685,8 @@ struct ext4_super_block {
>  	__u8	s_log_groups_per_flex;  /* FLEX_BG group size */
>  	__u8	s_reserved_char_pad2;
>  	__le16  s_reserved_pad;
> -	__u32   s_reserved[162];        /* Padding to the end of the block */
> +	__le64	s_kbytes_written;	/* nr of lifetime kilobytes written */
> +	__u32   s_reserved[160];        /* Padding to the end of the block */
>  };
> 
>  #ifdef __KERNEL__
> diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h
> index 4e4d9cc..50ab116 100644
> --- a/fs/ext4/ext4_sb.h
> +++ b/fs/ext4/ext4_sb.h
> @@ -142,6 +142,10 @@ struct ext4_sb_info {
>  	/* locality groups */
>  	struct ext4_locality_group *s_locality_groups;
> 
> +	/* for write statistics */
> +	unsigned long s_sectors_written_start;
> +	u64 s_kbytes_written;
> +
>  	unsigned int s_log_groups_per_flex;
>  	struct flex_groups *s_flex_groups;
>  };

Do we need this change ? We don't seems to be using it anywhere.

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
> index c69f04c..007aa0a 100644
> --- a/fs/ext4/super.c
> +++ b/fs/ext4/super.c
> @@ -2039,6 +2039,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
>  	sbi->s_resgid = EXT4_DEF_RESGID;
>  	sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS;
>  	sbi->s_sb_block = sb_block;
> +	sbi->s_sectors_written_start = part_stat_read(sb->s_bdev->bd_part,
> +						      sectors[1]);
> 
>  	unlock_kernel();
> 
> @@ -2535,6 +2537,7 @@ no_journal:
>  	}
> 
>  	ext4_setup_super(sb, es, sb->s_flags & MS_RDONLY);
> +	sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written);
> 
>  	/* determine the minimum size of new large inodes, if present */
>  	if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE) {
> @@ -2929,6 +2932,10 @@ static int ext4_commit_super(struct super_block *sb,
>  		set_buffer_uptodate(sbh);
>  	}
>  	es->s_wtime = cpu_to_le32(get_seconds());
> +	es->s_kbytes_written =
> +		cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + 
> +			    ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
> +			      EXT4_SB(sb)->s_sectors_written_start) >> 1));
>  	ext4_free_blocks_count_set(es, percpu_counter_sum_positive(
>  					&EXT4_SB(sb)->s_freeblocks_counter));
>  	es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive(

Can't we just do

es->s_kbytes_written = cpu_to_le64(le64_to_cpu(es->s_kbytes_written) + (part_stat_read(sb->s_bdev->bd_part, sectors[1]) >> 1))

During ext4_commit_super without even touching ext4_sb_info ? 

What is being tracked in s_sectors_written_start ?

-aneesh



  reply	other threads:[~2009-03-23 15:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-28  5:01 [PATCH] ext4: Track lifetime disk writes Theodore Ts'o
2009-03-23 15:50 ` Aneesh Kumar K.V [this message]
2009-03-30 10:08   ` Aneesh Kumar K.V

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=20090323155024.GA27876@skywalker \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).