From: "Zhang, Hongchao" <hongchao.zhang@intel.com>
To: "tytso@mit.edu" <tytso@mit.edu>
Cc: "Dilger, Andreas" <andreas.dilger@intel.com>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: an issue of ext4
Date: Wed, 5 Mar 2014 12:33:32 +0000 [thread overview]
Message-ID: <CF3D3A3F.283D%hongchao.zhang@intel.com> (raw)
[-- 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)) {
next reply other threads:[~2014-03-05 12:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 12:33 Zhang, Hongchao [this message]
2014-03-05 12:51 ` an issue of ext4 Theodore Ts'o
2014-03-06 23:57 ` Dilger, Andreas
2014-03-07 1:52 ` Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CF3D3A3F.283D%hongchao.zhang@intel.com \
--to=hongchao.zhang@intel.com \
--cc=andreas.dilger@intel.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).