All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 3/5] XFS: fix uninitialised variable bug in dquot release.
Date: Fri, 31 Oct 2008 12:15:27 +1100	[thread overview]
Message-ID: <1225415729-26514-4-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1225415729-26514-1-git-send-email-david@fromorbit.com>

gcc on ARM warns about an using an uninitialised variable
in xfs_qm_dqrele_all_inodes(). This is a real bug, but gcc
on x86_64 is not reporting this warning so it went unnoticed.

Fix the bug by bring the inode radix tree walk code up to
date with xfs_sync_inodes_ag().

Signed-off-by: Dave Chinner <david@fromorbit.com>
---
 fs/xfs/quota/xfs_qm_syscalls.c |   42 ++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/fs/xfs/quota/xfs_qm_syscalls.c b/fs/xfs/quota/xfs_qm_syscalls.c
index 9ff28e6..2c57a6e 100644
--- a/fs/xfs/quota/xfs_qm_syscalls.c
+++ b/fs/xfs/quota/xfs_qm_syscalls.c
@@ -1036,9 +1036,6 @@ xfs_qm_dqrele_inodes_ag(
 	int		nr_found;
 
 	do {
-		boolean_t	inode_refed;
-		struct inode	*inode;
-
 		/*
 		 * use a gang lookup to find the next inode in the tree
 		 * as the tree is sparse and a gang lookup walks to find
@@ -1053,27 +1050,37 @@ xfs_qm_dqrele_inodes_ag(
 			break;
 		}
 
-		/* update the index for the next lookup */
+		/*
+		 * Update the index for the next lookup. Catch overflows
+		 * into the next AG range which can occur if we have inodes
+		 * in the last block of the AG and we are currently
+		 * pointing to the last inode.
+		 */
 		first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1);
+		if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) {
+			read_unlock(&pag->pag_ici_lock);
+			break;
+		}
 
-		/* skip quota inodes and those in reclaim */
-		inode = VFS_I(ip);
-		if (!inode || ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) {
+		/* skip quota inodes */
+		if (ip == XFS_QI_UQIP(mp) || ip == XFS_QI_GQIP(mp)) {
 			ASSERT(ip->i_udquot == NULL);
 			ASSERT(ip->i_gdquot == NULL);
 			read_unlock(&pag->pag_ici_lock);
 			continue;
 		}
-		if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0) {
-			inode = igrab(inode);
-			read_unlock(&pag->pag_ici_lock);
-			if (!inode)
-				continue;
-			inode_refed = B_TRUE;
-			xfs_ilock(ip, XFS_ILOCK_EXCL);
-		} else {
+
+		/*
+		 * If we can't get a reference on the inode, it must be
+		 * in reclaim. Leave it for the reclaim code to flush.
+		 */
+		if (!igrab(VFS_I(ip))) {
 			read_unlock(&pag->pag_ici_lock);
+			continue;
 		}
+		read_unlock(&pag->pag_ici_lock);
+
+		xfs_ilock(ip, XFS_ILOCK_EXCL);
 		if ((flags & XFS_UQUOTA_ACCT) && ip->i_udquot) {
 			xfs_qm_dqrele(ip->i_udquot);
 			ip->i_udquot = NULL;
@@ -1083,9 +1090,8 @@ xfs_qm_dqrele_inodes_ag(
 			xfs_qm_dqrele(ip->i_gdquot);
 			ip->i_gdquot = NULL;
 		}
-		xfs_iunlock(ip, XFS_ILOCK_EXCL);
-		if (inode_refed)
-			IRELE(ip);
+		xfs_iput(ip, XFS_ILOCK_EXCL);
+
 	} while (nr_found);
 }
 
-- 
1.5.6.5

  parent reply	other threads:[~2008-10-31  1:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-31  1:15 [PATCH 0/5] Miscellaneous bug fixes Dave Chinner
2008-10-31  1:15 ` [PATCH 1/5] XFS: fix error inversion problems with data flushing Dave Chinner
2008-10-31 20:18   ` Christoph Hellwig
2008-11-02 22:51     ` Dave Chinner
2008-11-06 15:39       ` Christoph Hellwig
2008-10-31  1:15 ` [PATCH 2/5] XFS: Fix double free of log tickets Dave Chinner
2008-11-12  9:20   ` Christoph Hellwig
2008-10-31  1:15 ` Dave Chinner [this message]
2008-10-31 20:19   ` [PATCH 3/5] XFS: fix uninitialised variable bug in dquot release Christoph Hellwig
2008-10-31  1:15 ` [PATCH 4/5] XFS: fix spurious uninitialised variable warning in xfs_growfs_rt Dave Chinner
2008-10-31 20:20   ` Christoph Hellwig
2008-10-31  1:15 ` [PATCH 5/5] XFS: Avoid using inodes that haven't been completely initialised Dave Chinner
2008-10-31 20:21   ` Christoph Hellwig

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=1225415729-26514-4-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.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.