diff options
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/acl.c | 4 | ||||
-rw-r--r-- | fs/ext2/ialloc.c | 1 | ||||
-rw-r--r-- | fs/ext2/inode.c | 1 | ||||
-rw-r--r-- | fs/ext2/super.c | 38 | ||||
-rw-r--r-- | fs/ext2/xattr.c | 3 |
5 files changed, 24 insertions, 23 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c index da52b4a5db64..7c420b800c34 100644 --- a/fs/ext2/acl.c +++ b/fs/ext2/acl.c | |||
@@ -89,8 +89,8 @@ ext2_acl_to_disk(const struct posix_acl *acl, size_t *size) | |||
89 | size_t n; | 89 | size_t n; |
90 | 90 | ||
91 | *size = ext2_acl_size(acl->a_count); | 91 | *size = ext2_acl_size(acl->a_count); |
92 | ext_acl = (ext2_acl_header *)kmalloc(sizeof(ext2_acl_header) + | 92 | ext_acl = kmalloc(sizeof(ext2_acl_header) + acl->a_count * |
93 | acl->a_count * sizeof(ext2_acl_entry), GFP_KERNEL); | 93 | sizeof(ext2_acl_entry), GFP_KERNEL); |
94 | if (!ext_acl) | 94 | if (!ext_acl) |
95 | return ERR_PTR(-ENOMEM); | 95 | return ERR_PTR(-ENOMEM); |
96 | ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION); | 96 | ext_acl->a_version = cpu_to_le32(EXT2_ACL_VERSION); |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 695f69ccf908..2cb545bf0f3c 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -574,7 +574,6 @@ got: | |||
574 | inode->i_mode = mode; | 574 | inode->i_mode = mode; |
575 | 575 | ||
576 | inode->i_ino = ino; | 576 | inode->i_ino = ino; |
577 | inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */ | ||
578 | inode->i_blocks = 0; | 577 | inode->i_blocks = 0; |
579 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; | 578 | inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC; |
580 | memset(ei->i_data, 0, sizeof(ei->i_data)); | 579 | memset(ei->i_data, 0, sizeof(ei->i_data)); |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index fb4d3220eb8d..dd4e14c221e0 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1094,7 +1094,6 @@ void ext2_read_inode (struct inode * inode) | |||
1094 | brelse (bh); | 1094 | brelse (bh); |
1095 | goto bad_inode; | 1095 | goto bad_inode; |
1096 | } | 1096 | } |
1097 | inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */ | ||
1098 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); | 1097 | inode->i_blocks = le32_to_cpu(raw_inode->i_blocks); |
1099 | ei->i_flags = le32_to_cpu(raw_inode->i_flags); | 1098 | ei->i_flags = le32_to_cpu(raw_inode->i_flags); |
1100 | ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); | 1099 | ei->i_faddr = le32_to_cpu(raw_inode->i_faddr); |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 4286ff6330b6..513cd421ac0b 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
@@ -184,8 +184,7 @@ static int init_inodecache(void) | |||
184 | 184 | ||
185 | static void destroy_inodecache(void) | 185 | static void destroy_inodecache(void) |
186 | { | 186 | { |
187 | if (kmem_cache_destroy(ext2_inode_cachep)) | 187 | kmem_cache_destroy(ext2_inode_cachep); |
188 | printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n"); | ||
189 | } | 188 | } |
190 | 189 | ||
191 | static void ext2_clear_inode(struct inode *inode) | 190 | static void ext2_clear_inode(struct inode *inode) |
@@ -544,17 +543,24 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
544 | int i; | 543 | int i; |
545 | int desc_block = 0; | 544 | int desc_block = 0; |
546 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 545 | struct ext2_sb_info *sbi = EXT2_SB(sb); |
547 | unsigned long block = le32_to_cpu(sbi->s_es->s_first_data_block); | 546 | unsigned long first_block = le32_to_cpu(sbi->s_es->s_first_data_block); |
547 | unsigned long last_block; | ||
548 | struct ext2_group_desc * gdp = NULL; | 548 | struct ext2_group_desc * gdp = NULL; |
549 | 549 | ||
550 | ext2_debug ("Checking group descriptors"); | 550 | ext2_debug ("Checking group descriptors"); |
551 | 551 | ||
552 | for (i = 0; i < sbi->s_groups_count; i++) | 552 | for (i = 0; i < sbi->s_groups_count; i++) |
553 | { | 553 | { |
554 | if (i == sbi->s_groups_count - 1) | ||
555 | last_block = le32_to_cpu(sbi->s_es->s_blocks_count) - 1; | ||
556 | else | ||
557 | last_block = first_block + | ||
558 | (EXT2_BLOCKS_PER_GROUP(sb) - 1); | ||
559 | |||
554 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) | 560 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) |
555 | gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; | 561 | gdp = (struct ext2_group_desc *) sbi->s_group_desc[desc_block++]->b_data; |
556 | if (le32_to_cpu(gdp->bg_block_bitmap) < block || | 562 | if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || |
557 | le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 563 | le32_to_cpu(gdp->bg_block_bitmap) > last_block) |
558 | { | 564 | { |
559 | ext2_error (sb, "ext2_check_descriptors", | 565 | ext2_error (sb, "ext2_check_descriptors", |
560 | "Block bitmap for group %d" | 566 | "Block bitmap for group %d" |
@@ -562,8 +568,8 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
562 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); | 568 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); |
563 | return 0; | 569 | return 0; |
564 | } | 570 | } |
565 | if (le32_to_cpu(gdp->bg_inode_bitmap) < block || | 571 | if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || |
566 | le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 572 | le32_to_cpu(gdp->bg_inode_bitmap) > last_block) |
567 | { | 573 | { |
568 | ext2_error (sb, "ext2_check_descriptors", | 574 | ext2_error (sb, "ext2_check_descriptors", |
569 | "Inode bitmap for group %d" | 575 | "Inode bitmap for group %d" |
@@ -571,9 +577,9 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
571 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); | 577 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); |
572 | return 0; | 578 | return 0; |
573 | } | 579 | } |
574 | if (le32_to_cpu(gdp->bg_inode_table) < block || | 580 | if (le32_to_cpu(gdp->bg_inode_table) < first_block || |
575 | le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group >= | 581 | le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group > |
576 | block + EXT2_BLOCKS_PER_GROUP(sb)) | 582 | last_block) |
577 | { | 583 | { |
578 | ext2_error (sb, "ext2_check_descriptors", | 584 | ext2_error (sb, "ext2_check_descriptors", |
579 | "Inode table for group %d" | 585 | "Inode table for group %d" |
@@ -581,7 +587,7 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
581 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); | 587 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); |
582 | return 0; | 588 | return 0; |
583 | } | 589 | } |
584 | block += EXT2_BLOCKS_PER_GROUP(sb); | 590 | first_block += EXT2_BLOCKS_PER_GROUP(sb); |
585 | gdp++; | 591 | gdp++; |
586 | } | 592 | } |
587 | return 1; | 593 | return 1; |
@@ -648,11 +654,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
648 | int i, j; | 654 | int i, j; |
649 | __le32 features; | 655 | __le32 features; |
650 | 656 | ||
651 | sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); | 657 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); |
652 | if (!sbi) | 658 | if (!sbi) |
653 | return -ENOMEM; | 659 | return -ENOMEM; |
654 | sb->s_fs_info = sbi; | 660 | sb->s_fs_info = sbi; |
655 | memset(sbi, 0, sizeof(*sbi)); | ||
656 | 661 | ||
657 | /* | 662 | /* |
658 | * See what the current blocksize for the device is, and | 663 | * See what the current blocksize for the device is, and |
@@ -861,10 +866,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
861 | 866 | ||
862 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) | 867 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) |
863 | goto cantfind_ext2; | 868 | goto cantfind_ext2; |
864 | sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - | 869 | sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - |
865 | le32_to_cpu(es->s_first_data_block) + | 870 | le32_to_cpu(es->s_first_data_block) - 1) |
866 | EXT2_BLOCKS_PER_GROUP(sb) - 1) / | 871 | / EXT2_BLOCKS_PER_GROUP(sb)) + 1; |
867 | EXT2_BLOCKS_PER_GROUP(sb); | ||
868 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / | 872 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / |
869 | EXT2_DESC_PER_BLOCK(sb); | 873 | EXT2_DESC_PER_BLOCK(sb); |
870 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); | 874 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); |
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c index 86ae8e93adb9..af52a7f8b291 100644 --- a/fs/ext2/xattr.c +++ b/fs/ext2/xattr.c | |||
@@ -521,11 +521,10 @@ bad_block: ext2_error(sb, "ext2_xattr_set", | |||
521 | } | 521 | } |
522 | } else { | 522 | } else { |
523 | /* Allocate a buffer where we construct the new block. */ | 523 | /* Allocate a buffer where we construct the new block. */ |
524 | header = kmalloc(sb->s_blocksize, GFP_KERNEL); | 524 | header = kzalloc(sb->s_blocksize, GFP_KERNEL); |
525 | error = -ENOMEM; | 525 | error = -ENOMEM; |
526 | if (header == NULL) | 526 | if (header == NULL) |
527 | goto cleanup; | 527 | goto cleanup; |
528 | memset(header, 0, sb->s_blocksize); | ||
529 | end = (char *)header + sb->s_blocksize; | 528 | end = (char *)header + sb->s_blocksize; |
530 | header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC); | 529 | header->h_magic = cpu_to_le32(EXT2_XATTR_MAGIC); |
531 | header->h_blocks = header->h_refcount = cpu_to_le32(1); | 530 | header->h_blocks = header->h_refcount = cpu_to_le32(1); |