diff options
author | Christoph Hellwig <hch@lst.de> | 2009-06-08 04:04:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-06-11 21:36:15 -0400 |
commit | 40f31dd47e7c3d15af1f9845eda0fa0c4c33f32f (patch) | |
tree | f711eb7629ced0f4ffd3cfb47eb69a9717143559 /fs/ext2 | |
parent | 80e09fb942d38beb19dcffbeb14d496beeb0a989 (diff) |
ext2: add ->sync_fs
Add a ->sync_fs method for data integrity syncs, and reimplement
->write_super ontop of it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/super.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index f8cbdf569190..458999638c3d 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -42,6 +42,7 @@ static void ext2_sync_super(struct super_block *sb, | |||
42 | struct ext2_super_block *es); | 42 | struct ext2_super_block *es); |
43 | static int ext2_remount (struct super_block * sb, int * flags, char * data); | 43 | static int ext2_remount (struct super_block * sb, int * flags, char * data); |
44 | static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf); | 44 | static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf); |
45 | static int ext2_sync_fs(struct super_block *sb, int wait); | ||
45 | 46 | ||
46 | void ext2_error (struct super_block * sb, const char * function, | 47 | void ext2_error (struct super_block * sb, const char * function, |
47 | const char * fmt, ...) | 48 | const char * fmt, ...) |
@@ -309,6 +310,7 @@ static const struct super_operations ext2_sops = { | |||
309 | .delete_inode = ext2_delete_inode, | 310 | .delete_inode = ext2_delete_inode, |
310 | .put_super = ext2_put_super, | 311 | .put_super = ext2_put_super, |
311 | .write_super = ext2_write_super, | 312 | .write_super = ext2_write_super, |
313 | .sync_fs = ext2_sync_fs, | ||
312 | .statfs = ext2_statfs, | 314 | .statfs = ext2_statfs, |
313 | .remount_fs = ext2_remount, | 315 | .remount_fs = ext2_remount, |
314 | .clear_inode = ext2_clear_inode, | 316 | .clear_inode = ext2_clear_inode, |
@@ -1132,25 +1134,36 @@ static void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es) | |||
1132 | * set s_state to EXT2_VALID_FS after some corrections. | 1134 | * set s_state to EXT2_VALID_FS after some corrections. |
1133 | */ | 1135 | */ |
1134 | 1136 | ||
1135 | void ext2_write_super (struct super_block * sb) | 1137 | static int ext2_sync_fs(struct super_block *sb, int wait) |
1136 | { | 1138 | { |
1137 | struct ext2_super_block * es; | 1139 | struct ext2_super_block *es = EXT2_SB(sb)->s_es; |
1140 | |||
1138 | lock_kernel(); | 1141 | lock_kernel(); |
1139 | if (!(sb->s_flags & MS_RDONLY)) { | 1142 | if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { |
1140 | es = EXT2_SB(sb)->s_es; | 1143 | ext2_debug("setting valid to 0\n"); |
1141 | 1144 | es->s_state &= cpu_to_le16(~EXT2_VALID_FS); | |
1142 | if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { | 1145 | es->s_free_blocks_count = |
1143 | ext2_debug ("setting valid to 0\n"); | 1146 | cpu_to_le32(ext2_count_free_blocks(sb)); |
1144 | es->s_state &= cpu_to_le16(~EXT2_VALID_FS); | 1147 | es->s_free_inodes_count = |
1145 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); | 1148 | cpu_to_le32(ext2_count_free_inodes(sb)); |
1146 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); | 1149 | es->s_mtime = cpu_to_le32(get_seconds()); |
1147 | es->s_mtime = cpu_to_le32(get_seconds()); | 1150 | ext2_sync_super(sb, es); |
1148 | ext2_sync_super(sb, es); | 1151 | } else { |
1149 | } else | 1152 | ext2_commit_super(sb, es); |
1150 | ext2_commit_super (sb, es); | ||
1151 | } | 1153 | } |
1152 | sb->s_dirt = 0; | 1154 | sb->s_dirt = 0; |
1153 | unlock_kernel(); | 1155 | unlock_kernel(); |
1156 | |||
1157 | return 0; | ||
1158 | } | ||
1159 | |||
1160 | |||
1161 | void ext2_write_super(struct super_block *sb) | ||
1162 | { | ||
1163 | if (!(sb->s_flags & MS_RDONLY)) | ||
1164 | ext2_sync_fs(sb, 1); | ||
1165 | else | ||
1166 | sb->s_dirt = 0; | ||
1154 | } | 1167 | } |
1155 | 1168 | ||
1156 | static int ext2_remount (struct super_block * sb, int * flags, char * data) | 1169 | static int ext2_remount (struct super_block * sb, int * flags, char * data) |