diff options
author | Peter Zijlstra <a.p.zijlstra@chello.nl> | 2007-10-17 10:25:45 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 19:42:44 +0400 |
commit | 833f4077bf7c2dcff6e31526e03ec2ad91c88581 (patch) | |
tree | 80916540be846267342c3e5e4a6255c2c18b44d5 /fs | |
parent | bf1d89c81352f6eca72d0c10cfee3dba29ef5efb (diff) | |
download | linux-833f4077bf7c2dcff6e31526e03ec2ad91c88581.tar.xz |
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.c | 15 | ||||
-rw-r--r-- | fs/ext3/super.c | 21 | ||||
-rw-r--r-- | fs/ext4/super.c | 21 |
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) int db_count; int i, j; __le32 features; + int err; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -906,12 +907,20 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) get_random_bytes(&sbi->s_next_generation, sizeof(u32)); spin_lock_init(&sbi->s_next_gen_lock); - percpu_counter_init(&sbi->s_freeblocks_counter, + err = percpu_counter_init(&sbi->s_freeblocks_counter, ext2_count_free_blocks(sb)); - percpu_counter_init(&sbi->s_freeinodes_counter, + if (!err) { + err = percpu_counter_init(&sbi->s_freeinodes_counter, ext2_count_free_inodes(sb)); - percpu_counter_init(&sbi->s_dirs_counter, + } + if (!err) { + err = percpu_counter_init(&sbi->s_dirs_counter, ext2_count_dirs(sb)); + } + if (err) { + printk(KERN_ERR "EXT2-fs: insufficient memory\n"); + goto failed_mount3; + } /* * set up enough so that it can read an inode */ 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) int i; int needs_recovery; __le32 features; + int err; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -1675,12 +1676,20 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) get_random_bytes(&sbi->s_next_generation, sizeof(u32)); spin_lock_init(&sbi->s_next_gen_lock); - percpu_counter_init(&sbi->s_freeblocks_counter, - ext3_count_free_blocks(sb)); - percpu_counter_init(&sbi->s_freeinodes_counter, - ext3_count_free_inodes(sb)); - percpu_counter_init(&sbi->s_dirs_counter, - ext3_count_dirs(sb)); + err = percpu_counter_init(&sbi->s_freeblocks_counter, + ext3_count_free_blocks(sb)); + if (!err) { + err = percpu_counter_init(&sbi->s_freeinodes_counter, + ext3_count_free_inodes(sb)); + } + if (!err) { + err = percpu_counter_init(&sbi->s_dirs_counter, + ext3_count_dirs(sb)); + } + if (err) { + printk(KERN_ERR "EXT3-fs: insufficient memory\n"); + goto failed_mount3; + } /* per fileystem reservation list head & lock */ 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) int needs_recovery; __le32 features; __u64 blocks_count; + int err; sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (!sbi) @@ -1759,12 +1760,20 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent) get_random_bytes(&sbi->s_next_generation, sizeof(u32)); spin_lock_init(&sbi->s_next_gen_lock); - percpu_counter_init(&sbi->s_freeblocks_counter, - ext4_count_free_blocks(sb)); - percpu_counter_init(&sbi->s_freeinodes_counter, - ext4_count_free_inodes(sb)); - percpu_counter_init(&sbi->s_dirs_counter, - ext4_count_dirs(sb)); + err = percpu_counter_init(&sbi->s_freeblocks_counter, + ext4_count_free_blocks(sb)); + if (!err) { + err = percpu_counter_init(&sbi->s_freeinodes_counter, + ext4_count_free_inodes(sb)); + } + if (!err) { + err = percpu_counter_init(&sbi->s_dirs_counter, + ext4_count_dirs(sb)); + } + if (err) { + printk(KERN_ERR "EXT4-fs: insufficient memory\n"); + goto failed_mount3; + } /* per fileystem reservation list head & lock */ spin_lock_init(&sbi->s_rsv_window_lock); |