aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext3
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 23:13:18 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-27 23:13:18 -0400
commit7d2f280e75f05919314e250cadf361a327ed555c (patch)
tree47db5a9a0ceaf31adf49c18b663b1e08184f7cff /fs/ext3
parente3e1288e86a07cdeb0aee5860a2dff111c6eff79 (diff)
parent4408ea41c0ab4b711d4da44dd954fb06dce6c3f8 (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')
-rw-r--r--fs/ext3/balloc.c17
-rw-r--r--fs/ext3/ialloc.c11
-rw-r--r--fs/ext3/inode.c20
-rw-r--r--fs/ext3/resize.c13
-rw-r--r--fs/ext3/super.c41
5 files changed, 69 insertions, 33 deletions
diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
index 4a32511f4ded..b3db22649426 100644
--- a/fs/ext3/balloc.c
+++ b/fs/ext3/balloc.c
@@ -792,9 +792,9 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
792 if (here < 0) 792 if (here < 0)
793 here = 0; 793 here = 0;
794 794
795 p = ((char *)bh->b_data) + (here >> 3); 795 p = bh->b_data + (here >> 3);
796 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3)); 796 r = memscan(p, 0, ((maxblocks + 7) >> 3) - (here >> 3));
797 next = (r - ((char *)bh->b_data)) << 3; 797 next = (r - bh->b_data) << 3;
798 798
799 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh)) 799 if (next < maxblocks && next >= start && ext3_test_allocatable(next, bh))
800 return next; 800 return next;
@@ -810,8 +810,9 @@ find_next_usable_block(ext3_grpblk_t start, struct buffer_head *bh,
810 810
811/** 811/**
812 * claim_block() 812 * claim_block()
813 * @lock: the spin lock for this block group
813 * @block: the free block (group relative) to allocate 814 * @block: the free block (group relative) to allocate
814 * @bh: the bufferhead containts the block group bitmap 815 * @bh: the buffer_head contains the block group bitmap
815 * 816 *
816 * We think we can allocate this block in this bitmap. Try to set the bit. 817 * We think we can allocate this block in this bitmap. Try to set the bit.
817 * If that succeeds then check that nobody has allocated and then freed the 818 * If that succeeds then check that nobody has allocated and then freed the
@@ -956,9 +957,11 @@ fail_access:
956 * but we will shift to the place where start_block is, 957 * but we will shift to the place where start_block is,
957 * then start from there, when looking for a reservable space. 958 * then start from there, when looking for a reservable space.
958 * 959 *
959 * @size: the target new reservation window size 960 * @my_rsv: the reservation window
960 * 961 *
961 * @group_first_block: the first block we consider to start 962 * @sb: the super block
963 *
964 * @start_block: the first block we consider to start
962 * the real search from 965 * the real search from
963 * 966 *
964 * @last_block: 967 * @last_block:
@@ -1084,7 +1087,7 @@ static int find_next_reservable_window(
1084 * 1087 *
1085 * failed: we failed to find a reservation window in this group 1088 * failed: we failed to find a reservation window in this group
1086 * 1089 *
1087 * @rsv: the reservation 1090 * @my_rsv: the reservation window
1088 * 1091 *
1089 * @grp_goal: The goal (group-relative). It is where the search for a 1092 * @grp_goal: The goal (group-relative). It is where the search for a
1090 * free reservable space should start from. 1093 * free reservable space should start from.
@@ -1273,8 +1276,8 @@ static void try_to_extend_reservation(struct ext3_reserve_window_node *my_rsv,
1273 * @group: given allocation block group 1276 * @group: given allocation block group
1274 * @bitmap_bh: bufferhead holds the block bitmap 1277 * @bitmap_bh: bufferhead holds the block bitmap
1275 * @grp_goal: given target block within the group 1278 * @grp_goal: given target block within the group
1276 * @count: target number of blocks to allocate
1277 * @my_rsv: reservation window 1279 * @my_rsv: reservation window
1280 * @count: target number of blocks to allocate
1278 * @errp: pointer to store the error code 1281 * @errp: pointer to store the error code
1279 * 1282 *
1280 * This is the main function used to allocate a new block and its reservation 1283 * This is the main function used to allocate a new block and its reservation
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c
index 4ab72db3559e..9724aef22460 100644
--- a/fs/ext3/ialloc.c
+++ b/fs/ext3/ialloc.c
@@ -570,9 +570,14 @@ got:
570 ei->i_state_flags = 0; 570 ei->i_state_flags = 0;
571 ext3_set_inode_state(inode, EXT3_STATE_NEW); 571 ext3_set_inode_state(inode, EXT3_STATE_NEW);
572 572
573 ei->i_extra_isize = 573 /* See comment in ext3_iget for explanation */
574 (EXT3_INODE_SIZE(inode->i_sb) > EXT3_GOOD_OLD_INODE_SIZE) ? 574 if (ino >= EXT3_FIRST_INO(sb) + 1 &&
575 sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE : 0; 575 EXT3_INODE_SIZE(sb) > EXT3_GOOD_OLD_INODE_SIZE) {
576 ei->i_extra_isize =
577 sizeof(struct ext3_inode) - EXT3_GOOD_OLD_INODE_SIZE;
578 } else {
579 ei->i_extra_isize = 0;
580 }
576 581
577 ret = inode; 582 ret = inode;
578 dquot_initialize(inode); 583 dquot_initialize(inode);
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index ad05353040a1..a9580617edd2 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -498,7 +498,7 @@ static ext3_fsblk_t ext3_find_goal(struct inode *inode, long block,
498} 498}
499 499
500/** 500/**
501 * ext3_blks_to_allocate: Look up the block map and count the number 501 * ext3_blks_to_allocate - Look up the block map and count the number
502 * of direct blocks need to be allocated for the given branch. 502 * of direct blocks need to be allocated for the given branch.
503 * 503 *
504 * @branch: chain of indirect blocks 504 * @branch: chain of indirect blocks
@@ -536,14 +536,18 @@ static int ext3_blks_to_allocate(Indirect *branch, int k, unsigned long blks,
536} 536}
537 537
538/** 538/**
539 * ext3_alloc_blocks: multiple allocate blocks needed for a branch 539 * ext3_alloc_blocks - multiple allocate blocks needed for a branch
540 * @handle: handle for this transaction
541 * @inode: owner
542 * @goal: preferred place for allocation
540 * @indirect_blks: the number of blocks need to allocate for indirect 543 * @indirect_blks: the number of blocks need to allocate for indirect
541 * blocks 544 * blocks
542 * 545 * @blks: number of blocks need to allocated for direct blocks
543 * @new_blocks: on return it will store the new block numbers for 546 * @new_blocks: on return it will store the new block numbers for
544 * the indirect blocks(if needed) and the first direct block, 547 * the indirect blocks(if needed) and the first direct block,
545 * @blks: on return it will store the total number of allocated 548 * @err: here we store the error value
546 * direct blocks 549 *
550 * return the number of direct blocks allocated
547 */ 551 */
548static int ext3_alloc_blocks(handle_t *handle, struct inode *inode, 552static int ext3_alloc_blocks(handle_t *handle, struct inode *inode,
549 ext3_fsblk_t goal, int indirect_blks, int blks, 553 ext3_fsblk_t goal, int indirect_blks, int blks,
@@ -598,9 +602,11 @@ failed_out:
598 602
599/** 603/**
600 * ext3_alloc_branch - allocate and set up a chain of blocks. 604 * ext3_alloc_branch - allocate and set up a chain of blocks.
605 * @handle: handle for this transaction
601 * @inode: owner 606 * @inode: owner
602 * @indirect_blks: number of allocated indirect blocks 607 * @indirect_blks: number of allocated indirect blocks
603 * @blks: number of allocated direct blocks 608 * @blks: number of allocated direct blocks
609 * @goal: preferred place for allocation
604 * @offsets: offsets (in the blocks) to store the pointers to next. 610 * @offsets: offsets (in the blocks) to store the pointers to next.
605 * @branch: place to store the chain in. 611 * @branch: place to store the chain in.
606 * 612 *
@@ -700,10 +706,9 @@ failed:
700 706
701/** 707/**
702 * ext3_splice_branch - splice the allocated branch onto inode. 708 * ext3_splice_branch - splice the allocated branch onto inode.
709 * @handle: handle for this transaction
703 * @inode: owner 710 * @inode: owner
704 * @block: (logical) number of block we are adding 711 * @block: (logical) number of block we are adding
705 * @chain: chain of indirect blocks (with a missing link - see
706 * ext3_alloc_branch)
707 * @where: location of missing link 712 * @where: location of missing link
708 * @num: number of indirect blocks we are adding 713 * @num: number of indirect blocks we are adding
709 * @blks: number of direct blocks we are adding 714 * @blks: number of direct blocks we are adding
@@ -2530,7 +2535,6 @@ void ext3_truncate(struct inode *inode)
2530 */ 2535 */
2531 } else { 2536 } else {
2532 /* Shared branch grows from an indirect block */ 2537 /* Shared branch grows from an indirect block */
2533 BUFFER_TRACE(partial->bh, "get_write_access");
2534 ext3_free_branches(handle, inode, partial->bh, 2538 ext3_free_branches(handle, inode, partial->bh,
2535 partial->p, 2539 partial->p,
2536 partial->p+1, (chain+n-1) - partial); 2540 partial->p+1, (chain+n-1) - partial);
diff --git a/fs/ext3/resize.c b/fs/ext3/resize.c
index 0ccd7b12b73c..e746d30b1232 100644
--- a/fs/ext3/resize.c
+++ b/fs/ext3/resize.c
@@ -977,7 +977,8 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
977 o_blocks_count = le32_to_cpu(es->s_blocks_count); 977 o_blocks_count = le32_to_cpu(es->s_blocks_count);
978 978
979 if (test_opt(sb, DEBUG)) 979 if (test_opt(sb, DEBUG))
980 printk(KERN_DEBUG "EXT3-fs: extending last group from "E3FSBLK" uto "E3FSBLK" blocks\n", 980 printk(KERN_DEBUG "EXT3-fs: extending last group from "E3FSBLK
981 " upto "E3FSBLK" blocks\n",
981 o_blocks_count, n_blocks_count); 982 o_blocks_count, n_blocks_count);
982 983
983 if (n_blocks_count == 0 || n_blocks_count == o_blocks_count) 984 if (n_blocks_count == 0 || n_blocks_count == o_blocks_count)
@@ -985,7 +986,7 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
985 986
986 if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 987 if (n_blocks_count > (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) {
987 printk(KERN_ERR "EXT3-fs: filesystem on %s:" 988 printk(KERN_ERR "EXT3-fs: filesystem on %s:"
988 " too large to resize to %lu blocks safely\n", 989 " too large to resize to "E3FSBLK" blocks safely\n",
989 sb->s_id, n_blocks_count); 990 sb->s_id, n_blocks_count);
990 if (sizeof(sector_t) < 8) 991 if (sizeof(sector_t) < 8)
991 ext3_warning(sb, __func__, 992 ext3_warning(sb, __func__,
@@ -1065,11 +1066,11 @@ int ext3_group_extend(struct super_block *sb, struct ext3_super_block *es,
1065 es->s_blocks_count = cpu_to_le32(o_blocks_count + add); 1066 es->s_blocks_count = cpu_to_le32(o_blocks_count + add);
1066 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh); 1067 ext3_journal_dirty_metadata(handle, EXT3_SB(sb)->s_sbh);
1067 mutex_unlock(&EXT3_SB(sb)->s_resize_lock); 1068 mutex_unlock(&EXT3_SB(sb)->s_resize_lock);
1068 ext3_debug("freeing blocks %lu through "E3FSBLK"\n", o_blocks_count, 1069 ext3_debug("freeing blocks "E3FSBLK" through "E3FSBLK"\n",
1069 o_blocks_count + add); 1070 o_blocks_count, o_blocks_count + add);
1070 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks); 1071 ext3_free_blocks_sb(handle, sb, o_blocks_count, add, &freed_blocks);
1071 ext3_debug("freed blocks "E3FSBLK" through "E3FSBLK"\n", o_blocks_count, 1072 ext3_debug("freed blocks "E3FSBLK" through "E3FSBLK"\n",
1072 o_blocks_count + add); 1073 o_blocks_count, o_blocks_count + add);
1073 if ((err = ext3_journal_stop(handle))) 1074 if ((err = ext3_journal_stop(handle)))
1074 goto exit_put; 1075 goto exit_put;
1075 if (test_opt(sb, DEBUG)) 1076 if (test_opt(sb, DEBUG))
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