diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 23:13:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 23:13:18 -0400 |
commit | 7d2f280e75f05919314e250cadf361a327ed555c (patch) | |
tree | 47db5a9a0ceaf31adf49c18b663b1e08184f7cff /fs/ext3/super.c | |
parent | e3e1288e86a07cdeb0aee5860a2dff111c6eff79 (diff) | |
parent | 4408ea41c0ab4b711d4da44dd954fb06dce6c3f8 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs-2.6: (24 commits)
quota: Fix possible oops in __dquot_initialize()
ext3: Update kernel-doc comments
jbd/2: fixed typos
ext2: fixed typo.
ext3: Fix debug messages in ext3_group_extend()
jbd: Convert atomic_inc() to get_bh()
ext3: Remove misplaced BUFFER_TRACE() in ext3_truncate()
jbd: Fix debug message in do_get_write_access()
jbd: Check return value of __getblk()
ext3: Use DIV_ROUND_UP() on group desc block counting
ext3: Return proper error code on ext3_fill_super()
ext3: Remove unnecessary casts on bh->b_data
ext3: Cleanup ext3_setup_super()
quota: Fix issuing of warnings from dquot_transfer
quota: fix dquot_disable vs dquot_transfer race v2
jbd: Convert bitops to buffer fns
ext3/jbd: Avoid WARN() messages when failing to write the superblock
jbd: Use offset_in_page() instead of manual calculation
jbd: Remove unnecessary goto statement
jbd: Use printk_ratelimited() in journal_alloc_journal_head()
...
Diffstat (limited to 'fs/ext3/super.c')
-rw-r--r-- | fs/ext3/super.c | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 377768009106..db87413d3479 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -1301,9 +1301,9 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1301 | ext3_msg(sb, KERN_WARNING, | 1301 | ext3_msg(sb, KERN_WARNING, |
1302 | "warning: mounting fs with errors, " | 1302 | "warning: mounting fs with errors, " |
1303 | "running e2fsck is recommended"); | 1303 | "running e2fsck is recommended"); |
1304 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && | 1304 | else if ((__s16) le16_to_cpu(es->s_max_mnt_count) > 0 && |
1305 | le16_to_cpu(es->s_mnt_count) >= | 1305 | le16_to_cpu(es->s_mnt_count) >= |
1306 | (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) | 1306 | le16_to_cpu(es->s_max_mnt_count)) |
1307 | ext3_msg(sb, KERN_WARNING, | 1307 | ext3_msg(sb, KERN_WARNING, |
1308 | "warning: maximal mount count reached, " | 1308 | "warning: maximal mount count reached, " |
1309 | "running e2fsck is recommended"); | 1309 | "running e2fsck is recommended"); |
@@ -1320,7 +1320,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, | |||
1320 | valid forever! :) */ | 1320 | valid forever! :) */ |
1321 | es->s_state &= cpu_to_le16(~EXT3_VALID_FS); | 1321 | es->s_state &= cpu_to_le16(~EXT3_VALID_FS); |
1322 | #endif | 1322 | #endif |
1323 | if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) | 1323 | if (!le16_to_cpu(es->s_max_mnt_count)) |
1324 | es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); | 1324 | es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT); |
1325 | le16_add_cpu(&es->s_mnt_count, 1); | 1325 | le16_add_cpu(&es->s_mnt_count, 1); |
1326 | es->s_mtime = cpu_to_le32(get_seconds()); | 1326 | es->s_mtime = cpu_to_le32(get_seconds()); |
@@ -1647,7 +1647,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1647 | * Note: s_es must be initialized as soon as possible because | 1647 | * Note: s_es must be initialized as soon as possible because |
1648 | * some ext3 macro-instructions depend on its value | 1648 | * some ext3 macro-instructions depend on its value |
1649 | */ | 1649 | */ |
1650 | es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); | 1650 | es = (struct ext3_super_block *) (bh->b_data + offset); |
1651 | sbi->s_es = es; | 1651 | sbi->s_es = es; |
1652 | sb->s_magic = le16_to_cpu(es->s_magic); | 1652 | sb->s_magic = le16_to_cpu(es->s_magic); |
1653 | if (sb->s_magic != EXT3_SUPER_MAGIC) | 1653 | if (sb->s_magic != EXT3_SUPER_MAGIC) |
@@ -1758,7 +1758,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1758 | "error: can't read superblock on 2nd try"); | 1758 | "error: can't read superblock on 2nd try"); |
1759 | goto failed_mount; | 1759 | goto failed_mount; |
1760 | } | 1760 | } |
1761 | es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); | 1761 | es = (struct ext3_super_block *)(bh->b_data + offset); |
1762 | sbi->s_es = es; | 1762 | sbi->s_es = es; |
1763 | if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { | 1763 | if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) { |
1764 | ext3_msg(sb, KERN_ERR, | 1764 | ext3_msg(sb, KERN_ERR, |
@@ -1857,13 +1857,13 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1857 | sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - | 1857 | sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - |
1858 | le32_to_cpu(es->s_first_data_block) - 1) | 1858 | le32_to_cpu(es->s_first_data_block) - 1) |
1859 | / EXT3_BLOCKS_PER_GROUP(sb)) + 1; | 1859 | / EXT3_BLOCKS_PER_GROUP(sb)) + 1; |
1860 | db_count = (sbi->s_groups_count + EXT3_DESC_PER_BLOCK(sb) - 1) / | 1860 | db_count = DIV_ROUND_UP(sbi->s_groups_count, EXT3_DESC_PER_BLOCK(sb)); |
1861 | EXT3_DESC_PER_BLOCK(sb); | ||
1862 | sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), | 1861 | sbi->s_group_desc = kmalloc(db_count * sizeof (struct buffer_head *), |
1863 | GFP_KERNEL); | 1862 | GFP_KERNEL); |
1864 | if (sbi->s_group_desc == NULL) { | 1863 | if (sbi->s_group_desc == NULL) { |
1865 | ext3_msg(sb, KERN_ERR, | 1864 | ext3_msg(sb, KERN_ERR, |
1866 | "error: not enough memory"); | 1865 | "error: not enough memory"); |
1866 | ret = -ENOMEM; | ||
1867 | goto failed_mount; | 1867 | goto failed_mount; |
1868 | } | 1868 | } |
1869 | 1869 | ||
@@ -1951,6 +1951,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
1951 | } | 1951 | } |
1952 | if (err) { | 1952 | if (err) { |
1953 | ext3_msg(sb, KERN_ERR, "error: insufficient memory"); | 1953 | ext3_msg(sb, KERN_ERR, "error: insufficient memory"); |
1954 | ret = err; | ||
1954 | goto failed_mount3; | 1955 | goto failed_mount3; |
1955 | } | 1956 | } |
1956 | 1957 | ||
@@ -2159,7 +2160,7 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, | |||
2159 | goto out_bdev; | 2160 | goto out_bdev; |
2160 | } | 2161 | } |
2161 | 2162 | ||
2162 | es = (struct ext3_super_block *) (((char *)bh->b_data) + offset); | 2163 | es = (struct ext3_super_block *) (bh->b_data + offset); |
2163 | if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || | 2164 | if ((le16_to_cpu(es->s_magic) != EXT3_SUPER_MAGIC) || |
2164 | !(le32_to_cpu(es->s_feature_incompat) & | 2165 | !(le32_to_cpu(es->s_feature_incompat) & |
2165 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { | 2166 | EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) { |
@@ -2352,6 +2353,21 @@ static int ext3_commit_super(struct super_block *sb, | |||
2352 | 2353 | ||
2353 | if (!sbh) | 2354 | if (!sbh) |
2354 | return error; | 2355 | return error; |
2356 | |||
2357 | if (buffer_write_io_error(sbh)) { | ||
2358 | /* | ||
2359 | * Oh, dear. A previous attempt to write the | ||
2360 | * superblock failed. This could happen because the | ||
2361 | * USB device was yanked out. Or it could happen to | ||
2362 | * be a transient write error and maybe the block will | ||
2363 | * be remapped. Nothing we can do but to retry the | ||
2364 | * write and hope for the best. | ||
2365 | */ | ||
2366 | ext3_msg(sb, KERN_ERR, "previous I/O error to " | ||
2367 | "superblock detected"); | ||
2368 | clear_buffer_write_io_error(sbh); | ||
2369 | set_buffer_uptodate(sbh); | ||
2370 | } | ||
2355 | /* | 2371 | /* |
2356 | * If the file system is mounted read-only, don't update the | 2372 | * If the file system is mounted read-only, don't update the |
2357 | * superblock write time. This avoids updating the superblock | 2373 | * superblock write time. This avoids updating the superblock |
@@ -2368,8 +2384,15 @@ static int ext3_commit_super(struct super_block *sb, | |||
2368 | es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); | 2384 | es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); |
2369 | BUFFER_TRACE(sbh, "marking dirty"); | 2385 | BUFFER_TRACE(sbh, "marking dirty"); |
2370 | mark_buffer_dirty(sbh); | 2386 | mark_buffer_dirty(sbh); |
2371 | if (sync) | 2387 | if (sync) { |
2372 | error = sync_dirty_buffer(sbh); | 2388 | error = sync_dirty_buffer(sbh); |
2389 | if (buffer_write_io_error(sbh)) { | ||
2390 | ext3_msg(sb, KERN_ERR, "I/O error while writing " | ||
2391 | "superblock"); | ||
2392 | clear_buffer_write_io_error(sbh); | ||
2393 | set_buffer_uptodate(sbh); | ||
2394 | } | ||
2395 | } | ||
2373 | return error; | 2396 | return error; |
2374 | } | 2397 | } |
2375 | 2398 | ||