All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 3/5] xfs: pass inode number to xfs_scrub_ino_set_{preen, warning}
Date: Mon, 06 Nov 2017 17:03:40 -0800	[thread overview]
Message-ID: <151001662000.26786.4013509197578072250.stgit@magnolia> (raw)
In-Reply-To: <151001660179.26786.15701876786383794673.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

There are two ways to scrub an inode -- calling xfs_iget and checking
the raw inode core, or by loading the inode cluster buffer and checking
the on-disk contents directly.  The second method is only useful if
_iget fails the verifiers; when this is the case, sc->ip is NULL and
calling the tracepoint will cause a system crash.

Therefore, pass the raw inode number directly into the _preen and
_warning functions.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/scrub/attr.c   |    2 +-
 fs/xfs/scrub/common.c |    6 ++++--
 fs/xfs/scrub/common.h |    5 +++--
 fs/xfs/scrub/inode.c  |    8 ++++----
 4 files changed, 12 insertions(+), 9 deletions(-)


diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
index 5cf30de..4ed8047 100644
--- a/fs/xfs/scrub/attr.c
+++ b/fs/xfs/scrub/attr.c
@@ -98,7 +98,7 @@ xfs_scrub_xattr_listent(
 
 	if (flags & XFS_ATTR_INCOMPLETE) {
 		/* Incomplete attr key, just mark the inode for preening. */
-		xfs_scrub_ino_set_preen(sx->sc, NULL);
+		xfs_scrub_ino_set_preen(sx->sc, context->dp->i_ino, NULL);
 		return;
 	}
 
diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
index 318dd97..ac95fe9 100644
--- a/fs/xfs/scrub/common.c
+++ b/fs/xfs/scrub/common.c
@@ -165,10 +165,11 @@ xfs_scrub_block_set_preen(
 void
 xfs_scrub_ino_set_preen(
 	struct xfs_scrub_context	*sc,
+	xfs_ino_t			ino,
 	struct xfs_buf			*bp)
 {
 	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
-	trace_xfs_scrub_ino_preen(sc, sc->ip->i_ino, bp ? bp->b_bn : 0,
+	trace_xfs_scrub_ino_preen(sc, ino, bp ? bp->b_bn : 0,
 			__return_address);
 }
 
@@ -215,10 +216,11 @@ xfs_scrub_fblock_set_corrupt(
 void
 xfs_scrub_ino_set_warning(
 	struct xfs_scrub_context	*sc,
+	xfs_ino_t			ino,
 	struct xfs_buf			*bp)
 {
 	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING;
-	trace_xfs_scrub_ino_warning(sc, sc->ip->i_ino, bp ? bp->b_bn : 0,
+	trace_xfs_scrub_ino_warning(sc, ino, bp ? bp->b_bn : 0,
 			__return_address);
 }
 
diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
index 0409ec2..5c04385 100644
--- a/fs/xfs/scrub/common.h
+++ b/fs/xfs/scrub/common.h
@@ -58,7 +58,8 @@ bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork,
 
 void xfs_scrub_block_set_preen(struct xfs_scrub_context *sc,
 		struct xfs_buf *bp);
-void xfs_scrub_ino_set_preen(struct xfs_scrub_context *sc, struct xfs_buf *bp);
+void xfs_scrub_ino_set_preen(struct xfs_scrub_context *sc, xfs_ino_t ino,
+		struct xfs_buf *bp);
 
 void xfs_scrub_block_set_corrupt(struct xfs_scrub_context *sc,
 		struct xfs_buf *bp);
@@ -67,7 +68,7 @@ void xfs_scrub_ino_set_corrupt(struct xfs_scrub_context *sc, xfs_ino_t ino,
 void xfs_scrub_fblock_set_corrupt(struct xfs_scrub_context *sc, int whichfork,
 		xfs_fileoff_t offset);
 
-void xfs_scrub_ino_set_warning(struct xfs_scrub_context *sc,
+void xfs_scrub_ino_set_warning(struct xfs_scrub_context *sc, xfs_ino_t ino,
 		struct xfs_buf *bp);
 void xfs_scrub_fblock_set_warning(struct xfs_scrub_context *sc, int whichfork,
 		xfs_fileoff_t offset);
diff --git a/fs/xfs/scrub/inode.c b/fs/xfs/scrub/inode.c
index f275dd2..637b7a8 100644
--- a/fs/xfs/scrub/inode.c
+++ b/fs/xfs/scrub/inode.c
@@ -328,7 +328,7 @@ xfs_scrub_dinode(
 		 * We autoconvert v1 inodes into v2 inodes on writeout,
 		 * so just mark this inode for preening.
 		 */
-		xfs_scrub_ino_set_preen(sc, bp);
+		xfs_scrub_ino_set_preen(sc, ino, bp);
 		break;
 	case 2:
 	case 3:
@@ -353,7 +353,7 @@ xfs_scrub_dinode(
 	 */
 	if (dip->di_uid == cpu_to_be32(-1U) ||
 	    dip->di_gid == cpu_to_be32(-1U))
-		xfs_scrub_ino_set_warning(sc, bp);
+		xfs_scrub_ino_set_warning(sc, ino, bp);
 
 	/* di_format */
 	switch (dip->di_format) {
@@ -408,7 +408,7 @@ xfs_scrub_dinode(
 	 * overly large offsets, flag the inode for admin review.
 	 */
 	if (isize >= mp->m_super->s_maxbytes)
-		xfs_scrub_ino_set_warning(sc, bp);
+		xfs_scrub_ino_set_warning(sc, ino, bp);
 
 	/* di_nblocks */
 	if (flags2 & XFS_DIFLAG2_REFLINK) {
@@ -601,7 +601,7 @@ xfs_scrub_inode(
 				XFS_INO_TO_AGBNO(mp, ino), &error))
 			goto out;
 		if (!has_shared)
-			xfs_scrub_ino_set_preen(sc, bp);
+			xfs_scrub_ino_set_preen(sc, ino, bp);
 	}
 
 out:


  parent reply	other threads:[~2017-11-07  1:03 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07  1:03 [PATCH 0/5] xfs: various 4.15 scrub fixes Darrick J. Wong
2017-11-07  1:03 ` [PATCH 1/5] xfs: check the uniqueness of the AGFL entries Darrick J. Wong
2017-11-09  2:08   ` Dave Chinner
2017-11-09  2:48     ` Darrick J. Wong
2017-11-09  5:02   ` [PATCH v2 " Darrick J. Wong
2017-11-09 22:12     ` Darrick J. Wong
2017-11-09 23:39   ` [PATCH v3 " Darrick J. Wong
2017-11-10  1:23     ` Dave Chinner
2017-11-07  1:03 ` [PATCH 2/5] xfs: refactor the directory data block bestfree checks Darrick J. Wong
2017-11-09  2:11   ` Dave Chinner
2017-11-07  1:03 ` Darrick J. Wong [this message]
2017-11-09  2:13   ` [PATCH 3/5] xfs: pass inode number to xfs_scrub_ino_set_{preen, warning} Dave Chinner
2017-11-07  1:03 ` [PATCH 4/5] xfs: fix uninitialized return values in scrub code Darrick J. Wong
2017-11-09  2:13   ` Dave Chinner
2017-11-07  1:03 ` [PATCH 5/5] xfs: fix btree scrub deref check Darrick J. Wong
2017-11-09  2:16   ` Dave Chinner
2017-11-08 20:56 ` [PATCH 6/5] xfs: only check da node header padding on v5 filesystems Darrick J. Wong
2017-11-09  2:17   ` Dave Chinner
2017-11-09  6:00 ` [PATCH 7/5] xfs: on failed mount, force-reclaim inodes after unmounting quota controls Darrick J. Wong
2017-11-09 23:24   ` Dave Chinner
2017-11-09 23:49     ` Darrick J. Wong
2017-11-09 23:57   ` [PATCH v2 " Darrick J. Wong
2017-11-10  1:19     ` Dave Chinner
2017-11-09 17:35 ` [PATCH 8/5] xfs: remove u_int* type usage Darrick J. Wong
2017-11-09 23:25   ` 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=151001662000.26786.4013509197578072250.stgit@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /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.