diff options
Diffstat (limited to 'fs/ext2')
| -rw-r--r-- | fs/ext2/Makefile | 2 | ||||
| -rw-r--r-- | fs/ext2/acl.c | 4 | ||||
| -rw-r--r-- | fs/ext2/balloc.c | 22 | ||||
| -rw-r--r-- | fs/ext2/bitmap.c | 32 | ||||
| -rw-r--r-- | fs/ext2/dir.c | 3 | ||||
| -rw-r--r-- | fs/ext2/ext2.h | 6 | ||||
| -rw-r--r-- | fs/ext2/fsync.c | 2 | ||||
| -rw-r--r-- | fs/ext2/ialloc.c | 4 | ||||
| -rw-r--r-- | fs/ext2/inode.c | 7 | ||||
| -rw-r--r-- | fs/ext2/super.c | 83 | ||||
| -rw-r--r-- | fs/ext2/xattr.c | 3 | ||||
| -rw-r--r-- | fs/ext2/xattr.h | 1 | 
12 files changed, 93 insertions, 76 deletions
| diff --git a/fs/ext2/Makefile b/fs/ext2/Makefile index c5d02da73bc3..e0b2b43c1fdb 100644 --- a/fs/ext2/Makefile +++ b/fs/ext2/Makefile | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | obj-$(CONFIG_EXT2_FS) += ext2.o | 5 | obj-$(CONFIG_EXT2_FS) += ext2.o | 
| 6 | 6 | ||
| 7 | ext2-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o \ | 7 | ext2-y := balloc.o dir.o file.o fsync.o ialloc.o inode.o \ | 
| 8 | ioctl.o namei.o super.o symlink.o | 8 | ioctl.o namei.o super.o symlink.o | 
| 9 | 9 | ||
| 10 | ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o | 10 | ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o xattr_trusted.o | 
| 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/balloc.c b/fs/ext2/balloc.c index 2c00953d4b0b..b1981d0e95ad 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 11 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 
| 12 | */ | 12 | */ | 
| 13 | 13 | ||
| 14 | #include <linux/config.h> | ||
| 15 | #include "ext2.h" | 14 | #include "ext2.h" | 
| 16 | #include <linux/quotaops.h> | 15 | #include <linux/quotaops.h> | 
| 17 | #include <linux/sched.h> | 16 | #include <linux/sched.h> | 
| @@ -521,6 +520,25 @@ io_error: | |||
| 521 | goto out_release; | 520 | goto out_release; | 
| 522 | } | 521 | } | 
| 523 | 522 | ||
| 523 | #ifdef EXT2FS_DEBUG | ||
| 524 | |||
| 525 | static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
| 526 | |||
| 527 | unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars) | ||
| 528 | { | ||
| 529 | unsigned int i; | ||
| 530 | unsigned long sum = 0; | ||
| 531 | |||
| 532 | if (!map) | ||
| 533 | return (0); | ||
| 534 | for (i = 0; i < numchars; i++) | ||
| 535 | sum += nibblemap[map->b_data[i] & 0xf] + | ||
| 536 | nibblemap[(map->b_data[i] >> 4) & 0xf]; | ||
| 537 | return (sum); | ||
| 538 | } | ||
| 539 | |||
| 540 | #endif /* EXT2FS_DEBUG */ | ||
| 541 | |||
| 524 | unsigned long ext2_count_free_blocks (struct super_block * sb) | 542 | unsigned long ext2_count_free_blocks (struct super_block * sb) | 
| 525 | { | 543 | { | 
| 526 | struct ext2_group_desc * desc; | 544 | struct ext2_group_desc * desc; | 
| @@ -530,7 +548,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) | |||
| 530 | unsigned long bitmap_count, x; | 548 | unsigned long bitmap_count, x; | 
| 531 | struct ext2_super_block *es; | 549 | struct ext2_super_block *es; | 
| 532 | 550 | ||
| 533 | lock_super (sb); | ||
| 534 | es = EXT2_SB(sb)->s_es; | 551 | es = EXT2_SB(sb)->s_es; | 
| 535 | desc_count = 0; | 552 | desc_count = 0; | 
| 536 | bitmap_count = 0; | 553 | bitmap_count = 0; | 
| @@ -554,7 +571,6 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) | |||
| 554 | printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", | 571 | printk("ext2_count_free_blocks: stored = %lu, computed = %lu, %lu\n", | 
| 555 | (long)le32_to_cpu(es->s_free_blocks_count), | 572 | (long)le32_to_cpu(es->s_free_blocks_count), | 
| 556 | desc_count, bitmap_count); | 573 | desc_count, bitmap_count); | 
| 557 | unlock_super (sb); | ||
| 558 | return bitmap_count; | 574 | return bitmap_count; | 
| 559 | #else | 575 | #else | 
| 560 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 576 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 
| diff --git a/fs/ext2/bitmap.c b/fs/ext2/bitmap.c deleted file mode 100644 index e9983a0dd396..000000000000 --- a/fs/ext2/bitmap.c +++ /dev/null | |||
| @@ -1,32 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * linux/fs/ext2/bitmap.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1992, 1993, 1994, 1995 | ||
| 5 | * Remy Card (card@masi.ibp.fr) | ||
| 6 | * Laboratoire MASI - Institut Blaise Pascal | ||
| 7 | * Universite Pierre et Marie Curie (Paris VI) | ||
| 8 | */ | ||
| 9 | |||
| 10 | #ifdef EXT2FS_DEBUG | ||
| 11 | |||
| 12 | #include <linux/buffer_head.h> | ||
| 13 | |||
| 14 | #include "ext2.h" | ||
| 15 | |||
| 16 | static int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0}; | ||
| 17 | |||
| 18 | unsigned long ext2_count_free (struct buffer_head * map, unsigned int numchars) | ||
| 19 | { | ||
| 20 | unsigned int i; | ||
| 21 | unsigned long sum = 0; | ||
| 22 | |||
| 23 | if (!map) | ||
| 24 | return (0); | ||
| 25 | for (i = 0; i < numchars; i++) | ||
| 26 | sum += nibblemap[map->b_data[i] & 0xf] + | ||
| 27 | nibblemap[(map->b_data[i] >> 4) & 0xf]; | ||
| 28 | return (sum); | ||
| 29 | } | ||
| 30 | |||
| 31 | #endif /* EXT2FS_DEBUG */ | ||
| 32 | |||
| diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 3c1c9aaaca6b..92ea8265d7d5 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c | |||
| @@ -399,8 +399,7 @@ ino_t ext2_inode_by_name(struct inode * dir, struct dentry *dentry) | |||
| 399 | de = ext2_find_entry (dir, dentry, &page); | 399 | de = ext2_find_entry (dir, dentry, &page); | 
| 400 | if (de) { | 400 | if (de) { | 
| 401 | res = le32_to_cpu(de->inode); | 401 | res = le32_to_cpu(de->inode); | 
| 402 | kunmap(page); | 402 | ext2_put_page(page); | 
| 403 | page_cache_release(page); | ||
| 404 | } | 403 | } | 
| 405 | return res; | 404 | return res; | 
| 406 | } | 405 | } | 
| diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h index 9f74a62be555..e65a019fc7a5 100644 --- a/fs/ext2/ext2.h +++ b/fs/ext2/ext2.h | |||
| @@ -162,9 +162,9 @@ extern const struct file_operations ext2_file_operations; | |||
| 162 | extern const struct file_operations ext2_xip_file_operations; | 162 | extern const struct file_operations ext2_xip_file_operations; | 
| 163 | 163 | ||
| 164 | /* inode.c */ | 164 | /* inode.c */ | 
| 165 | extern struct address_space_operations ext2_aops; | 165 | extern const struct address_space_operations ext2_aops; | 
| 166 | extern struct address_space_operations ext2_aops_xip; | 166 | extern const struct address_space_operations ext2_aops_xip; | 
| 167 | extern struct address_space_operations ext2_nobh_aops; | 167 | extern const struct address_space_operations ext2_nobh_aops; | 
| 168 | 168 | ||
| 169 | /* namei.c */ | 169 | /* namei.c */ | 
| 170 | extern struct inode_operations ext2_dir_inode_operations; | 170 | extern struct inode_operations ext2_dir_inode_operations; | 
| diff --git a/fs/ext2/fsync.c b/fs/ext2/fsync.c index c9c2e5ffa48e..7806b9e8155b 100644 --- a/fs/ext2/fsync.c +++ b/fs/ext2/fsync.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | #include "ext2.h" | 25 | #include "ext2.h" | 
| 26 | #include <linux/smp_lock.h> | 26 | #include <linux/smp_lock.h> | 
| 27 | #include <linux/buffer_head.h> /* for fsync_inode_buffers() */ | 27 | #include <linux/buffer_head.h> /* for sync_mapping_buffers() */ | 
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | /* | 30 | /* | 
| diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index e52765219e16..2cb545bf0f3c 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 12 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 
| 13 | */ | 13 | */ | 
| 14 | 14 | ||
| 15 | #include <linux/config.h> | ||
| 16 | #include <linux/quotaops.h> | 15 | #include <linux/quotaops.h> | 
| 17 | #include <linux/sched.h> | 16 | #include <linux/sched.h> | 
| 18 | #include <linux/backing-dev.h> | 17 | #include <linux/backing-dev.h> | 
| @@ -575,7 +574,6 @@ got: | |||
| 575 | inode->i_mode = mode; | 574 | inode->i_mode = mode; | 
| 576 | 575 | ||
| 577 | inode->i_ino = ino; | 576 | inode->i_ino = ino; | 
| 578 | inode->i_blksize = PAGE_SIZE; /* This is the optimal IO size (for stat), not the fs block size */ | ||
| 579 | inode->i_blocks = 0; | 577 | inode->i_blocks = 0; | 
| 580 | 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; | 
| 581 | memset(ei->i_data, 0, sizeof(ei->i_data)); | 579 | memset(ei->i_data, 0, sizeof(ei->i_data)); | 
| @@ -649,7 +647,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb) | |||
| 649 | unsigned long bitmap_count = 0; | 647 | unsigned long bitmap_count = 0; | 
| 650 | struct buffer_head *bitmap_bh = NULL; | 648 | struct buffer_head *bitmap_bh = NULL; | 
| 651 | 649 | ||
| 652 | lock_super (sb); | ||
| 653 | es = EXT2_SB(sb)->s_es; | 650 | es = EXT2_SB(sb)->s_es; | 
| 654 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 651 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 
| 655 | unsigned x; | 652 | unsigned x; | 
| @@ -672,7 +669,6 @@ unsigned long ext2_count_free_inodes (struct super_block * sb) | |||
| 672 | printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", | 669 | printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", | 
| 673 | percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), | 670 | percpu_counter_read(&EXT2_SB(sb)->s_freeinodes_counter), | 
| 674 | desc_count, bitmap_count); | 671 | desc_count, bitmap_count); | 
| 675 | unlock_super(sb); | ||
| 676 | return desc_count; | 672 | return desc_count; | 
| 677 | #else | 673 | #else | 
| 678 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 674 | for (i = 0; i < EXT2_SB(sb)->s_groups_count; i++) { | 
| diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 04af9c45dce2..dd4e14c221e0 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
| @@ -684,7 +684,7 @@ ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) | |||
| 684 | return mpage_writepages(mapping, wbc, ext2_get_block); | 684 | return mpage_writepages(mapping, wbc, ext2_get_block); | 
| 685 | } | 685 | } | 
| 686 | 686 | ||
| 687 | struct address_space_operations ext2_aops = { | 687 | const struct address_space_operations ext2_aops = { | 
| 688 | .readpage = ext2_readpage, | 688 | .readpage = ext2_readpage, | 
| 689 | .readpages = ext2_readpages, | 689 | .readpages = ext2_readpages, | 
| 690 | .writepage = ext2_writepage, | 690 | .writepage = ext2_writepage, | 
| @@ -697,12 +697,12 @@ struct address_space_operations ext2_aops = { | |||
| 697 | .migratepage = buffer_migrate_page, | 697 | .migratepage = buffer_migrate_page, | 
| 698 | }; | 698 | }; | 
| 699 | 699 | ||
| 700 | struct address_space_operations ext2_aops_xip = { | 700 | const struct address_space_operations ext2_aops_xip = { | 
| 701 | .bmap = ext2_bmap, | 701 | .bmap = ext2_bmap, | 
| 702 | .get_xip_page = ext2_get_xip_page, | 702 | .get_xip_page = ext2_get_xip_page, | 
| 703 | }; | 703 | }; | 
| 704 | 704 | ||
| 705 | struct address_space_operations ext2_nobh_aops = { | 705 | const struct address_space_operations ext2_nobh_aops = { | 
| 706 | .readpage = ext2_readpage, | 706 | .readpage = ext2_readpage, | 
| 707 | .readpages = ext2_readpages, | 707 | .readpages = ext2_readpages, | 
| 708 | .writepage = ext2_nobh_writepage, | 708 | .writepage = ext2_nobh_writepage, | 
| @@ -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 ee4ba759581e..513cd421ac0b 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 16 | * David S. Miller (davem@caip.rutgers.edu), 1995 | 
| 17 | */ | 17 | */ | 
| 18 | 18 | ||
| 19 | #include <linux/config.h> | ||
| 20 | #include <linux/module.h> | 19 | #include <linux/module.h> | 
| 21 | #include <linux/string.h> | 20 | #include <linux/string.h> | 
| 22 | #include <linux/fs.h> | 21 | #include <linux/fs.h> | 
| @@ -185,8 +184,7 @@ static int init_inodecache(void) | |||
| 185 | 184 | ||
| 186 | static void destroy_inodecache(void) | 185 | static void destroy_inodecache(void) | 
| 187 | { | 186 | { | 
| 188 | if (kmem_cache_destroy(ext2_inode_cachep)) | 187 | kmem_cache_destroy(ext2_inode_cachep); | 
| 189 | printk(KERN_INFO "ext2_inode_cache: not all structures were freed\n"); | ||
| 190 | } | 188 | } | 
| 191 | 189 | ||
| 192 | static void ext2_clear_inode(struct inode *inode) | 190 | static void ext2_clear_inode(struct inode *inode) | 
| @@ -252,6 +250,44 @@ static struct super_operations ext2_sops = { | |||
| 252 | #endif | 250 | #endif | 
| 253 | }; | 251 | }; | 
| 254 | 252 | ||
| 253 | static struct dentry *ext2_get_dentry(struct super_block *sb, void *vobjp) | ||
| 254 | { | ||
| 255 | __u32 *objp = vobjp; | ||
| 256 | unsigned long ino = objp[0]; | ||
| 257 | __u32 generation = objp[1]; | ||
| 258 | struct inode *inode; | ||
| 259 | struct dentry *result; | ||
| 260 | |||
| 261 | if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO) | ||
| 262 | return ERR_PTR(-ESTALE); | ||
| 263 | if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) | ||
| 264 | return ERR_PTR(-ESTALE); | ||
| 265 | |||
| 266 | /* iget isn't really right if the inode is currently unallocated!! | ||
| 267 | * ext2_read_inode currently does appropriate checks, but | ||
| 268 | * it might be "neater" to call ext2_get_inode first and check | ||
| 269 | * if the inode is valid..... | ||
| 270 | */ | ||
| 271 | inode = iget(sb, ino); | ||
| 272 | if (inode == NULL) | ||
| 273 | return ERR_PTR(-ENOMEM); | ||
| 274 | if (is_bad_inode(inode) || | ||
| 275 | (generation && inode->i_generation != generation)) { | ||
| 276 | /* we didn't find the right inode.. */ | ||
| 277 | iput(inode); | ||
| 278 | return ERR_PTR(-ESTALE); | ||
| 279 | } | ||
| 280 | /* now to find a dentry. | ||
| 281 | * If possible, get a well-connected one | ||
| 282 | */ | ||
| 283 | result = d_alloc_anon(inode); | ||
| 284 | if (!result) { | ||
| 285 | iput(inode); | ||
| 286 | return ERR_PTR(-ENOMEM); | ||
| 287 | } | ||
| 288 | return result; | ||
| 289 | } | ||
| 290 | |||
| 255 | /* Yes, most of these are left as NULL!! | 291 | /* Yes, most of these are left as NULL!! | 
| 256 | * A NULL value implies the default, which works with ext2-like file | 292 | * A NULL value implies the default, which works with ext2-like file | 
| 257 | * systems, but can be improved upon. | 293 | * systems, but can be improved upon. | 
| @@ -259,6 +295,7 @@ static struct super_operations ext2_sops = { | |||
| 259 | */ | 295 | */ | 
| 260 | static struct export_operations ext2_export_ops = { | 296 | static struct export_operations ext2_export_ops = { | 
| 261 | .get_parent = ext2_get_parent, | 297 | .get_parent = ext2_get_parent, | 
| 298 | .get_dentry = ext2_get_dentry, | ||
| 262 | }; | 299 | }; | 
| 263 | 300 | ||
| 264 | static unsigned long get_sb_block(void **data) | 301 | static unsigned long get_sb_block(void **data) | 
| @@ -506,17 +543,24 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
| 506 | int i; | 543 | int i; | 
| 507 | int desc_block = 0; | 544 | int desc_block = 0; | 
| 508 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 545 | struct ext2_sb_info *sbi = EXT2_SB(sb); | 
| 509 | 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; | ||
| 510 | struct ext2_group_desc * gdp = NULL; | 548 | struct ext2_group_desc * gdp = NULL; | 
| 511 | 549 | ||
| 512 | ext2_debug ("Checking group descriptors"); | 550 | ext2_debug ("Checking group descriptors"); | 
| 513 | 551 | ||
| 514 | for (i = 0; i < sbi->s_groups_count; i++) | 552 | for (i = 0; i < sbi->s_groups_count; i++) | 
| 515 | { | 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 | |||
| 516 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) | 560 | if ((i % EXT2_DESC_PER_BLOCK(sb)) == 0) | 
| 517 | 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; | 
| 518 | if (le32_to_cpu(gdp->bg_block_bitmap) < block || | 562 | if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || | 
| 519 | le32_to_cpu(gdp->bg_block_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 563 | le32_to_cpu(gdp->bg_block_bitmap) > last_block) | 
| 520 | { | 564 | { | 
| 521 | ext2_error (sb, "ext2_check_descriptors", | 565 | ext2_error (sb, "ext2_check_descriptors", | 
| 522 | "Block bitmap for group %d" | 566 | "Block bitmap for group %d" | 
| @@ -524,8 +568,8 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
| 524 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); | 568 | i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); | 
| 525 | return 0; | 569 | return 0; | 
| 526 | } | 570 | } | 
| 527 | if (le32_to_cpu(gdp->bg_inode_bitmap) < block || | 571 | if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || | 
| 528 | le32_to_cpu(gdp->bg_inode_bitmap) >= block + EXT2_BLOCKS_PER_GROUP(sb)) | 572 | le32_to_cpu(gdp->bg_inode_bitmap) > last_block) | 
| 529 | { | 573 | { | 
| 530 | ext2_error (sb, "ext2_check_descriptors", | 574 | ext2_error (sb, "ext2_check_descriptors", | 
| 531 | "Inode bitmap for group %d" | 575 | "Inode bitmap for group %d" | 
| @@ -533,9 +577,9 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
| 533 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); | 577 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); | 
| 534 | return 0; | 578 | return 0; | 
| 535 | } | 579 | } | 
| 536 | if (le32_to_cpu(gdp->bg_inode_table) < block || | 580 | if (le32_to_cpu(gdp->bg_inode_table) < first_block || | 
| 537 | 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 > | 
| 538 | block + EXT2_BLOCKS_PER_GROUP(sb)) | 582 | last_block) | 
| 539 | { | 583 | { | 
| 540 | ext2_error (sb, "ext2_check_descriptors", | 584 | ext2_error (sb, "ext2_check_descriptors", | 
| 541 | "Inode table for group %d" | 585 | "Inode table for group %d" | 
| @@ -543,7 +587,7 @@ static int ext2_check_descriptors (struct super_block * sb) | |||
| 543 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); | 587 | i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); | 
| 544 | return 0; | 588 | return 0; | 
| 545 | } | 589 | } | 
| 546 | block += EXT2_BLOCKS_PER_GROUP(sb); | 590 | first_block += EXT2_BLOCKS_PER_GROUP(sb); | 
| 547 | gdp++; | 591 | gdp++; | 
| 548 | } | 592 | } | 
| 549 | return 1; | 593 | return 1; | 
| @@ -610,11 +654,10 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 610 | int i, j; | 654 | int i, j; | 
| 611 | __le32 features; | 655 | __le32 features; | 
| 612 | 656 | ||
| 613 | sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); | 657 | sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); | 
| 614 | if (!sbi) | 658 | if (!sbi) | 
| 615 | return -ENOMEM; | 659 | return -ENOMEM; | 
| 616 | sb->s_fs_info = sbi; | 660 | sb->s_fs_info = sbi; | 
| 617 | memset(sbi, 0, sizeof(*sbi)); | ||
| 618 | 661 | ||
| 619 | /* | 662 | /* | 
| 620 | * See what the current blocksize for the device is, and | 663 | * See what the current blocksize for the device is, and | 
| @@ -776,7 +819,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 776 | if (EXT2_INODE_SIZE(sb) == 0) | 819 | if (EXT2_INODE_SIZE(sb) == 0) | 
| 777 | goto cantfind_ext2; | 820 | goto cantfind_ext2; | 
| 778 | sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); | 821 | sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); | 
| 779 | if (sbi->s_inodes_per_block == 0) | 822 | if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0) | 
| 780 | goto cantfind_ext2; | 823 | goto cantfind_ext2; | 
| 781 | sbi->s_itb_per_group = sbi->s_inodes_per_group / | 824 | sbi->s_itb_per_group = sbi->s_inodes_per_group / | 
| 782 | sbi->s_inodes_per_block; | 825 | sbi->s_inodes_per_block; | 
| @@ -823,10 +866,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 823 | 866 | ||
| 824 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) | 867 | if (EXT2_BLOCKS_PER_GROUP(sb) == 0) | 
| 825 | goto cantfind_ext2; | 868 | goto cantfind_ext2; | 
| 826 | sbi->s_groups_count = (le32_to_cpu(es->s_blocks_count) - | 869 | sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - | 
| 827 | le32_to_cpu(es->s_first_data_block) + | 870 | le32_to_cpu(es->s_first_data_block) - 1) | 
| 828 | EXT2_BLOCKS_PER_GROUP(sb) - 1) / | 871 | / EXT2_BLOCKS_PER_GROUP(sb)) + 1; | 
| 829 | EXT2_BLOCKS_PER_GROUP(sb); | ||
| 830 | 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) / | 
| 831 | EXT2_DESC_PER_BLOCK(sb); | 873 | EXT2_DESC_PER_BLOCK(sb); | 
| 832 | 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); | 
| @@ -854,7 +896,6 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 854 | } | 896 | } | 
| 855 | if (!ext2_check_descriptors (sb)) { | 897 | if (!ext2_check_descriptors (sb)) { | 
| 856 | printk ("EXT2-fs: group descriptors corrupted!\n"); | 898 | printk ("EXT2-fs: group descriptors corrupted!\n"); | 
| 857 | db_count = i; | ||
| 858 | goto failed_mount2; | 899 | goto failed_mount2; | 
| 859 | } | 900 | } | 
| 860 | sbi->s_gdb_count = db_count; | 901 | sbi->s_gdb_count = db_count; | 
| @@ -1157,7 +1198,7 @@ static ssize_t ext2_quota_write(struct super_block *sb, int type, | |||
| 1157 | struct buffer_head tmp_bh; | 1198 | struct buffer_head tmp_bh; | 
| 1158 | struct buffer_head *bh; | 1199 | struct buffer_head *bh; | 
| 1159 | 1200 | ||
| 1160 | mutex_lock(&inode->i_mutex); | 1201 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); | 
| 1161 | while (towrite > 0) { | 1202 | while (towrite > 0) { | 
| 1162 | tocopy = sb->s_blocksize - offset < towrite ? | 1203 | tocopy = sb->s_blocksize - offset < towrite ? | 
| 1163 | sb->s_blocksize - offset : towrite; | 1204 | sb->s_blocksize - offset : towrite; | 
| 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); | 
| diff --git a/fs/ext2/xattr.h b/fs/ext2/xattr.h index 67cfeb66e897..bf8175b2ced9 100644 --- a/fs/ext2/xattr.h +++ b/fs/ext2/xattr.h | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> | 6 | (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> | 
| 7 | */ | 7 | */ | 
| 8 | 8 | ||
| 9 | #include <linux/config.h> | ||
| 10 | #include <linux/init.h> | 9 | #include <linux/init.h> | 
| 11 | #include <linux/xattr.h> | 10 | #include <linux/xattr.h> | 
| 12 | 11 | ||
