diff options
author | Theodore Ts'o <tytso@mit.edu> | 2009-02-28 19:39:58 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-02-28 19:39:58 -0500 |
commit | afc32f7ee9febc020c73da61402351d4c90437f3 (patch) | |
tree | 7b78aaaac87eb704074f6ece996b2c78a69fbe18 /fs/ext4 | |
parent | d6014301b5599fba395c42a1e96a7fe86f7d0b2d (diff) |
ext4: Track lifetime disk writes
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>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/ext4.h | 3 | ||||
-rw-r--r-- | fs/ext4/ext4_sb.h | 4 | ||||
-rw-r--r-- | 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 1b0c17364631..0bd39188531c 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -683,7 +683,8 @@ struct ext4_super_block { | |||
683 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ | 683 | __u8 s_log_groups_per_flex; /* FLEX_BG group size */ |
684 | __u8 s_reserved_char_pad2; | 684 | __u8 s_reserved_char_pad2; |
685 | __le16 s_reserved_pad; | 685 | __le16 s_reserved_pad; |
686 | __u32 s_reserved[162]; /* Padding to the end of the block */ | 686 | __le64 s_kbytes_written; /* nr of lifetime kilobytes written */ |
687 | __u32 s_reserved[160]; /* Padding to the end of the block */ | ||
687 | }; | 688 | }; |
688 | 689 | ||
689 | #ifdef __KERNEL__ | 690 | #ifdef __KERNEL__ |
diff --git a/fs/ext4/ext4_sb.h b/fs/ext4/ext4_sb.h index 4e4d9cc3f40d..50ab1169c378 100644 --- a/fs/ext4/ext4_sb.h +++ b/fs/ext4/ext4_sb.h | |||
@@ -142,6 +142,10 @@ struct ext4_sb_info { | |||
142 | /* locality groups */ | 142 | /* locality groups */ |
143 | struct ext4_locality_group *s_locality_groups; | 143 | struct ext4_locality_group *s_locality_groups; |
144 | 144 | ||
145 | /* for write statistics */ | ||
146 | unsigned long s_sectors_written_start; | ||
147 | u64 s_kbytes_written; | ||
148 | |||
145 | unsigned int s_log_groups_per_flex; | 149 | unsigned int s_log_groups_per_flex; |
146 | struct flex_groups *s_flex_groups; | 150 | struct flex_groups *s_flex_groups; |
147 | }; | 151 | }; |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index a3768709ce05..30fc27cdf8fc 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -2035,6 +2035,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2035 | sbi->s_resgid = EXT4_DEF_RESGID; | 2035 | sbi->s_resgid = EXT4_DEF_RESGID; |
2036 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; | 2036 | sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; |
2037 | sbi->s_sb_block = sb_block; | 2037 | sbi->s_sb_block = sb_block; |
2038 | sbi->s_sectors_written_start = part_stat_read(sb->s_bdev->bd_part, | ||
2039 | sectors[1]); | ||
2038 | 2040 | ||
2039 | unlock_kernel(); | 2041 | unlock_kernel(); |
2040 | 2042 | ||
@@ -2072,6 +2074,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2072 | sb->s_magic = le16_to_cpu(es->s_magic); | 2074 | sb->s_magic = le16_to_cpu(es->s_magic); |
2073 | if (sb->s_magic != EXT4_SUPER_MAGIC) | 2075 | if (sb->s_magic != EXT4_SUPER_MAGIC) |
2074 | goto cantfind_ext4; | 2076 | goto cantfind_ext4; |
2077 | sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written); | ||
2075 | 2078 | ||
2076 | /* Set defaults before we parse the mount options */ | 2079 | /* Set defaults before we parse the mount options */ |
2077 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); | 2080 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); |
@@ -2921,6 +2924,10 @@ static int ext4_commit_super(struct super_block *sb, | |||
2921 | set_buffer_uptodate(sbh); | 2924 | set_buffer_uptodate(sbh); |
2922 | } | 2925 | } |
2923 | es->s_wtime = cpu_to_le32(get_seconds()); | 2926 | es->s_wtime = cpu_to_le32(get_seconds()); |
2927 | es->s_kbytes_written = | ||
2928 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written + | ||
2929 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - | ||
2930 | EXT4_SB(sb)->s_sectors_written_start) >> 1)); | ||
2924 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( | 2931 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( |
2925 | &EXT4_SB(sb)->s_freeblocks_counter)); | 2932 | &EXT4_SB(sb)->s_freeblocks_counter)); |
2926 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( | 2933 | es->s_free_inodes_count = cpu_to_le32(percpu_counter_sum_positive( |