aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2007-10-17 02:25:45 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-17 11:42:44 -0400
commit833f4077bf7c2dcff6e31526e03ec2ad91c88581 (patch)
tree80916540be846267342c3e5e4a6255c2c18b44d5 /fs
parentbf1d89c81352f6eca72d0c10cfee3dba29ef5efb (diff)
lib: percpu_counter_init error handling
alloc_percpu can fail, propagate that error. Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext2/super.c15
-rw-r--r--fs/ext3/super.c21
-rw-r--r--fs/ext4/super.c21
3 files changed, 42 insertions, 15 deletions
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 639a32c3c9c1..2690e460f2ef 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -653,6 +653,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
653 int db_count; 653 int db_count;
654 int i, j; 654 int i, j;
655 __le32 features; 655 __le32 features;
656 int err;
656 657
657 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 658 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
658 if (!sbi) 659 if (!sbi)
@@ -906,12 +907,20 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
906 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 907 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
907 spin_lock_init(&sbi->s_next_gen_lock); 908 spin_lock_init(&sbi->s_next_gen_lock);
908 909
909 percpu_counter_init(&sbi->s_freeblocks_counter, 910 err = percpu_counter_init(&sbi->s_freeblocks_counter,
910 ext2_count_free_blocks(sb)); 911 ext2_count_free_blocks(sb));
911 percpu_counter_init(&sbi->s_freeinodes_counter, 912 if (!err) {
913 err = percpu_counter_init(&sbi->s_freeinodes_counter,
912 ext2_count_free_inodes(sb)); 914 ext2_count_free_inodes(sb));
913 percpu_counter_init(&sbi->s_dirs_counter, 915 }
916 if (!err) {
917 err = percpu_counter_init(&sbi->s_dirs_counter,
914 ext2_count_dirs(sb)); 918 ext2_count_dirs(sb));
919 }
920 if (err) {
921 printk(KERN_ERR "EXT2-fs: insufficient memory\n");
922 goto failed_mount3;
923 }
915 /* 924 /*
916 * set up enough so that it can read an inode 925 * set up enough so that it can read an inode
917 */ 926 */
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index c5a52c9775a0..ac5c6b0ecd64 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -1416,6 +1416,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1416 int i; 1416 int i;
1417 int needs_recovery; 1417 int needs_recovery;
1418 __le32 features; 1418 __le32 features;
1419 int err;
1419 1420
1420 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 1421 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1421 if (!sbi) 1422 if (!sbi)
@@ -1675,12 +1676,20 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
1675 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 1676 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1676 spin_lock_init(&sbi->s_next_gen_lock); 1677 spin_lock_init(&sbi->s_next_gen_lock);
1677 1678
1678 percpu_counter_init(&sbi->s_freeblocks_counter, 1679 err = percpu_counter_init(&sbi->s_freeblocks_counter,
1679 ext3_count_free_blocks(sb)); 1680 ext3_count_free_blocks(sb));
1680 percpu_counter_init(&sbi->s_freeinodes_counter, 1681 if (!err) {
1681 ext3_count_free_inodes(sb)); 1682 err = percpu_counter_init(&sbi->s_freeinodes_counter,
1682 percpu_counter_init(&sbi->s_dirs_counter, 1683 ext3_count_free_inodes(sb));
1683 ext3_count_dirs(sb)); 1684 }
1685 if (!err) {
1686 err = percpu_counter_init(&sbi->s_dirs_counter,
1687 ext3_count_dirs(sb));
1688 }
1689 if (err) {
1690 printk(KERN_ERR "EXT3-fs: insufficient memory\n");
1691 goto failed_mount3;
1692 }
1684 1693
1685 /* per fileystem reservation list head & lock */ 1694 /* per fileystem reservation list head & lock */
1686 spin_lock_init(&sbi->s_rsv_window_lock); 1695 spin_lock_init(&sbi->s_rsv_window_lock);
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 1814d4b8ff1f..157c64c9a4e7 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1479,6 +1479,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1479 int needs_recovery; 1479 int needs_recovery;
1480 __le32 features; 1480 __le32 features;
1481 __u64 blocks_count; 1481 __u64 blocks_count;
1482 int err;
1482 1483
1483 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 1484 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
1484 if (!sbi) 1485 if (!sbi)
@@ -1759,12 +1760,20 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1759 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); 1760 get_random_bytes(&sbi->s_next_generation, sizeof(u32));
1760 spin_lock_init(&sbi->s_next_gen_lock); 1761 spin_lock_init(&sbi->s_next_gen_lock);
1761 1762
1762 percpu_counter_init(&sbi->s_freeblocks_counter, 1763 err = percpu_counter_init(&sbi->s_freeblocks_counter,
1763 ext4_count_free_blocks(sb)); 1764 ext4_count_free_blocks(sb));
1764 percpu_counter_init(&sbi->s_freeinodes_counter, 1765 if (!err) {
1765 ext4_count_free_inodes(sb)); 1766 err = percpu_counter_init(&sbi->s_freeinodes_counter,
1766 percpu_counter_init(&sbi->s_dirs_counter, 1767 ext4_count_free_inodes(sb));
1767 ext4_count_dirs(sb)); 1768 }
1769 if (!err) {
1770 err = percpu_counter_init(&sbi->s_dirs_counter,
1771 ext4_count_dirs(sb));
1772 }
1773 if (err) {
1774 printk(KERN_ERR "EXT4-fs: insufficient memory\n");
1775 goto failed_mount3;
1776 }
1768 1777
1769 /* per fileystem reservation list head & lock */ 1778 /* per fileystem reservation list head & lock */
1770 spin_lock_init(&sbi->s_rsv_window_lock); 1779 spin_lock_init(&sbi->s_rsv_window_lock);