From: Lachlan McIlroy <lachlan@sgi.com>
To: xfs-dev <xfs-dev@sgi.com>, xfs-oss <xfs@oss.sgi.com>
Subject: review: fix infinite loop in bulkstat
Date: Thu, 04 Oct 2007 15:20:12 +1000 [thread overview]
Message-ID: <4704780C.2020100@sgi.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
This fix prevents bulkstat from spinning in an infinite loop.
Here 'agino' increments through the inodes in an allocation group.
At the end of the innermost 'for' loop it will hold the value of the
next inode to look at (ie the first inode in the next cluster/chunk).
Assigning 'lastino' to 'agino' resets it to the last inode in the
last inode cluster we just looked at. This causes us to look up
the very same cluster and examine all the inodes all over again,
and again, and again...
We also want to set 'lastino' for the cases when we're not interested
in the inode so that the next call to bulkstat wont re-examine the
same uninteresting inodes.
[-- Attachment #2: bulkstat.diff --]
[-- Type: text/x-patch, Size: 1014 bytes --]
--- fs/xfs/xfs_itable.c_1.155 2007-10-03 13:05:22.000000000 +1000
+++ fs/xfs/xfs_itable.c 2007-10-04 12:16:46.000000000 +1000
@@ -622,8 +622,10 @@ xfs_bulkstat(
/*
* Skip if this inode is free.
*/
- if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free)
+ if (XFS_INOBT_MASK(chunkidx) & irbp->ir_free) {
+ lastino = ino;
continue;
+ }
/*
* Count used inodes as free so we can tell
* when the chunk is used up.
@@ -632,8 +634,10 @@ xfs_bulkstat(
ino = XFS_AGINO_TO_INO(mp, agno, agino);
bno = XFS_AGB_TO_DADDR(mp, agno, agbno);
if (!xfs_bulkstat_use_dinode(mp, flags, bp,
- clustidx, &dip))
+ clustidx, &dip)) {
+ lastino = ino;
continue;
+ }
/*
* If we need to do an iget, cannot hold bp.
* Drop it, until starting the next cluster.
@@ -694,8 +698,7 @@ xfs_bulkstat(
if (end_of_ag) {
agno++;
agino = 0;
- } else
- agino = XFS_INO_TO_AGINO(mp, lastino);
+ }
} else
break;
}
next reply other threads:[~2007-10-04 5:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-04 5:20 Lachlan McIlroy [this message]
2007-10-04 6:21 ` review: fix infinite loop in bulkstat David 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=4704780C.2020100@sgi.com \
--to=lachlan@sgi.com \
--cc=xfs-dev@sgi.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox