diff options
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/balloc.c | 29 | ||||
-rw-r--r-- | fs/ext2/dir.c | 20 | ||||
-rw-r--r-- | fs/ext2/ialloc.c | 12 | ||||
-rw-r--r-- | fs/ext2/inode.c | 15 | ||||
-rw-r--r-- | fs/ext2/super.c | 27 | ||||
-rw-r--r-- | fs/ext2/xattr.c | 15 | ||||
-rw-r--r-- | fs/ext2/xip.c | 53 | ||||
-rw-r--r-- | fs/ext2/xip.h | 9 |
8 files changed, 85 insertions, 95 deletions
diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index e7b2bafa1dd9..10bb02c3f25c 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c | |||
@@ -106,7 +106,7 @@ static int ext2_valid_block_bitmap(struct super_block *sb, | |||
106 | return 1; | 106 | return 1; |
107 | 107 | ||
108 | err_out: | 108 | err_out: |
109 | ext2_error(sb, __FUNCTION__, | 109 | ext2_error(sb, __func__, |
110 | "Invalid block bitmap - " | 110 | "Invalid block bitmap - " |
111 | "block_group = %d, block = %lu", | 111 | "block_group = %d, block = %lu", |
112 | block_group, bitmap_blk); | 112 | block_group, bitmap_blk); |
@@ -132,7 +132,7 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) | |||
132 | bitmap_blk = le32_to_cpu(desc->bg_block_bitmap); | 132 | bitmap_blk = le32_to_cpu(desc->bg_block_bitmap); |
133 | bh = sb_getblk(sb, bitmap_blk); | 133 | bh = sb_getblk(sb, bitmap_blk); |
134 | if (unlikely(!bh)) { | 134 | if (unlikely(!bh)) { |
135 | ext2_error(sb, __FUNCTION__, | 135 | ext2_error(sb, __func__, |
136 | "Cannot read block bitmap - " | 136 | "Cannot read block bitmap - " |
137 | "block_group = %d, block_bitmap = %u", | 137 | "block_group = %d, block_bitmap = %u", |
138 | block_group, le32_to_cpu(desc->bg_block_bitmap)); | 138 | block_group, le32_to_cpu(desc->bg_block_bitmap)); |
@@ -143,17 +143,18 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) | |||
143 | 143 | ||
144 | if (bh_submit_read(bh) < 0) { | 144 | if (bh_submit_read(bh) < 0) { |
145 | brelse(bh); | 145 | brelse(bh); |
146 | ext2_error(sb, __FUNCTION__, | 146 | ext2_error(sb, __func__, |
147 | "Cannot read block bitmap - " | 147 | "Cannot read block bitmap - " |
148 | "block_group = %d, block_bitmap = %u", | 148 | "block_group = %d, block_bitmap = %u", |
149 | block_group, le32_to_cpu(desc->bg_block_bitmap)); | 149 | block_group, le32_to_cpu(desc->bg_block_bitmap)); |
150 | return NULL; | 150 | return NULL; |
151 | } | 151 | } |
152 | if (!ext2_valid_block_bitmap(sb, desc, block_group, bh)) { | ||
153 | brelse(bh); | ||
154 | return NULL; | ||
155 | } | ||
156 | 152 | ||
153 | ext2_valid_block_bitmap(sb, desc, block_group, bh); | ||
154 | /* | ||
155 | * file system mounted not to panic on error, continue with corrupt | ||
156 | * bitmap | ||
157 | */ | ||
157 | return bh; | 158 | return bh; |
158 | } | 159 | } |
159 | 160 | ||
@@ -245,11 +246,10 @@ restart: | |||
245 | prev = rsv; | 246 | prev = rsv; |
246 | } | 247 | } |
247 | printk("Window map complete.\n"); | 248 | printk("Window map complete.\n"); |
248 | if (bad) | 249 | BUG_ON(bad); |
249 | BUG(); | ||
250 | } | 250 | } |
251 | #define rsv_window_dump(root, verbose) \ | 251 | #define rsv_window_dump(root, verbose) \ |
252 | __rsv_window_dump((root), (verbose), __FUNCTION__) | 252 | __rsv_window_dump((root), (verbose), __func__) |
253 | #else | 253 | #else |
254 | #define rsv_window_dump(root, verbose) do {} while (0) | 254 | #define rsv_window_dump(root, verbose) do {} while (0) |
255 | #endif | 255 | #endif |
@@ -548,7 +548,7 @@ do_more: | |||
548 | for (i = 0, group_freed = 0; i < count; i++) { | 548 | for (i = 0, group_freed = 0; i < count; i++) { |
549 | if (!ext2_clear_bit_atomic(sb_bgl_lock(sbi, block_group), | 549 | if (!ext2_clear_bit_atomic(sb_bgl_lock(sbi, block_group), |
550 | bit + i, bitmap_bh->b_data)) { | 550 | bit + i, bitmap_bh->b_data)) { |
551 | ext2_error(sb, __FUNCTION__, | 551 | ext2_error(sb, __func__, |
552 | "bit already cleared for block %lu", block + i); | 552 | "bit already cleared for block %lu", block + i); |
553 | } else { | 553 | } else { |
554 | group_freed++; | 554 | group_freed++; |
@@ -1381,7 +1381,12 @@ allocated: | |||
1381 | "Allocating block in system zone - " | 1381 | "Allocating block in system zone - " |
1382 | "blocks from "E2FSBLK", length %lu", | 1382 | "blocks from "E2FSBLK", length %lu", |
1383 | ret_block, num); | 1383 | ret_block, num); |
1384 | goto out; | 1384 | /* |
1385 | * ext2_try_to_allocate marked the blocks we allocated as in | ||
1386 | * use. So we may want to selectively mark some of the blocks | ||
1387 | * as free | ||
1388 | */ | ||
1389 | goto retry_alloc; | ||
1385 | } | 1390 | } |
1386 | 1391 | ||
1387 | performed_allocation = 1; | 1392 | performed_allocation = 1; |
diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 8dededd80fe2..a78c6b4af060 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
@@ -41,8 +41,8 @@ static inline __le16 ext2_rec_len_to_disk(unsigned len) | |||
41 | { | 41 | { |
42 | if (len == (1 << 16)) | 42 | if (len == (1 << 16)) |
43 | return cpu_to_le16(EXT2_MAX_REC_LEN); | 43 | return cpu_to_le16(EXT2_MAX_REC_LEN); |
44 | else if (len > (1 << 16)) | 44 | else |
45 | BUG(); | 45 | BUG_ON(len > (1 << 16)); |
46 | return cpu_to_le16(len); | 46 | return cpu_to_le16(len); |
47 | } | 47 | } |
48 | 48 | ||
@@ -295,11 +295,11 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) | |||
295 | struct page *page = ext2_get_page(inode, n); | 295 | struct page *page = ext2_get_page(inode, n); |
296 | 296 | ||
297 | if (IS_ERR(page)) { | 297 | if (IS_ERR(page)) { |
298 | ext2_error(sb, __FUNCTION__, | 298 | ext2_error(sb, __func__, |
299 | "bad page in #%lu", | 299 | "bad page in #%lu", |
300 | inode->i_ino); | 300 | inode->i_ino); |
301 | filp->f_pos += PAGE_CACHE_SIZE - offset; | 301 | filp->f_pos += PAGE_CACHE_SIZE - offset; |
302 | return -EIO; | 302 | return PTR_ERR(page); |
303 | } | 303 | } |
304 | kaddr = page_address(page); | 304 | kaddr = page_address(page); |
305 | if (unlikely(need_revalidate)) { | 305 | if (unlikely(need_revalidate)) { |
@@ -314,7 +314,7 @@ ext2_readdir (struct file * filp, void * dirent, filldir_t filldir) | |||
314 | limit = kaddr + ext2_last_byte(inode, n) - EXT2_DIR_REC_LEN(1); | 314 | limit = kaddr + ext2_last_byte(inode, n) - EXT2_DIR_REC_LEN(1); |
315 | for ( ;(char*)de <= limit; de = ext2_next_entry(de)) { | 315 | for ( ;(char*)de <= limit; de = ext2_next_entry(de)) { |
316 | if (de->rec_len == 0) { | 316 | if (de->rec_len == 0) { |
317 | ext2_error(sb, __FUNCTION__, | 317 | ext2_error(sb, __func__, |
318 | "zero-length directory entry"); | 318 | "zero-length directory entry"); |
319 | ext2_put_page(page); | 319 | ext2_put_page(page); |
320 | return -EIO; | 320 | return -EIO; |
@@ -381,7 +381,7 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, | |||
381 | kaddr += ext2_last_byte(dir, n) - reclen; | 381 | kaddr += ext2_last_byte(dir, n) - reclen; |
382 | while ((char *) de <= kaddr) { | 382 | while ((char *) de <= kaddr) { |
383 | if (de->rec_len == 0) { | 383 | if (de->rec_len == 0) { |
384 | ext2_error(dir->i_sb, __FUNCTION__, | 384 | ext2_error(dir->i_sb, __func__, |
385 | "zero-length directory entry"); | 385 | "zero-length directory entry"); |
386 | ext2_put_page(page); | 386 | ext2_put_page(page); |
387 | goto out; | 387 | goto out; |
@@ -396,7 +396,7 @@ struct ext2_dir_entry_2 * ext2_find_entry (struct inode * dir, | |||
396 | n = 0; | 396 | n = 0; |
397 | /* next page is past the blocks we've got */ | 397 | /* next page is past the blocks we've got */ |
398 | if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) { | 398 | if (unlikely(n > (dir->i_blocks >> (PAGE_CACHE_SHIFT - 9)))) { |
399 | ext2_error(dir->i_sb, __FUNCTION__, | 399 | ext2_error(dir->i_sb, __func__, |
400 | "dir %lu size %lld exceeds block count %llu", | 400 | "dir %lu size %lld exceeds block count %llu", |
401 | dir->i_ino, dir->i_size, | 401 | dir->i_ino, dir->i_size, |
402 | (unsigned long long)dir->i_blocks); | 402 | (unsigned long long)dir->i_blocks); |
@@ -506,7 +506,7 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode) | |||
506 | goto got_it; | 506 | goto got_it; |
507 | } | 507 | } |
508 | if (de->rec_len == 0) { | 508 | if (de->rec_len == 0) { |
509 | ext2_error(dir->i_sb, __FUNCTION__, | 509 | ext2_error(dir->i_sb, __func__, |
510 | "zero-length directory entry"); | 510 | "zero-length directory entry"); |
511 | err = -EIO; | 511 | err = -EIO; |
512 | goto out_unlock; | 512 | goto out_unlock; |
@@ -578,7 +578,7 @@ int ext2_delete_entry (struct ext2_dir_entry_2 * dir, struct page * page ) | |||
578 | 578 | ||
579 | while ((char*)de < (char*)dir) { | 579 | while ((char*)de < (char*)dir) { |
580 | if (de->rec_len == 0) { | 580 | if (de->rec_len == 0) { |
581 | ext2_error(inode->i_sb, __FUNCTION__, | 581 | ext2_error(inode->i_sb, __func__, |
582 | "zero-length directory entry"); | 582 | "zero-length directory entry"); |
583 | err = -EIO; | 583 | err = -EIO; |
584 | goto out; | 584 | goto out; |
@@ -670,7 +670,7 @@ int ext2_empty_dir (struct inode * inode) | |||
670 | 670 | ||
671 | while ((char *)de <= kaddr) { | 671 | while ((char *)de <= kaddr) { |
672 | if (de->rec_len == 0) { | 672 | if (de->rec_len == 0) { |
673 | ext2_error(inode->i_sb, __FUNCTION__, | 673 | ext2_error(inode->i_sb, __func__, |
674 | "zero-length directory entry"); | 674 | "zero-length directory entry"); |
675 | printk("kaddr=%p, de=%p\n", kaddr, de); | 675 | printk("kaddr=%p, de=%p\n", kaddr, de); |
676 | goto not_empty; | 676 | goto not_empty; |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 08f647d8188d..f59741346760 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -75,11 +75,9 @@ static void ext2_release_inode(struct super_block *sb, int group, int dir) | |||
75 | } | 75 | } |
76 | 76 | ||
77 | spin_lock(sb_bgl_lock(EXT2_SB(sb), group)); | 77 | spin_lock(sb_bgl_lock(EXT2_SB(sb), group)); |
78 | desc->bg_free_inodes_count = | 78 | le16_add_cpu(&desc->bg_free_inodes_count, 1); |
79 | cpu_to_le16(le16_to_cpu(desc->bg_free_inodes_count) + 1); | ||
80 | if (dir) | 79 | if (dir) |
81 | desc->bg_used_dirs_count = | 80 | le16_add_cpu(&desc->bg_used_dirs_count, -1); |
82 | cpu_to_le16(le16_to_cpu(desc->bg_used_dirs_count) - 1); | ||
83 | spin_unlock(sb_bgl_lock(EXT2_SB(sb), group)); | 81 | spin_unlock(sb_bgl_lock(EXT2_SB(sb), group)); |
84 | if (dir) | 82 | if (dir) |
85 | percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter); | 83 | percpu_counter_dec(&EXT2_SB(sb)->s_dirs_counter); |
@@ -539,13 +537,11 @@ got: | |||
539 | percpu_counter_inc(&sbi->s_dirs_counter); | 537 | percpu_counter_inc(&sbi->s_dirs_counter); |
540 | 538 | ||
541 | spin_lock(sb_bgl_lock(sbi, group)); | 539 | spin_lock(sb_bgl_lock(sbi, group)); |
542 | gdp->bg_free_inodes_count = | 540 | le16_add_cpu(&gdp->bg_free_inodes_count, -1); |
543 | cpu_to_le16(le16_to_cpu(gdp->bg_free_inodes_count) - 1); | ||
544 | if (S_ISDIR(mode)) { | 541 | if (S_ISDIR(mode)) { |
545 | if (sbi->s_debts[group] < 255) | 542 | if (sbi->s_debts[group] < 255) |
546 | sbi->s_debts[group]++; | 543 | sbi->s_debts[group]++; |
547 | gdp->bg_used_dirs_count = | 544 | le16_add_cpu(&gdp->bg_used_dirs_count, 1); |
548 | cpu_to_le16(le16_to_cpu(gdp->bg_used_dirs_count) + 1); | ||
549 | } else { | 545 | } else { |
550 | if (sbi->s_debts[group]) | 546 | if (sbi->s_debts[group]) |
551 | sbi->s_debts[group]--; | 547 | sbi->s_debts[group]--; |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index b8a2990bab83..384fc0d1dd74 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -254,13 +254,13 @@ no_block: | |||
254 | * Caller must make sure that @ind is valid and will stay that way. | 254 | * Caller must make sure that @ind is valid and will stay that way. |
255 | */ | 255 | */ |
256 | 256 | ||
257 | static unsigned long ext2_find_near(struct inode *inode, Indirect *ind) | 257 | static ext2_fsblk_t ext2_find_near(struct inode *inode, Indirect *ind) |
258 | { | 258 | { |
259 | struct ext2_inode_info *ei = EXT2_I(inode); | 259 | struct ext2_inode_info *ei = EXT2_I(inode); |
260 | __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data; | 260 | __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data; |
261 | __le32 *p; | 261 | __le32 *p; |
262 | unsigned long bg_start; | 262 | ext2_fsblk_t bg_start; |
263 | unsigned long colour; | 263 | ext2_fsblk_t colour; |
264 | 264 | ||
265 | /* Try to find previous block */ | 265 | /* Try to find previous block */ |
266 | for (p = ind->p - 1; p >= start; p--) | 266 | for (p = ind->p - 1; p >= start; p--) |
@@ -275,8 +275,7 @@ static unsigned long ext2_find_near(struct inode *inode, Indirect *ind) | |||
275 | * It is going to be refered from inode itself? OK, just put it into | 275 | * It is going to be refered from inode itself? OK, just put it into |
276 | * the same cylinder group then. | 276 | * the same cylinder group then. |
277 | */ | 277 | */ |
278 | bg_start = (ei->i_block_group * EXT2_BLOCKS_PER_GROUP(inode->i_sb)) + | 278 | bg_start = ext2_group_first_block_no(inode->i_sb, ei->i_block_group); |
279 | le32_to_cpu(EXT2_SB(inode->i_sb)->s_es->s_first_data_block); | ||
280 | colour = (current->pid % 16) * | 279 | colour = (current->pid % 16) * |
281 | (EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16); | 280 | (EXT2_BLOCKS_PER_GROUP(inode->i_sb) / 16); |
282 | return bg_start + colour; | 281 | return bg_start + colour; |
@@ -291,8 +290,8 @@ static unsigned long ext2_find_near(struct inode *inode, Indirect *ind) | |||
291 | * Returns preferred place for a block (the goal). | 290 | * Returns preferred place for a block (the goal). |
292 | */ | 291 | */ |
293 | 292 | ||
294 | static inline int ext2_find_goal(struct inode *inode, long block, | 293 | static inline ext2_fsblk_t ext2_find_goal(struct inode *inode, long block, |
295 | Indirect *partial) | 294 | Indirect *partial) |
296 | { | 295 | { |
297 | struct ext2_block_alloc_info *block_i; | 296 | struct ext2_block_alloc_info *block_i; |
298 | 297 | ||
@@ -796,7 +795,7 @@ const struct address_space_operations ext2_aops = { | |||
796 | 795 | ||
797 | const struct address_space_operations ext2_aops_xip = { | 796 | const struct address_space_operations ext2_aops_xip = { |
798 | .bmap = ext2_bmap, | 797 | .bmap = ext2_bmap, |
799 | .get_xip_page = ext2_get_xip_page, | 798 | .get_xip_mem = ext2_get_xip_mem, |
800 | }; | 799 | }; |
801 | 800 | ||
802 | const struct address_space_operations ext2_nobh_aops = { | 801 | const struct address_space_operations ext2_nobh_aops = { |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 088b011bb97e..ef50cbc792db 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -51,8 +51,7 @@ void ext2_error (struct super_block * sb, const char * function, | |||
51 | 51 | ||
52 | if (!(sb->s_flags & MS_RDONLY)) { | 52 | if (!(sb->s_flags & MS_RDONLY)) { |
53 | sbi->s_mount_state |= EXT2_ERROR_FS; | 53 | sbi->s_mount_state |= EXT2_ERROR_FS; |
54 | es->s_state = | 54 | es->s_state |= cpu_to_le16(EXT2_ERROR_FS); |
55 | cpu_to_le16(le16_to_cpu(es->s_state) | EXT2_ERROR_FS); | ||
56 | ext2_sync_super(sb, es); | 55 | ext2_sync_super(sb, es); |
57 | } | 56 | } |
58 | 57 | ||
@@ -90,7 +89,7 @@ void ext2_update_dynamic_rev(struct super_block *sb) | |||
90 | if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) | 89 | if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) |
91 | return; | 90 | return; |
92 | 91 | ||
93 | ext2_warning(sb, __FUNCTION__, | 92 | ext2_warning(sb, __func__, |
94 | "updating to rev %d because of new feature flag, " | 93 | "updating to rev %d because of new feature flag, " |
95 | "running e2fsck is recommended", | 94 | "running e2fsck is recommended", |
96 | EXT2_DYNAMIC_REV); | 95 | EXT2_DYNAMIC_REV); |
@@ -604,7 +603,7 @@ static int ext2_setup_super (struct super_block * sb, | |||
604 | "running e2fsck is recommended\n"); | 603 | "running e2fsck is recommended\n"); |
605 | if (!le16_to_cpu(es->s_max_mnt_count)) | 604 | if (!le16_to_cpu(es->s_max_mnt_count)) |
606 | es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); | 605 | es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); |
607 | es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); | 606 | le16_add_cpu(&es->s_mnt_count, 1); |
608 | ext2_write_super(sb); | 607 | ext2_write_super(sb); |
609 | if (test_opt (sb, DEBUG)) | 608 | if (test_opt (sb, DEBUG)) |
610 | printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " | 609 | printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, " |
@@ -622,13 +621,13 @@ static int ext2_check_descriptors(struct super_block *sb) | |||
622 | { | 621 | { |
623 | int i; | 622 | int i; |
624 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 623 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
625 | unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block); | ||
626 | unsigned long last_block; | ||
627 | 624 | ||
628 | ext2_debug ("Checking group descriptors"); | 625 | ext2_debug ("Checking group descriptors"); |
629 | 626 | ||
630 | for (i = 0; i < sbi->s_groups_count; i++) { | 627 | for (i = 0; i < sbi->s_groups_count; i++) { |
631 | struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL); | 628 | struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL); |
629 | ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i); | ||
630 | ext2_fsblk_t last_block; | ||
632 | 631 | ||
633 | if (i == sbi->s_groups_count - 1) | 632 | if (i == sbi->s_groups_count - 1) |
634 | last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; | 633 | last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; |
@@ -664,7 +663,6 @@ static int ext2_check_descriptors(struct super_block *sb) | |||
664 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); | 663 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); |
665 | return 0; | 664 | return 0; |
666 | } | 665 | } |
667 | first_block += EXT2_BLOCKS_PER_GROUP(sb); | ||
668 | } | 666 | } |
669 | return 1; | 667 | return 1; |
670 | } | 668 | } |
@@ -721,10 +719,9 @@ static unsigned long descriptor_loc(struct super_block *sb, | |||
721 | int nr) | 719 | int nr) |
722 | { | 720 | { |
723 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 721 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
724 | unsigned long bg, first_data_block, first_meta_bg; | 722 | unsigned long bg, first_meta_bg; |
725 | int has_super = 0; | 723 | int has_super = 0; |
726 | 724 | ||
727 | first_data_block = le32_to_cpu(sbi->s_es->s_first_data_block); | ||
728 | first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); | 725 | first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); |
729 | 726 | ||
730 | if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) || | 727 | if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) || |
@@ -733,7 +730,8 @@ static unsigned long descriptor_loc(struct super_block *sb, | |||
733 | bg = sbi->s_desc_per_block * nr; | 730 | bg = sbi->s_desc_per_block * nr; |
734 | if (ext2_bg_has_super(sb, bg)) | 731 | if (ext2_bg_has_super(sb, bg)) |
735 | has_super = 1; | 732 | has_super = 1; |
736 | return (first_data_block + has_super + (bg * sbi->s_blocks_per_group)); | 733 | |
734 | return ext2_group_first_block_no(sb, bg) + has_super; | ||
737 | } | 735 | } |
738 | 736 | ||
739 | static int ext2_fill_super(struct super_block *sb, void *data, int silent) | 737 | static int ext2_fill_super(struct super_block *sb, void *data, int silent) |
@@ -1062,7 +1060,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
1062 | goto failed_mount3; | 1060 | goto failed_mount3; |
1063 | } | 1061 | } |
1064 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) | 1062 | if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) |
1065 | ext2_warning(sb, __FUNCTION__, | 1063 | ext2_warning(sb, __func__, |
1066 | "mounting ext3 filesystem as ext2"); | 1064 | "mounting ext3 filesystem as ext2"); |
1067 | ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); | 1065 | ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY); |
1068 | return 0; | 1066 | return 0; |
@@ -1126,10 +1124,9 @@ void ext2_write_super (struct super_block * sb) | |||
1126 | if (!(sb->s_flags & MS_RDONLY)) { | 1124 | if (!(sb->s_flags & MS_RDONLY)) { |
1127 | es = EXT2_SB(sb)->s_es; | 1125 | es = EXT2_SB(sb)->s_es; |
1128 | 1126 | ||
1129 | if (le16_to_cpu(es->s_state) & EXT2_VALID_FS) { | 1127 | if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { |
1130 | ext2_debug ("setting valid to 0\n"); | 1128 | ext2_debug ("setting valid to 0\n"); |
1131 | es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & | 1129 | es->s_state &= cpu_to_le16(~EXT2_VALID_FS); |
1132 | ~EXT2_VALID_FS); | ||
1133 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); | 1130 | es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); |
1134 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); | 1131 | es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); |
1135 | es->s_mtime = cpu_to_le32(get_seconds()); | 1132 | es->s_mtime = cpu_to_le32(get_seconds()); |
@@ -1180,7 +1177,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data) | |||
1180 | if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != | 1177 | if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) != |
1181 | (old_mount_opt & EXT2_MOUNT_XIP)) && | 1178 | (old_mount_opt & EXT2_MOUNT_XIP)) && |
1182 | invalidate_inodes(sb)) | 1179 | invalidate_inodes(sb)) |
1183 | ext2_warning(sb, __FUNCTION__, "busy inodes while remounting "\ | 1180 | ext2_warning(sb, __func__, "busy inodes while remounting "\ |
1184 | "xip remain in cache (no functional problem)"); | 1181 | "xip remain in cache (no functional problem)"); |
1185 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) | 1182 | if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) |
1186 | return 0; | 1183 | return 0; |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index a99d46f3b26e..987a5261cc2e 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -646,8 +646,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
646 | unlock_buffer(new_bh); | 646 | unlock_buffer(new_bh); |
647 | goto cleanup; | 647 | goto cleanup; |
648 | } | 648 | } |
649 | HDR(new_bh)->h_refcount = cpu_to_le32(1 + | 649 | le32_add_cpu(&HDR(new_bh)->h_refcount, 1); |
650 | le32_to_cpu(HDR(new_bh)->h_refcount)); | ||
651 | ea_bdebug(new_bh, "refcount now=%d", | 650 | ea_bdebug(new_bh, "refcount now=%d", |
652 | le32_to_cpu(HDR(new_bh)->h_refcount)); | 651 | le32_to_cpu(HDR(new_bh)->h_refcount)); |
653 | } | 652 | } |
@@ -660,10 +659,8 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
660 | ext2_xattr_cache_insert(new_bh); | 659 | ext2_xattr_cache_insert(new_bh); |
661 | } else { | 660 | } else { |
662 | /* We need to allocate a new block */ | 661 | /* We need to allocate a new block */ |
663 | int goal = le32_to_cpu(EXT2_SB(sb)->s_es-> | 662 | ext2_fsblk_t goal = ext2_group_first_block_no(sb, |
664 | s_first_data_block) + | 663 | EXT2_I(inode)->i_block_group); |
665 | EXT2_I(inode)->i_block_group * | ||
666 | EXT2_BLOCKS_PER_GROUP(sb); | ||
667 | int block = ext2_new_block(inode, goal, &error); | 664 | int block = ext2_new_block(inode, goal, &error); |
668 | if (error) | 665 | if (error) |
669 | goto cleanup; | 666 | goto cleanup; |
@@ -731,8 +728,7 @@ ext2_xattr_set2(struct inode *inode, struct buffer_head *old_bh, | |||
731 | bforget(old_bh); | 728 | bforget(old_bh); |
732 | } else { | 729 | } else { |
733 | /* Decrement the refcount only. */ | 730 | /* Decrement the refcount only. */ |
734 | HDR(old_bh)->h_refcount = cpu_to_le32( | 731 | le32_add_cpu(&HDR(old_bh)->h_refcount, -1); |
735 | le32_to_cpu(HDR(old_bh)->h_refcount) - 1); | ||
736 | if (ce) | 732 | if (ce) |
737 | mb_cache_entry_release(ce); | 733 | mb_cache_entry_release(ce); |
738 | DQUOT_FREE_BLOCK(inode, 1); | 734 | DQUOT_FREE_BLOCK(inode, 1); |
@@ -789,8 +785,7 @@ ext2_xattr_delete_inode(struct inode *inode) | |||
789 | bforget(bh); | 785 | bforget(bh); |
790 | unlock_buffer(bh); | 786 | unlock_buffer(bh); |
791 | } else { | 787 | } else { |
792 | HDR(bh)->h_refcount = cpu_to_le32( | 788 | le32_add_cpu(&HDR(bh)->h_refcount, -1); |
793 | le32_to_cpu(HDR(bh)->h_refcount) - 1); | ||
794 | if (ce) | 789 | if (ce) |
795 | mb_cache_entry_release(ce); | 790 | mb_cache_entry_release(ce); |
796 | ea_bdebug(bh, "refcount now=%d", | 791 | ea_bdebug(bh, "refcount now=%d", |
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c index ca7f00312388..4fb94c20041b 100644 --- a/fs/ext2/xip.c +++ b/fs/ext2/xip.c | |||
@@ -15,24 +15,28 @@ | |||
15 | #include "xip.h" | 15 | #include "xip.h" |
16 | 16 | ||
17 | static inline int | 17 | static inline int |
18 | __inode_direct_access(struct inode *inode, sector_t sector, | 18 | __inode_direct_access(struct inode *inode, sector_t block, |
19 | unsigned long *data) | 19 | void **kaddr, unsigned long *pfn) |
20 | { | 20 | { |
21 | BUG_ON(!inode->i_sb->s_bdev->bd_disk->fops->direct_access); | 21 | struct block_device *bdev = inode->i_sb->s_bdev; |
22 | return inode->i_sb->s_bdev->bd_disk->fops | 22 | struct block_device_operations *ops = bdev->bd_disk->fops; |
23 | ->direct_access(inode->i_sb->s_bdev,sector,data); | 23 | sector_t sector; |
24 | |||
25 | sector = block * (PAGE_SIZE / 512); /* ext2 block to bdev sector */ | ||
26 | |||
27 | BUG_ON(!ops->direct_access); | ||
28 | return ops->direct_access(bdev, sector, kaddr, pfn); | ||
24 | } | 29 | } |
25 | 30 | ||
26 | static inline int | 31 | static inline int |
27 | __ext2_get_sector(struct inode *inode, sector_t offset, int create, | 32 | __ext2_get_block(struct inode *inode, pgoff_t pgoff, int create, |
28 | sector_t *result) | 33 | sector_t *result) |
29 | { | 34 | { |
30 | struct buffer_head tmp; | 35 | struct buffer_head tmp; |
31 | int rc; | 36 | int rc; |
32 | 37 | ||
33 | memset(&tmp, 0, sizeof(struct buffer_head)); | 38 | memset(&tmp, 0, sizeof(struct buffer_head)); |
34 | rc = ext2_get_block(inode, offset/ (PAGE_SIZE/512), &tmp, | 39 | rc = ext2_get_block(inode, pgoff, &tmp, create); |
35 | create); | ||
36 | *result = tmp.b_blocknr; | 40 | *result = tmp.b_blocknr; |
37 | 41 | ||
38 | /* did we get a sparse block (hole in the file)? */ | 42 | /* did we get a sparse block (hole in the file)? */ |
@@ -45,15 +49,15 @@ __ext2_get_sector(struct inode *inode, sector_t offset, int create, | |||
45 | } | 49 | } |
46 | 50 | ||
47 | int | 51 | int |
48 | ext2_clear_xip_target(struct inode *inode, int block) | 52 | ext2_clear_xip_target(struct inode *inode, sector_t block) |
49 | { | 53 | { |
50 | sector_t sector = block * (PAGE_SIZE/512); | 54 | void *kaddr; |
51 | unsigned long data; | 55 | unsigned long pfn; |
52 | int rc; | 56 | int rc; |
53 | 57 | ||
54 | rc = __inode_direct_access(inode, sector, &data); | 58 | rc = __inode_direct_access(inode, block, &kaddr, &pfn); |
55 | if (!rc) | 59 | if (!rc) |
56 | clear_page((void*)data); | 60 | clear_page(kaddr); |
57 | return rc; | 61 | return rc; |
58 | } | 62 | } |
59 | 63 | ||
@@ -64,30 +68,23 @@ void ext2_xip_verify_sb(struct super_block *sb) | |||
64 | if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) && | 68 | if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) && |
65 | !sb->s_bdev->bd_disk->fops->direct_access) { | 69 | !sb->s_bdev->bd_disk->fops->direct_access) { |
66 | sbi->s_mount_opt &= (~EXT2_MOUNT_XIP); | 70 | sbi->s_mount_opt &= (~EXT2_MOUNT_XIP); |
67 | ext2_warning(sb, __FUNCTION__, | 71 | ext2_warning(sb, __func__, |
68 | "ignoring xip option - not supported by bdev"); | 72 | "ignoring xip option - not supported by bdev"); |
69 | } | 73 | } |
70 | } | 74 | } |
71 | 75 | ||
72 | struct page * | 76 | int ext2_get_xip_mem(struct address_space *mapping, pgoff_t pgoff, int create, |
73 | ext2_get_xip_page(struct address_space *mapping, sector_t offset, | 77 | void **kmem, unsigned long *pfn) |
74 | int create) | ||
75 | { | 78 | { |
76 | int rc; | 79 | int rc; |
77 | unsigned long data; | 80 | sector_t block; |
78 | sector_t sector; | ||
79 | 81 | ||
80 | /* first, retrieve the sector number */ | 82 | /* first, retrieve the sector number */ |
81 | rc = __ext2_get_sector(mapping->host, offset, create, §or); | 83 | rc = __ext2_get_block(mapping->host, pgoff, create, &block); |
82 | if (rc) | 84 | if (rc) |
83 | goto error; | 85 | return rc; |
84 | 86 | ||
85 | /* retrieve address of the target data */ | 87 | /* retrieve address of the target data */ |
86 | rc = __inode_direct_access | 88 | rc = __inode_direct_access(mapping->host, block, kmem, pfn); |
87 | (mapping->host, sector * (PAGE_SIZE/512), &data); | 89 | return rc; |
88 | if (!rc) | ||
89 | return virt_to_page(data); | ||
90 | |||
91 | error: | ||
92 | return ERR_PTR(rc); | ||
93 | } | 90 | } |
diff --git a/fs/ext2/xip.h b/fs/ext2/xip.h index aa85331d6c56..18b34d2f31b3 100644 --- a/fs/ext2/xip.h +++ b/fs/ext2/xip.h | |||
@@ -7,19 +7,20 @@ | |||
7 | 7 | ||
8 | #ifdef CONFIG_EXT2_FS_XIP | 8 | #ifdef CONFIG_EXT2_FS_XIP |
9 | extern void ext2_xip_verify_sb (struct super_block *); | 9 | extern void ext2_xip_verify_sb (struct super_block *); |
10 | extern int ext2_clear_xip_target (struct inode *, int); | 10 | extern int ext2_clear_xip_target (struct inode *, sector_t); |
11 | 11 | ||
12 | static inline int ext2_use_xip (struct super_block *sb) | 12 | static inline int ext2_use_xip (struct super_block *sb) |
13 | { | 13 | { |
14 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 14 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
15 | return (sbi->s_mount_opt & EXT2_MOUNT_XIP); | 15 | return (sbi->s_mount_opt & EXT2_MOUNT_XIP); |
16 | } | 16 | } |
17 | struct page* ext2_get_xip_page (struct address_space *, sector_t, int); | 17 | int ext2_get_xip_mem(struct address_space *, pgoff_t, int, |
18 | #define mapping_is_xip(map) unlikely(map->a_ops->get_xip_page) | 18 | void **, unsigned long *); |
19 | #define mapping_is_xip(map) unlikely(map->a_ops->get_xip_mem) | ||
19 | #else | 20 | #else |
20 | #define mapping_is_xip(map) 0 | 21 | #define mapping_is_xip(map) 0 |
21 | #define ext2_xip_verify_sb(sb) do { } while (0) | 22 | #define ext2_xip_verify_sb(sb) do { } while (0) |
22 | #define ext2_use_xip(sb) 0 | 23 | #define ext2_use_xip(sb) 0 |
23 | #define ext2_clear_xip_target(inode, chain) 0 | 24 | #define ext2_clear_xip_target(inode, chain) 0 |
24 | #define ext2_get_xip_page NULL | 25 | #define ext2_get_xip_mem NULL |
25 | #endif | 26 | #endif |