All of lore.kernel.org
 help / color / mirror / Atom feed
* an issue of ext4
@ 2014-03-05 12:33 Zhang, Hongchao
  2014-03-05 12:51 ` Theodore Ts'o
  0 siblings, 1 reply; 4+ messages in thread
From: Zhang, Hongchao @ 2014-03-05 12:33 UTC (permalink / raw)
  To: tytso@mit.edu; +Cc: Dilger, Andreas, linux-ext4@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

Hi,

in ext4_fill_super, the variables related to statfs should be initialized after journal recovery is completed.
otherwise, if a large number of blocks were being allocated before the filesystem crashed, then the blocks
and inode counters may become negative during use and report incorrect values to statfs call.

Thanks
Hongchao

[-- Attachment #2: statfs-issue.patch --]
[-- Type: application/octet-stream, Size: 1737 bytes --]

diff -p -u linux-3.13.5.orig/fs/ext4/super.c linux-3.13.5/fs/ext4/super.c
--- linux-3.13.5.orig/fs/ext4/super.c
+++ linux-3.13.5/fs/ext4/super.c
@@ -3871,27 +3871,6 @@ static int ext4_fill_super(struct super_
 	/* Register extent status tree shrinker */
 	ext4_es_register_shrinker(sbi);
 
-	err = percpu_counter_init(&sbi->s_freeclusters_counter,
-			ext4_count_free_clusters(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_dirtyclusters_counter, 0);
-	}
-	if (!err) {
-		err = percpu_counter_init(&sbi->s_extent_cache_cnt, 0);
-	}
-	if (err) {
-		ext4_msg(sb, KERN_ERR, "insufficient memory");
-		goto failed_mount3;
-	}
-
 	sbi->s_stripe = ext4_get_stripe_size(sbi);
 	sbi->s_extent_max_zeroout_kb = 32;
 
@@ -3948,6 +3927,27 @@ static int ext4_fill_super(struct super_
 		goto no_journal;
 	}
 
+	err = percpu_counter_init(&sbi->s_freeclusters_counter,
+			ext4_count_free_clusters(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_dirtyclusters_counter, 0);
+	}
+	if (!err) {
+		err = percpu_counter_init(&sbi->s_extent_cache_cnt, 0);
+	}
+	if (err) {
+		ext4_msg(sb, KERN_ERR, "insufficient memory");
+		goto failed_mount3;
+	}
+
 	if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_64BIT) &&
 	    !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0,
 				       JBD2_FEATURE_INCOMPAT_64BIT)) {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-07  1:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-05 12:33 an issue of ext4 Zhang, Hongchao
2014-03-05 12:51 ` Theodore Ts'o
2014-03-06 23:57   ` Dilger, Andreas
2014-03-07  1:52     ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.