linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yongqiang Yang <xiaoqiangnk@gmail.com>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, Yongqiang Yang <xiaoqiangnk@gmail.com>
Subject: [PATCH 2/2] ext4: check free inode count before allocaing an inode
Date: Sun,  2 Sep 2012 17:45:09 +0800	[thread overview]
Message-ID: <1346579109-25016-2-git-send-email-xiaoqiangnk@gmail.com> (raw)
In-Reply-To: <1346579109-25016-1-git-send-email-xiaoqiangnk@gmail.com>

Recnetly, I ecountered some corrupted filesystems in which some
groups' free inode counts were negative, it seemed that free inode
count was overflow.  This patch teaches ext4 to check free inode
count before allocaing an inode.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 fs/ext4/ialloc.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 26154b8..fa36372 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -697,6 +697,15 @@ got_group:
 		if (!gdp)
 			goto fail;
 
+		/*
+		 * Check free inodes count before loading bitmap.
+		 */
+		if (ext4_free_inodes_count(sb, gdp) == 0) {
+			if (++group == ngroups)
+				group = 0;
+			continue;
+		}
+
 		brelse(inode_bitmap_bh);
 		inode_bitmap_bh = ext4_read_inode_bitmap(sb, group);
 		if (!inode_bitmap_bh)
-- 
1.7.5.1


  reply	other threads:[~2012-09-02 10:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-02  9:45 [PATCH 1/2] ext4: check free block counters in ext4_mb_find_by_goal Yongqiang Yang
2012-09-02  9:45 ` Yongqiang Yang [this message]
2012-09-05  2:17   ` [PATCH 2/2] ext4: check free inode count before allocaing an inode Yongqiang Yang

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=1346579109-25016-2-git-send-email-xiaoqiangnk@gmail.com \
    --to=xiaoqiangnk@gmail.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).