diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2009-01-03 22:33:39 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2009-01-03 22:33:39 -0500 |
commit | 3300beda523136f9f87821e4fba85c5c9e319645 (patch) | |
tree | 0af91284ffa44b9c8c1b0de26674bca30271561f /fs | |
parent | 560671a0d3c9ad2d647fa6d09375a262e1f19c4f (diff) |
ext4: code cleanup
Rename some variables. We also unlock locks in the reverse order we
acquired as a part of cleanup.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/balloc.c | 2 | ||||
-rw-r--r-- | fs/ext4/ialloc.c | 65 | ||||
-rw-r--r-- | fs/ext4/mballoc.c | 2 |
3 files changed, 37 insertions, 32 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 902bf66c8dfb..1b26b68aa428 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -329,8 +329,8 @@ ext4_read_block_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
329 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { | 329 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { |
330 | ext4_init_block_bitmap(sb, bh, block_group, desc); | 330 | ext4_init_block_bitmap(sb, bh, block_group, desc); |
331 | set_buffer_uptodate(bh); | 331 | set_buffer_uptodate(bh); |
332 | unlock_buffer(bh); | ||
333 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); | 332 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); |
333 | unlock_buffer(bh); | ||
334 | return bh; | 334 | return bh; |
335 | } | 335 | } |
336 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); | 336 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index 11c4f6f5bd61..b47427a21f1c 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
@@ -124,8 +124,8 @@ ext4_read_inode_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
124 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) { | 124 | if (desc->bg_flags & cpu_to_le16(EXT4_BG_INODE_UNINIT)) { |
125 | ext4_init_inode_bitmap(sb, bh, block_group, desc); | 125 | ext4_init_inode_bitmap(sb, bh, block_group, desc); |
126 | set_buffer_uptodate(bh); | 126 | set_buffer_uptodate(bh); |
127 | unlock_buffer(bh); | ||
128 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); | 127 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); |
128 | unlock_buffer(bh); | ||
129 | return bh; | 129 | return bh; |
130 | } | 130 | } |
131 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); | 131 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), block_group)); |
@@ -585,8 +585,8 @@ static int find_group_other(struct super_block *sb, struct inode *parent, | |||
585 | struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) | 585 | struct inode *ext4_new_inode(handle_t *handle, struct inode *dir, int mode) |
586 | { | 586 | { |
587 | struct super_block *sb; | 587 | struct super_block *sb; |
588 | struct buffer_head *bitmap_bh = NULL; | 588 | struct buffer_head *inode_bitmap_bh = NULL; |
589 | struct buffer_head *bh2; | 589 | struct buffer_head *group_desc_bh; |
590 | ext4_group_t group = 0; | 590 | ext4_group_t group = 0; |
591 | unsigned long ino = 0; | 591 | unsigned long ino = 0; |
592 | struct inode *inode; | 592 | struct inode *inode; |
@@ -634,41 +634,44 @@ got_group: | |||
634 | for (i = 0; i < sbi->s_groups_count; i++) { | 634 | for (i = 0; i < sbi->s_groups_count; i++) { |
635 | err = -EIO; | 635 | err = -EIO; |
636 | 636 | ||
637 | gdp = ext4_get_group_desc(sb, group, &bh2); | 637 | gdp = ext4_get_group_desc(sb, group, &group_desc_bh); |
638 | if (!gdp) | 638 | if (!gdp) |
639 | goto fail; | 639 | goto fail; |
640 | 640 | ||
641 | brelse(bitmap_bh); | 641 | brelse(inode_bitmap_bh); |
642 | bitmap_bh = ext4_read_inode_bitmap(sb, group); | 642 | inode_bitmap_bh = ext4_read_inode_bitmap(sb, group); |
643 | if (!bitmap_bh) | 643 | if (!inode_bitmap_bh) |
644 | goto fail; | 644 | goto fail; |
645 | 645 | ||
646 | ino = 0; | 646 | ino = 0; |
647 | 647 | ||
648 | repeat_in_this_group: | 648 | repeat_in_this_group: |
649 | ino = ext4_find_next_zero_bit((unsigned long *) | 649 | ino = ext4_find_next_zero_bit((unsigned long *) |
650 | bitmap_bh->b_data, EXT4_INODES_PER_GROUP(sb), ino); | 650 | inode_bitmap_bh->b_data, |
651 | EXT4_INODES_PER_GROUP(sb), ino); | ||
652 | |||
651 | if (ino < EXT4_INODES_PER_GROUP(sb)) { | 653 | if (ino < EXT4_INODES_PER_GROUP(sb)) { |
652 | 654 | ||
653 | BUFFER_TRACE(bitmap_bh, "get_write_access"); | 655 | BUFFER_TRACE(inode_bitmap_bh, "get_write_access"); |
654 | err = ext4_journal_get_write_access(handle, bitmap_bh); | 656 | err = ext4_journal_get_write_access(handle, |
657 | inode_bitmap_bh); | ||
655 | if (err) | 658 | if (err) |
656 | goto fail; | 659 | goto fail; |
657 | 660 | ||
658 | if (!ext4_set_bit_atomic(sb_bgl_lock(sbi, group), | 661 | if (!ext4_set_bit_atomic(sb_bgl_lock(sbi, group), |
659 | ino, bitmap_bh->b_data)) { | 662 | ino, inode_bitmap_bh->b_data)) { |
660 | /* we won it */ | 663 | /* we won it */ |
661 | BUFFER_TRACE(bitmap_bh, | 664 | BUFFER_TRACE(inode_bitmap_bh, |
662 | "call ext4_handle_dirty_metadata"); | 665 | "call ext4_handle_dirty_metadata"); |
663 | err = ext4_handle_dirty_metadata(handle, | 666 | err = ext4_handle_dirty_metadata(handle, |
664 | inode, | 667 | inode, |
665 | bitmap_bh); | 668 | inode_bitmap_bh); |
666 | if (err) | 669 | if (err) |
667 | goto fail; | 670 | goto fail; |
668 | goto got; | 671 | goto got; |
669 | } | 672 | } |
670 | /* we lost it */ | 673 | /* we lost it */ |
671 | ext4_handle_release_buffer(handle, bitmap_bh); | 674 | ext4_handle_release_buffer(handle, inode_bitmap_bh); |
672 | 675 | ||
673 | if (++ino < EXT4_INODES_PER_GROUP(sb)) | 676 | if (++ino < EXT4_INODES_PER_GROUP(sb)) |
674 | goto repeat_in_this_group; | 677 | goto repeat_in_this_group; |
@@ -699,19 +702,21 @@ got: | |||
699 | goto fail; | 702 | goto fail; |
700 | } | 703 | } |
701 | 704 | ||
702 | BUFFER_TRACE(bh2, "get_write_access"); | 705 | BUFFER_TRACE(group_desc_bh, "get_write_access"); |
703 | err = ext4_journal_get_write_access(handle, bh2); | 706 | err = ext4_journal_get_write_access(handle, group_desc_bh); |
704 | if (err) goto fail; | 707 | if (err) |
708 | goto fail; | ||
705 | 709 | ||
706 | /* We may have to initialize the block bitmap if it isn't already */ | 710 | /* We may have to initialize the block bitmap if it isn't already */ |
707 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && | 711 | if (EXT4_HAS_RO_COMPAT_FEATURE(sb, EXT4_FEATURE_RO_COMPAT_GDT_CSUM) && |
708 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { | 712 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { |
709 | struct buffer_head *block_bh = ext4_read_block_bitmap(sb, group); | 713 | struct buffer_head *block_bitmap_bh; |
710 | 714 | ||
711 | BUFFER_TRACE(block_bh, "get block bitmap access"); | 715 | block_bitmap_bh = ext4_read_block_bitmap(sb, group); |
712 | err = ext4_journal_get_write_access(handle, block_bh); | 716 | BUFFER_TRACE(block_bitmap_bh, "get block bitmap access"); |
717 | err = ext4_journal_get_write_access(handle, block_bitmap_bh); | ||
713 | if (err) { | 718 | if (err) { |
714 | brelse(block_bh); | 719 | brelse(block_bitmap_bh); |
715 | goto fail; | 720 | goto fail; |
716 | } | 721 | } |
717 | 722 | ||
@@ -719,8 +724,8 @@ got: | |||
719 | spin_lock(sb_bgl_lock(sbi, group)); | 724 | spin_lock(sb_bgl_lock(sbi, group)); |
720 | /* recheck and clear flag under lock if we still need to */ | 725 | /* recheck and clear flag under lock if we still need to */ |
721 | if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { | 726 | if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { |
722 | gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT); | ||
723 | free = ext4_free_blocks_after_init(sb, group, gdp); | 727 | free = ext4_free_blocks_after_init(sb, group, gdp); |
728 | gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT); | ||
724 | ext4_free_blks_set(sb, gdp, free); | 729 | ext4_free_blks_set(sb, gdp, free); |
725 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, | 730 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, |
726 | gdp); | 731 | gdp); |
@@ -729,12 +734,12 @@ got: | |||
729 | 734 | ||
730 | /* Don't need to dirty bitmap block if we didn't change it */ | 735 | /* Don't need to dirty bitmap block if we didn't change it */ |
731 | if (free) { | 736 | if (free) { |
732 | BUFFER_TRACE(block_bh, "dirty block bitmap"); | 737 | BUFFER_TRACE(block_bitmap_bh, "dirty block bitmap"); |
733 | err = ext4_handle_dirty_metadata(handle, | 738 | err = ext4_handle_dirty_metadata(handle, |
734 | NULL, block_bh); | 739 | NULL, block_bitmap_bh); |
735 | } | 740 | } |
736 | 741 | ||
737 | brelse(block_bh); | 742 | brelse(block_bitmap_bh); |
738 | if (err) | 743 | if (err) |
739 | goto fail; | 744 | goto fail; |
740 | } | 745 | } |
@@ -778,8 +783,8 @@ got: | |||
778 | } | 783 | } |
779 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); | 784 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group, gdp); |
780 | spin_unlock(sb_bgl_lock(sbi, group)); | 785 | spin_unlock(sb_bgl_lock(sbi, group)); |
781 | BUFFER_TRACE(bh2, "call ext4_handle_dirty_metadata"); | 786 | BUFFER_TRACE(group_desc_bh, "call ext4_handle_dirty_metadata"); |
782 | err = ext4_handle_dirty_metadata(handle, NULL, bh2); | 787 | err = ext4_handle_dirty_metadata(handle, NULL, group_desc_bh); |
783 | if (err) goto fail; | 788 | if (err) goto fail; |
784 | 789 | ||
785 | percpu_counter_dec(&sbi->s_freeinodes_counter); | 790 | percpu_counter_dec(&sbi->s_freeinodes_counter); |
@@ -881,7 +886,7 @@ out: | |||
881 | iput(inode); | 886 | iput(inode); |
882 | ret = ERR_PTR(err); | 887 | ret = ERR_PTR(err); |
883 | really_out: | 888 | really_out: |
884 | brelse(bitmap_bh); | 889 | brelse(inode_bitmap_bh); |
885 | return ret; | 890 | return ret; |
886 | 891 | ||
887 | fail_free_drop: | 892 | fail_free_drop: |
@@ -893,7 +898,7 @@ fail_drop: | |||
893 | inode->i_nlink = 0; | 898 | inode->i_nlink = 0; |
894 | unlock_new_inode(inode); | 899 | unlock_new_inode(inode); |
895 | iput(inode); | 900 | iput(inode); |
896 | brelse(bitmap_bh); | 901 | brelse(inode_bitmap_bh); |
897 | return ERR_PTR(err); | 902 | return ERR_PTR(err); |
898 | } | 903 | } |
899 | 904 | ||
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 3809a9348f29..aac33590ac64 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
@@ -804,8 +804,8 @@ static int ext4_mb_init_cache(struct page *page, char *incore) | |||
804 | ext4_init_block_bitmap(sb, bh[i], | 804 | ext4_init_block_bitmap(sb, bh[i], |
805 | first_group + i, desc); | 805 | first_group + i, desc); |
806 | set_buffer_uptodate(bh[i]); | 806 | set_buffer_uptodate(bh[i]); |
807 | unlock_buffer(bh[i]); | ||
808 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); | 807 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); |
808 | unlock_buffer(bh[i]); | ||
809 | continue; | 809 | continue; |
810 | } | 810 | } |
811 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); | 811 | spin_unlock(sb_bgl_lock(EXT4_SB(sb), first_group + i)); |