All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Ajeet Yadav <ajeet.yadav.77@gmail.com>
Cc: xfs@oss.sgi.com
Subject: Re: XFS internal error xfs_iformat(realtime) even after xfs_repair.
Date: Tue, 18 Jan 2011 15:57:30 +1100	[thread overview]
Message-ID: <20110118045730.GU28803@dastard> (raw)
In-Reply-To: <AANLkTin=nqXCVJRgqBuTDx6nxMx1GLiG2DortJG+pz2L@mail.gmail.com>

On Mon, Jan 17, 2011 at 09:12:54PM +0900, Ajeet Yadav wrote:
> Kernel: 2.6.30.9, XFS backported from 2.6.34, xfsprogs-3.0.5
> 
> I used a script
> 1. create some file, directories, symlinks
> 2. unmount the file system
> 3. run xfs_bd with blocktrash
> 4. xfs_xfsrepair -L
> 5. list "ls -lR"
> 6. remove all file and directory "rm -rf *

OK, so you are effectively corrupting random blocks by introducing
random bit errors in the blocks. No surprise that some errors are
not being detected - what is the blocktrash command that you are
using?

> Often during testing I get the below backtrace from kernel during ls, rm
> even though I already run xfs_repair on it.
> Is it related to xfsrepair or xfs ?. I think xfs_repair must have detected
> this problem and corrected it.

xfs_repair is not checking the di_flags field in the inode for
sanity, hence having a wrong flag set is going unnoticed.

> There is similar problem already reported by
> http://oss.sgi.com/archives/xfs/2010-06/msg00349.html

Similar error message (xfs_iformt found an inode corruption), but
that one is a completely different problem.

Does the patch below (compile tested only) detect the bad inode?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

xfs_repair: validate inode di_flags field

xfs_repair is not validating the di_flags field in the inode for
sanity. Block fuzzing indicates that we are not picking situations
like the RT bit being set on filesystems without realtime devices.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 repair/dinode.c |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/repair/dinode.c b/repair/dinode.c
index 2fa850d..e05d4e0 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c
@@ -2519,6 +2519,68 @@ process_dinode_int(xfs_mount_t *mp,
 		goto clear_bad_out;
 	}
 
+	/*
+	 * check that we only have valid flags set, and those that are set make
+	 * sense.
+	 */
+	if (dino->di_flags) {
+		uint16_t flags = be16_to_cpu(dino->di_flags);
+
+		if (flags & ~XFS_DIFLAG_ANY) {
+			do_warn(_("Bad flags set in inode %llu"), lino);
+			flags &= ~XFS_DIFLAG_ANY;
+		}
+
+		if (flags & (XFS_DIFLAG_REALTIME | XFS_DIFLAG_RTINHERIT)) {
+			/* need an rt-dev! */
+			if (!rt_name) {
+				do_warn(_(
+	"inode %llu has RT flag set but there is no RT device"), lino);
+				flags &= ~(XFS_DIFLAG_REALTIME |
+						XFS_DIFLAG_RTINHERIT);
+			}
+		}
+		if (flags & XFS_DIFLAG_NEWRTBM_BIT) {
+			/* must be a rt bitmap inode */
+			if (lino != mp->m_sb.sb_rbmino) {
+				do_warn(_("inode %llu not rt bitmap"), lino);
+				flags &= ~XFS_DIFLAG_NEWRTBM_BIT;
+			}
+		}
+		if (flags & (XFS_DIFLAG_RTINHERIT |
+			     XFS_DIFLAG_EXTSZINHERIT |
+			     XFS_DIFLAG_PROJINHERIT |
+			     XFS_DIFLAG_NOSYMLINKS)) {
+			/* must be a directory */
+			if (di_mode && !S_ISDIR(di_mode)) {
+				do_warn(_(
+			"directory flags set on non-directory inode %llu"),
+					lino);
+				flags &= ~(XFS_DIFLAG_RTINHERIT |
+						XFS_DIFLAG_EXTSZINHERIT |
+						XFS_DIFLAG_PROJINHERIT |
+						XFS_DIFLAG_NOSYMLINKS);
+			}
+		}
+		if (flags & (XFS_DIFLAG_REALTIME | XFS_XFLAG_EXTSIZE)) {
+			/* must be a file */
+			if (di_mode && !S_ISREG(di_mode)) {
+				do_warn(_(
+			"file flags set on non-file inode %llu"), lino);
+				flags &= ~(XFS_DIFLAG_REALTIME |
+						XFS_XFLAG_EXTSIZE);
+			}
+		}
+		if (!verify_mode && flags != be16_to_cpu(dino->di_flags)) {
+			if (!no_modify) {
+				do_warn(_(", fixing bad flags.\n"));
+				dino->di_flags = cpu_to_be16(flags);
+				*dirty = 1;
+			} else
+				do_warn(_(", would fix bad flags.\n"));
+		}
+	}
+
 	if (verify_mode)
 		return retval;
 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2011-01-18  4:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 12:12 XFS internal error xfs_iformat(realtime) even after xfs_repair Ajeet Yadav
2011-01-18  4:57 ` Dave Chinner [this message]
2011-01-19  1:06   ` Ajeet Yadav
2011-02-01  1:26     ` Ajeet Yadav
2011-02-01  4:12       ` Dave Chinner
2011-02-01 21:28         ` Christoph Hellwig
2011-02-01 23:04           ` Dave Chinner

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=20110118045730.GU28803@dastard \
    --to=david@fromorbit.com \
    --cc=ajeet.yadav.77@gmail.com \
    --cc=xfs@oss.sgi.com \
    /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 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.