diff options
Diffstat (limited to 'fs/ext4/balloc.c')
-rw-r--r-- | fs/ext4/balloc.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 0737e05ba3dd..da994374ec3b 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
@@ -15,12 +15,12 @@ | |||
15 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
16 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
17 | #include <linux/jbd2.h> | 17 | #include <linux/jbd2.h> |
18 | #include <linux/ext4_fs.h> | ||
19 | #include <linux/ext4_jbd2.h> | ||
20 | #include <linux/quotaops.h> | 18 | #include <linux/quotaops.h> |
21 | #include <linux/buffer_head.h> | 19 | #include <linux/buffer_head.h> |
22 | 20 | #include "ext4.h" | |
21 | #include "ext4_jbd2.h" | ||
23 | #include "group.h" | 22 | #include "group.h" |
23 | |||
24 | /* | 24 | /* |
25 | * balloc.c contains the blocks allocation and deallocation routines | 25 | * balloc.c contains the blocks allocation and deallocation routines |
26 | */ | 26 | */ |
@@ -48,7 +48,6 @@ void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr, | |||
48 | unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | 48 | unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, |
49 | ext4_group_t block_group, struct ext4_group_desc *gdp) | 49 | ext4_group_t block_group, struct ext4_group_desc *gdp) |
50 | { | 50 | { |
51 | unsigned long start; | ||
52 | int bit, bit_max; | 51 | int bit, bit_max; |
53 | unsigned free_blocks, group_blocks; | 52 | unsigned free_blocks, group_blocks; |
54 | struct ext4_sb_info *sbi = EXT4_SB(sb); | 53 | struct ext4_sb_info *sbi = EXT4_SB(sb); |
@@ -59,7 +58,7 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
59 | /* If checksum is bad mark all blocks used to prevent allocation | 58 | /* If checksum is bad mark all blocks used to prevent allocation |
60 | * essentially implementing a per-group read-only flag. */ | 59 | * essentially implementing a per-group read-only flag. */ |
61 | if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { | 60 | if (!ext4_group_desc_csum_verify(sbi, block_group, gdp)) { |
62 | ext4_error(sb, __FUNCTION__, | 61 | ext4_error(sb, __func__, |
63 | "Checksum bad for group %lu\n", block_group); | 62 | "Checksum bad for group %lu\n", block_group); |
64 | gdp->bg_free_blocks_count = 0; | 63 | gdp->bg_free_blocks_count = 0; |
65 | gdp->bg_free_inodes_count = 0; | 64 | gdp->bg_free_inodes_count = 0; |
@@ -106,11 +105,12 @@ unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh, | |||
106 | free_blocks = group_blocks - bit_max; | 105 | free_blocks = group_blocks - bit_max; |
107 | 106 | ||
108 | if (bh) { | 107 | if (bh) { |
108 | ext4_fsblk_t start; | ||
109 | |||
109 | for (bit = 0; bit < bit_max; bit++) | 110 | for (bit = 0; bit < bit_max; bit++) |
110 | ext4_set_bit(bit, bh->b_data); | 111 | ext4_set_bit(bit, bh->b_data); |
111 | 112 | ||
112 | start = block_group * EXT4_BLOCKS_PER_GROUP(sb) + | 113 | start = ext4_group_first_block_no(sb, block_group); |
113 | le32_to_cpu(sbi->s_es->s_first_data_block); | ||
114 | 114 | ||
115 | /* Set bits for block and inode bitmaps, and inode table */ | 115 | /* Set bits for block and inode bitmaps, and inode table */ |
116 | ext4_set_bit(ext4_block_bitmap(sb, gdp) - start, bh->b_data); | 116 | ext4_set_bit(ext4_block_bitmap(sb, gdp) - start, bh->b_data); |
@@ -235,7 +235,7 @@ static int ext4_valid_block_bitmap(struct super_block *sb, | |||
235 | return 1; | 235 | return 1; |
236 | 236 | ||
237 | err_out: | 237 | err_out: |
238 | ext4_error(sb, __FUNCTION__, | 238 | ext4_error(sb, __func__, |
239 | "Invalid block bitmap - " | 239 | "Invalid block bitmap - " |
240 | "block_group = %d, block = %llu", | 240 | "block_group = %d, block = %llu", |
241 | block_group, bitmap_blk); | 241 | block_group, bitmap_blk); |
@@ -264,7 +264,7 @@ read_block_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
264 | bitmap_blk = ext4_block_bitmap(sb, desc); | 264 | bitmap_blk = ext4_block_bitmap(sb, desc); |
265 | bh = sb_getblk(sb, bitmap_blk); | 265 | bh = sb_getblk(sb, bitmap_blk); |
266 | if (unlikely(!bh)) { | 266 | if (unlikely(!bh)) { |
267 | ext4_error(sb, __FUNCTION__, | 267 | ext4_error(sb, __func__, |
268 | "Cannot read block bitmap - " | 268 | "Cannot read block bitmap - " |
269 | "block_group = %d, block_bitmap = %llu", | 269 | "block_group = %d, block_bitmap = %llu", |
270 | (int)block_group, (unsigned long long)bitmap_blk); | 270 | (int)block_group, (unsigned long long)bitmap_blk); |
@@ -281,7 +281,7 @@ read_block_bitmap(struct super_block *sb, ext4_group_t block_group) | |||
281 | } | 281 | } |
282 | if (bh_submit_read(bh) < 0) { | 282 | if (bh_submit_read(bh) < 0) { |
283 | put_bh(bh); | 283 | put_bh(bh); |
284 | ext4_error(sb, __FUNCTION__, | 284 | ext4_error(sb, __func__, |
285 | "Cannot read block bitmap - " | 285 | "Cannot read block bitmap - " |
286 | "block_group = %d, block_bitmap = %llu", | 286 | "block_group = %d, block_bitmap = %llu", |
287 | (int)block_group, (unsigned long long)bitmap_blk); | 287 | (int)block_group, (unsigned long long)bitmap_blk); |
@@ -360,7 +360,7 @@ restart: | |||
360 | BUG(); | 360 | BUG(); |
361 | } | 361 | } |
362 | #define rsv_window_dump(root, verbose) \ | 362 | #define rsv_window_dump(root, verbose) \ |
363 | __rsv_window_dump((root), (verbose), __FUNCTION__) | 363 | __rsv_window_dump((root), (verbose), __func__) |
364 | #else | 364 | #else |
365 | #define rsv_window_dump(root, verbose) do {} while (0) | 365 | #define rsv_window_dump(root, verbose) do {} while (0) |
366 | #endif | 366 | #endif |
@@ -740,7 +740,7 @@ do_more: | |||
740 | if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group), | 740 | if (!ext4_clear_bit_atomic(sb_bgl_lock(sbi, block_group), |
741 | bit + i, bitmap_bh->b_data)) { | 741 | bit + i, bitmap_bh->b_data)) { |
742 | jbd_unlock_bh_state(bitmap_bh); | 742 | jbd_unlock_bh_state(bitmap_bh); |
743 | ext4_error(sb, __FUNCTION__, | 743 | ext4_error(sb, __func__, |
744 | "bit already cleared for block %llu", | 744 | "bit already cleared for block %llu", |
745 | (ext4_fsblk_t)(block + i)); | 745 | (ext4_fsblk_t)(block + i)); |
746 | jbd_lock_bh_state(bitmap_bh); | 746 | jbd_lock_bh_state(bitmap_bh); |
@@ -752,9 +752,7 @@ do_more: | |||
752 | jbd_unlock_bh_state(bitmap_bh); | 752 | jbd_unlock_bh_state(bitmap_bh); |
753 | 753 | ||
754 | spin_lock(sb_bgl_lock(sbi, block_group)); | 754 | spin_lock(sb_bgl_lock(sbi, block_group)); |
755 | desc->bg_free_blocks_count = | 755 | le16_add_cpu(&desc->bg_free_blocks_count, group_freed); |
756 | cpu_to_le16(le16_to_cpu(desc->bg_free_blocks_count) + | ||
757 | group_freed); | ||
758 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); | 756 | desc->bg_checksum = ext4_group_desc_csum(sbi, block_group, desc); |
759 | spin_unlock(sb_bgl_lock(sbi, block_group)); | 757 | spin_unlock(sb_bgl_lock(sbi, block_group)); |
760 | percpu_counter_add(&sbi->s_freeblocks_counter, count); | 758 | percpu_counter_add(&sbi->s_freeblocks_counter, count); |
@@ -1798,7 +1796,7 @@ allocated: | |||
1798 | if (ext4_test_bit(grp_alloc_blk+i, | 1796 | if (ext4_test_bit(grp_alloc_blk+i, |
1799 | bh2jh(bitmap_bh)->b_committed_data)) { | 1797 | bh2jh(bitmap_bh)->b_committed_data)) { |
1800 | printk("%s: block was unexpectedly set in " | 1798 | printk("%s: block was unexpectedly set in " |
1801 | "b_committed_data\n", __FUNCTION__); | 1799 | "b_committed_data\n", __func__); |
1802 | } | 1800 | } |
1803 | } | 1801 | } |
1804 | } | 1802 | } |
@@ -1823,8 +1821,7 @@ allocated: | |||
1823 | spin_lock(sb_bgl_lock(sbi, group_no)); | 1821 | spin_lock(sb_bgl_lock(sbi, group_no)); |
1824 | if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) | 1822 | if (gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) |
1825 | gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT); | 1823 | gdp->bg_flags &= cpu_to_le16(~EXT4_BG_BLOCK_UNINIT); |
1826 | gdp->bg_free_blocks_count = | 1824 | le16_add_cpu(&gdp->bg_free_blocks_count, -num); |
1827 | cpu_to_le16(le16_to_cpu(gdp->bg_free_blocks_count)-num); | ||
1828 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp); | 1825 | gdp->bg_checksum = ext4_group_desc_csum(sbi, group_no, gdp); |
1829 | spin_unlock(sb_bgl_lock(sbi, group_no)); | 1826 | spin_unlock(sb_bgl_lock(sbi, group_no)); |
1830 | percpu_counter_sub(&sbi->s_freeblocks_counter, num); | 1827 | percpu_counter_sub(&sbi->s_freeblocks_counter, num); |