* [PATCH 1/2] ext3: init statistics after journal recovery @ 2010-04-12 19:12 Dmitry Monakhov 2010-04-12 19:12 ` [PATCH 2/2] ext4: init statistics after journal recovery v2 Dmitry Monakhov 2010-04-12 19:30 ` [PATCH 1/2] ext3: init statistics after journal recovery Jan Kara 0 siblings, 2 replies; 8+ messages in thread From: Dmitry Monakhov @ 2010-04-12 19:12 UTC (permalink / raw) To: linux-ext4; +Cc: tytso, jack, Dmitry Monakhov Currently block/inode/dir counters initialized before journal was recovered. In fact after journal recovery this info will probably change. And freeblocks it critical for correct delalloc mode accounting. BUG:#15768 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext3/super.c | 38 ++++++++++++++++++-------------------- 1 files changed, 18 insertions(+), 20 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index e844acc..613b5ed 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1890,21 +1890,6 @@ 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); - 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) { - ext3_msg(sb, KERN_ERR, "error: insufficient memory"); - goto failed_mount3; - } - /* per fileystem reservation list head & lock */ spin_lock_init(&sbi->s_rsv_window_lock); sbi->s_rsv_window_root = RB_ROOT; @@ -1945,16 +1930,30 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) if (!test_opt(sb, NOLOAD) && EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { if (ext3_load_journal(sb, es, journal_devnum)) - goto failed_mount3; + goto failed_mount2; } else if (journal_inum) { if (ext3_create_journal(sb, es, journal_inum)) - goto failed_mount3; + goto failed_mount2; } else { if (!silent) ext3_msg(sb, KERN_ERR, "error: no journal found. " "mounting ext3 over ext2?"); - goto failed_mount3; + goto failed_mount2; + } + 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) { + ext3_msg(sb, KERN_ERR, "error: insufficient memory"); + goto failed_mount4; } /* We have now updated the journal if required, so we can @@ -2040,11 +2039,10 @@ cantfind_ext3: goto failed_mount; failed_mount4: - journal_destroy(sbi->s_journal); -failed_mount3: percpu_counter_destroy(&sbi->s_freeblocks_counter); percpu_counter_destroy(&sbi->s_freeinodes_counter); percpu_counter_destroy(&sbi->s_dirs_counter); + journal_destroy(sbi->s_journal); failed_mount2: for (i = 0; i < db_count; i++) brelse(sbi->s_group_desc[i]); -- 1.6.6.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] ext4: init statistics after journal recovery v2 2010-04-12 19:12 [PATCH 1/2] ext3: init statistics after journal recovery Dmitry Monakhov @ 2010-04-12 19:12 ` Dmitry Monakhov 2010-04-12 19:37 ` Jan Kara 2010-04-12 19:30 ` [PATCH 1/2] ext3: init statistics after journal recovery Jan Kara 1 sibling, 1 reply; 8+ messages in thread From: Dmitry Monakhov @ 2010-04-12 19:12 UTC (permalink / raw) To: linux-ext4; +Cc: tytso, jack, Dmitry Monakhov Currently block/inode/dir counters initialized before journal was recovered. In fact after journal recovery this info will probably change. And freeblocks it critical for correct delalloc mode accounting. BUG:#15768 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext4/super.c | 44 ++++++++++++++++++++++---------------------- 1 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 29c6875..04a30ef 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2793,24 +2793,6 @@ 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); - 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) { - err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); - } - if (err) { - ext4_msg(sb, KERN_ERR, "insufficient memory"); - goto failed_mount3; - } - sbi->s_stripe = ext4_get_stripe_size(sbi); sbi->s_max_writeback_mb_bump = 128; @@ -2910,6 +2892,24 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); no_journal: + 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) { + err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); + } + if (err) { + ext4_msg(sb, KERN_ERR, "insufficient memory"); + goto failed_mount_wq; + } + if (test_opt(sb, NOBH)) { if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " @@ -3059,6 +3059,10 @@ failed_mount_wq: jbd2_journal_destroy(sbi->s_journal); sbi->s_journal = NULL; } + percpu_counter_destroy(&sbi->s_freeblocks_counter); + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyblocks_counter); failed_mount3: if (sbi->s_flex_groups) { if (is_vmalloc_addr(sbi->s_flex_groups)) @@ -3066,10 +3070,6 @@ failed_mount3: else kfree(sbi->s_flex_groups); } - percpu_counter_destroy(&sbi->s_freeblocks_counter); - percpu_counter_destroy(&sbi->s_freeinodes_counter); - percpu_counter_destroy(&sbi->s_dirs_counter); - percpu_counter_destroy(&sbi->s_dirtyblocks_counter); failed_mount2: for (i = 0; i < db_count; i++) brelse(sbi->s_group_desc[i]); -- 1.6.6.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: init statistics after journal recovery v2 2010-04-12 19:12 ` [PATCH 2/2] ext4: init statistics after journal recovery v2 Dmitry Monakhov @ 2010-04-12 19:37 ` Jan Kara 2010-04-21 20:03 ` tytso 0 siblings, 1 reply; 8+ messages in thread From: Jan Kara @ 2010-04-12 19:37 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: linux-ext4, tytso, jack On Mon 12-04-10 23:12:56, Dmitry Monakhov wrote: > Currently block/inode/dir counters initialized before journal was > recovered. In fact after journal recovery this info will probably > change. And freeblocks it critical for correct delalloc mode > accounting. > BUG:#15768 This patch looks fine. Acked-by: Jan Kara <jack@suse.cz> Honza > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> > --- > fs/ext4/super.c | 44 ++++++++++++++++++++++---------------------- > 1 files changed, 22 insertions(+), 22 deletions(-) > > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index 29c6875..04a30ef 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -2793,24 +2793,6 @@ 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); > > - 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) { > - err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); > - } > - if (err) { > - ext4_msg(sb, KERN_ERR, "insufficient memory"); > - goto failed_mount3; > - } > - > sbi->s_stripe = ext4_get_stripe_size(sbi); > sbi->s_max_writeback_mb_bump = 128; > > @@ -2910,6 +2892,24 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) > set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); > > no_journal: > + 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) { > + err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); > + } > + if (err) { > + ext4_msg(sb, KERN_ERR, "insufficient memory"); > + goto failed_mount_wq; > + } > + > if (test_opt(sb, NOBH)) { > if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { > ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " > @@ -3059,6 +3059,10 @@ failed_mount_wq: > jbd2_journal_destroy(sbi->s_journal); > sbi->s_journal = NULL; > } > + percpu_counter_destroy(&sbi->s_freeblocks_counter); > + percpu_counter_destroy(&sbi->s_freeinodes_counter); > + percpu_counter_destroy(&sbi->s_dirs_counter); > + percpu_counter_destroy(&sbi->s_dirtyblocks_counter); > failed_mount3: > if (sbi->s_flex_groups) { > if (is_vmalloc_addr(sbi->s_flex_groups)) > @@ -3066,10 +3070,6 @@ failed_mount3: > else > kfree(sbi->s_flex_groups); > } > - percpu_counter_destroy(&sbi->s_freeblocks_counter); > - percpu_counter_destroy(&sbi->s_freeinodes_counter); > - percpu_counter_destroy(&sbi->s_dirs_counter); > - percpu_counter_destroy(&sbi->s_dirtyblocks_counter); > failed_mount2: > for (i = 0; i < db_count; i++) > brelse(sbi->s_group_desc[i]); > -- > 1.6.6.1 > -- Jan Kara <jack@suse.cz> SUSE Labs, CR ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ext4: init statistics after journal recovery v2 2010-04-12 19:37 ` Jan Kara @ 2010-04-21 20:03 ` tytso 0 siblings, 0 replies; 8+ messages in thread From: tytso @ 2010-04-21 20:03 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: Jan Kara, linux-ext4 This is what I've checked into the ext4 patch queue. Fixes some whitespace issues, and removed some unneeded curly braces. - Ted ext4: init statistics after journal recovery From: Dmitry Monakhov <dmonakhov@openvz.org> Currently block/inode/dir counters initialized before journal was recovered. In fact after journal recovery this info will probably change. And freeblocks it critical for correct delalloc mode accounting. https://bugzilla.kernel.org/show_bug.cgi?id=15768 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Acked-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> --- fs/ext4/super.c | 40 ++++++++++++++++++---------------------- 1 files changed, 18 insertions(+), 22 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 00d09f5..d83cdcb 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -2794,24 +2794,6 @@ 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); - 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) { - err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); - } - if (err) { - ext4_msg(sb, KERN_ERR, "insufficient memory"); - goto failed_mount3; - } - sbi->s_stripe = ext4_get_stripe_size(sbi); sbi->s_max_writeback_mb_bump = 128; @@ -2911,6 +2893,20 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); no_journal: + 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) + err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); + if (err) { + ext4_msg(sb, KERN_ERR, "insufficient memory"); + goto failed_mount_wq; + } if (test_opt(sb, NOBH)) { if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " @@ -3060,6 +3056,10 @@ failed_mount_wq: jbd2_journal_destroy(sbi->s_journal); sbi->s_journal = NULL; } + percpu_counter_destroy(&sbi->s_freeblocks_counter); + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyblocks_counter); failed_mount3: if (sbi->s_flex_groups) { if (is_vmalloc_addr(sbi->s_flex_groups)) @@ -3067,10 +3067,6 @@ failed_mount3: else kfree(sbi->s_flex_groups); } - percpu_counter_destroy(&sbi->s_freeblocks_counter); - percpu_counter_destroy(&sbi->s_freeinodes_counter); - percpu_counter_destroy(&sbi->s_dirs_counter); - percpu_counter_destroy(&sbi->s_dirtyblocks_counter); failed_mount2: for (i = 0; i < db_count; i++) brelse(sbi->s_group_desc[i]); ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ext3: init statistics after journal recovery 2010-04-12 19:12 [PATCH 1/2] ext3: init statistics after journal recovery Dmitry Monakhov 2010-04-12 19:12 ` [PATCH 2/2] ext4: init statistics after journal recovery v2 Dmitry Monakhov @ 2010-04-12 19:30 ` Jan Kara 2010-04-12 19:34 ` Dmitry Monakhov 2010-04-12 19:46 ` [PATCH 1/2] ext3: init statistics after journal recovery v2 Dmitry Monakhov 1 sibling, 2 replies; 8+ messages in thread From: Jan Kara @ 2010-04-12 19:30 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: linux-ext4, tytso, jack On Mon 12-04-10 23:12:55, Dmitry Monakhov wrote: > Currently block/inode/dir counters initialized before journal was > recovered. In fact after journal recovery this info will probably > change. And freeblocks it critical for correct delalloc mode > accounting. > BUG:#15768 Thanks for the patch. Could you please also rename failed_mount4 to failed_mount3 so that the label numbering is continguous? Otherwise the patch is fine. Honza > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> > --- > fs/ext3/super.c | 38 ++++++++++++++++++-------------------- > 1 files changed, 18 insertions(+), 20 deletions(-) > > diff --git a/fs/ext3/super.c b/fs/ext3/super.c > index e844acc..613b5ed 100644 > --- a/fs/ext3/super.c > +++ b/fs/ext3/super.c > @@ -1890,21 +1890,6 @@ 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); > > - 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) { > - ext3_msg(sb, KERN_ERR, "error: insufficient memory"); > - goto failed_mount3; > - } > - > /* per fileystem reservation list head & lock */ > spin_lock_init(&sbi->s_rsv_window_lock); > sbi->s_rsv_window_root = RB_ROOT; > @@ -1945,16 +1930,30 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) > if (!test_opt(sb, NOLOAD) && > EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { > if (ext3_load_journal(sb, es, journal_devnum)) > - goto failed_mount3; > + goto failed_mount2; > } else if (journal_inum) { > if (ext3_create_journal(sb, es, journal_inum)) > - goto failed_mount3; > + goto failed_mount2; > } else { > if (!silent) > ext3_msg(sb, KERN_ERR, > "error: no journal found. " > "mounting ext3 over ext2?"); > - goto failed_mount3; > + goto failed_mount2; > + } > + 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) { > + ext3_msg(sb, KERN_ERR, "error: insufficient memory"); > + goto failed_mount4; > } > > /* We have now updated the journal if required, so we can > @@ -2040,11 +2039,10 @@ cantfind_ext3: > goto failed_mount; > > failed_mount4: > - journal_destroy(sbi->s_journal); > -failed_mount3: > percpu_counter_destroy(&sbi->s_freeblocks_counter); > percpu_counter_destroy(&sbi->s_freeinodes_counter); > percpu_counter_destroy(&sbi->s_dirs_counter); > + journal_destroy(sbi->s_journal); > failed_mount2: > for (i = 0; i < db_count; i++) > brelse(sbi->s_group_desc[i]); > -- > 1.6.6.1 > -- Jan Kara <jack@suse.cz> SUSE Labs, CR ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ext3: init statistics after journal recovery 2010-04-12 19:30 ` [PATCH 1/2] ext3: init statistics after journal recovery Jan Kara @ 2010-04-12 19:34 ` Dmitry Monakhov 2010-04-12 19:46 ` [PATCH 1/2] ext3: init statistics after journal recovery v2 Dmitry Monakhov 1 sibling, 0 replies; 8+ messages in thread From: Dmitry Monakhov @ 2010-04-12 19:34 UTC (permalink / raw) To: Jan Kara; +Cc: linux-ext4, tytso Jan Kara <jack@suse.cz> writes: > On Mon 12-04-10 23:12:55, Dmitry Monakhov wrote: >> Currently block/inode/dir counters initialized before journal was >> recovered. In fact after journal recovery this info will probably >> change. And freeblocks it critical for correct delalloc mode >> accounting. >> BUG:#15768 > Thanks for the patch. Could you please also rename failed_mount4 > to failed_mount3 so that the label numbering is continguous? Otherwise > the patch is fine. Ok, in a minute. > Honza >> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> >> --- >> fs/ext3/super.c | 38 ++++++++++++++++++-------------------- >> 1 files changed, 18 insertions(+), 20 deletions(-) >> >> diff --git a/fs/ext3/super.c b/fs/ext3/super.c >> index e844acc..613b5ed 100644 >> --- a/fs/ext3/super.c >> +++ b/fs/ext3/super.c >> @@ -1890,21 +1890,6 @@ 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); >> >> - 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) { >> - ext3_msg(sb, KERN_ERR, "error: insufficient memory"); >> - goto failed_mount3; >> - } >> - >> /* per fileystem reservation list head & lock */ >> spin_lock_init(&sbi->s_rsv_window_lock); >> sbi->s_rsv_window_root = RB_ROOT; >> @@ -1945,16 +1930,30 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) >> if (!test_opt(sb, NOLOAD) && >> EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { >> if (ext3_load_journal(sb, es, journal_devnum)) >> - goto failed_mount3; >> + goto failed_mount2; >> } else if (journal_inum) { >> if (ext3_create_journal(sb, es, journal_inum)) >> - goto failed_mount3; >> + goto failed_mount2; >> } else { >> if (!silent) >> ext3_msg(sb, KERN_ERR, >> "error: no journal found. " >> "mounting ext3 over ext2?"); >> - goto failed_mount3; >> + goto failed_mount2; >> + } >> + 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) { >> + ext3_msg(sb, KERN_ERR, "error: insufficient memory"); >> + goto failed_mount4; >> } >> >> /* We have now updated the journal if required, so we can >> @@ -2040,11 +2039,10 @@ cantfind_ext3: >> goto failed_mount; >> >> failed_mount4: >> - journal_destroy(sbi->s_journal); >> -failed_mount3: >> percpu_counter_destroy(&sbi->s_freeblocks_counter); >> percpu_counter_destroy(&sbi->s_freeinodes_counter); >> percpu_counter_destroy(&sbi->s_dirs_counter); >> + journal_destroy(sbi->s_journal); >> failed_mount2: >> for (i = 0; i < db_count; i++) >> brelse(sbi->s_group_desc[i]); >> -- >> 1.6.6.1 >> ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/2] ext3: init statistics after journal recovery v2 2010-04-12 19:30 ` [PATCH 1/2] ext3: init statistics after journal recovery Jan Kara 2010-04-12 19:34 ` Dmitry Monakhov @ 2010-04-12 19:46 ` Dmitry Monakhov 2010-04-13 14:26 ` Jan Kara 1 sibling, 1 reply; 8+ messages in thread From: Dmitry Monakhov @ 2010-04-12 19:46 UTC (permalink / raw) To: Jan Kara; +Cc: linux-ext4, tytso Currently block/inode/dir counters initialized before journal was recovered. In fact after journal recovery this info will probably change which result in incorrect statfs() BUG:#15768 Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext3/super.c | 44 +++++++++++++++++++++----------------------- 1 files changed, 21 insertions(+), 23 deletions(-) diff --git a/fs/ext3/super.c b/fs/ext3/super.c index e844acc..436e0dc 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -1890,21 +1890,6 @@ 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); - 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) { - ext3_msg(sb, KERN_ERR, "error: insufficient memory"); - goto failed_mount3; - } - /* per fileystem reservation list head & lock */ spin_lock_init(&sbi->s_rsv_window_lock); sbi->s_rsv_window_root = RB_ROOT; @@ -1945,15 +1930,29 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) if (!test_opt(sb, NOLOAD) && EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { if (ext3_load_journal(sb, es, journal_devnum)) - goto failed_mount3; + goto failed_mount2; } else if (journal_inum) { if (ext3_create_journal(sb, es, journal_inum)) - goto failed_mount3; + goto failed_mount2; } else { if (!silent) ext3_msg(sb, KERN_ERR, "error: no journal found. " "mounting ext3 over ext2?"); + goto failed_mount2; + } + 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) { + ext3_msg(sb, KERN_ERR, "error: insufficient memory"); goto failed_mount3; } @@ -1978,7 +1977,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ext3_msg(sb, KERN_ERR, "error: journal does not support " "requested data journaling mode"); - goto failed_mount4; + goto failed_mount3; } default: break; @@ -2001,19 +2000,19 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) if (IS_ERR(root)) { ext3_msg(sb, KERN_ERR, "error: get root inode failed"); ret = PTR_ERR(root); - goto failed_mount4; + goto failed_mount3; } if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { iput(root); ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); - goto failed_mount4; + goto failed_mount3; } sb->s_root = d_alloc_root(root); if (!sb->s_root) { ext3_msg(sb, KERN_ERR, "error: get root dentry failed"); iput(root); ret = -ENOMEM; - goto failed_mount4; + goto failed_mount3; } ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); @@ -2039,12 +2038,11 @@ cantfind_ext3: sb->s_id); goto failed_mount; -failed_mount4: - journal_destroy(sbi->s_journal); failed_mount3: percpu_counter_destroy(&sbi->s_freeblocks_counter); percpu_counter_destroy(&sbi->s_freeinodes_counter); percpu_counter_destroy(&sbi->s_dirs_counter); + journal_destroy(sbi->s_journal); failed_mount2: for (i = 0; i < db_count; i++) brelse(sbi->s_group_desc[i]); -- 1.6.6.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ext3: init statistics after journal recovery v2 2010-04-12 19:46 ` [PATCH 1/2] ext3: init statistics after journal recovery v2 Dmitry Monakhov @ 2010-04-13 14:26 ` Jan Kara 0 siblings, 0 replies; 8+ messages in thread From: Jan Kara @ 2010-04-13 14:26 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: Jan Kara, linux-ext4, tytso On Mon 12-04-10 23:46:00, Dmitry Monakhov wrote: > > Currently block/inode/dir counters initialized before journal was > recovered. In fact after journal recovery this info will probably > change which result in incorrect statfs() > BUG:#15768 Merged. Thanks. Honza > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> > --- > fs/ext3/super.c | 44 +++++++++++++++++++++----------------------- > 1 files changed, 21 insertions(+), 23 deletions(-) > > diff --git a/fs/ext3/super.c b/fs/ext3/super.c > index e844acc..436e0dc 100644 > --- a/fs/ext3/super.c > +++ b/fs/ext3/super.c > @@ -1890,21 +1890,6 @@ 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); > > - 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) { > - ext3_msg(sb, KERN_ERR, "error: insufficient memory"); > - goto failed_mount3; > - } > - > /* per fileystem reservation list head & lock */ > spin_lock_init(&sbi->s_rsv_window_lock); > sbi->s_rsv_window_root = RB_ROOT; > @@ -1945,15 +1930,29 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) > if (!test_opt(sb, NOLOAD) && > EXT3_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL)) { > if (ext3_load_journal(sb, es, journal_devnum)) > - goto failed_mount3; > + goto failed_mount2; > } else if (journal_inum) { > if (ext3_create_journal(sb, es, journal_inum)) > - goto failed_mount3; > + goto failed_mount2; > } else { > if (!silent) > ext3_msg(sb, KERN_ERR, > "error: no journal found. " > "mounting ext3 over ext2?"); > + goto failed_mount2; > + } > + 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) { > + ext3_msg(sb, KERN_ERR, "error: insufficient memory"); > goto failed_mount3; > } > > @@ -1978,7 +1977,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) > ext3_msg(sb, KERN_ERR, > "error: journal does not support " > "requested data journaling mode"); > - goto failed_mount4; > + goto failed_mount3; > } > default: > break; > @@ -2001,19 +2000,19 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) > if (IS_ERR(root)) { > ext3_msg(sb, KERN_ERR, "error: get root inode failed"); > ret = PTR_ERR(root); > - goto failed_mount4; > + goto failed_mount3; > } > if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { > iput(root); > ext3_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck"); > - goto failed_mount4; > + goto failed_mount3; > } > sb->s_root = d_alloc_root(root); > if (!sb->s_root) { > ext3_msg(sb, KERN_ERR, "error: get root dentry failed"); > iput(root); > ret = -ENOMEM; > - goto failed_mount4; > + goto failed_mount3; > } > > ext3_setup_super (sb, es, sb->s_flags & MS_RDONLY); > @@ -2039,12 +2038,11 @@ cantfind_ext3: > sb->s_id); > goto failed_mount; > > -failed_mount4: > - journal_destroy(sbi->s_journal); > failed_mount3: > percpu_counter_destroy(&sbi->s_freeblocks_counter); > percpu_counter_destroy(&sbi->s_freeinodes_counter); > percpu_counter_destroy(&sbi->s_dirs_counter); > + journal_destroy(sbi->s_journal); > failed_mount2: > for (i = 0; i < db_count; i++) > brelse(sbi->s_group_desc[i]); > -- > 1.6.6.1 > -- Jan Kara <jack@suse.cz> SUSE Labs, CR ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-04-21 20:03 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-04-12 19:12 [PATCH 1/2] ext3: init statistics after journal recovery Dmitry Monakhov 2010-04-12 19:12 ` [PATCH 2/2] ext4: init statistics after journal recovery v2 Dmitry Monakhov 2010-04-12 19:37 ` Jan Kara 2010-04-21 20:03 ` tytso 2010-04-12 19:30 ` [PATCH 1/2] ext3: init statistics after journal recovery Jan Kara 2010-04-12 19:34 ` Dmitry Monakhov 2010-04-12 19:46 ` [PATCH 1/2] ext3: init statistics after journal recovery v2 Dmitry Monakhov 2010-04-13 14:26 ` Jan Kara
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).