From: Ashish Sangwan <ashishsangwan2@gmail.com>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org,
Ashish Sangwan <ashish.sangwan2@gmail.com>,
Namjae Jeon <linkinjeon@gmail.com>
Subject: [PATCH, RFC] Ext4: Mount partition as read only if during orphan cleanup truncate fails to obtain journal handle.
Date: Wed, 24 Oct 2012 16:10:40 +0530 [thread overview]
Message-ID: <1351075240-2725-1-git-send-email-ashish.sangwan2@gmail.com> (raw)
During orphan cleanup while doing truncate, if we fail to obtain journal
handle, the inode for which truncate was called would not be removed from
both the on-disk and in-memory orphan lists as the call to ext4_orphan_del
would not be executed.
This would have following consequences:
a) As the inode is not removed from the on-disk list, truncate would be
called again for the same inode. Each call would add the inode to the
in-memory list. This operation would continue endlessly or until truncate
is succeed.
b) If somehow, after some iterations, truncate is succeed, ext4_orphan_del
will only remove the inode from in-memory list just 1 time. This will trigger
j_assert during put super.
This patch handles both the problems. If truncate fails, first in-memory
list is cleared and than the partition is mounted as read only.
Failure to obtain journal handle during mount may suggest that journal
device is corrupted.
Signed-off-by: Ashish Sangwan <ashish.sangwan2@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
---
fs/ext4/super.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 4e2aacb..859eccb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -2201,7 +2201,21 @@ static void ext4_orphan_cleanup(struct super_block *sb,
jbd_debug(2, "truncating inode %lu to %lld bytes\n",
inode->i_ino, inode->i_size);
ext4_truncate(inode);
- nr_truncates++;
+ if (list_empty(&EXT4_I(inode)->i_orphan)) {
+ nr_truncates++;
+ } else {
+ /* Remove inode from in-memory orphan list */
+ list_del_init(&EXT4_I(inode)->i_orphan);
+ ext4_msg(sb, KERN_ERR, "Truncate failed for "
+ "orphan inode = %lu. Running e2fsck"
+ " is recommended", inode->i_ino);
+ if (!(s_flags & MS_RDONLY)) {
+ ext4_msg(sb, KERN_INFO, "FS would be"
+ " mounted as readonly");
+ s_flags |= MS_RDONLY;
+ }
+ break;
+ }
} else {
ext4_msg(sb, KERN_DEBUG,
"%s: deleting unreferenced inode %lu",
--
1.7.11.4
next reply other threads:[~2012-10-24 10:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 10:40 Ashish Sangwan [this message]
2012-10-26 11:41 ` [PATCH, RFC] Ext4: Mount partition as read only if during orphan cleanup truncate fails to obtain journal handle Namjae Jeon
2012-12-06 11:29 ` Ashish Sangwan
2012-12-06 17:09 ` Theodore Ts'o
2012-12-07 9:22 ` Ashish Sangwan
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=1351075240-2725-1-git-send-email-ashish.sangwan2@gmail.com \
--to=ashishsangwan2@gmail.com \
--cc=ashish.sangwan2@gmail.com \
--cc=linkinjeon@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).